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
|
Build new docker image and push it to ECR
|
||||||
|
|
||||||
```shell
|
```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 .
|
$ 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]
|
(defn get-posts-until-id [id]
|
||||||
(let [limit 10
|
(let [limit 10
|
||||||
posts
|
url (str (@config :mastodon-host) "/api/v1/accounts/" (@config :mastodon-account-id) "/statuses")]
|
||||||
(-> (http-client/get
|
(tel/log! {:level :info :data {:url url :post-id id}} "Getting mastodon posts until id")
|
||||||
(str (@config :mastodon-host) "/api/v1/accounts/" (@config :mastodon-account-id) "/statuses")
|
(->>
|
||||||
{:query-params {:limit limit}
|
(-> (http-client/get
|
||||||
:content-type :json
|
url
|
||||||
:as :json})
|
{:query-params {:limit limit}
|
||||||
:body
|
:content-type :json
|
||||||
(utils/validate-with-throw post-res-schema))]
|
:as :json})
|
||||||
(take-while #(not= (:id %) id) posts)))
|
:body
|
||||||
|
(utils/validate-with-throw post-res-schema))
|
||||||
(defn extract-images [post]
|
(take-while #(not= (:id %) id)))))
|
||||||
(let [images (get-in post [:embed :images] [])]
|
|
||||||
(map #(vector (:fullsize %) (:alt %)) images)))
|
|
||||||
|
|
||||||
(defn run []
|
(defn run []
|
||||||
(tel/log! :info "Running mastodon fetcher")
|
(tel/log! :info "Running mastodon fetcher")
|
||||||
(let [last-saved-id (pb/get-latest-post-remote-id-by-source :mastodon)
|
(let [last-saved-id (pb/get-latest-post-remote-id-by-source :mastodon)
|
||||||
new-posts (reverse (get-posts-until-id last-saved-id))]
|
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
|
(->> new-posts
|
||||||
(map #(hash-map :source :mastodon
|
(map #(hash-map :source :mastodon
|
||||||
:fullPost %
|
:fullPost %
|
||||||
|
|
|
||||||
|
|
@ -18,11 +18,11 @@
|
||||||
(> (.toHours duration) 23)))) ; 23 to be safe, or use 24
|
(> (.toHours duration) 23)))) ; 23 to be safe, or use 24
|
||||||
|
|
||||||
(defn get-new-login-token []
|
(defn get-new-login-token []
|
||||||
(tel/log! :info "Getting new login token")
|
|
||||||
(let [user-name (@config :pocket-base-user)
|
(let [user-name (@config :pocket-base-user)
|
||||||
pw (@config :pocket-base-pw)
|
pw (@config :pocket-base-pw)
|
||||||
body {:identity user-name :password pw}
|
body {:identity user-name :password pw}
|
||||||
url (str (@config :pocket-base-host) "/api/collections/users/auth-with-password")]
|
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
|
(http-client/post url
|
||||||
{:form-params body
|
{:form-params body
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue