custodisco-kiosk/ssb-post.sh

68 lines
1.2 KiB
Bash
Executable File

#!/bin/bash
# custodisco posting
#GIVE and MINT options
## ok we need to be passed a number of arguments
## item description/GIVE to account ID = $2
## image path/messageID of existing item = $3
if [ -z "$1" ]
then
echo "need arguments pls"
fi
## mint
if [ "$1" == "mint" ]
then
itemDescription=$2
itemImagePath=$3
# remove meta-data from the image and compress a bit
jpegoptim --strip-all --overwrite "$itemImagePath" --size=200k > /dev/null 2>&1
#add blob
blobID=$(cat $itemImagePath | ssb-server blobs.add) || exit 1
# publish the item
ssb-server publish . <<BLAAB
{
"type":"post",
"text":"![photo.jpg]($blobID)\\n\\n$itemDescription\\n\\n a #custodisco item ",
"custodisco":"true",
"nft": "mint",
"mentions": [
{
"name": "photo.jpg",
"type": "image/jpeg",
"link": "$blobID"
}
]
}
BLAAB
fi
## give
if [ "$1" == "give" ]
then
account=$2
messageID=$3
ssb-server publish . <<BLAAB
{
"type":"post",
"text":"This item is stewarded by $account",
"custodisco":"true",
"nft": "give",
"target": "$account",
"root": "$messageID",
"branch": "$messageID"
}
BLAAB
fi