From ab3db7a4f31335269223c83e65737b7d50caf70e Mon Sep 17 00:00:00 2001 From: Masaya Tojo Date: Mon, 13 Jul 2020 04:43:30 +0900 Subject: qkbox: toot: Add display-notification procedure. --- qkbox/toot.scm | 24 ++++++++++++++++++++++-- 1 file 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~)~]" -- cgit v1.2.3