1
0
Fork 0

- used the new pagination API.

This commit is contained in:
cage 2023-10-14 10:59:28 +02:00
parent 653ca72baa
commit ef034729e8
2 changed files with 19 additions and 19 deletions

View File

@ -28,8 +28,7 @@
(defun main ()
(connect)
(db-utils:with-ready-database (:connect t)
(let* ((username (swconf:config-username))
(local-server-name (swconf:config-server-name))
(let* ((local-server-name (swconf:config-server-name))
(user-acct (api-client:local-user-acct))
(follows-accounts (api-client:get-following user-acct)))
(loop for account in follows-accounts do

View File

@ -267,11 +267,17 @@ Returns nil if the user did not provided a server in the configuration file"
(when (client-valid-p)
,@remaining-forms))))
(defmacro slurp-all-pages (starting-form)
(with-gensyms (results page)
`(let ((,results '()))
(tooter:do-pages (*client* ,page :direction :next)
,starting-form
(setf ,results (append ,results ,page)))
,results)))
(defun-api-call get-announcements ()
"Get all the non dismissed announcements"
(let ((all-announcements (tooter:get-announcements *client* :with-dismissed nil)))
;; even if asked for non dismissed posts, the server returns all the
;; announcements anyway...
(let ((all-announcements (tooter:get-announcements *client*)))
(remove-if #'tooter:readp all-announcements)))
(defun-api-call dismiss-announcement (announcement-id)
@ -314,12 +320,12 @@ Returns nil if the user did not provided a server in the configuration file"
(tooter:unfollow-tag *client* tag-name))
(defun-api-call get-followed-tags (&key max-id since-id min-id (limit 20))
"Unfollow a tag"
(tooter:followed-tags *client*
:max-id max-id
:since-id since-id
:min-id min-id
:limit limit))
"Unfollow a tag"
(slurp-all-pages (tooter:followed-tags *client*
:max-id max-id
:since-id since-id
:min-id min-id
:limit limit)))
(define-constant +public-timeline+ "public" :test #'string=)
@ -574,7 +580,7 @@ database."
(defun-api-call follow-requests ()
"Gets the request to follow the user of this client"
(let ((requests (tooter:follow-requests *client*)))
(let ((requests (slurp-all-pages (tooter:follow-requests *client*))))
(values requests
(mapcar #'tooter:account-name requests))))
@ -588,14 +594,9 @@ database."
(when user-id
(tooter:reject-request *client* user-id)))
(defun-api-call get-following (user-id &optional (min-id nil) (accum '()))
(defun-api-call get-following (user-id &optional (min-id nil))
"Get a list of accounts that user is following"
(let ((partial (sort-id< (tooter:get-following api-client:*client*
user-id
:max-id min-id))))
(if partial
(get-following user-id (tooter:id (first partial)) (append partial accum))
accum)))
(sort-id< (slurp-all-pages (tooter:get-following *client* user-id :max-id min-id))))
(defun local-user-acct ()
(tooter:id (tooter:account *client*)))