Merge pull request #3 from mattisboeckle/master
WIP Changes to allow comment function
This commit is contained in:
commit
14dd5afe87
3 changed files with 72 additions and 14 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -11,6 +11,8 @@ pom.xml.asc
|
||||||
.lein-plugins/
|
.lein-plugins/
|
||||||
.lein-failures
|
.lein-failures
|
||||||
.nrepl-port
|
.nrepl-port
|
||||||
|
package-lock.json
|
||||||
|
output.calva-repl
|
||||||
.cpcache/
|
.cpcache/
|
||||||
.shadow-cljs/
|
.shadow-cljs/
|
||||||
node_modules/
|
node_modules/
|
||||||
|
|
|
@ -41,8 +41,40 @@
|
||||||
(str "accounts/" account-id "/statuses")
|
(str "accounts/" account-id "/statuses")
|
||||||
#js {}))
|
#js {}))
|
||||||
|
|
||||||
|
; https://mastodon.example/api/v1/statuses/:id/context
|
||||||
|
; for parent and child statuses
|
||||||
|
; "descendants"
|
||||||
|
(defn get-replies
|
||||||
|
[host-url
|
||||||
|
status-id]
|
||||||
|
(.get (mastodon-client host-url)
|
||||||
|
(str "statuses/" status-id "/context")
|
||||||
|
#js {}))
|
||||||
|
|
||||||
|
(defn get-filtered-replies
|
||||||
|
[host-url
|
||||||
|
status-id
|
||||||
|
account]
|
||||||
|
(->> (.get (mastodon-client host-url)
|
||||||
|
(str "statuses/" status-id "/context")
|
||||||
|
#js {})
|
||||||
|
mastojs->edn
|
||||||
|
(:descendants)))
|
||||||
|
|
||||||
|
(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?
|
(defn-spec get-directory any?
|
||||||
[host-url ::host-url]
|
[host-url ::host-url]
|
||||||
(.get (mastodon-client host-url)
|
(.get (mastodon-client host-url)
|
||||||
(str "directory?local=true")
|
(str "directory?local=true")
|
||||||
#js {}))
|
#js {}))
|
||||||
|
|
||||||
|
; TODO:
|
||||||
|
; 1. ID of status with reply: 107655615528722482
|
||||||
|
; 2. Get replies to status
|
||||||
|
; 3. Filter by favorited and or tags
|
|
@ -25,20 +25,19 @@
|
||||||
|
|
||||||
(def masto-embed "masto-embed")
|
(def masto-embed "masto-embed")
|
||||||
|
|
||||||
(defn host-url-from-document []
|
(defn element-from-document-by-name [name]
|
||||||
(-> js/document
|
(-> js/document
|
||||||
(.getElementById masto-embed)
|
(.getElementById masto-embed)
|
||||||
(.getAttribute "host_url")))
|
(.getAttribute name)))
|
||||||
|
|
||||||
|
(defn host-url-from-document []
|
||||||
|
(element-from-document-by-name "host_url"))
|
||||||
|
|
||||||
(defn account-name-from-document []
|
(defn account-name-from-document []
|
||||||
(-> js/document
|
(element-from-document-by-name "account_name"))
|
||||||
(.getElementById masto-embed)
|
|
||||||
(.getAttribute "account_name")))
|
|
||||||
|
|
||||||
(defn account-id-from-document []
|
(defn account-id-from-document []
|
||||||
(-> js/document
|
(element-from-document-by-name "account_id"))
|
||||||
(.getElementById masto-embed)
|
|
||||||
(.getAttribute "account_id")))
|
|
||||||
|
|
||||||
(defn render-to-document
|
(defn render-to-document
|
||||||
[input]
|
[input]
|
||||||
|
@ -60,6 +59,16 @@
|
||||||
first)))
|
first)))
|
||||||
out))
|
out))
|
||||||
|
|
||||||
|
(defn favorited-replies? [host-url reply-id account-name]
|
||||||
|
(let [out (chan)]
|
||||||
|
(go (>! out
|
||||||
|
(->>
|
||||||
|
(<p! (api/get-favorited-by host-url reply-id))
|
||||||
|
api/mastojs->edn
|
||||||
|
(filter #(= account-name (:acct %)))
|
||||||
|
)))
|
||||||
|
out))
|
||||||
|
|
||||||
(defn init []
|
(defn init []
|
||||||
(go
|
(go
|
||||||
(let [host-url (host-url-from-document)
|
(let [host-url (host-url-from-document)
|
||||||
|
@ -70,10 +79,25 @@
|
||||||
statuus (->
|
statuus (->
|
||||||
(<p! (api/get-account-statuses host-url account-id))
|
(<p! (api/get-account-statuses host-url account-id))
|
||||||
api/mastojs->edn)
|
api/mastojs->edn)
|
||||||
|
test-status (->
|
||||||
|
(<p! (api/get-favorited-by host-url "107779492679907372"))
|
||||||
|
api/mastojs->edn)
|
||||||
|
filtered (filter #(go (<! (favorited-replies? host-url "107779739758156958" "bastian@digitalcourage.social"))) (:descendants test-status))
|
||||||
]
|
]
|
||||||
(->> statuus
|
;(->> statuus
|
||||||
(take 4)
|
; (take 4)
|
||||||
(rb/masto->html)
|
; (rb/masto->html)
|
||||||
(render-html)
|
; (render-html)
|
||||||
(render-to-document))
|
; (render-to-document))
|
||||||
|
;(go (infra/debug (<! (favorited-replies? host-url "107779739758156958" "team@meissa.social"))))
|
||||||
|
;(go (let [test (api/mastojs->edn (<p! (api/get-favorited-by host-url "107779739758156958")))]
|
||||||
|
; (infra/debug (filter #(= "team@meissa.social" (:acct %)) test))))
|
||||||
|
(infra/debug test-status)
|
||||||
|
;(->> filtered
|
||||||
|
; (infra/debug)
|
||||||
|
; (rb/masto->html)
|
||||||
|
; (render-html)
|
||||||
|
; (render-to-document))
|
||||||
)))
|
)))
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue