From a1533bd452c4290cc365155fa5ce9d75b12d8ae8 Mon Sep 17 00:00:00 2001 From: bom Date: Wed, 2 Mar 2022 14:40:25 +0100 Subject: [PATCH] WIP for automatic comments --- src/main/dda/masto_embed/api.cljs | 12 +++++++++++ src/main/dda/masto_embed/app.cljs | 36 +++++++++++++++++++++++++------ 2 files changed, 42 insertions(+), 6 deletions(-) diff --git a/src/main/dda/masto_embed/api.cljs b/src/main/dda/masto_embed/api.cljs index 97ce77f..85354aa 100644 --- a/src/main/dda/masto_embed/api.cljs +++ b/src/main/dda/masto_embed/api.cljs @@ -51,8 +51,20 @@ (str "statuses/" status-id "/context") #js {})) +(defn get-favorited-by + [host-url + status-id] + (.get (mastodon-client host-url) + (str "statuses/" status-id "/favourited_by") + #js {})) + (defn-spec get-directory any? [host-url ::host-url] (.get (mastodon-client host-url) (str "directory?local=true") #js {})) + +; TODO: +; 1. ID of status with reply: 107655615528722482 +; 2. Get replies to status +; 3. Filter by favorited and or tags \ No newline at end of file diff --git a/src/main/dda/masto_embed/app.cljs b/src/main/dda/masto_embed/app.cljs index 325ded6..882cb14 100644 --- a/src/main/dda/masto_embed/app.cljs +++ b/src/main/dda/masto_embed/app.cljs @@ -59,20 +59,44 @@ first))) out)) +(defn favorited-replies? [host-url reply-id account-name] + (let [out (chan)] + (go (>! out + (->> + (edn + (filter #(= account-name (:acct %))) + (empty?) + (not) + (infra/debug)))) + out)) + (defn init [] (go (let [host-url (host-url-from-document) account-name (account-name-from-document) - account-id (or + account-id (or (account-id-from-document) ( (edn) - ] - (->> statuus - (take 4) + test-status (-> + (edn) + filtered (->> + (:descendants test-status) + (filter #(favorited-replies? host-url (:id %) account-name)) + (infra/debug))] + ;(->> statuus + ; (take 4) + ; (rb/masto->html) + ; (render-html) + ; (render-to-document)) + (->> filtered + (infra/debug) (rb/masto->html) (render-html) - (render-to-document)) - ))) + (render-to-document))))) + +