From ae178546b98d6b4655787c0495db1944e6c6e1da Mon Sep 17 00:00:00 2001 From: cage Date: Fri, 19 Feb 2021 16:34:38 +0100 Subject: [PATCH] - added version 2 of get chat list endpoint. --- src/api-client.lisp | 6 +++--- src/api-pleroma.lisp | 31 +++++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+), 3 deletions(-) diff --git a/src/api-client.lisp b/src/api-client.lisp index 9ca1115..c787b1a 100644 --- a/src/api-client.lisp +++ b/src/api-client.lisp @@ -307,9 +307,9 @@ Returns nil if the user did not provided a server in the configuration file" (program-events:push-event add-fetched-event)))) (defun-api-call update-timeline (timeline - kind - folder - &key + kind + folder + &key recover-from-skipped-statuses local only-media diff --git a/src/api-pleroma.lisp b/src/api-pleroma.lisp index 6a34318..4b30755 100644 --- a/src/api-pleroma.lisp +++ b/src/api-pleroma.lisp @@ -25,6 +25,37 @@ "/api/v1/pleroma/chats/by-account-id/~a" account-id)))) + +(defgeneric get-chats-list (object &key with-muted-p max-id min-id since-id offset limits)) + +(defmethod get-chats-list ((object tooter:client) + &key + (with-muted-p t) + (max-id nil) + (min-id nil) + (since-id nil) + (offset 0) + (limits 200)) + "Get a list of all chats, ordered from the more recent updated. Note: uses version 2 of the API." + (decode-chat (tooter:query object + "/api/v2/pleroma/chats" + :with-muted with-muted-p + :max-id max-id + :min-id min-id + :since-id since-id + :offset offset + :limits limits))) + +(defgeneric get-all-chats-v2 (object min-id &key &allow-other-keys)) + +(defmethod get-all-chats-v2 ((object tooter:client) min-id &key (accum ())) + "Get a list of all chats, ordered from the more recent updated." + (let ((chats (api-client:sort-id< (get-chats-list object)))) + (if chats + (let ((new-min-id (tooter:id (last-elt chats)))) + (get-all-chats-v2 object object new-min-id (append chats accum))) + (api-client:sort-id< accum)))) + (defgeneric get-all-chats (object)) (defmethod get-all-chats ((object tooter:client))