From 8fc5e4bc3cbd592b136afe3e83336ca527295dce Mon Sep 17 00:00:00 2001 From: Anish Lakhwara Date: Tue, 30 Aug 2022 21:33:53 +1000 Subject: [PATCH] fix: bug which wasn't actually getting all shaarli requests, turns out shaarli's api has limit: all which negates the need to do what i was doing --- flake.nix | 1 + src/dhyan/connections/shaarli.clj | 20 +++++--------------- 2 files changed, 6 insertions(+), 15 deletions(-) diff --git a/flake.nix b/flake.nix index f3b2a1b..4482696 100644 --- a/flake.nix +++ b/flake.nix @@ -29,6 +29,7 @@ options.enable = lib.mkEnableOption "Dhyan daily runner"; in { + # TODO This won't work either because secrets aren't passed options.services.mossnet.dhyan = options; config = lib.mkIf serviceConfig.enable { systemd.services."dhyan" = { diff --git a/src/dhyan/connections/shaarli.clj b/src/dhyan/connections/shaarli.clj index 0528349..7b54752 100644 --- a/src/dhyan/connections/shaarli.clj +++ b/src/dhyan/connections/shaarli.clj @@ -40,32 +40,22 @@ (def token (generate-token (System/getenv "SHAARLI_TOKEN"))) -(defn shaarli-request [offset] - (-> (curl/get (str "http://links.mossnet.lan/api/v1/links?searchtags=music&limit=" offset) {:headers {"Authorization" (str "Bearer " token)}}) +(defn shaarli-request [limit offset] + (-> (curl/get (str "http://links.mossnet.lan/api/v1/links?searchtags=music&limit=" limit "&offset=" offset) {:headers {"Authorization" (str "Bearer " token)}}) (:body) (json/parse-string true))) (defn get-all-shaarli-data - ([] (get-all-shaarli-data {} 0)) - ([data offset] - (let [new-data (shaarli-request offset) - total-data (concat data new-data) - old-last (last data) - new-last (last new-data)] - (if (= old-last new-last) - total-data - (get-all-shaarli-data total-data (+ offset 100)))))) + [] + (shaarli-request "all" 0)) (comment - (shaarli-request 0) + (shaarli-request 100 0) (count (get-all-shaarli-data)) (url-filterer {:url "bandcamp"} "bandcamp") (filter (fn [x] (.contains (get x :url) "bandcamp")) [{:url "bandcamp"}]) (println "somestring") (.getBytes (str {"iat" (sh "date" "-u" "+%s")})) - (def signature (-> (Mac/getInstance "HmacSHA256") - (.init (SecretKeySpec. (.getBytes "test secret") "HmacSHA256")) - (.doFinal (.getBytes (str "header.payload") "UTF-8")))) (def sig (let [algo "HmacSHA256" mac (Mac/getInstance algo)]