commit 29b050b383fa550b9cbac77dc1d69441f3085ec9
parent 03b74b38deaaa124bd9d415cc9c7e7259cec0056
Author: Jake Bauer <jbauer@paritybit.ca>
Date: Sat, 8 Aug 2020 14:22:09 -0400
Update publish script, having fixed access token problems
Diffstat:
M | publish | | | 35 | +++++++++++++++++------------------ |
1 file changed, 17 insertions(+), 18 deletions(-)
diff --git a/publish b/publish
@@ -61,6 +61,8 @@ categoryPage="html/blog.html"
autoUpload="true"
# Set to false to disable auto posting statuses on Mastodon
autoPost="true"
+# Social media upload OAuth access token
+accessToken=""
# Prints the message passed as the 1st argument in red.
print_error_msg()
@@ -181,9 +183,7 @@ auto_upload()
"$categoryPage" "$article" "$remote" && cd ..
}
-# Post a status update on Mastodon linking to the new blog post
-# Temporarily just print the status for copying while I figure out how to do
-# this with Pleroma
+# Post a status update on Pleroma linking to the new blog post
auto_post()
{
if [ "$autoPost" != "true" ]; then
@@ -191,7 +191,6 @@ auto_post()
fi
print_info_msg "Generating social media post"
- accessToken=""
meta="$(head -n3 "$file" | tail -n1 \
| cut -d'#' -f2 | sed -e 's/^[[:space:]]*//')"
printf "New Blog Post: %s\n\n%s/%s\n\n%s\n\n#100DaysToOffload" \
@@ -202,20 +201,20 @@ auto_post()
cat /tmp/status.txt
echo ""
- # resp="$(curl -s -S -i -X POST \
- # -H "Idempotency-Key: $uniqueId" \
- # -H "Authorization: Bearer $accessToken" \
- # -F status="$(cat /tmp/status.txt)" \
- # -F visibility=public \
- # https://social.paritybit.ca/api/v1/statuses)"
- # httpCode="$(echo "$resp" | grep HTTP/ | awk '{print $2}')"
-
- # if [ "$httpCode" = "200" ]; then
- # print_success_msg "Successfully posted status update"
- # else
- # print_error_msg "ERROR: Failed to post status update"
- # echo "$resp"
- # fi
+ resp="$(curl -s -S -i -X POST \
+ -H "Idempotency-Key: $uniqueId" \
+ -H "Authorization: Bearer $accessToken" \
+ -F status="$(cat /tmp/status.txt)" \
+ -F visibility=public \
+ https://social.paritybit.ca/api/v1/statuses)"
+ httpCode="$(echo "$resp" | grep HTTP/ | awk '{print $2}')"
+
+ if [ "$httpCode" = "200" ]; then
+ print_success_msg "Successfully posted status update"
+ else
+ print_error_msg "ERROR: Failed to post status update"
+ echo "$resp"
+ fi
}
for file in "$@"; do