3 Commity cea28c643c ... 1e2eaf0dbe

Autor SHA1 Správa Dátum
  Jaidyn Ann 1e2eaf0dbe Support configuring posts’ scope 1 rok pred
  Jaidyn Ann 61b22d1e09 Escape quotation-marks in post descriptions 1 rok pred
  Jaidyn Ann edb9ccd1ac Fix typo in mirror_feed.sh 1 rok pred
2 zmenil súbory, kde vykonal 16 pridanie a 6 odobranie
  1. 2 2
      docs/mirror_feed.sh
  2. 14 4
      sfeed_mastodon

+ 2 - 2
docs/mirror_feed.sh

@@ -51,5 +51,5 @@ if test -z "$FEDI_AUTH" -o -z "$FEDI_SERVER"; then
 fi
 fi
 
 
 
 
-sfeed_update "$MIRROR_DIR/.sfeedrc"
-cat "$MIRROR_DIR/sfeed/* | sfeed_mastodon "$FEDI_SERVER"
+sfeed_update "$MIRROR_DIR"/sfeedrc
+cat "$MIRROR_DIR"/sfeed/* | sfeed_mastodon "$FEDI_SERVER"

+ 14 - 4
sfeed_mastodon

@@ -14,8 +14,9 @@ usage() {
 	echo "Posts sfeed(1) feed data from stdin to Mastodon-compatible servers."
 	echo "Posts sfeed(1) feed data from stdin to Mastodon-compatible servers."
 	echo ""
 	echo ""
 	echo "  -h             print this message and exit"
 	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 ""
 	echo "To find your authorization token, you can snoop through request headers in"
 	echo "To find your authorization token, you can snoop through request headers in"
 	echo "your web-browser. In Firefox, this can be done through:"
 	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.
 # Takes a post’s contents and create the corresponding client-API JSON.
 post_json() {
 post_json() {
 	local message_text="$1"
 	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"
 	printf '"status": "%s" }\n' "$message_text"
 }
 }
 
 
@@ -79,7 +80,8 @@ sfeed_post_text() {
 		| sed "s|{{url}}|$url|g" \
 		| sed "s|{{url}}|$url|g" \
 		| sed "s|{{desc}}|$desc|g" \
 		| sed "s|{{desc}}|$desc|g" \
 		| sed "s|{{desc_short}}|$desc_snip|g" \
 		| sed "s|{{desc_short}}|$desc_snip|g" \
-		| sed 's%\\n%%' \
+		| sed 's|\\n||g' \
+		| sed 's|"|\\"|g' \
 		| tr -d '	\n'
 		| tr -d '	\n'
 }
 }
 
 
@@ -101,6 +103,9 @@ while getopts 'ha:t:' arg; do
 			usage
 			usage
 			exit 0
 			exit 0
 			;;
 			;;
+		s)
+			FEDI_SCOPE="$OPTARG"
+			;;
 		a)
 		a)
 			FEDI_AUTH="$OPTARG"
 			FEDI_AUTH="$OPTARG"
 			;;
 			;;
@@ -132,6 +137,11 @@ if test -z "$SERVER_URL"; then
 fi
 fi
 
 
 
 
+if test -z "$FEDI_SCOPE"; then
+	FEDI_SCOPE="public"
+fi
+
+
 IFS="
 IFS="
 "
 "
 while read -r line; do
 while read -r line; do