summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoreltrac <hi@eltr.ac>2026-03-03 11:30:07 +0800
committereltrac <hi@eltr.ac>2026-03-03 11:30:07 +0800
commite9541ffc6623d73270c1367ca1d326c7fecb62ab (patch)
tree6c8e2fbae1489304a432d9b22b8747539d26e7ba
parentac3c39a37a33d82f2149e9cfa7acaa9e0d823e9d (diff)
feat: verify webmention, GET source in search of mention
-rw-r--r--project.clj3
-rw-r--r--src/weepinbell/processor.clj19
2 files changed, 19 insertions, 3 deletions
diff --git a/project.clj b/project.clj
index 685a932..7906912 100644
--- a/project.clj
+++ b/project.clj
@@ -8,7 +8,8 @@
[ring/ring-defaults "0.3.2"]
[ring/ring-json "0.5.1"]
[cheshire "6.1.0"]
- [commons-validator "1.4.1"]]
+ [commons-validator "1.4.1"]
+ [clj-http "3.13.1"]]
:plugins [[lein-ring "0.12.5"]]
:ring {:handler weepinbell.handler/app}
:profiles
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)))