diff --git a/chatdir.scm b/chatdir.scm index 3bc7de9..2784082 100644 --- a/chatdir.scm +++ b/chatdir.scm @@ -114,6 +114,12 @@ (create-directory user-path #t)]))) +;; Return a list of all users of a channel of given state. +;; (Lists files in /$channel/.users/$state/). +(define (channel-users root channel #!optional (state "online")) + (directory (subpath root channel ".users" state))) + + ;; Sets a file in the user's directory to given value. ;; Sets /.users/$user/$key to $value. (define (user-file-set! root username key value #!optional (xattr-alist '())) @@ -237,7 +243,6 @@ xattr-alist))) - (define (directory-file-get directory key) (read-file-to-string (subpath directory key))) @@ -271,6 +276,16 @@ (directory-file-get* (subpath root channel ".meta") key)) +;; Return a list of all metadata key (files in /$channel/.meta/). +(define (channel-metadata root channel) + (directory (subpath root channel ".meta"))) + + +;; Lists all currently-joined channels. +(define (channels root) + (directory root)) + + ;; Return a file path with the given parameters as elements of the path ;; E.g., "/etc/", "/systemd/user" "mom" => "/etc/systemd/user/mom" (define (subpath . children) @@ -319,6 +334,11 @@ contents attrs))) +;; List all messages of the given channel. +(define (channel-messages root channel) + (directory (subpath root channel))) + + ;; Initialization for the input loop (define (input-loop-init root-dir callbacks-alist) (let ([join-callback (alist-ref 'join-channel callbacks-alist)])