added blocks and mutes export; fixes; reorder

This commit is contained in:
localhost_frssoft 2022-04-13 20:14:22 +03:00
parent 93d672b5f0
commit e321f3584d
1 changed files with 74 additions and 7 deletions

View File

@ -90,7 +90,14 @@ follow_api_export()
while [ $count -gt 0 ]; do
followings=$(followings_api_get $acc_id)
count=$(echo $followings | jj \#)
if [ $count -gt 0 ]; then
if [ $count -lt 40 ]; 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"
count=0
echo "$acc_following_count followings exported"
elif [ $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)
@ -102,10 +109,60 @@ follow_api_export()
done
}
mutes_api_import()
blocks_api_export()
{
curl -s --compressed -H "Authorization: Bearer $auth" "$instance_point_pleroma/mutes_import" \
--data 'list=@restore/mutes.csv'
count=40
mkdir -m 711 -p backups_$instance
while [ $count -gt 0 ]; do
blocks=$(blocks_api_get)
count=$(echo $blocks | jj \#)
if [ $count -lt 40 ]; then
countindex=$(expr $count - 1)
echo $blocks | jj -l \#.fqn | sed 's/"//g' >> backups_$instance/blocks.csv
offset=$(echo $blocks | jj $countindex.id)
echo "+$count blocks"
count=0
echo "Blocks exported"
elif [ $count -gt 0 ]; then
echo $blocks | jj -l \#.fqn | sed 's/"//g' >> backups_$instance/blocks.csv
offset=$(echo $blocks | jj $countindex.id)
echo "+$count blocks"
else
echo "Blocks exported"
fi
sleep 1
done
}
mutes_api_export()
{
count=40
mkdir -m 711 -p backups_$instance
while [ $count -gt 0 ]; do
mutes=$(mutes_api_get)
count=$(echo $mutes | jj \#)
if [ $count -lt 40 ]; then
countindex=$(expr $count - 1)
echo $mutes | jj -l \#.fqn | sed 's/"//g' >> backups_$instance/mutes.csv
offset=$(echo $mutes | jj $countindex.id)
echo "+$count mutes"
count=0
echo "Mutes exported"
elif [ $count -gt 0 ]; then
echo $mutes | jj -l \#.fqn | sed 's/"//g' >> backups_$instance/mutes.csv
offset=$(echo $mutes | jj $countindex.id)
echo "+$count mutes"
else
echo "Mutes exported"
fi
sleep 1
done
}
follow_api_import()
{
curl -v --compressed -H "Authorization: Bearer $auth" "$instance_point_pleroma/follow_import" \
--data 'list=@restore/friends.csv'
}
blocks_api_import()
@ -114,10 +171,10 @@ blocks_api_import()
--data 'list=@restore/blocks.csv'
}
follow_api_import()
mutes_api_import()
{
curl -v --compressed -H "Authorization: Bearer $auth" "$instance_point_pleroma/follow_import" \
--data 'list=@restore/friends.csv'
curl -s --compressed -H "Authorization: Bearer $auth" "$instance_point_pleroma/mutes_import" \
--data 'list=@restore/mutes.csv'
}
#[MIGRATION SECTION END]
@ -131,6 +188,16 @@ followings_api_get()
default_curl_opt "$instance_point/accounts/$1/following?limit=40&max_id=$offset"
}
blocks_api_get()
{
default_curl_opt "$instance_point/blocks?limit=40&max_id=$offset"
}
mutes_api_get()
{
default_curl_opt "$instance_point/mutes?limit=40&max_id=$offset"
}
thread_api_statuses()
{
default_curl_opt "$instance_point/statuses/$1/context"