|
236 | 236 | ;; provided by us |
237 | 237 | #_[:id {:optional true} :string] |
238 | 238 | ;; provided by boost client |
239 | | - [:action [:enum :boost :stream]] |
| 239 | + [:action {:decode/json str/lower-case |
| 240 | + :decode/string str/lower-case} [:enum "boost" "stream"]] |
240 | 241 | [:split {:json-schema/default 1.0} [:double {:min 0.0}]] |
241 | 242 | [:value_msat {:json-schema/default 2222000} [:int {:min 1}]] |
242 | 243 | [:value_msat_total {:json-schema/default 2222000} [:int {:min 1}]] |
243 | 244 | [:timestamp {:json-schema/default (java.time.Instant/now)} |
244 | 245 | [:and :string |
245 | 246 | [:fn {:error/message "must be ISO-8601"} valid-iso8601?]]] |
246 | | - ;; optional keys |
247 | | - [:group {:optional true} :string] |
248 | | - [:message {:optional true :json-schema/default "row of ducks"} :string] |
249 | | - [:app_name {:optional true} :string] |
250 | | - [:app_version {:optional true} :string] |
251 | | - [:sender_id {:optional true} :string] |
252 | | - [:sender_name {:optional true} :string] |
253 | | - [:recipient_name {:optional true} :string] |
254 | | - [:recipient_address {:optional true} :string] |
255 | | - [:value_usd {:optional true} [:double {:min 0.0}]] |
256 | | - [:position {:optional true} :int] |
257 | | - [:feed_guid {:optional true} :string] |
258 | | - [:feed_title {:optional true} :string] |
259 | | - [:item_guid {:optional true} :string] |
260 | | - [:item_title {:optional true} :string] |
261 | | - [:publisher_guid {:optional true} :string] |
262 | | - [:publisher_title {:optional true} :string] |
263 | | - [:remote_feed_guid {:optional true} :string] |
264 | | - [:remote_item_guid {:optional true} :string] |
265 | | - [:remote_publisher_guid {:optional true} :string]]) |
| 247 | + ;; optional keys |
| 248 | + [:group {:optional true} [:maybe :string]] |
| 249 | + [:message {:optional true :json-schema/default "row of ducks"} [:maybe :string]] |
| 250 | + [:app_name {:optional true} [:maybe :string]] |
| 251 | + [:app_version {:optional true} [:maybe :string]] |
| 252 | + [:sender_id {:optional true} [:maybe :string]] |
| 253 | + [:sender_name {:optional true} [:maybe :string]] |
| 254 | + [:recipient_name {:optional true} [:maybe :string]] |
| 255 | + [:recipient_address {:optional true} [:maybe :string]] |
| 256 | + [:value_usd {:optional true} [:maybe [:double {:min 0.0}]]] |
| 257 | + [:position {:optional true} [:maybe :int]] |
| 258 | + [:feed_guid {:optional true} [:maybe :string]] |
| 259 | + [:feed_title {:optional true} [:maybe :string]] |
| 260 | + [:item_guid {:optional true} [:maybe :string]] |
| 261 | + [:item_title {:optional true} [:maybe :string]] |
| 262 | + [:publisher_guid {:optional true} [:maybe :string]] |
| 263 | + [:publisher_title {:optional true} [:maybe :string]] |
| 264 | + [:remote_feed_guid {:optional true} [:maybe :string]] |
| 265 | + [:remote_item_guid {:optional true} [:maybe :string]] |
| 266 | + [:remote_publisher_guid {:optional true} [:maybe :string]]]) |
266 | 267 |
|
267 | 268 | ;; ~~~~~~~~~~~~~~~~~~~ GET View ~~~~~~~~~~~~~~~~~~~ |
268 | 269 | (defn encode-header [data] |
|
292 | 293 | (let [boost-id (get data "id") |
293 | 294 | json-pretty (json/write-value-as-string data (json/object-mapper {:pretty true})) |
294 | 295 | sender-name (get data "sender_name") |
295 | | - value-msats (get data "value_msat") |
| 296 | + value-msats (get data "value_msat_total") |
296 | 297 | sats (format-sats value-msats) |
297 | 298 | feed-title (get data "feed_title") |
298 | 299 | item-title (get data "item_title") |
|
390 | 391 | (str "rss::payment::" action " " url))) |
391 | 392 |
|
392 | 393 | (defn add-boost [cfg storage] |
393 | | - (fn [{:keys [:body-params] :as request}] |
| 394 | + (fn [{{body-params :body} :parameters :as request}] |
394 | 395 | (let [id (gen-ulid) |
395 | 396 | url (str (:base-url cfg) "/boost/" id) |
396 | 397 | boost (assoc body-params :id id) |
|
489 | 490 | :coercion (reitit.coercion.malli/create |
490 | 491 | {:error-keys #{:in :humanized} |
491 | 492 | :compile mu/open-schema |
| 493 | + :strip-extra-keys false |
492 | 494 | :default-values true}) |
493 | 495 | :middleware [swagger/swagger-feature |
494 | 496 | parameters/parameters-middleware |
|
531 | 533 | (assoc-in response [:headers "x-correlation-id"] correlation-id)))) |
532 | 534 |
|
533 | 535 | (defn mulog-wrapper [handler] |
534 | | - (fn [{:keys [:request-method :uri :query-params :path-params :body-params :correlation-id] :as request}] |
| 536 | + (fn [{:keys [:request-method :uri :correlation-id] :as request}] |
535 | 537 | (u/trace ::http-request |
536 | 538 | {:pairs [:correlation-id correlation-id |
537 | 539 | :method request-method |
538 | | - :uri uri |
539 | | - :query-params query-params |
540 | | - :path-params path-params |
541 | | - :body-params body-params] |
| 540 | + :uri uri] |
542 | 541 | :capture (fn [{:keys [:status ::exception] :as response}] |
543 | 542 | (let [success (< status 400) |
544 | 543 | base {:status status |
|
0 commit comments