fix screen name & add untrimmed option
This commit is contained in:
parent
8ccdbde8ec
commit
0a0e9fb2ae
2 changed files with 17 additions and 10 deletions
|
@ -8,9 +8,13 @@
|
|||
|
||||
(s/def ::created-at any?)
|
||||
(s/def ::text string?)
|
||||
(s/def ::untrimmed-text string?)
|
||||
(s/def ::media-links string?)
|
||||
(s/def ::screen_name string?)
|
||||
(def element? (s/keys :req-un [::created-at ::text ::media-links ::screen_name]))
|
||||
(def input? (s/keys :req-un [::created-at ::text ::screen_name]
|
||||
:opt-un [::media-links ::untrimmed-text]))
|
||||
(def mastodon-output? (s/keys :req-un [::created-at ::text]
|
||||
:opt-un [::media-links]))
|
||||
|
||||
(defn trim-text [text max-post-length]
|
||||
(cond
|
||||
|
@ -29,14 +33,16 @@
|
|||
|
||||
:else text))
|
||||
|
||||
(defn-spec to-mastodon any?
|
||||
(defn-spec to-mastodon mastodon-output?
|
||||
[mastodon-config masto/mastodon-config?
|
||||
input element?]
|
||||
(let [{:keys [created-at text media-links screen_name]} input]
|
||||
input input?]
|
||||
(let [{:keys [created-at text media-links screen_name untrimmed-text]} input]
|
||||
{:created-at created-at
|
||||
:text (trim-text
|
||||
(str text
|
||||
:text (str (trim-text
|
||||
text
|
||||
(masto/max-post-length mastodon-config))
|
||||
(if (some? untrimmed-text)
|
||||
(str " " untrimmed-text) "")
|
||||
(if (masto/append-screen-name? mastodon-config)
|
||||
(str "\n - " screen_name) ""))
|
||||
(masto/max-post-length mastodon-config))
|
||||
:media-links media-links}))
|
|
@ -47,6 +47,7 @@
|
|||
{:keys [screen_name]} :user :as tweet}]
|
||||
{:created-at (js/Date. created-at)
|
||||
:text (chop-tail-media-url text media)
|
||||
:screen_name screen_name
|
||||
:media-links (keep #(when (= (:type %) "photo") (:media_url_https %)) media)})
|
||||
|
||||
(defn-spec user-timeline any?
|
||||
|
|
Reference in a new issue