Add option for setting posts’ scope
This commit is contained in:
parent
3048c4ad68
commit
3b130b7a28
25
manicito
25
manicito
|
@ -17,6 +17,7 @@ usage() {
|
||||||
echo
|
echo
|
||||||
echo ' -h print this message and exit'
|
echo ' -h print this message and exit'
|
||||||
echo ' -H file used to store/check quoted posts; to avoid duplicates'
|
echo ' -H file used to store/check quoted posts; to avoid duplicates'
|
||||||
|
echo ' -s scope for posts, one of: public/[unlisted]/private/direct'
|
||||||
echo
|
echo
|
||||||
echo 'Posts tagged under HASHTAG will all be quote-posted to the'
|
echo 'Posts tagged under HASHTAG will all be quote-posted to the'
|
||||||
echo 'Mastodon-compatible server at SERVER_URL.'
|
echo 'Mastodon-compatible server at SERVER_URL.'
|
||||||
|
@ -92,7 +93,7 @@ quote_posts() {
|
||||||
# post_json $tagged_post-json
|
# post_json $tagged_post-json
|
||||||
post_json() {
|
post_json() {
|
||||||
local tagged_post_json="$1"
|
local tagged_post_json="$1"
|
||||||
printf '{ "content_type": "text/html", "visibility": "unlisted",'
|
printf '{ "content_type": "text/html", "visibility": "%s",' "$FEDI_SCOPE"
|
||||||
printf '"quote_id": "%s",' "$(echo "$tagged_post_json" | jq -r .id)"
|
printf '"quote_id": "%s",' "$(echo "$tagged_post_json" | jq -r .id)"
|
||||||
printf '"expires_in": %s,' 864000
|
printf '"expires_in": %s,' 864000
|
||||||
printf '"status": "%s" }\n' "$(post_body "$tagged_post_json")"
|
printf '"status": "%s" }\n' "$(post_body "$tagged_post_json")"
|
||||||
|
@ -176,7 +177,10 @@ env_subst() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
while getopts 'hH:' arg; do
|
FEDI_SCOPE="unlisted" # Default value.
|
||||||
|
|
||||||
|
|
||||||
|
while getopts 'hH:s:' arg; do
|
||||||
case $arg in
|
case $arg in
|
||||||
h)
|
h)
|
||||||
usage
|
usage
|
||||||
|
@ -185,9 +189,26 @@ while getopts 'hH:' arg; do
|
||||||
H)
|
H)
|
||||||
HISTORY_FILE="$OPTARG"
|
HISTORY_FILE="$OPTARG"
|
||||||
;;
|
;;
|
||||||
|
s)
|
||||||
|
OPTARG="$(echo "$OPTARG" | tr 'A-Z' 'a-z')"
|
||||||
|
if test "$OPTARG" = "unlisted" -o "$OPTARG" = "public" \
|
||||||
|
-o "$OPTARG" = "private" -o "$OPTARG" = "direct"; then
|
||||||
|
FEDI_SCOPE="$OPTARG"
|
||||||
|
else
|
||||||
|
1>&2 echo '$OPTARG is an invalid scope; must be one of:'
|
||||||
|
1>&2 echo ' • unlisted'
|
||||||
|
1>&2 echo ' • public'
|
||||||
|
1>&2 echo ' • private'
|
||||||
|
1>&2 echo ' • direct'
|
||||||
|
1>&2 echo
|
||||||
|
1>&2 echo 'Run with -h for more information.'
|
||||||
|
exit 6
|
||||||
|
fi
|
||||||
|
;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
|
|
||||||
shift $((OPTIND-1))
|
shift $((OPTIND-1))
|
||||||
HASHTAG="$1"
|
HASHTAG="$1"
|
||||||
FEDI_SERVER="$2"
|
FEDI_SERVER="$2"
|
||||||
|
|
Ŝarĝante…
Reference in New Issue