MCPcopy Create free account
hub / github.com/chatmail/core / accept_ex

Method accept_ex

src/chat.rs:439–476  ·  view source on GitHub ↗
(self, context: &Context, sync: sync::Sync)

Source from the content-addressed store, hash-verified

437 }
438
439 pub(crate) async fn accept_ex(self, context: &Context, sync: sync::Sync) -> Result<()> {
440 let chat = Chat::load_from_db(context, self).await?;
441
442 match chat.typ {
443 Chattype::Single | Chattype::Group | Chattype::OutBroadcast | Chattype::InBroadcast => {
444 // Previously accepting a chat literally created a chat because unaccepted chats
445 // went to "contact requests" list rather than normal chatlist.
446 // But for groups we use lower origin because users don't always check all members
447 // before accepting a chat and may not want to have the group members mixed with
448 // existing contacts. `IncomingTo` fits here by its definition.
449 let origin = match chat.typ {
450 Chattype::Group => Origin::IncomingTo,
451 _ => Origin::CreateChat,
452 };
453 for contact_id in get_chat_contacts(context, self).await? {
454 if contact_id != ContactId::SELF {
455 ContactId::scaleup_origin(context, &[contact_id], origin).await?;
456 }
457 }
458 }
459 Chattype::Mailinglist => {
460 // If the message is from a mailing list, the contacts are not counted as "known"
461 }
462 }
463
464 if self.set_blocked(context, Blocked::Not).await? {
465 context.emit_event(EventType::ChatModified(self));
466 chatlist_events::emit_chatlist_item_changed(context, self);
467 }
468
469 if sync.into() {
470 chat.sync(context, SyncAction::Accept)
471 .await
472 .log_err(context)
473 .ok();
474 }
475 Ok(())
476 }
477
478 /// Adds message "Messages are end-to-end encrypted".
479 pub(crate) async fn add_e2ee_notice(self, context: &Context, timestamp: i64) -> Result<()> {

Callers 2

acceptMethod · 0.80
sync_alter_chatMethod · 0.80

Calls 6

get_chat_contactsFunction · 0.85
log_errMethod · 0.80
set_blockedMethod · 0.45
emit_eventMethod · 0.45
syncMethod · 0.45

Tested by

no test coverage detected