diff options
| author | eltrac <hi@eltr.ac> | 2026-03-03 11:30:07 +0800 |
|---|---|---|
| committer | eltrac <hi@eltr.ac> | 2026-03-03 11:30:07 +0800 |
| commit | e9541ffc6623d73270c1367ca1d326c7fecb62ab (patch) | |
| tree | 6c8e2fbae1489304a432d9b22b8747539d26e7ba /src | |
| parent | ac3c39a37a33d82f2149e9cfa7acaa9e0d823e9d (diff) | |
feat: verify webmention, GET source in search of mention
Diffstat (limited to 'src')
| -rw-r--r-- | src/weepinbell/processor.clj | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/src/weepinbell/processor.clj b/src/weepinbell/processor.clj index e17bd92..84041e8 100644 --- a/src/weepinbell/processor.clj +++ b/src/weepinbell/processor.clj @@ -1,6 +1,17 @@ (ns weepinbell.processor - (:require [clojure.core.async :refer [go-loop <!]])) + (:require [clojure.core.async :refer [go-loop <!]] + [clojure.string :refer [includes?]] + [clj-http.client :as client])) +(defn verify-mention + "Get source and follow redirects to check if target link is present." + [source target] + ;; the client follows redirects automatically + (let [{:keys [body]} (client/get source)] + (println "Verifying mention") + ;; check if body contains source + ;; TODO needs to be more robust + (includes? body target))) (defn process-webmention "Retrieve webmention from queue and process it." @@ -8,8 +19,12 @@ (println "Processor started.") (go-loop [] (let [wm (<! wmc)] + (println "Webmention found in queue.") (if wm - (println "webmention found in queue") + (let [{:keys [s t]} wm] + (if (verify-mention s t) + (println "Found mention") + (println "Invalid mention"))) (println "Idling"))) (recur))) |
