From f4721274e77495fa74822badca774cd701d91d0d Mon Sep 17 00:00:00 2001 From: Jaidyn Ann <10477760+JadedCtrl@users.noreply.github.com> Date: Tue, 13 Feb 2024 09:55:24 -0600 Subject: [PATCH] =?UTF-8?q?Add=20optionally-auth=E2=80=99d=20archival=20to?= =?UTF-8?q?=20fedi-archive?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Now even private posts can be fetched, if you so choose. --- fedi-archive.sh | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/fedi-archive.sh b/fedi-archive.sh index 235aee0..c1159d2 100644 --- a/fedi-archive.sh +++ b/fedi-archive.sh @@ -36,11 +36,16 @@ 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=true&exclude_reblogs=true&limit=40" + local url="https://$server/api/v1/accounts/$user/statuses?exclude_replies=false&exclude_reblogs=true&limit=40" if test -n "$max_id"; then url="${url}&max_id=${max_id}" fi - curl "$url" + if test -n "$FEDI_AUTH"; then + curl --header "Authorization: Bearer $FEDI_AUTH" \ + "$url" + else + curl "$url" + fi } @@ -102,10 +107,15 @@ 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 "$(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 exit 2; }