2020-03-25 14:26:40 +01:00
|
|
|
#!/bin/bash
|
|
|
|
########################################################################
|
|
|
|
# Author: Fred (support@qo-op.com)
|
|
|
|
# Version: 2020.03.24
|
|
|
|
# License: AGPL-3.0 (https://choosealicense.com/licenses/agpl-3.0/)
|
|
|
|
########################################################################
|
|
|
|
MY_PATH="`dirname \"$0\"`" # relative
|
|
|
|
MY_PATH="`( cd \"$MY_PATH\" && pwd )`" # absolutized and normalized
|
|
|
|
ME="${0##*/}"
|
|
|
|
echo '
|
|
|
|
########################################################################
|
|
|
|
# \\///
|
|
|
|
# qo-op
|
|
|
|
############# '$MY_PATH/$ME'
|
|
|
|
########################################################################
|
|
|
|
# ex: ./'$ME'
|
2020-03-26 03:08:15 +01:00
|
|
|
# SURVEY received #astroport-swarmkey and copy it to IPFS
|
2020-03-25 14:26:40 +01:00
|
|
|
######################################################################## _ _ _ _ _
|
|
|
|
___ _ _ __
|
|
|
|
| |_)|_(_ _ _.._._ _ | _
|
|
|
|
_|_| | __) _>\/\/(_|| | | ||<(/_\/
|
|
|
|
/
|
2020-03-26 03:08:15 +01:00
|
|
|
USED ONLY ONCE... Next swarm.key change will use ipfs.
|
2020-03-25 14:26:40 +01:00
|
|
|
'
|
|
|
|
|
|
|
|
self=$(sbotc whoami | jq -r .id) || exit 1
|
|
|
|
g1self=$(echo $self | cut -d '@' -f 2 | cut -d '.' -f 1 | base64 -d | base58)
|
|
|
|
self_name=$(sbotc query.read '{"query":[{"$filter":{"value":{"author": "'"$self"'", "content":{"type":"about", "about": "'"$self"'"}}}}]}' | jq -r .value?.content?.name | grep -v null | tail -n 1)
|
|
|
|
|
|
|
|
ipfsnodeid=$(ipfs id -f='<id>\n')
|
|
|
|
[[ ! $ipfsnodeid ]] && echo "ERROR ipfs id" && exit 1
|
|
|
|
|
2020-03-26 03:08:15 +01:00
|
|
|
messages=$(sbotc backlinks.read '{"query":[{"$filter":{"dest":"#astroport-swarmkey","value":{"content":{"type":"post"}}}}]}')
|
2020-03-25 14:26:40 +01:00
|
|
|
while read -r msg
|
|
|
|
do
|
|
|
|
|
|
|
|
autofollow=$(printf %s "$msg" | jq .value.content.autofollow)
|
|
|
|
[[ ! $autofollow ]] && echo "I am NOT the Pub..." && echo "$msg" | jq && continue
|
|
|
|
|
|
|
|
echo "
|
|
|
|
___ _______ _ _ ___ ____
|
|
|
|
| |\ |\ /| ||_ / / \|\ || /\ / |
|
|
|
|
_|_| \| \/_|_ ||_ \_\_/| \||/--\\_ | RECEIVED
|
|
|
|
|
|
|
|
|
|
|
|
"
|
|
|
|
author=$(printf %s "$msg" | jq -r .value.author)
|
|
|
|
g1author=$(printf %s "$msg" | jq -r .value.author | cut -d '@' -f 2 | cut -d '.' -f 1 | base64 -d | base58)
|
|
|
|
|
|
|
|
# Crypt, ipfs store, send
|
|
|
|
if [[ -f ~/.ipfs/swarm.key ]]; then
|
|
|
|
|
|
|
|
|
|
|
|
mkdir -p ~/.zen/ipfs/.${ipfsnodeid}/INVITE/${g1author}
|
|
|
|
|
|
|
|
file=~/.zen/ipfs/.${ipfsnodeid}/INVITE/${g1author}/ipfs_swarm.key.crypt
|
|
|
|
$MY_PATH/tools/natools.py encrypt -p ${g1author} -i ~/.ipfs/swarm.key -o ${file}
|
|
|
|
cp ${file} ~/.zen/ipfs/.${ipfsnodeid}/INVITE/${g1author}/
|
|
|
|
echo "
|
|
|
|
$author
|
|
|
|
|
|
|
|
\|/ \|/ \|/
|
|
|
|
/|\ /|\ /|\ cyphering swarmkey
|
|
|
|
|
|
|
|
IPFS
|
|
|
|
~/.zen/ipfs/.${ipfsnodeid}/INVITE/${g1author}/ipfs_swarm.key.crypt
|
|
|
|
|
|
|
|
"
|
|
|
|
|
|
|
|
name=${file##*/}
|
|
|
|
id="$(sbotc blobs.add < "$file")"
|
|
|
|
type="$(file -b --mime-type "$file")"
|
|
|
|
size="$(wc -c < "$file")"
|
|
|
|
|
|
|
|
echo "
|
|
|
|
______ _ _ _ ____ __ _ _ _ _ _____
|
|
|
|
/\ (_ ||_)/ \|_)/ \|_)|__(_\ //\ |_)|\/||/|_\_/ |_)/ \(_ |
|
|
|
|
/--\__) || \\_/| \_/| \| __)\/\//--\| \| ||\|_ | | \_/__) |
|
|
|
|
|
|
|
|
SSB
|
|
|
|
#astroport-swarmkey
|
|
|
|
[$name]($id)
|
|
|
|
TO.SSB_${author}
|
|
|
|
TO.G1_${g1author}
|
|
|
|
+++
|
|
|
|
FROM.SSB_${self_name}
|
|
|
|
FROM.G1_${g1self}
|
|
|
|
FROM.IPFS_${ipfsnodeid}
|
|
|
|
|
|
|
|
"
|
|
|
|
|
2020-03-26 04:52:57 +01:00
|
|
|
sbotc publish '{"type":"post","text":"#astroport-swarmkey = ['"$name"']('"$id"') TO.SSB_'"$author"' TO.G1_'"$g1author"' +++ FROM.SSB_'"$self_name"' FROM.G1_'"$g1self"' FROM.IPFS_'"$ipfsnodeid"'","mentions":[{"link":"'"$id"'","name":"'"$name"'","size":'"$size"',"type":"'"$type"'"}]}'
|
2020-03-25 14:26:40 +01:00
|
|
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
done < <(printf '%s\n' "$messages")
|