1
0
Fork 0

fix in toot.sh

This commit is contained in:
ekardnam 2019-02-22 10:20:11 +00:00
parent 5621cfe1fa
commit e491bf729f

21
toot.sh
View file

@ -39,7 +39,7 @@ toot_upload_image(){
exit 1 exit 1
} }
toot_post(){ toot_post_with_image(){
local status="$1" local status="$1"
local image="$2" local image="$2"
local sensitive="$3" local sensitive="$3"
@ -52,7 +52,19 @@ toot_post(){
echo $error echo $error
exit 1 exit 1
fi fi
}
toot_post(){
local status="$1"
local data="status=$status"
local error=$(curl --header "Authorization: Bearer $MASTODON_TOKEN" -sS -X POST https://$MASTODON_SERVER/api/v1/statuses -d "$data" | jq -r .error)
if [ "$error" = "null" ]
then
echo "[$(date)][INFO] Tooted: $status"
else
echo $error
exit 1
fi
} }
image_to_toot="" image_to_toot=""
@ -99,9 +111,10 @@ then
exit 1 exit 1
fi fi
if [ -n $image_to_toot ] && [ -f $image_to_toot ] if [ "$image_to_toot" != "" ] && [ -f $image_to_toot ]
then then
image_id=$(toot_upload_image "$image_to_toot" "$image_alt") image_id=$(toot_upload_image "$image_to_toot" "$image_alt")
toot_post_with_image "$*" "$image_id" "$sensitive"
else
toot_post "$*" "$image_id" "$sensitive"
fi fi
toot_post "$*" "$image_id" "$sensitive"