Added edit/remove statuses

This commit is contained in:
localhost_frssoft 2022-08-03 00:12:14 +03:00
parent 5eb9853a1c
commit 059831d9d5

View file

@ -64,10 +64,15 @@ make_login()
{
curl -s --compressed -X PUT -H "Authorization: Bearer $auth" "$@"
}
delete_request()
{
curl -s --compressed -X DELETE -H "Authorization: Bearer $auth" "$@"
}
echo '+Authorized account+'
export default_curl_opt
export post_request
export put_request
export delete_request
else
default_curl_opt()
{
@ -285,6 +290,8 @@ account_api_me()
default_curl_opt "$instance_point/accounts/verify_credentials"
}
me_acct=$(account_api_me | jj acct)
followings_api_get()
{
default_curl_opt "$instance_point/accounts/$1/following?limit=40&max_id=$offset"
@ -464,6 +471,10 @@ statuses_render()
reply_to_id=$(echo "$status" | jj in_reply_to_id)
visibility_status=$(echo "$status" | jj visibility)
s_f_menu='\nShare\nShare and favorite'
edit_del_menu=
if [ "$whoacct" = "$me_acct" ]; then
edit_del_menu='\nEdit\nDelete'
fi
if [ "$visibility_status" = "private" ] || [ "$visibility_status" = "direct" ]; then
s_f_menu=
fi
@ -508,7 +519,7 @@ statuses_render()
next=0
force_stop=0
while [ "$next" -eq 0 ]; do
per_status_menu=$(echo "Next$menuattachments"$menu_pgp"\nFavorite$s_f_menu\nBookmark\nReply\nBack" | fzy)
per_status_menu=$(echo "Next$menuattachments"$menu_pgp"\nFavorite$s_f_menu\nBookmark\nReply$edit_del_menu\nBack" | fzy)
case "$per_status_menu" in
"Next")
next=1
@ -525,6 +536,8 @@ statuses_render()
"Favorite") favorite_api_status "$id_status" ;;
"Bookmark") bookmark_api_status "$id_status" ;;
"Reply") reply_mode "$id_status" ;;
"Edit") reply_mode "$id_status" '1' ;;
"Delete") delete_api_status "$id_status" ;;
"Back")
next=1
force_stop=1
@ -687,8 +700,10 @@ reply_mode()
read status_id
reply_status=$(status_api_one "$status_id")
fi
if [ "$quoting_reply" = 'true' ]; then
if [ "$quoting_reply" = 'true' && "$2" = '' ]; then
echo "$reply_status" | jj -r content | html_to_txt_render | delqse | sed 's/^/> /' > tmp_status.md
elif [ "$2" = '1' ]; then
echo "$reply_status" | jj -r content | html_to_txt_render | delqse > tmp_status.md
fi
if [ "$copy_mentions" = 'true' ]; then
mentions_reply=$(echo "$reply_status" | jj -l 'mentions.#.acct' | delq)
@ -770,6 +785,17 @@ bookmark_api_status()
chmod 600 "bookmarks/$instance/$1"
}
delete_api_status()
{
remove_status=$(delete_request "$instance_point/statuses/$1" | jj id)
if [ -n "$remove_status" ]; then
echo "SUCCESS"
sleep 1
else
echo "Failed"
fi
}
write_api_status()
{
if [ -n "$mediaattach" ]; then
@ -791,6 +817,12 @@ write_api_status()
fi
}
edit_api_status()
{
put_request --url "$instance_point"/statuses/$1 \
--data-urlencode "status@$2"
}
upload_api_media()
{
post_request --url "$instance_point"/media \
@ -834,10 +866,11 @@ write_status_menu()
elif [ -n "$(echo "$status_data_send" | jj error)" ]; then
echo "Send state: ERR: $(echo "$status_data_send" | jj error)"
fi
wrirepostmenu=$(echo "Edit\nSend\nAdd attach\nAdd recipient\nChange type\nVisiblity\nReset\nBack\nMain menu" | fzy)
wrirepostmenu=$(echo "Edit\nSend\nSend-edited\nAdd attach\nAdd recipient\nChange type\nVisiblity\nReset\nBack\nMain menu" | fzy)
case $wrirepostmenu in
"Edit") $EDITOR tmp_status.md ;;
"Send") status_data_send=$(write_api_status tmp_status.md) ;;
"Send-edited") status_data_send=$(edit_api_status $replyto tmp_status.md) ;;
"Add attach")
echo 'Input path to attach (ex. @image.png or @/full/path/to/attach.png)'
read mediaattach