mirror of
https://github.com/chatmail/core.git
synced 2026-05-22 16:26:31 +03:00
refactor: flatten create_or_lookup_mailinglist()
This commit is contained in:
@@ -2007,7 +2007,10 @@ async fn apply_mailinglist_changes(
|
|||||||
mime_parser: &MimeMessage,
|
mime_parser: &MimeMessage,
|
||||||
chat_id: ChatId,
|
chat_id: ChatId,
|
||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
if let Some(list_post) = &mime_parser.list_post {
|
let Some(list_post) = &mime_parser.list_post else {
|
||||||
|
return Ok(());
|
||||||
|
};
|
||||||
|
|
||||||
let mut chat = Chat::load_from_db(context, chat_id).await?;
|
let mut chat = Chat::load_from_db(context, chat_id).await?;
|
||||||
if chat.typ != Chattype::Mailinglist {
|
if chat.typ != Chattype::Mailinglist {
|
||||||
return Ok(());
|
return Ok(());
|
||||||
@@ -2021,8 +2024,7 @@ async fn apply_mailinglist_changes(
|
|||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
let (contact_id, _) =
|
let (contact_id, _) = Contact::add_or_lookup(context, "", list_post, Origin::Hidden).await?;
|
||||||
Contact::add_or_lookup(context, "", list_post, Origin::Hidden).await?;
|
|
||||||
let mut contact = Contact::get_by_id(context, contact_id).await?;
|
let mut contact = Contact::get_by_id(context, contact_id).await?;
|
||||||
if contact.param.get(Param::ListId) != Some(listid) {
|
if contact.param.get(Param::ListId) != Some(listid) {
|
||||||
contact.param.set(Param::ListId, listid);
|
contact.param.set(Param::ListId, listid);
|
||||||
@@ -2040,7 +2042,6 @@ async fn apply_mailinglist_changes(
|
|||||||
chat.param.set(Param::ListPost, list_post);
|
chat.param.set(Param::ListPost, list_post);
|
||||||
chat.update_param(context).await?;
|
chat.update_param(context).await?;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user