added support for status flags

This commit is contained in:
Dmitri Sotnikov 2018-08-26 00:59:43 -04:00
parent 0c2832ddf0
commit 6c3879a7fa
2 changed files with 11 additions and 5 deletions

View file

@ -51,6 +51,11 @@ If you get a [permission failure](https://github.com/anmonteiro/lumo/issues/206)
"r/Clojure" "https://www.reddit.com/r/clojure/.rss"} "r/Clojure" "https://www.reddit.com/r/clojure/.rss"}
:mastodon {:access_token "XXXX" :mastodon {:access_token "XXXX"
:api_url "https://botsin.space/api/v1/" :api_url "https://botsin.space/api/v1/"
;; optional boolean to makr content as sensitive
:sensitive true
;; optional visibility flag: direct, private, unlisted, public
;; defaults to public
:visibility "unlisted"
;; optional limit for the post length ;; optional limit for the post length
:max-post-length 300 :max-post-length 300
;; optional flag specifying wether the name of the account ;; optional flag specifying wether the name of the account

View file

@ -63,11 +63,12 @@
([status-text] ([status-text]
(post-status status-text nil)) (post-status status-text nil))
([status-text media-ids] ([status-text media-ids]
(let [{:keys [sensitive signature visibility]} (:mastodon config)]
(.post mastodon-client "statuses" (.post mastodon-client "statuses"
(clj->js (merge {:status (if-let [signature (-> config :mastodon :signature)] (clj->js (merge {:status (if signature (str status-text "\n" signature) status-text)}
(str status-text "\n" signature) (when media-ids {:media_ids media-ids})
status-text)} (when sensitive {:sensitive sensitive})
(when media-ids {:media_ids media-ids})))))) (when visibility {:visibility visibility})))))))
(defn post-image [image-stream description callback] (defn post-image [image-stream description callback]
(-> (.post mastodon-client "media" #js {:file image-stream :description description}) (-> (.post mastodon-client "media" #js {:file image-stream :description description})