diff options
author | Masaya Tojo <masaya@tojo.tokyo> | 2020-07-13 04:43:30 +0900 |
---|---|---|
committer | Masaya Tojo <masaya@tojo.tokyo> | 2020-07-13 04:43:30 +0900 |
commit | ab3db7a4f31335269223c83e65737b7d50caf70e (patch) | |
tree | c9584a1d0055addf7be3718a852f39b780821a7e | |
parent | 0c9f642ddd3c7a5bc77f88a88a6a0f5ebc43a6af (diff) |
qkbox: toot: Add display-notification procedure.
-rw-r--r-- | qkbox/toot.scm | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/qkbox/toot.scm b/qkbox/toot.scm index 8241794..ad6b742 100644 --- a/qkbox/toot.scm +++ b/qkbox/toot.scm @@ -52,7 +52,12 @@ (make-parameter (getenv "MASTODON_ACCESS_TOKEN"))) (define (created-at-string->date str) - (string->date str "~Y-~m-~dT~H:~M~S.~NZ")) + (time-utc->date + (date->time-utc + (string->date str "~Y-~m-~dT~H:~M:~S.~N~z")))) + +(define (creation-time->string date) + (date->string date "~4")) (define*-public (post text #:key @@ -154,6 +159,19 @@ (assoc-ref (notification-json notification) "created_at"))) +(define* (display-notification notification #:key (port (current-output-port))) + (let ((account (notification-account notification)) + (status (notification-status notification)) + (time (notification-creation-time notification))) + (format port + "[NOTIFICATION] ~:@(~a~)~%~a ~a ~a~%> " + (notification-type notification) + (fetch-avatar-static + (account-avatar-static account)) + (account-to-string account) + (creation-time->string time)) + (display-status (notification-status notification)))) + (define-public (status-public? status) (eq? 'public (status-visibility status))) @@ -176,9 +194,11 @@ (cond (else (format port - "~s ~a~@?~@?~@?~@?~@?~%~@?~@?" + "~s ~a ~a~@?~@?~@?~@?~@?~%~@?~@?" (status-avatar-pict status/original) (account-to-string account) + (creation-time->string + (status-creation-time status/original)) "~@[~% * status-id: ~s~]" (and display-id? (status-id status/original)) "~@[~% * visibility: ~:@(~a~)~]" |