diff options
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))) |
