Added manage followings function: add and delete

This commit is contained in:
localhost_frssoft 2022-05-06 16:15:55 +03:00
parent bfdce6ecf0
commit eeb88482f6
1 changed files with 37 additions and 7 deletions

View File

@ -300,9 +300,12 @@ followings_menu()
"Main menu") sub_menu_lvl=0 ;;
"Next") offset=$(echo "$followings" | jj $(expr $(echo "$followings" | jj \#) - 1).id) ;;
*)
index=$(echo "$choice" | cut -f 1 -d:)
statuses_view_menu "$(echo "$followings" | jj "$index".acct)"
;;
index=$(echo "$choice" | cut -f 1 -d:)
case "$1" in
'Remove following') unfollow_account "$(echo "$followings" | jj "$index".id)" ;;
'') statuses_view_menu "$(echo "$followings" | jj "$index".acct)" ;;
esac
;;
esac
done
}
@ -322,6 +325,17 @@ reject_follow_request()
post_request "$instance_point/follow_requests/$1/reject"
}
follow_account()
{
acct_id=$(account_api_get "$1" | jj id)
post_request "$instance_point/accounts/$acct_id/follow"
}
unfollow_account()
{
post_request "$instance_point/accounts/$1/unfollow"
}
menu_follow_requests()
{
follow_req=$(following_requests)
@ -385,6 +399,11 @@ delqse()
sed 's/^"//g; s/"$//g'
}
account_api_get()
{
default_curl_opt "$instance_point/accounts/$1"
}
statuses_api_account()
{
default_curl_opt "$instance_point/accounts/$1/statuses?limit=$max_statuses&max_id=$2&min_id=$3"
@ -853,11 +872,12 @@ notif_api_remove_all()
menu_write_status='Write status'
menu_timeline='Timelines'
notif='Notifications'
followingsmenu='Followings'
followrequests='Follow requests'
my_account='Account'
followingsmenu='Followings'
followrequests='Follow requests'
backup_restore='Backup/Restore'
manage_followings='Manage followings'
authmake='Auth'
backup_restore='Backup/Restore'
switchinstance='Switch instance'
Exit='Exit'
@ -875,10 +895,20 @@ while true; do
;;
"$notif") notif_menu ;;
"$my_account")
my_account_menu=$(echo "$followingsmenu\n$followrequests\n$backup_restore" | fzy)
my_account_menu=$(echo "$followingsmenu\n$followrequests\n$manage_followings\n$backup_restore" | fzy)
case $my_account_menu in
"$followingsmenu") followings_menu ;;
"$followrequests") menu_follow_requests ;;
"$manage_followings")
action_manage=$(echo 'Add following\nRemove following' | fzy)
if [ "$action_manage" = 'Add following' ]; then
echo 'Input nick or full address (ex. example_nick or example@domain'
read add_account
follow_account "$add_account"
else
followings_menu "$action_manage"
fi
;;
"$backup_restore") backup_restore_menu ;;
esac
;;