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-failures
|
||||
.nrepl-port
|
||||
package-lock.json
|
||||
output.calva-repl
|
||||
.cpcache/
|
||||
.shadow-cljs/
|
||||
node_modules/
|
||||
|
|
|
@ -41,8 +41,40 @@
|
|||
(str "accounts/" account-id "/statuses")
|
||||
#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?
|
||||
[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
|
|
@ -25,20 +25,19 @@
|
|||
|
||||
(def masto-embed "masto-embed")
|
||||
|
||||
(defn host-url-from-document []
|
||||
(defn element-from-document-by-name [name]
|
||||
(-> js/document
|
||||
(.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 []
|
||||
(-> js/document
|
||||
(.getElementById masto-embed)
|
||||
(.getAttribute "account_name")))
|
||||
(element-from-document-by-name "account_name"))
|
||||
|
||||
(defn account-id-from-document []
|
||||
(-> js/document
|
||||
(.getElementById masto-embed)
|
||||
(.getAttribute "account_id")))
|
||||
(element-from-document-by-name "account_id"))
|
||||
|
||||
(defn render-to-document
|
||||
[input]
|
||||
|
@ -60,20 +59,45 @@
|
|||
first)))
|
||||
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 []
|
||||
(go
|
||||
(let [host-url (host-url-from-document)
|
||||
account-name (account-name-from-document)
|
||||
account-id (or
|
||||
account-id (or
|
||||
(account-id-from-document)
|
||||
(<! (find-account-id host-url account-name)))
|
||||
statuus (->
|
||||
(<p! (api/get-account-statuses host-url account-id))
|
||||
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
|
||||
(take 4)
|
||||
(rb/masto->html)
|
||||
(render-html)
|
||||
(render-to-document))
|
||||
;(->> statuus
|
||||
; (take 4)
|
||||
; (rb/masto->html)
|
||||
; (render-html)
|
||||
; (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