From da6a960bcdb9d9b5d19b23b7fbfc5dfc878dea13 Mon Sep 17 00:00:00 2001 From: stormdragon2976 Date: Thu, 2 Feb 2023 20:43:30 -0500 Subject: [PATCH] I think I fixed the weird posting bug. Posts from within the main loop should work as expected now. --- ratatoskr.sh | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/ratatoskr.sh b/ratatoskr.sh index 123f9bd..8140487 100755 --- a/ratatoskr.sh +++ b/ratatoskr.sh @@ -142,24 +142,25 @@ post_status() { if [[ "${1}" == "" ]]; then return fi - local text="$@" - visibility="${visibility:-public}" - local content_type="${content_type:-text/markdown}" -local json="$(jq -n --arg status "$text" \ - --arg spoiler_text "$spoiler_text" \ - --arg visibility "$visibility" \ - --arg content_type "$content_type" \ + local statusText="$@" + local statusVisibility="${statusVisibility:-public}" + local statusContent_type="${statusContent_type:-text/markdown}" + local statusSpoiler_text="" + local statusJson="$(jq -n --arg status "$statusText" \ + --arg spoiler_text "$statusSpoiler_text" \ + --arg visibility "$statusVisibility" \ + --arg content_type "$statusContent_type" \ '{ status: $status, spoiler_text: $spoiler_text, visibility: $visibility, content_type: $content_type }')" - local result - result="$(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')" \ + local statusResult + statusResult="$(curl -sS --oauth2-bearer "${oauth_token}" -H "Content-Type: application/json" \ + -d "$(echo "$statusJson" | jq 'if .spoiler_text == "" then del(.spoiler_text) else . end | if .visibility == "" then del(.visibility) else . end')" \ "${instanceURL}/api/v1/statuses")" if [[ $? -ne 0 ]]; then echo "there was a problem contacting the server" play_sound error exit 1 fi - local error="$(echo "$result" | jq -r '.error')" + local error="$(echo "$statusResult" | jq -r '.error')" if [[ "$error" != "null" ]]; then echo "Error: $error" play_sound error @@ -170,6 +171,8 @@ local json="$(jq -n --arg status "$text" \ } + + # Display timelines show_timeline() { result="$(curl -sS --oauth2-bearer "${oauth_token}" "${instanceURL}/api/v1/timelines/${timeline:-home}")"