summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authoreltrac <hi@eltr.ac>2026-05-08 15:24:17 +0800
committereltrac <hi@eltr.ac>2026-05-08 15:24:17 +0800
commit9925b406e162eb5a5a46d12fa06909c54c28cd4d (patch)
treef87f4afe58d5e751817776e99c38c6265ea621a3 /src
parent033af3de12a232f34dd8b1881dd9867173e92399 (diff)
fix(processor, verifier): not deleting wm when url respond with HTTP error
Content-Type checks are somehow written in process-webmention function, when it should be in verify-mention function, which causes weepinbell not deleting Webmention when one of target and source is not found (or any other HTTP status code that is not 2**)
Diffstat (limited to 'src')
-rw-r--r--src/weepinbell/processor.clj13
-rw-r--r--src/weepinbell/verifier.clj15
2 files changed, 14 insertions, 14 deletions
diff --git a/src/weepinbell/processor.clj b/src/weepinbell/processor.clj
index 4466745..2eccb84 100644
--- a/src/weepinbell/processor.clj
+++ b/src/weepinbell/processor.clj
@@ -5,7 +5,7 @@
If exists and verification passes, update it."
(:require [clojure.core.async :refer [go-loop <!]]
[weepinbell.wrapper :as wrapper]
- [weepinbell.verifier :refer [verify-mention verify-content-types]]
+ [weepinbell.verifier :refer [verify-mention]]
[taoensso.timbre :as timbre]))
(defn process-new-webmention
@@ -43,20 +43,15 @@
Callbacks and storage are maps of functions, to avoid
depending on technical details directly."
[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 (verify-content-types s t)
- ;; second check if such webmention exists
+ (let [{:keys [s t]} wm]
+ ;; 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."))))
+ ((:on-receive callbacks)))))
(defn start
"Start a go-loop that recursively calls to process-webmention."
diff --git a/src/weepinbell/verifier.clj b/src/weepinbell/verifier.clj
index 0928fb5..2824c10 100644
--- a/src/weepinbell/verifier.clj
+++ b/src/weepinbell/verifier.clj
@@ -23,12 +23,17 @@
:headers {"Range" "bytes=0-1048575"}})]
;; Verify status code
(if (and (>= status 200) (< status 300))
- ;; Verify inclusion of target URL
- ;; TODO needs to be more robust
- (if (includes? (str body) target)
- true
+ ;; Verify Content-Types
+ (if (verify-content-types source target)
+ ;; Verify inclusion of target URL
+ ;; TODO needs to be more robust
+ (if (includes? (str body) target)
+ true
+ (do
+ (timbre/error "Target link not found in source body.")
+ false))
(do
- (timbre/error "Target link not found in source body.")
+ (timbre/error "Source or target is neither HTML nor plain text content.")
false))
(do
(timbre/error "Source returned status:" status)