From 93d672b5f017d45209a80d1e68e749d5899ca1a7 Mon Sep 17 00:00:00 2001 From: localhost_frssoft Date: Wed, 13 Apr 2022 19:30:59 +0300 Subject: [PATCH] Add import followings; pleroma api point variable --- pleroma-cli.sh | 39 +++++++++++++++++++++++++++++++++++---- 1 file changed, 35 insertions(+), 4 deletions(-) diff --git a/pleroma-cli.sh b/pleroma-cli.sh index 2d34bb1..a3b3559 100755 --- a/pleroma-cli.sh +++ b/pleroma-cli.sh @@ -2,6 +2,7 @@ instance=$(jj -i config.json instance) instance_point="https://$instance/api/v1" +instance_point_pleroma="https://$instance/api/pleroma" instance_hist='instance.hist' max_statuses=$(jj -i config.json max_statuses) default_visibility=$(jj -i config.json default_visibility) @@ -79,25 +80,55 @@ backup_api_list() curl -s --compressed -H "Authorization: Bearer $auth" "$instance_point/pleroma/backups" } +follow_api_export() +{ + count=40 + mkdir -m 711 -p backups_$instance + account_info=$(account_api_me) + acc_id=$(echo $account_info | jj id) + acc_following_count=$(echo $account_info | jj following_count) + while [ $count -gt 0 ]; do + followings=$(followings_api_get $acc_id) + count=$(echo $followings | jj \#) + if [ $count -gt 0 ]; then + countindex=$(expr $count - 1) + echo $followings | jj -l \#.fqn | sed 's/"//g' >> backups_$instance/friends.csv + offset=$(echo $followings | jj $countindex.id) + echo "+$count follows" + else + echo "$acc_following_count followings exported" + fi + sleep 1 + done +} + mutes_api_import() { - curl -s --compressed -X POST -H "Authorization: Bearer $auth" "$instance_point/pleroma/mutes_import" + curl -s --compressed -H "Authorization: Bearer $auth" "$instance_point_pleroma/mutes_import" \ + --data 'list=@restore/mutes.csv' } blocks_api_import() { - curl -s --compressed -X POST -H "Authorization: Bearer $auth" "$instance_point/pleroma/blocks_import" + curl -s --compressed -H "Authorization: Bearer $auth" "$instance_point_pleroma/blocks_import" \ + --data 'list=@restore/blocks.csv' } follow_api_import() { - curl -s --compressed -X POST -H "Authorization: Bearer $auth" "$instance_point/pleroma/follow_import" + curl -v --compressed -H "Authorization: Bearer $auth" "$instance_point_pleroma/follow_import" \ + --data 'list=@restore/friends.csv' } #[MIGRATION SECTION END] +account_api_me() +{ + default_curl_opt $instance_point/accounts/verify_credentials +} + followings_api_get() { - default_curl_opt -H "Authorization: Bearer $auth" "$instance_point/accounts/$1/following?limit=40" + default_curl_opt "$instance_point/accounts/$1/following?limit=40&max_id=$offset" } thread_api_statuses()