From 8263c09b5080f6c451ae2cb20ca1720eaede20ac Mon Sep 17 00:00:00 2001 From: Travis Shears Date: Fri, 8 Aug 2025 23:27:04 +0200 Subject: [PATCH] fix mastodon fetch issues --- README.md | 1 + src/micro_blog/mastodon.clj | 25 ++++++++++++------------- src/micro_blog/pocket_base.clj | 2 +- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index 1c10baf..d523f33 100644 --- a/README.md +++ b/README.md @@ -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 . ``` diff --git a/src/micro_blog/mastodon.clj b/src/micro_blog/mastodon.clj index d350c95..dc06781 100644 --- a/src/micro_blog/mastodon.clj +++ b/src/micro_blog/mastodon.clj @@ -20,24 +20,23 @@ (defn get-posts-until-id [id] (let [limit 10 - posts - (-> (http-client/get - (str (@config :mastodon-host) "/api/v1/accounts/" (@config :mastodon-account-id) "/statuses") - {: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))) + 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 + url + {:query-params {:limit limit} + :content-type :json + :as :json}) + :body + (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 % diff --git a/src/micro_blog/pocket_base.clj b/src/micro_blog/pocket_base.clj index 877151b..e64cae1 100644 --- a/src/micro_blog/pocket_base.clj +++ b/src/micro_blog/pocket_base.clj @@ -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