From 1e2eaf0dbe835edfd2167957469fb6b38aec12e8 Mon Sep 17 00:00:00 2001 From: Jaidyn Ann <10477760+JadedCtrl@users.noreply.github.com> Date: Mon, 20 Nov 2023 00:17:30 -0600 Subject: [PATCH] =?UTF-8?q?Support=20configuring=20posts=E2=80=99=20scope?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sfeed_mastodon | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/sfeed_mastodon b/sfeed_mastodon index 2c7405a..6e9328d 100755 --- a/sfeed_mastodon +++ b/sfeed_mastodon @@ -14,8 +14,9 @@ usage() { echo "Posts sfeed(1) feed data from stdin to Mastodon-compatible servers." echo "" echo " -h print this message and exit" - echo " -a the authorization token for your account; see below" - echo " -t template for post contents; see below" + echo " -a the authorization token for your account" + echo " -s the scope for posts, one of: public/unlisted/private/direct" + echo " -t template for post contents" echo "" echo "To find your authorization token, you can snoop through request headers in" echo "your web-browser. In Firefox, this can be done through:" @@ -43,7 +44,7 @@ url_deescape() { # Takes a post’s contents and create the corresponding client-API JSON. post_json() { local message_text="$1" - printf '{ "content_type": "text/html", "visibility": "unlisted",' + printf '{ "content_type": "text/html", "visibility": "%s",' "$FEDI_SCOPE" printf '"status": "%s" }\n' "$message_text" } @@ -102,6 +103,9 @@ while getopts 'ha:t:' arg; do usage exit 0 ;; + s) + FEDI_SCOPE="$OPTARG" + ;; a) FEDI_AUTH="$OPTARG" ;; @@ -133,6 +137,11 @@ if test -z "$SERVER_URL"; then fi +if test -z "$FEDI_SCOPE"; then + FEDI_SCOPE="public" +fi + + IFS=" " while read -r line; do