summaryrefslogtreecommitdiff
path: root/src/weepinbell/processor/janitor.clj
blob: e3c0b1696eb754e325f95fd681ff8c833461a5ca (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
(ns weepinbell.processor.janitor
  (:require [taoensso.timbre :as timbre]))

(defn clean
  [data storage callbacks]
  (when (:ok? data)
    (let [{:keys [verified? new? id old-data]} data]
      (if (and (not new?) (not verified?))
        (do ;; delete old unverified webmention 
          (timbre/warn "webmention" id "no longer valid, deleting...")
          ((:delete storage) id)
          ((:on-delete callbacks) old-data)
          (-> data (assoc :ok? false)))
        (-> data (assoc :ok? true))))))