diff --git a/src/main/lemondronor/advisorycircular.cljs b/src/main/lemondronor/advisorycircular.cljs index 56762ef..7238908 100644 --- a/src/main/lemondronor/advisorycircular.cljs +++ b/src/main/lemondronor/advisorycircular.cljs @@ -63,14 +63,16 @@ "ac"))}) -(defn get-adsbexchange-live-data [{:keys [url lat lon radius-nm api-key]}] +(defn get-adsbexchange-live-data [{:keys [url lat lon radius-nm api-key api-whitelist]}] (let [url (->> [url "lat" lat "lon" lon "dist" (.toFixed radius-nm 1)] (map str) - (string/join "/"))] - (p/let [http-result (util/http-get url {:headers {:api-auth api-key}})] + (string/join "/")) + headers (cond-> {:api-auth api-key} + api-whitelist (assoc :ADSBX-WL api-whitelist))] + (p/let [http-result (util/http-get url {:headers headers})] (let [result (parse-adsbexchange-live-data http-result)] (log-verbose "Got %s aircraft from API" (count (:aircraft result))) result)))) @@ -653,11 +655,10 @@ (write-history-db {} history-db-path)) db (read-history-db history-db-path) data (get-adsbexchange-live-data - {:url (get-in config [:adsbx :url]) - :api-key (get-in config [:adsbx :api-key]) - :lat (:lat config) - :lon (:lon config) - :radius-nm (* (:radius-km config) 0.539957)}) + (merge (:adsbx config) + {:lat (:lat config) + :lon (:lon config) + :radius-nm (* (:radius-km config) 0.539957)})) now (current-time) [new-db potential-circles] (-> db (update-history-db (:aircraft data) now config)