mirror of
https://github.com/chatmail/core.git
synced 2026-04-26 09:56:35 +03:00
fix: Correct member-added info messages
This commit is contained in:
10
src/chat.rs
10
src/chat.rs
@@ -4065,7 +4065,15 @@ pub(crate) async fn add_contact_to_chat_ex(
|
||||
msg.viewtype = Viewtype::Text;
|
||||
|
||||
let contact_addr = contact.get_addr().to_lowercase();
|
||||
msg.text = stock_str::msg_add_member_local(context, contact.id, ContactId::SELF).await;
|
||||
let added_by = if from_handshake && chat.is_out_broadcast() {
|
||||
// The contact was added via a QR code rather than explicit user action,
|
||||
// and there is added information in saying 'You added member Alice'
|
||||
// if self is the only one who can add members.
|
||||
ContactId::UNDEFINED
|
||||
} else {
|
||||
ContactId::SELF
|
||||
};
|
||||
msg.text = stock_str::msg_add_member_local(context, contact.id, added_by).await;
|
||||
msg.param.set_cmd(SystemMessage::MemberAddedToGroup);
|
||||
msg.param.set(Param::Arg, contact_addr);
|
||||
msg.param.set_int(Param::Arg2, from_handshake.into());
|
||||
|
||||
@@ -3504,6 +3504,17 @@ async fn apply_out_broadcast_changes(
|
||||
silent: true,
|
||||
extra_msgs: vec![],
|
||||
});
|
||||
} else if let Some(added_addr) = mime_parser.get_header(HeaderDef::ChatGroupMemberAdded) {
|
||||
// TODO this may lookup the wrong contact if multiple contacts have the same email addr.
|
||||
// We can send sync messages instead,
|
||||
// lookup the fingerprint by gossip header (like it's done for groups right now)
|
||||
// or add a header ChatGroupMemberAddedFpr.
|
||||
let contact = lookup_key_contact_by_address(context, added_addr, None).await?;
|
||||
if let Some(contact) = contact {
|
||||
better_msg.get_or_insert(
|
||||
stock_str::msg_add_member_local(context, contact, ContactId::UNDEFINED).await,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if send_event_chat_modified {
|
||||
@@ -3546,6 +3557,12 @@ async fn apply_in_broadcast_changes(
|
||||
better_msg
|
||||
.get_or_insert(stock_str::msg_group_left_local(context, ContactId::SELF).await);
|
||||
}
|
||||
} else if let Some(added_addr) = mime_parser.get_header(HeaderDef::ChatGroupMemberAdded) {
|
||||
if context.is_self_addr(added_addr).await? {
|
||||
better_msg.get_or_insert(
|
||||
stock_str::msg_add_member_local(context, ContactId::SELF, from_id).await,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if send_event_chat_modified {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
OutBroadcast#Chat#10: My Channel [1 member(s)] Icon: e9b6c7a78aa2e4f415644f55a553e73.png
|
||||
--------------------------------------------------------------------------------
|
||||
Msg#10🔒: Me (Contact#Contact#Self): You changed the group image. [INFO] √
|
||||
Msg#12🔒: Me (Contact#Contact#Self): You added member bob@example.net. [INFO] √
|
||||
Msg#12🔒: Me (Contact#Contact#Self): Member bob@example.net added. [INFO] √
|
||||
Msg#13🔒: (Contact#Contact#10): Secure-Join: vb-request-with-auth [FRESH]
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
InBroadcast#Chat#11: My Channel [1 member(s)] Icon: e9b6c7a78aa2e4f415644f55a553e73.png
|
||||
--------------------------------------------------------------------------------
|
||||
Msg#12: info (Contact#Contact#Info): You were invited to join this channel. Waiting for the channel owner's device to reply… [NOTICED][INFO]
|
||||
Msg#13🔒: (Contact#Contact#10): I added member bob@example.net. [FRESH][INFO]
|
||||
Msg#13🔒: (Contact#Contact#10): Member Me added by Alice. [FRESH][INFO]
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user