Follow requests handler added

This commit is contained in:
localhost_frssoft 2022-04-22 01:56:10 +03:00
parent 5eeb8c2984
commit 755fdc0df9

View file

@ -277,7 +277,46 @@ followings_menu()
following_requests() following_requests()
{ {
echo 'TODO: make followings requests handle' default_curl_opt "$instance_point/follow_requests"
}
accept_follow_request()
{
default_curl_opt "$instance_point/follow_requests/$1/authorize"
}
reject_follow_requests()
{
default_curl_opt "$instance_point/follow_requests/$1/reject"
}
menu_follow_requests()
{
follow_req=$(following_requests)
count=$(echo "$follow_req" | jj \#)
ids=$(echo "$follow_req" | jj -l \#.id | delq)
clear
echo "Follow requests: $count"
for i in $ids; do
whoacct=$(echo "$follow_req" | jj "#[id=$i].acct")
datecreate=$(echo "$follow_req" | jj "#[id=$i].created_at")
acct_display=$(echo "$follow_req" | jj "#[id=$i].display_name")
acct_bot=$(echo "$follow_req" | jj "#[id=$i].bot")
note=$(echo "$follow_req" | jj "#[id=$i].note" | html_to_txt_render)
echo "$acct_display $whoacct"
echo "Account creation date: $(date -d "$datecreate" "$format_time")"
echo "Bot: $acct_bot"
echo "Note:\n $note"
choice=$(echo 'Accept\nReject\nNothing' | fzy)
case "$choice" in
"Accept") accept_follow_request "$i" ;;
"Reject") reject_follow_request "$i" ;;
"Nothing") echo ;;
esac
clear
done
} }
blocks_api_get() blocks_api_get()
@ -745,6 +784,7 @@ menu_write_status='Write status'
menu_timeline='Timelines' menu_timeline='Timelines'
notif='Notifications' notif='Notifications'
followingsmenu='Followings' followingsmenu='Followings'
followrequests='Follow requests'
authmake='Auth' authmake='Auth'
backup_restore='Backup/Restore' backup_restore='Backup/Restore'
switchinstance='Switch instance' switchinstance='Switch instance'
@ -752,7 +792,7 @@ Exit='Exit'
while true; do while true; do
if [ -n "$auth" ]; then if [ -n "$auth" ]; then
main_menu=$(echo "$menu_write_status\n$menu_timeline\n$notif\n$followingsmenu\n$backup_restore\n$switchinstance\n$Exit" | fzy) main_menu=$(echo "$menu_write_status\n$menu_timeline\n$notif\n$followingsmenu\n$followrequests\n$backup_restore\n$switchinstance\n$Exit" | fzy)
else else
main_menu=$(echo "$authmake\n$menu_timeline\n$switchinstance\n$Exit" | fzy) main_menu=$(echo "$authmake\n$menu_timeline\n$switchinstance\n$Exit" | fzy)
fi fi
@ -764,6 +804,7 @@ case $main_menu in
;; ;;
"$notif") notif_menu ;; "$notif") notif_menu ;;
"$followingsmenu") followings_menu ;; "$followingsmenu") followings_menu ;;
"$followrequests") menu_follow_requests ;;
"$backup_restore") backup_restore_menu ;; "$backup_restore") backup_restore_menu ;;
"$switchinstance") "$switchinstance")
empty=0 empty=0