From 83ce8024a37265e5e9ade60331bf6cc0c9148c2e Mon Sep 17 00:00:00 2001 From: Zergling_man Date: Sun, 4 Sep 2022 04:09:08 +1000 Subject: [PATCH] Comments no longer show post's link instead of id->replyid. --- shitty_api.sh | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/shitty_api.sh b/shitty_api.sh index d406c2f..8675a3a 100755 --- a/shitty_api.sh +++ b/shitty_api.sh @@ -11,13 +11,19 @@ TOKE=${tokes[0]} baseurl="https://$INSTANCE/api/v3/" # Please don't abuse jq like this +showpost='(.post | (.id | tostring)+" "+(.name | tostring)), +(.post.url)+", "+(.creator.display_name // .creator.name)+":", +((.comment // .post) | .published, +(.body // .content)), +""' showcomment='(.post | (.id | tostring)+" "+(.name | tostring)), -(.post.url // (.comment | (.parent_id | tostring)+"->"+(.id | tostring)))+", "+(.creator.display_name // .creator.name)+":", +(.comment | (.parent_id | tostring)+"->"+(.id | tostring))+", "+(.creator.display_name // .creator.name)+":", ((.comment // .post) | .published, (.body // .content)), ""' comments=".[] | $showcomment" +posts=".[] | $showpost" #Generics get(){ curl -s "$baseurl$1?${*:3}" | jq "$2"; } @@ -34,15 +40,15 @@ actions="notifs notifs2 comments freepost shitpost follow unfollow following der #Lurkan notifs(){ getauth "user/replies" ".replies | $comments"; } notifs2(){ getauth "user/mention"; } -following(){ getauth "post/list" ".posts | $comments" "type_=Subscribed"; } -comments(){ getauth "post" "(.post_view | $showcomment), (.comments | reverse | $comments)" "id=$1"; } +following(){ getauth "post/list" ".posts | $posts" "type_=Subscribed"; } +comments(){ getauth "post" "(.post_view | $showpost), (.comments | reverse | $comments)" "id=$1"; } #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\"}"; } #Post hoardan save(){ put "post/save" "{\"post_id\":$1,\"save\":true}"; } unsave(){ put "post/save" "{\"post_id\":$1,\"save\":false}"; } -load(){ getauth "post/list" ".posts | $comments" "type_=All&saved_only=true"; } +load(){ getauth "post/list" ".posts | $posts" "type_=All&saved_only=true"; } #Community hoardan follow(){ post "community/follow" "{\"community_id\":$1,\"follow\":true}"; } unfollow(){ post "community/follow" "{\"community_id\":$1,\"follow\":false}"; }