From 7f6911b73eba4a8183a89e36ab048f3912965099 Mon Sep 17 00:00:00 2001 From: Travis Shears Date: Wed, 3 Sep 2025 10:19:32 +0200 Subject: [PATCH] add api endpoint to restart nostr --- deploy.sh => build.sh | 0 src/micro_blog/api.clj | 22 ++++++++++++++++------ src/micro_blog/nostr.clj | 1 + 3 files changed, 17 insertions(+), 6 deletions(-) rename deploy.sh => build.sh (100%) diff --git a/deploy.sh b/build.sh similarity index 100% rename from deploy.sh rename to build.sh diff --git a/src/micro_blog/api.clj b/src/micro_blog/api.clj index 38262e1..b200cb6 100644 --- a/src/micro_blog/api.clj +++ b/src/micro_blog/api.clj @@ -4,10 +4,11 @@ [micro-blog.config :refer [config]] micro-blog.mastodon micro-blog.blue-sky + micro-blog.nostr [taoensso.telemere :as tel])) (defn mastodon-proc-handler [_request] - (let [msg "Proceding Mastodon Scrape"] + (let [msg "Procding Mastodon Scrape"] (tel/log! :info msg) (micro-blog.mastodon/run) {:status 200 @@ -15,14 +16,23 @@ (defn blue-sky-proc-handler [_request] (let [msg "Procing BlueSky Scrape"] - (tel/log! :info msg) - (micro-blog.mastodon/run) - {:status 200 - :body msg})) + (tel/log! :info msg) + (micro-blog.mastodon/run) + {:status 200 + :body msg})) + +(defn nostr-proc-handler [_request] + (let [msg "Restarting Nostr scraper"] + (tel/log! :info msg) + (micro-blog.nostr/close) + (micro-blog.nostr/start) + {:status 200 + :body msg})) (def routes #{["/bluesky" :get blue-sky-proc-handler :route-name :blue-sky] - ["/mastodon" :get mastodon-proc-handler :route-name :mastodon]}) + ["/mastodon" :get mastodon-proc-handler :route-name :mastodon] + ["/nostr" :get nostr-proc-handler :route-name :nostr]}) (defn create-connector [] (-> (conn/default-connector-map (:api-host @config) (Integer/parseInt (str (:api-port @config)))) diff --git a/src/micro_blog/nostr.clj b/src/micro_blog/nostr.clj index 3e751fa..9a5a3de 100644 --- a/src/micro_blog/nostr.clj +++ b/src/micro_blog/nostr.clj @@ -74,6 +74,7 @@ (.get (ws/send! @socket msg)))) (defn close [] + (tel/log! :info "Closing nostr socket") (ws/close! @socket)) (defn start []