1
0
mirror of https://codeberg.org/cage/tinmop/ synced 2025-02-20 08:40:36 +01:00

- added code to try to recover from a failed tag request.

This commit is contained in:
cage 2022-11-12 14:12:45 +01:00
parent ccff6616c4
commit c0cbe8f519
3 changed files with 45 additions and 28 deletions

View File

@ -377,14 +377,25 @@ Returns nil if the user did not provided a server in the configuration file"
(defun-api-call get-timeline-tag (tag &key min-id (limit 20)) (defun-api-call get-timeline-tag (tag &key min-id (limit 20))
"Gets messages that contains tags identified by parameter `tag'" "Gets messages that contains tags identified by parameter `tag'"
(tooter:timeline-tag *client* (restart-case
tag (tooter:timeline-tag *client*
:local nil tag
:only-media nil :local nil
:max-id nil :only-media nil
:since-id nil :max-id nil
:min-id min-id :since-id nil
:limit limit)) :min-id min-id
:limit limit)
(retry-ignoring-min-id ()
(ignore-errors
(tooter:timeline-tag *client*
tag
:local nil
:only-media nil
:max-id nil
:since-id nil
:min-id nil
:limit limit)))))
(defun-api-call update-timeline-tag (tag folder &key (defun-api-call update-timeline-tag (tag folder &key
(recover-count 0) (recover-count 0)
@ -395,22 +406,22 @@ Returns nil if the user did not provided a server in the configuration file"
reflectings the changes in the timeline (saves messages in the reflectings the changes in the timeline (saves messages in the
database etc.)" database etc.)"
(when tag (when tag
(let* ((timeline-statuses (get-timeline-tag tag (when-let* ((timeline-statuses (get-timeline-tag tag
:min-id min-id :min-id min-id
:limit limit)) :limit limit))
(trees (if command-line:*update-timeline-climb-message-tree* (trees (if command-line:*update-timeline-climb-message-tree*
(flatten (loop (flatten (loop
for node-status in timeline-statuses for node-status in timeline-statuses
collect collect
(expand-status-tree node-status))) (expand-status-tree node-status)))
timeline-statuses)) timeline-statuses))
(save-timeline-in-db-event (make-instance 'program-events:save-timeline-in-db-event (save-timeline-in-db-event (make-instance 'program-events:save-timeline-in-db-event
:payload trees :payload trees
:timeline-type db:+federated-timeline+ :timeline-type db:+federated-timeline+
:folder folder :folder folder
:localp nil :localp nil
:min-id min-id :min-id min-id
:recover-count recover-count))) :recover-count recover-count)))
(update-pagination-statuses-so-far timeline-statuses (update-pagination-statuses-so-far timeline-statuses
db:+default-tag-timeline+ db:+default-tag-timeline+
folder folder

View File

@ -21,11 +21,11 @@
(defun safe-parse-number (maybe-number &key (fix-fn #'(lambda (e) (declare (ignore e)) nil))) (defun safe-parse-number (maybe-number &key (fix-fn #'(lambda (e) (declare (ignore e)) nil)))
(handler-bind ((error (handler-bind ((error
(lambda(e) (lambda (e)
(return-from safe-parse-number (funcall fix-fn e))))) (return-from safe-parse-number (funcall fix-fn e)))))
(if (or (not (stringp maybe-number)) (if (or (not (stringp maybe-number))
(string= maybe-number "-")) (string= maybe-number "-"))
(error "Paring a non string element") (error "Parsing a non string element")
(parse-number:parse-number maybe-number)))) (parse-number:parse-number maybe-number))))
(defun parse-number-default (maybe-number default) (defun parse-number-default (maybe-number default)

View File

@ -473,7 +473,7 @@ Metadata includes:
(setf intersect-sorted (setf intersect-sorted
(remove window intersect-sorted)) (remove window intersect-sorted))
(setf intersect-sorted (setf intersect-sorted
(remove-if-not (lambda(a) (typep a 'main-window::focus-marked-window)) (remove-if-not (lambda (a) (typep a 'main-window::focus-marked-window))
intersect-sorted)) intersect-sorted))
(when intersect-sorted (when intersect-sorted
(remove-focus-to-all-windows) (remove-focus-to-all-windows)
@ -1025,7 +1025,13 @@ If some posts was deleted before, download them again."
(let* ((all-tags (db:all-subscribed-tags-name)) (let* ((all-tags (db:all-subscribed-tags-name))
(all-paginations (db:all-tag-paginations-status all-tags))) (all-paginations (db:all-tag-paginations-status all-tags)))
(flet ((update () (flet ((update ()
(client:update-subscribed-tags all-tags all-paginations) (handler-bind ((tooter:request-failed
(lambda (e)
(notify (format nil
(_ "Error getting the latest unread messages for tag ~a, trying fetching the latest")
(tooter:url e)))
(invoke-restart 'api-client::retry-ignoring-min-id))))
(client:update-subscribed-tags all-tags all-paginations))
(let ((update-got-message-event (let ((update-got-message-event
(make-instance 'tag-mark-got-messages-event)) (make-instance 'tag-mark-got-messages-event))
(notify-event (notify-event