diff --git a/api.sh b/api.sh index 026ddc2..3bb0a95 100644 --- a/api.sh +++ b/api.sh @@ -3,6 +3,6 @@ baseurl(){ if [ -z $INSEC ]; then sec=s; fi; echo "http$sec://$INSTANCE/api/v3/" #Generics get(){ curl -s "$(baseurl)$1?${*:3}" | jq "$2"; } getauth(){ get "$1" "$2" "auth=$TOKE&${*:3}"; } -post(){ curl -s "$(baseurl)$1" --json "$(echo ${*:2} | jq .+{\"auth\":\"$TOKE\"})"; } +post(){ curl -s "$(baseurl)$1" --json "$(echo ${*:2} | jq '.+{"auth":"'$TOKE'"}')"; } # I'm just gonna clone this thing rather than try to palm the -X PUT into post. I can fix it later. -put(){ curl -sX PUT "$(baseurl)$1" --json "$(echo ${*:2} | jq .+{\"auth\":\"$TOKE\"})"; } \ No newline at end of file +put(){ curl -sX PUT "$(baseurl)$1" --json "$(echo ${*:2} | jq '.+{"auth":"'$TOKE'"}')"; } \ No newline at end of file diff --git a/commands/accounts.sh b/commands/accounts.sh index d74adea..05b3579 100644 --- a/commands/accounts.sh +++ b/commands/accounts.sh @@ -2,8 +2,9 @@ whoami(){ echo $INSTANCE $TOKE; } login() { - post "user/login" "{\"username_or_email\":\"$1\",\"password\":\"$2\"}" + post "user/login" '{"username_or_email":"'$1'","password":"'$2'"}' } + register() { get "site" ".site_view.site | .open_registration,.require_email_verification,.require_application,.application_question" | jq -r . | read reg em app appq @@ -17,7 +18,7 @@ register() if [ ! reg_pw == reg_pw2 ]; then echo "passwords don't match (continuing anyway, expect failure later though)"; fi namedget reg_email "Email address $em" if [ $app == true ]; then namedget reg_appa "Application question: $appq"; fi - result="$(post "user/register" "{\"username\":\"$reg_username\",\"password\":\"$reg_pw\",\"password_verify\":\"$reg_pw2\",\"email\":\"$reg_email\",\"answer\":\"$reg_appa\"}")" + result="$(post "user/register" '{"username":"'$reg_username'","password":"'$reg_pw'","password_verify":"'$reg_pw2'","email":"'$reg_email'","answer":"'$reg_appa'"}')" if [ ! $(jq .error <<< "$result") == "captcha_incorrect" ]; then jq <<< "$result"; exit; fi @@ -26,5 +27,5 @@ register() jq -r '.wav' <<< "$a" | base64 -d > "captcha.wav" jq -r '.png' <<< "$a" | base64 -d > "captcha.png" namedget reg_captcha "Please open captcha.wav and captcha.png and input the text - in that order, no spaces" - post "user/register" "{\"username\":\"$reg_username\",\"password\":\"$reg_pw\",\"password_verify\":\"$reg_pw2\",\"email\":\"$reg_email\",\"answer\":\"$reg_appa\",\"captcha_uuid\":\"$reg_uuid\",\"captcha_answer\":\"$reg_captcha\"}" + post "user/register" '{"username":"'$reg_username'","password":"'$reg_pw'","password_verify":"'$reg_pw2'","email":"'$reg_email'","answer":"'$reg_appa'","captcha_uuid":"'$reg_uuid'","captcha_answer":"'$reg_captcha'"}' } \ No newline at end of file diff --git a/commands/admin.sh b/commands/admin.sh index 629187e..064b4bc 100644 --- a/commands/admin.sh +++ b/commands/admin.sh @@ -16,8 +16,8 @@ pending() namedget ans "Accept? (y)es (n)o (s)kip" done case $ans in - y) put "admin/registration_application/approve" "{\"id\":$appid,\"approve\":true}";; - n) namedget rejected "Why not?" true; put "admin/registration_application/approve" "{\"id\":$appid,\"deny_reason\":\"$rejected\",\"approve\":false}";; + y) put "admin/registration_application/approve" '{"id":'$appid',"approve":true}';; + n) namedget rejected "Why not?" true; put "admin/registration_application/approve" '{"id":'$appid',"deny_reason":"'$rejected'","approve":false}';; esac done } \ No newline at end of file diff --git a/commands/communities.sh b/commands/communities.sh index 788e539..afd4b91 100644 --- a/commands/communities.sh +++ b/commands/communities.sh @@ -1,4 +1,4 @@ #Community hoardan -follow(){ post "community/follow" "{\"community_id\":$1,\"follow\":true}"; } -unfollow(){ post "community/follow" "{\"community_id\":$1,\"follow\":false}"; } +follow(){ post "community/follow" '{"community_id":'$1',"follow":true}'; } +unfollow(){ post "community/follow" '{"community_id":'$1',"follow":false}'; } following(){ echo "use instead"; } # Maybe this will help. \ No newline at end of file diff --git a/commands/posts.sh b/commands/posts.sh index 1e1f1f3..7a663e3 100644 --- a/commands/posts.sh +++ b/commands/posts.sh @@ -1,7 +1,7 @@ #Post hoardan -save(){ put "post/save" "{\"post_id\":$1,\"save\":true}"; } -unsave(){ put "post/save" "{\"post_id\":$1,\"save\":false}"; } +save(){ put "post/save" '{"post_id":'$1',"save":true}'; } +unsave(){ put "post/save" '{"post_id":'$1',"save":false}'; } load(){ getauth "post/list" ".posts | .[] | $postsummary" "type_=All&saved_only=true"; } #Postan -freepost(){ getbody; post "post" "{\"community_id\":$1,\"name\":\"${*:2}\",\"body\":\"$body\"}"; } -shitpost(){ getbody; postid=$1; parentid=$2; post "comment" "{\"post_id\":$postid,\"parent_id\":$parentid,\"content\":\"$body\"}"; } \ No newline at end of file +freepost(){ getbody; post "post" '{"community_id":'$1',"name":"'${*:2}'","body":"'$body'"}'; } +shitpost(){ getbody; postid=$1; parentid=$2; if [ -z $parentid ]; then parentid=null; fi; post "comment" '{"post_id":'$postid',"parent_id":'$parentid',"content":"'$body'"}'; } \ No newline at end of file