fix mastodon fetch issues
This commit is contained in:
parent
ded5314125
commit
8263c09b50
3 changed files with 14 additions and 14 deletions
|
|
@ -33,6 +33,7 @@ $ java -jar ./target/micro-blog-standalone.jar
|
|||
Build new docker image and push it to ECR
|
||||
|
||||
```shell
|
||||
$ export AWS_PROFILE=personal
|
||||
$ docker buildx build --platform linux/amd64,linux/arm64 -t 853019563312.dkr.ecr.eu-central-1.amazonaws.com/micro-blog-fetchers-homelabstack:latest --push .
|
||||
```
|
||||
|
||||
|
|
|
|||
|
|
@ -20,24 +20,23 @@
|
|||
|
||||
(defn get-posts-until-id [id]
|
||||
(let [limit 10
|
||||
posts
|
||||
url (str (@config :mastodon-host) "/api/v1/accounts/" (@config :mastodon-account-id) "/statuses")]
|
||||
(tel/log! {:level :info :data {:url url :post-id id}} "Getting mastodon posts until id")
|
||||
(->>
|
||||
(-> (http-client/get
|
||||
(str (@config :mastodon-host) "/api/v1/accounts/" (@config :mastodon-account-id) "/statuses")
|
||||
url
|
||||
{:query-params {:limit limit}
|
||||
:content-type :json
|
||||
:as :json})
|
||||
:body
|
||||
(utils/validate-with-throw post-res-schema))]
|
||||
(take-while #(not= (:id %) id) posts)))
|
||||
|
||||
(defn extract-images [post]
|
||||
(let [images (get-in post [:embed :images] [])]
|
||||
(map #(vector (:fullsize %) (:alt %)) images)))
|
||||
(utils/validate-with-throw post-res-schema))
|
||||
(take-while #(not= (:id %) id)))))
|
||||
|
||||
(defn run []
|
||||
(tel/log! :info "Running mastodon fetcher")
|
||||
(let [last-saved-id (pb/get-latest-post-remote-id-by-source :mastodon)
|
||||
new-posts (reverse (get-posts-until-id last-saved-id))]
|
||||
(tel/log! {:level :info :data {:count (if (nil? new-posts) 0 (count new-posts))}} "Found new posts to save")
|
||||
(->> new-posts
|
||||
(map #(hash-map :source :mastodon
|
||||
:fullPost %
|
||||
|
|
|
|||
|
|
@ -18,11 +18,11 @@
|
|||
(> (.toHours duration) 23)))) ; 23 to be safe, or use 24
|
||||
|
||||
(defn get-new-login-token []
|
||||
(tel/log! :info "Getting new login token")
|
||||
(let [user-name (@config :pocket-base-user)
|
||||
pw (@config :pocket-base-pw)
|
||||
body {:identity user-name :password pw}
|
||||
url (str (@config :pocket-base-host) "/api/collections/users/auth-with-password")]
|
||||
(tel/log! {:level :info :data {:url url}} "Getting new login token")
|
||||
(->
|
||||
(http-client/post url
|
||||
{:form-params body
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue