feat: make email sending async

This commit is contained in:
Zack Fu Zi Xiang 2024-04-30 01:17:23 +08:00
parent 8f2182900c
commit 781448442c
No known key found for this signature in database
1 changed files with 20 additions and 13 deletions

View File

@ -228,7 +228,10 @@ pub async fn invite_workspace_members(
) )
.await?; .await?;
mailer // send email can be slow, so send email in background
let cloned_mailer = mailer.clone();
tokio::spawn(async move {
if let Err(err) = cloned_mailer
.send_workspace_invite( .send_workspace_invite(
invitation.email, invitation.email,
WorkspaceInviteMailerParam { WorkspaceInviteMailerParam {
@ -240,7 +243,11 @@ pub async fn invite_workspace_members(
accept_url, accept_url,
}, },
) )
.await?; .await
{
tracing::error!("Failed to send workspace invite email: {:?}", err);
};
});
} }
txn txn