summaryrefslogtreecommitdiff
path: root/qkbox
diff options
context:
space:
mode:
authorMasaya Tojo <masaya@tojo.tokyo>2020-07-10 10:26:20 +0900
committerMasaya Tojo <masaya@tojo.tokyo>2020-07-10 10:26:20 +0900
commit17755d5cc6e21b277071200c5f39f100bda71984 (patch)
treecbe52712b1b2c096668c143ffd980a50f8275811 /qkbox
parent0a99852d5154de3ac62d0d48080f0034745d3c88 (diff)
qkbox: toot: Use receive.
Diffstat (limited to 'qkbox')
-rw-r--r--qkbox/toot.scm80
1 files changed, 40 insertions, 40 deletions
diff --git a/qkbox/toot.scm b/qkbox/toot.scm
index 57964b4..b3379d1 100644
--- a/qkbox/toot.scm
+++ b/qkbox/toot.scm
@@ -49,17 +49,17 @@
visibility
sensitive?
reply-to)
- (define-values (res body)
- (/api/v1/statuses #:status text
- #:spoiler-text spoiler-text
- #:visibility visibility
- #:sensitive? sensitive?
- #:reply-to reply-to))
- (case (response-code res)
- ((200)
- (assoc-ref body "id"))
- (else
- (error "post: failed" res body))))
+ (receive (res body)
+ (/api/v1/statuses #:status text
+ #:spoiler-text spoiler-text
+ #:visibility visibility
+ #:sensitive? sensitive?
+ #:reply-to reply-to)
+ (case (response-code res)
+ ((200)
+ (assoc-ref body "id"))
+ (else
+ (error "post: failed" res body)))))
(define* (/api/v1/statuses #:key
status
@@ -248,12 +248,12 @@
pict))))
(define*-public (status id #:key (authorization? #t))
- (define-values (res body)
- (/api/v1/statuses/:id id #:authorization? authorization?))
- (case (response-code res)
- ((200) (make-status body))
- (else
- (error "status: failed" res body))))
+ (receive (res body)
+ (/api/v1/statuses/:id id #:authorization? authorization?)
+ (case (response-code res)
+ ((200) (make-status body))
+ (else
+ (error "status: failed" res body)))))
(define* (/api/v1/statuses/:id id #:key (authorization? #t))
(request
@@ -262,19 +262,19 @@
#:authorization? authorization?))
(define*-public (timeline #:key max-id since-id min-id limit local?)
- (define-values (res body)
+ (receive (res body)
(/api/v1/timelines/home #:max-id max-id
#:since-id since-id
#:min-id min-id
#:limit limit
- #:local? local?))
- (case (response-code res)
- ((200)
- (map make-status (vector->list body)))
- ((206)
- (error "timeline: Home feed is regenerating"))
- (else
- (error "timeline: failed" res body))))
+ #:local? local?)
+ (case (response-code res)
+ ((200)
+ (map make-status (vector->list body)))
+ ((206)
+ (error "timeline: Home feed is regenerating"))
+ (else
+ (error "timeline: failed" res body)))))
(define* (/api/v1/timelines/home #:key max-id since-id min-id limit local?)
(request
@@ -380,20 +380,20 @@
(values res body))))
(define*-public (account id)
- (define-values (res body)
- (/api/v1/accounts/:id id))
- (case (response-code res)
- ((200) (make-account body))
- ((401)
- (error "account: Unauthorized" id))
- ((404)
- (error "account: Not Found" id))
- ((410)
- (error "account: Account is suspended" id))
- (else
- (error "account: failed"
- (response-code res)
- (utf8->string body)))))
+ (receive (res body)
+ (/api/v1/accounts/:id id)
+ (case (response-code res)
+ ((200) (make-account body))
+ ((401)
+ (error "account: Unauthorized" id))
+ ((404)
+ (error "account: Not Found" id))
+ ((410)
+ (error "account: Account is suspended" id))
+ (else
+ (error "account: failed"
+ (response-code res)
+ (utf8->string body))))))
(define* (/api/v1/accounts/:id id)
(request