mirror of
https://github.com/rustmailer/rustmailer.git
synced 2026-09-09 00:01:34 +00:00
feat(graph): add Graph API support and GraphAPI account type
This commit is contained in:
@@ -108,6 +108,7 @@ impl AppendReplyToDraftRequest {
|
||||
self.append_reply_to_draft_gmail(&account, account_id)
|
||||
.await?
|
||||
}
|
||||
MailerType::GraphApi => todo!(),
|
||||
}
|
||||
|
||||
Ok(())
|
||||
|
||||
@@ -73,6 +73,7 @@ impl AttachmentRequest {
|
||||
));
|
||||
}
|
||||
}
|
||||
MailerType::GraphApi => todo!(),
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
@@ -171,6 +172,7 @@ pub async fn retrieve_email_attachment(
|
||||
let reader = retrieve_gmail_attachment(&account, &request.id, &attachment_info).await?;
|
||||
Ok((reader, filename))
|
||||
}
|
||||
MailerType::GraphApi => todo!(),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -98,6 +98,7 @@ impl MessageContentRequest {
|
||||
));
|
||||
}
|
||||
}
|
||||
MailerType::GraphApi => todo!(),
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
@@ -423,6 +424,7 @@ pub async fn retrieve_email_content(
|
||||
retrieve_gmail_message_content(account_id, request.id, request.max_length, skip_cache)
|
||||
.await
|
||||
}
|
||||
MailerType::GraphApi => todo!(),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -66,6 +66,7 @@ pub async fn move_to_trash(
|
||||
move_to_trash_or_delete_messages_directly(account_id, &uids, mailbox).await
|
||||
}
|
||||
MailerType::GmailApi => gmail_move_to_trash(&account, &request.ids).await,
|
||||
MailerType::GraphApi => todo!(),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -58,6 +58,7 @@ pub async fn retrieve_raw_email(
|
||||
retrieve_imap_raw_email(account_id, mailbox, uid).await
|
||||
}
|
||||
MailerType::GmailApi => retrieve_gmail_raw_email(&account, id).await,
|
||||
MailerType::GraphApi => todo!(),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -9,8 +9,9 @@ use crate::{
|
||||
cache::{
|
||||
imap::{mailbox::MailBox, migration::EmailEnvelopeV3, thread::EmailThread},
|
||||
model::Envelope,
|
||||
vendor::gmail::sync::{
|
||||
client::GmailClient, envelope::GmailEnvelope, labels::GmailLabels,
|
||||
vendor::{
|
||||
gmail::sync::{client::GmailClient, envelope::GmailEnvelope, labels::GmailLabels},
|
||||
outlook::sync::{envelope::OutlookEnvelope, folders::OutlookFolder},
|
||||
},
|
||||
},
|
||||
common::{decode_page_token, parallel::run_with_limit},
|
||||
@@ -188,6 +189,7 @@ async fn fetch_remote_messages(
|
||||
total_pages: Some(total_pages),
|
||||
})
|
||||
}
|
||||
MailerType::GraphApi => todo!(),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -256,7 +258,6 @@ async fn fetch_local_messages(
|
||||
))
|
||||
}
|
||||
}
|
||||
|
||||
MailerType::GmailApi => {
|
||||
let target_label = GmailLabels::get_by_name(account.id, mailbox_name).await?;
|
||||
let DataPage {
|
||||
@@ -294,6 +295,43 @@ async fn fetch_local_messages(
|
||||
))
|
||||
}
|
||||
}
|
||||
MailerType::GraphApi => {
|
||||
let target_label = OutlookFolder::get_by_name(account.id, mailbox_name).await?;
|
||||
|
||||
let DataPage {
|
||||
current_page: _,
|
||||
page_size,
|
||||
total_items,
|
||||
items,
|
||||
total_pages,
|
||||
} = OutlookEnvelope::list_messages_in_folder(target_label.id, page, page_size, desc)
|
||||
.await?;
|
||||
|
||||
if total_items == 0 {
|
||||
Ok(CursorDataPage::new(None, page_size, 0, None, vec![]))
|
||||
} else {
|
||||
let total_pages = total_pages.ok_or_else(|| {
|
||||
raise_error!(
|
||||
"Internal error: total_pages is None (this should never happen)".into(),
|
||||
ErrorCode::InternalError
|
||||
)
|
||||
})?;
|
||||
|
||||
let next_page_token = if page == total_pages {
|
||||
None
|
||||
} else {
|
||||
Some(base64_encode_url_safe!((page + 1).to_string()))
|
||||
};
|
||||
|
||||
Ok(CursorDataPage::new(
|
||||
next_page_token,
|
||||
page_size,
|
||||
total_items,
|
||||
Some(total_pages),
|
||||
items.into_iter().map(|e| e.into()).collect(),
|
||||
))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -341,6 +379,7 @@ pub async fn list_threads_in_mailbox(
|
||||
let label = GmailLabels::get_by_name(account_id, mailbox_name).await?;
|
||||
EmailThread::list_threads_in_label(account, label.id, page, page_size, desc).await
|
||||
}
|
||||
MailerType::GraphApi => todo!(),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -371,5 +410,6 @@ pub async fn get_thread_messages(
|
||||
.map(|e| e.into_envelope(&map))
|
||||
.collect())
|
||||
}
|
||||
MailerType::GraphApi => todo!(),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -497,6 +497,7 @@ impl MessageSearchRequest {
|
||||
self.gmail_api_search_impl(&account, next_page_token, page_size)
|
||||
.await
|
||||
}
|
||||
MailerType::GraphApi => todo!(),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -831,6 +832,7 @@ impl UnifiedSearchRequest {
|
||||
})?;
|
||||
envelope.into_envelope(&label_map)
|
||||
}
|
||||
MailerType::GraphApi => todo!(),
|
||||
};
|
||||
items.push(envelope);
|
||||
}
|
||||
|
||||
@@ -178,5 +178,6 @@ pub async fn transfer_messages(
|
||||
}
|
||||
}
|
||||
}
|
||||
MailerType::GraphApi => todo!(),
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user