summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authoreltrac <hi@eltr.ac>2026-04-08 22:40:08 +0800
committereltrac <hi@eltr.ac>2026-04-08 22:40:08 +0800
commit9278240c8fdb013076a766d90fda0130daa75e27 (patch)
tree7a71fb3ff29cad48c788e845fc793d1ca51a0ff9 /src
parentaa0d982d7581bd24a9f02922dd336a6f7f0184d1 (diff)
perf: do not show :microformats and :extra when empty
Diffstat (limited to 'src')
-rw-r--r--src/weepinbell/retriever.clj19
1 files changed, 10 insertions, 9 deletions
diff --git a/src/weepinbell/retriever.clj b/src/weepinbell/retriever.clj
index 681229d..7bc0818 100644
--- a/src/weepinbell/retriever.clj
+++ b/src/weepinbell/retriever.clj
@@ -1,13 +1,9 @@
(ns weepinbell.retriever
(:require [weepinbell.storage :as storage]
- [weepinbell.utils :refer [valid-http-url?
- get-domain
+ [weepinbell.utils :refer [get-domain
get-path
- get-target
respond-json]]
- [weepinbell.microformats-wrapper :as mf-wrapper]
- [clojure.string :refer [includes?]]
- [cheshire.core :as json]))
+ [weepinbell.microformats-wrapper :as mf-wrapper]))
;; utilities
(defn- respond-webmention-json [data]
@@ -18,9 +14,14 @@
404)))
(defn- wrap-response-object [data]
- {:webmention (:webmention data)
- :microformats (mf-wrapper/wrap-entry (:microformats data))
- :extra (:extra data)})
+ (let [result {:webmention (:webmention data)}]
+ (cond-> result
+ (not (empty? (:microformats data)))
+ (assoc :microformats (-> data
+ :microformats
+ mf-wrapper/wrap-entry))
+ (:extra data)
+ (assoc :extra (:extra data)))))
(defn- wrap-response-list [data]
(map wrap-response-object data))