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 () (defun main ()
(connect) (connect)
(db-utils:with-ready-database (:connect t) (db-utils:with-ready-database (:connect t)
(let* ((username (swconf:config-username)) (let* ((local-server-name (swconf:config-server-name))
(local-server-name (swconf:config-server-name))
(user-acct (api-client:local-user-acct)) (user-acct (api-client:local-user-acct))
(follows-accounts (api-client:get-following user-acct))) (follows-accounts (api-client:get-following user-acct)))
(loop for account in follows-accounts do (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) (when (client-valid-p)
,@remaining-forms)))) ,@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 () (defun-api-call get-announcements ()
"Get all the non dismissed announcements" "Get all the non dismissed announcements"
(let ((all-announcements (tooter:get-announcements *client* :with-dismissed nil))) (let ((all-announcements (tooter:get-announcements *client*)))
;; even if asked for non dismissed posts, the server returns all the
;; announcements anyway...
(remove-if #'tooter:readp all-announcements))) (remove-if #'tooter:readp all-announcements)))
(defun-api-call dismiss-announcement (announcement-id) (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)) (tooter:unfollow-tag *client* tag-name))
(defun-api-call get-followed-tags (&key max-id since-id min-id (limit 20)) (defun-api-call get-followed-tags (&key max-id since-id min-id (limit 20))
"Unfollow a tag" "Unfollow a tag"
(tooter:followed-tags *client* (slurp-all-pages (tooter:followed-tags *client*
:max-id max-id :max-id max-id
:since-id since-id :since-id since-id
:min-id min-id :min-id min-id
:limit limit)) :limit limit)))
(define-constant +public-timeline+ "public" :test #'string=) (define-constant +public-timeline+ "public" :test #'string=)
@ -574,7 +580,7 @@ database."
(defun-api-call follow-requests () (defun-api-call follow-requests ()
"Gets the request to follow the user of this client" "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 (values requests
(mapcar #'tooter:account-name requests)))) (mapcar #'tooter:account-name requests))))
@ -588,14 +594,9 @@ database."
(when user-id (when user-id
(tooter:reject-request *client* 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" "Get a list of accounts that user is following"
(let ((partial (sort-id< (tooter:get-following api-client:*client* (sort-id< (slurp-all-pages (tooter:get-following *client* user-id :max-id min-id))))
user-id
:max-id min-id))))
(if partial
(get-following user-id (tooter:id (first partial)) (append partial accum))
accum)))
(defun local-user-acct () (defun local-user-acct ()
(tooter:id (tooter:account *client*))) (tooter:id (tooter:account *client*)))