Compare commits
No commits in common. "43ce10b5a59b75c911c8a93e38463efdee4e820c" and "92b9476c870c9b59e69f0ec6e74748140b8da139" have entirely different histories.
43ce10b5a5
...
92b9476c87
|
@ -36,16 +36,11 @@ output_post_of_index() {
|
|||
# `max_id` can be passed to return only messages older than said message.
|
||||
fetch_page() {
|
||||
local server="$1"; local user="$2"; local max_id="$3"
|
||||
local url="https://$server/api/v1/accounts/$user/statuses?exclude_replies=false&exclude_reblogs=true&limit=40"
|
||||
local url="https://$server/api/v1/accounts/$user/statuses?exclude_replies=true&exclude_reblogs=true&limit=40"
|
||||
if test -n "$max_id"; then
|
||||
url="${url}&max_id=${max_id}"
|
||||
fi
|
||||
if test -n "$FEDI_AUTH"; then
|
||||
curl --header "Authorization: Bearer $FEDI_AUTH" \
|
||||
"$url"
|
||||
else
|
||||
curl "$url"
|
||||
fi
|
||||
curl "$url"
|
||||
}
|
||||
|
||||
|
||||
|
@ -107,15 +102,10 @@ archive_all_posts() {
|
|||
|
||||
usage() {
|
||||
echo "usage: $(basename $0) username server" 1>&2
|
||||
echo 1>&2
|
||||
echo "$(basename $0) is a script that fetches all of a user’s Mastodon/Pleroma" 1>&2
|
||||
echo 'posts for archival purposes.' 1>&2
|
||||
echo 'Mainly for use with fedi-post.sh or pleroma-migrate.sh.' 1>&2
|
||||
echo 1>&2
|
||||
echo 'Optionally, you can fetch also any private statuses by the account visible' 1>&2
|
||||
echo 'to you by providing your auth key in the $FEDI_AUTH environment variable.' 1>&2
|
||||
echo 'You can find your auth key by examining the “Authentication: Bearer” header' 1>&2
|
||||
echo 'used in requests by your server’s web-client. In Firefox, F12→Network.' 1>&2
|
||||
echo "" 1>&2
|
||||
echo "$(basename $0) is a script that fetches all of a user's Mastodon/Pleroma" 1>&2
|
||||
echo "posts for archival purposes." 1>&2
|
||||
echo "Mainly for use with fedi-post.sh or pleroma-migrate.sh." 1>&2
|
||||
exit 2;
|
||||
}
|
||||
|
||||
|
|
63
fedi-nuke.sh
63
fedi-nuke.sh
|
@ -1,63 +0,0 @@
|
|||
#!/bin/sh
|
||||
#―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――
|
||||
# Name: fedi-nuke.sh
|
||||
# Desc: Deletes a given status of yours from a Mastodon-compatible fedi server.
|
||||
# Reqs: curl, jq
|
||||
# Date: 2024-02-13
|
||||
# Auth: @jadedctrl@jam.xwx.moe
|
||||
#―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――
|
||||
|
||||
|
||||
# Post a status of the given message and JSON-array of uploaded media-IDs.
|
||||
remove_post() {
|
||||
local status_id="$1"
|
||||
|
||||
curl --request DELETE \
|
||||
--header "Authorization: Bearer $FEDI_AUTH" \
|
||||
"https://$SERVER/api/v1/statuses/$status_id"
|
||||
}
|
||||
|
||||
|
||||
# Take a post file generated by fedi-archive.sh, and post it.
|
||||
# Just *do it*. Why not? What're you scared of? Huh, huh? Huh?!
|
||||
remove_archived_post() {
|
||||
local file="$1"
|
||||
IFS="
|
||||
"
|
||||
local id="$(head -1 "$file" | awk '{print $3}')"
|
||||
remove_post "$id"
|
||||
}
|
||||
|
||||
|
||||
usage() {
|
||||
echo "usage: $(basename "$0") SERVER POST-ID" 1>&1
|
||||
echo " $(basename "$0") SERVER ARCHIVED-POST" 1>&2
|
||||
echo 1>&2
|
||||
echo 'Will delete a post from a Mastodon-compatible fedi server by either' 1>&1
|
||||
echo 'ID or by an archived-post file (in fedi-archive.sh format).' 1>&2
|
||||
echo 'Your authorization key must be borrowed from your web-browser and' 1>&2
|
||||
echo 'placed in the $FEDI_AUTH environment variable.' 1>&2
|
||||
exit 2
|
||||
}
|
||||
|
||||
|
||||
if test -z "$FEDI_AUTH"; then
|
||||
echo 'You need to set the environment variable $FEDI_AUTH!' 1>&2
|
||||
echo 'You can find your auth key by examining the "Authentication: Bearer" header' 1>&2
|
||||
echo "used in requests by your server's web-client." 1>&2
|
||||
echo 'In Firefox, F12→Network.' 1>&2
|
||||
echo "" 1>&2
|
||||
usage
|
||||
fi
|
||||
|
||||
SERVER="$1"
|
||||
TARGET="$2"
|
||||
if test -z "$SERVER" -o -z "$TARGET" -o "$1" = "-h" -o "$1" = "--help"; then
|
||||
usage
|
||||
fi
|
||||
|
||||
if test -f "$TARGET"; then
|
||||
remove_archived_post "$TARGET"
|
||||
else
|
||||
remove_post "$TARGET"
|
||||
fi
|
25
fedi-post.sh
25
fedi-post.sh
|
@ -75,7 +75,7 @@ post_media() {
|
|||
--header "Content-Type: multipart/form-data" \
|
||||
--form "file=@$media_file" \
|
||||
--form "description=$description" \
|
||||
"https://$SERVER/api/v1/media"
|
||||
"https://jam.xwx.moe/api/v1/media"
|
||||
}
|
||||
|
||||
|
||||
|
@ -89,7 +89,7 @@ post_status() {
|
|||
--header "Authorization: Bearer $FEDI_AUTH" \
|
||||
--header "Content-Type: application/json" \
|
||||
--data "$(post_json "$message" "$media_ids" "$spoiler" | tr -d '\n')" \
|
||||
"https://$SERVER/api/v1/statuses"
|
||||
"https://jam.xwx.moe/api/v1/statuses"
|
||||
}
|
||||
|
||||
|
||||
|
@ -119,10 +119,10 @@ post_archived_post() {
|
|||
|
||||
usage() {
|
||||
echo "usage: $(basename "$0") ARCHIVED-POST" 1>&2
|
||||
echo 1>&2
|
||||
echo 'Will post a new status with the same text and attachments as one' 1>&2
|
||||
echo 'from an archived post (in fedi-archive.sh format).' 1>&2
|
||||
echo 'Your authorization key must be borrowed from your web-browser and' 1>&2
|
||||
echo "" 1>&2
|
||||
echo "Will post a new status with the same text and attachments as one" 1>&2
|
||||
echo "from an archived post (in fedi-archive.sh format)." 1>&2
|
||||
echo "Your authorization key must be borrowed from your web-browser and" 1>&2
|
||||
echo 'placed in the $FEDI_AUTH environment variable.' 1>&2
|
||||
exit 2
|
||||
}
|
||||
|
@ -130,18 +130,17 @@ usage() {
|
|||
|
||||
if test -z "$FEDI_AUTH"; then
|
||||
echo 'You need to set the environment variable $FEDI_AUTH!' 1>&2
|
||||
echo 'You can find your auth key by examining the “Authentication: Bearer” header' 1>&2
|
||||
echo 'used in requests by your server’s web-client.' 1>&2
|
||||
echo 'You can find your auth key by examining the "Authentication: Bearer" header' 1>&2
|
||||
echo "used in requests by your server's web-client." 1>&2
|
||||
echo 'In Firefox, F12→Network.' 1>&2
|
||||
echo 1>&2
|
||||
echo "" 1>&2
|
||||
usage
|
||||
fi
|
||||
|
||||
SERVER="$1"
|
||||
FILE="$2"
|
||||
if test -z "$SERVER" -o -z "$FILE" -o "$1" = "-h" -o "$1" = "--help"; then
|
||||
FILE="$1"
|
||||
if test -z "$FILE" -o "$1" = "-h" -o "$1" = "--help"; then
|
||||
usage
|
||||
fi
|
||||
|
||||
|
||||
post_archived_post "$SERVER" "$FILE"
|
||||
post_archived_post "$FILE"
|
||||
|
|
|
@ -10,31 +10,30 @@
|
|||
#―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――
|
||||
|
||||
usage() {
|
||||
echo "usage: $(basename "$0") OLD-USERNAME OLD-SERVER NEW-SERVER" 1>&2
|
||||
echo 1>&2
|
||||
echo 'Will archive all posts from your old account (fedi-archive.sh),' 1>&2
|
||||
echo 'post them to your new one (fedi-post.sh), and then modify Pleroma’s' 1>&2
|
||||
echo 'database to match the copy-posts’ creation dates with the original posts.' 1>&2
|
||||
echo "usage: $(basename "$0") USERNAME OLD-SERVER" 1>&2
|
||||
echo "" 1>&2
|
||||
echo "Will archive all posts from your old account (fedi-archive.sh)," 1>&2
|
||||
echo "post them to your new one (fedi-post.sh), and then modify Pleroma's" 1>&2
|
||||
echo "database to match the copy-posts' creation dates with the original posts." 1>&2
|
||||
echo 'The env variable $FEDI_AUTH must contain your authentication key from your browser.' 1>&2
|
||||
exit 2
|
||||
}
|
||||
|
||||
|
||||
USERNAME="$1"
|
||||
OLD_SERVER="$2"
|
||||
NEW_SERVER="$3"
|
||||
if test -z "$USERNAME" -o -z "$OLD_SERVER" -o -z "$NEW_SERVER" -o "$1" = "-h" -o "$1" = "--help"; then
|
||||
SERVER="$2"
|
||||
if test -z "$USERNAME" -o -z "$SERVER" -o "$1" = "-h" -o "$1" = "--help"; then
|
||||
usage
|
||||
fi
|
||||
|
||||
|
||||
mkdir archive
|
||||
cd archive/
|
||||
sh ../fedi-archive.sh "$USERNAME" "$OLD_SERVER"
|
||||
sh ../fedi-archive.sh "$USERNAME" "$SERVER"
|
||||
|
||||
|
||||
for file in ./*; do
|
||||
sh ../fedi-post.sh "$NEW_SERVER" "$file" \
|
||||
sh ../fedi-post.sh "$file" \
|
||||
>> imports-data.txt
|
||||
done
|
||||
|
||||
|
@ -42,13 +41,12 @@ done
|
|||
IFS="
|
||||
"
|
||||
|
||||
echo 'It’s time to re-date your posts!'
|
||||
echo 'Are you suuuuuuuuuuuuure you wanna risk your database? Do a backup, first!'
|
||||
echo '^C now, before you risk it! Hit ENTER, if you’re sure.'
|
||||
read
|
||||
echo "It's time to re-date your posts!"
|
||||
echo "Are you suuuuuuuuuuuuure you wanna risk your database? Do a backup, first!"
|
||||
echo "^C now, before you risk it! Hit ENTER, if you're sure."
|
||||
read
|
||||
sleep 5
|
||||
echo 'Alright, then, you brave fellow! I’m touched you trust me so much, though :o'
|
||||
echo "Alright, then, you brave fellow! I'm touched you trust me so much, though :o"
|
||||
|
||||
for line in $(cat imports-data.txt); do
|
||||
sh ../pleroma-redate.sh "$(echo "$line" | awk '{print $3}')" \
|
||||
|
|
Ŝarĝante…
Reference in New Issue