diff --git a/pleroma-cli.sh b/pleroma-cli.sh index a9758e9..fd3d09d 100755 --- a/pleroma-cli.sh +++ b/pleroma-cli.sh @@ -277,7 +277,46 @@ followings_menu() 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() @@ -745,6 +784,7 @@ menu_write_status='Write status' menu_timeline='Timelines' notif='Notifications' followingsmenu='Followings' +followrequests='Follow requests' authmake='Auth' backup_restore='Backup/Restore' switchinstance='Switch instance' @@ -752,7 +792,7 @@ Exit='Exit' while true; do 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 main_menu=$(echo "$authmake\n$menu_timeline\n$switchinstance\n$Exit" | fzy) fi @@ -764,6 +804,7 @@ case $main_menu in ;; "$notif") notif_menu ;; "$followingsmenu") followings_menu ;; + "$followrequests") menu_follow_requests ;; "$backup_restore") backup_restore_menu ;; "$switchinstance") empty=0