diff options
| author | eltrac <hi@eltr.ac> | 2026-05-06 11:30:35 +0800 |
|---|---|---|
| committer | eltrac <hi@eltr.ac> | 2026-05-06 11:30:35 +0800 |
| commit | f5e63ff9704582affe74dba844f3578a0bed5008 (patch) | |
| tree | 54acf4ab23ef3134a78f315cf07d9a9b8e235a47 | |
| parent | 15b357f569055dcac47c9716e23d75d536da8645 (diff) | |
fix(processor): cannot use <! outside of go-loop
| -rw-r--r-- | src/weepinbell/processor.clj | 41 |
1 files changed, 20 insertions, 21 deletions
diff --git a/src/weepinbell/processor.clj b/src/weepinbell/processor.clj index 766185f..f454763 100644 --- a/src/weepinbell/processor.clj +++ b/src/weepinbell/processor.clj @@ -51,35 +51,34 @@ (timbre/info "Webmention no longer valid, deleted.")))) (defn- process-webmention - "Process webmention ONCE request found in a specified channel. + "Process webmention one webmention request. Validate source's Content-Type, inclusion of target URL. If validated, create webmention when no identical is found, update or delete if webmention already exists. Callbacks and storage are maps of functions, to avoid depending on technical details directly." - [wmc callbacks storage] - (when-let [webmention (<! wmc)] - (timbre/info "Webmention found in queue.") - (let [{:keys [s t]} webmention] - ;; first check Content-Types of both urls - ;; only proceed when it's HTML or plain text - (if (validate-content-types s t) - ;; second check if such webmention exists - ;; if so, update it or delete it - ;; if not, write to data - (do - (if ((:get storage) s t) - (process-existing-webmention s t callbacks storage) - (process-new-webmention s t callbacks storage)) - ((:on-receive callbacks))) - ;; if content-type check fails - (timbre/error "Source or target is not HTML or plain text; or error occurred trying to get content type."))))) + [wm callbacks storage] + (let [{:keys [s t]} wm] + ;; first check Content-Types of both urls + ;; only proceed when it's HTML or plain text + (if (validate-content-types s t) + ;; second check if such webmention exists + ;; if so, update it or delete it + ;; if not, write to data + (do + (if ((:get storage) s t) + (process-existing-webmention s t callbacks storage) + (process-new-webmention s t callbacks storage)) + ((:on-receive callbacks))) + ;; if content-type check fails + (timbre/error "Source or target is not HTML or plain text; or error occurred trying to get content type.")))) (defn start "Start a go-loop that recursively calls to process-webmention." [wmc callbacks storage] - (go-loop [] - (process-webmention wmc callbacks storage) - (recur))) + (go-loop [wm (<! wmc)] + (timbre/info "Webmention found in queue.") + (process-webmention wm callbacks storage) + (recur (<! wmc)))) |
