refactor(list-messages): switch from page-based to cursor-based pagination

- Changed `list-messages` API from page/page_size to cursor/next_page_token
- Aligns pagination approach with Gmail API for easier integration
- Frontend updates to handle cursor-based navigation
This commit is contained in:
rustmailer
2025-09-28 07:39:40 +08:00
parent 08ef77c23c
commit 16c84abe67
15 changed files with 401 additions and 145 deletions
+2 -2
View File
@@ -202,9 +202,9 @@ impl GmailClient {
account_id: u64,
use_proxy: Option<u64>,
label_id: &str,
page_token: Option<String>,
page_token: Option<&str>,
after: Option<&str>,
max_results: u32,
max_results: u64,
) -> RustMailerResult<MessageList> {
let mut url = format!(
"https://gmail.googleapis.com/gmail/v1/users/me/messages?labelIds={}&maxResults={}",
+4 -4
View File
@@ -43,9 +43,9 @@ pub async fn fetch_and_save_since_date(
account_id,
use_proxy,
&label.label_id,
page_token,
page_token.as_deref(),
Some(date),
ENVELOPE_BATCH_SIZE,
ENVELOPE_BATCH_SIZE as u64,
)
.await?;
// The total number of messages can only be retrieved via an API query
@@ -156,9 +156,9 @@ pub async fn fetch_and_save_full_label(
account_id,
use_proxy,
&label.label_id,
page_token,
page_token.as_deref(),
None,
ENVELOPE_BATCH_SIZE,
ENVELOPE_BATCH_SIZE as u64,
)
.await?;
// Update page_token returned by Gmail API