mirror of
http://gitea.phreedom.club/localhost_frssoft/pleroma-cli
synced 2024-11-24 10:31:28 +00:00
Added edit/remove statuses
This commit is contained in:
parent
5eb9853a1c
commit
059831d9d5
|
@ -64,10 +64,15 @@ make_login()
|
||||||
{
|
{
|
||||||
curl -s --compressed -X PUT -H "Authorization: Bearer $auth" "$@"
|
curl -s --compressed -X PUT -H "Authorization: Bearer $auth" "$@"
|
||||||
}
|
}
|
||||||
|
delete_request()
|
||||||
|
{
|
||||||
|
curl -s --compressed -X DELETE -H "Authorization: Bearer $auth" "$@"
|
||||||
|
}
|
||||||
echo '+Authorized account+'
|
echo '+Authorized account+'
|
||||||
export default_curl_opt
|
export default_curl_opt
|
||||||
export post_request
|
export post_request
|
||||||
export put_request
|
export put_request
|
||||||
|
export delete_request
|
||||||
else
|
else
|
||||||
default_curl_opt()
|
default_curl_opt()
|
||||||
{
|
{
|
||||||
|
@ -285,6 +290,8 @@ account_api_me()
|
||||||
default_curl_opt "$instance_point/accounts/verify_credentials"
|
default_curl_opt "$instance_point/accounts/verify_credentials"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
me_acct=$(account_api_me | jj acct)
|
||||||
|
|
||||||
followings_api_get()
|
followings_api_get()
|
||||||
{
|
{
|
||||||
default_curl_opt "$instance_point/accounts/$1/following?limit=40&max_id=$offset"
|
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)
|
reply_to_id=$(echo "$status" | jj in_reply_to_id)
|
||||||
visibility_status=$(echo "$status" | jj visibility)
|
visibility_status=$(echo "$status" | jj visibility)
|
||||||
s_f_menu='\nShare\nShare and favorite'
|
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
|
if [ "$visibility_status" = "private" ] || [ "$visibility_status" = "direct" ]; then
|
||||||
s_f_menu=
|
s_f_menu=
|
||||||
fi
|
fi
|
||||||
|
@ -508,7 +519,7 @@ statuses_render()
|
||||||
next=0
|
next=0
|
||||||
force_stop=0
|
force_stop=0
|
||||||
while [ "$next" -eq 0 ]; do
|
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
|
case "$per_status_menu" in
|
||||||
"Next")
|
"Next")
|
||||||
next=1
|
next=1
|
||||||
|
@ -525,6 +536,8 @@ statuses_render()
|
||||||
"Favorite") favorite_api_status "$id_status" ;;
|
"Favorite") favorite_api_status "$id_status" ;;
|
||||||
"Bookmark") bookmark_api_status "$id_status" ;;
|
"Bookmark") bookmark_api_status "$id_status" ;;
|
||||||
"Reply") reply_mode "$id_status" ;;
|
"Reply") reply_mode "$id_status" ;;
|
||||||
|
"Edit") reply_mode "$id_status" '1' ;;
|
||||||
|
"Delete") delete_api_status "$id_status" ;;
|
||||||
"Back")
|
"Back")
|
||||||
next=1
|
next=1
|
||||||
force_stop=1
|
force_stop=1
|
||||||
|
@ -687,8 +700,10 @@ reply_mode()
|
||||||
read status_id
|
read status_id
|
||||||
reply_status=$(status_api_one "$status_id")
|
reply_status=$(status_api_one "$status_id")
|
||||||
fi
|
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
|
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
|
fi
|
||||||
if [ "$copy_mentions" = 'true' ]; then
|
if [ "$copy_mentions" = 'true' ]; then
|
||||||
mentions_reply=$(echo "$reply_status" | jj -l 'mentions.#.acct' | delq)
|
mentions_reply=$(echo "$reply_status" | jj -l 'mentions.#.acct' | delq)
|
||||||
|
@ -770,6 +785,17 @@ bookmark_api_status()
|
||||||
chmod 600 "bookmarks/$instance/$1"
|
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()
|
write_api_status()
|
||||||
{
|
{
|
||||||
if [ -n "$mediaattach" ]; then
|
if [ -n "$mediaattach" ]; then
|
||||||
|
@ -791,6 +817,12 @@ write_api_status()
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
edit_api_status()
|
||||||
|
{
|
||||||
|
put_request --url "$instance_point"/statuses/$1 \
|
||||||
|
--data-urlencode "status@$2"
|
||||||
|
}
|
||||||
|
|
||||||
upload_api_media()
|
upload_api_media()
|
||||||
{
|
{
|
||||||
post_request --url "$instance_point"/media \
|
post_request --url "$instance_point"/media \
|
||||||
|
@ -834,10 +866,11 @@ write_status_menu()
|
||||||
elif [ -n "$(echo "$status_data_send" | jj error)" ]; then
|
elif [ -n "$(echo "$status_data_send" | jj error)" ]; then
|
||||||
echo "Send state: ERR: $(echo "$status_data_send" | jj error)"
|
echo "Send state: ERR: $(echo "$status_data_send" | jj error)"
|
||||||
fi
|
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
|
case $wrirepostmenu in
|
||||||
"Edit") $EDITOR tmp_status.md ;;
|
"Edit") $EDITOR tmp_status.md ;;
|
||||||
"Send") status_data_send=$(write_api_status 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")
|
"Add attach")
|
||||||
echo 'Input path to attach (ex. @image.png or @/full/path/to/attach.png)'
|
echo 'Input path to attach (ex. @image.png or @/full/path/to/attach.png)'
|
||||||
read mediaattach
|
read mediaattach
|
||||||
|
|
Loading…
Reference in a new issue