From 6ded583d3df053144f0b9e3087ec4bd3ad45c12f Mon Sep 17 00:00:00 2001 From: Masaya Tojo Date: Wed, 8 Jul 2020 10:03:09 +0900 Subject: qkbox: toot: Update post-json procedure. * qkbox/toot.scm[post-json]: Add authorization? keyword. --- qkbox/toot.scm | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) (limited to 'qkbox') diff --git a/qkbox/toot.scm b/qkbox/toot.scm index 122e1bf..796d9c1 100644 --- a/qkbox/toot.scm +++ b/qkbox/toot.scm @@ -42,8 +42,8 @@ "/api/v1/statuses" `(,@(if status `((status . ,(if (string? status) - status - (format #f "~y" status)))) + status + (format #f "~y" status)))) '()) ,@(if spoiler-text `((spoiler_text . ,spoiler-text)) @@ -62,19 +62,22 @@ '()) ,@(if media-ids `((media_ids . ,(list->vector (map number->string media-ids)))) - '())))) + '())) + #:authorization? #t)) -(define (post-json path json) +(define* (post-json path json #:key authorization?) (define-values (res body) (http-post (string-append "https://" (current-mastodon-host) path) #:headers `((content-type application/json) - (authorization - ,(string->symbol - (string-append - "Bearer " - (current-mastodon-access-token))))) + ,@(if authorization? + `((authorization + ,(string->symbol + (string-append + "Bearer " + (current-mastodon-access-token))))) + '())) #:decode-body? #t #:body (scm->json-string json))) (if (= 200 (response-code res)) -- cgit v1.2.3