3 次代碼提交 cea28c643c ... 1e2eaf0dbe

作者 SHA1 備註 提交日期
  Jaidyn Ann 1e2eaf0dbe Support configuring posts’ scope 1 年之前
  Jaidyn Ann 61b22d1e09 Escape quotation-marks in post descriptions 1 年之前
  Jaidyn Ann edb9ccd1ac Fix typo in mirror_feed.sh 1 年之前
共有 2 個文件被更改,包括 16 次插入6 次删除
  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
 
 
-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 ""
 	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"
 }
 
@@ -79,7 +80,8 @@ sfeed_post_text() {
 		| sed "s|{{url}}|$url|g" \
 		| sed "s|{{desc}}|$desc|g" \
 		| sed "s|{{desc_short}}|$desc_snip|g" \
-		| sed 's%\\n%%' \
+		| sed 's|\\n||g' \
+		| sed 's|"|\\"|g' \
 		| tr -d '	\n'
 }
 
@@ -101,6 +103,9 @@ while getopts 'ha:t:' arg; do
 			usage
 			exit 0
 			;;
+		s)
+			FEDI_SCOPE="$OPTARG"
+			;;
 		a)
 			FEDI_AUTH="$OPTARG"
 			;;
@@ -132,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