I think I fixed the weird posting bug. Posts from within the main loop should work as expected now.

This commit is contained in:
stormdragon2976 2023-02-02 20:43:30 -05:00
parent cabe5058ff
commit da6a960bcd

View File

@ -142,24 +142,25 @@ post_status() {
if [[ "${1}" == "" ]]; then if [[ "${1}" == "" ]]; then
return return
fi fi
local text="$@" local statusText="$@"
visibility="${visibility:-public}" local statusVisibility="${statusVisibility:-public}"
local content_type="${content_type:-text/markdown}" local statusContent_type="${statusContent_type:-text/markdown}"
local json="$(jq -n --arg status "$text" \ local statusSpoiler_text=""
--arg spoiler_text "$spoiler_text" \ local statusJson="$(jq -n --arg status "$statusText" \
--arg visibility "$visibility" \ --arg spoiler_text "$statusSpoiler_text" \
--arg content_type "$content_type" \ --arg visibility "$statusVisibility" \
--arg content_type "$statusContent_type" \
'{ status: $status, spoiler_text: $spoiler_text, visibility: $visibility, content_type: $content_type }')" '{ status: $status, spoiler_text: $spoiler_text, visibility: $visibility, content_type: $content_type }')"
local result local statusResult
result="$(curl -sS --oauth2-bearer "${oauth_token}" -H "Content-Type: application/json" \ statusResult="$(curl -sS --oauth2-bearer "${oauth_token}" -H "Content-Type: application/json" \
-d "$(echo "$json" | jq 'if .spoiler_text == "" then del(.spoiler_text) else . end | if .visibility == "" then del(.visibility) else . end')" \ -d "$(echo "$statusJson" | jq 'if .spoiler_text == "" then del(.spoiler_text) else . end | if .visibility == "" then del(.visibility) else . end')" \
"${instanceURL}/api/v1/statuses")" "${instanceURL}/api/v1/statuses")"
if [[ $? -ne 0 ]]; then if [[ $? -ne 0 ]]; then
echo "there was a problem contacting the server" echo "there was a problem contacting the server"
play_sound error play_sound error
exit 1 exit 1
fi fi
local error="$(echo "$result" | jq -r '.error')" local error="$(echo "$statusResult" | jq -r '.error')"
if [[ "$error" != "null" ]]; then if [[ "$error" != "null" ]]; then
echo "Error: $error" echo "Error: $error"
play_sound error play_sound error
@ -170,6 +171,8 @@ local json="$(jq -n --arg status "$text" \
} }
# Display timelines # Display timelines
show_timeline() { show_timeline() {
result="$(curl -sS --oauth2-bearer "${oauth_token}" "${instanceURL}/api/v1/timelines/${timeline:-home}")" result="$(curl -sS --oauth2-bearer "${oauth_token}" "${instanceURL}/api/v1/timelines/${timeline:-home}")"