mirror of
https://github.com/chatmail/core.git
synced 2026-05-02 04:46:29 +03:00
feat: get contact-id for info messages (#6714)
instead of showing addresses in info message, provide an API to get the contact-id. UI can then make the info message tappable and open the contact profile in scope the corresponding iOS PR - incl. **screencast** - is at https://github.com/deltachat/deltachat-ios/pull/2652 ; jsonrpc can come in a subsequent PR when things are settled on android/ios the number of parameters in `add_info_msg_with_cmd` gets bigger and bigger, however, i did not want to refactor this in this PR. it is also not really adding complexity closes #6702 --------- Co-authored-by: link2xt <link2xt@testrun.org> Co-authored-by: Hocuri <hocuri@gmx.de>
This commit is contained in:
@@ -1451,13 +1451,13 @@ async fn add_parts(
|
||||
None => better_msg = Some(m),
|
||||
Some(_) => {
|
||||
if !m.is_empty() {
|
||||
group_changes.extra_msgs.push((m, is_system_message))
|
||||
group_changes.extra_msgs.push((m, is_system_message, None))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (group_changes_msg, cmd) in group_changes.extra_msgs {
|
||||
for (group_changes_msg, cmd, added_removed_id) in group_changes.extra_msgs {
|
||||
chat::add_info_msg_with_cmd(
|
||||
context,
|
||||
chat_id,
|
||||
@@ -1467,6 +1467,7 @@ async fn add_parts(
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
added_removed_id,
|
||||
)
|
||||
.await?;
|
||||
}
|
||||
@@ -1550,6 +1551,10 @@ async fn add_parts(
|
||||
let part_is_empty =
|
||||
typ == Viewtype::Text && msg.is_empty() && part.param.get(Param::Quote).is_none();
|
||||
|
||||
if let Some(contact_id) = group_changes.added_removed_id {
|
||||
param.set(Param::ContactAddedRemoved, contact_id.to_u32().to_string());
|
||||
}
|
||||
|
||||
save_mime_modified |= mime_parser.is_mime_modified && !part_is_empty && !hidden;
|
||||
let save_mime_modified = save_mime_modified && parts.peek().is_none();
|
||||
|
||||
@@ -2334,10 +2339,12 @@ struct GroupChangesInfo {
|
||||
/// Optional: A better message that should replace the original system message.
|
||||
/// If this is an empty string, the original system message should be trashed.
|
||||
better_msg: Option<String>,
|
||||
/// Added/removed contact `better_msg` refers to.
|
||||
added_removed_id: Option<ContactId>,
|
||||
/// If true, the user should not be notified about the group change.
|
||||
silent: bool,
|
||||
/// A list of additional group changes messages that should be shown in the chat.
|
||||
extra_msgs: Vec<(String, SystemMessage)>,
|
||||
extra_msgs: Vec<(String, SystemMessage, Option<ContactId>)>,
|
||||
}
|
||||
|
||||
/// Apply group member list, name, avatar and protection status changes from the MIME message.
|
||||
@@ -2654,6 +2661,11 @@ async fn apply_group_changes(
|
||||
}
|
||||
Ok(GroupChangesInfo {
|
||||
better_msg,
|
||||
added_removed_id: if added_id.is_some() {
|
||||
added_id
|
||||
} else {
|
||||
removed_id
|
||||
},
|
||||
silent,
|
||||
extra_msgs: group_changes_msgs,
|
||||
})
|
||||
@@ -2665,7 +2677,7 @@ async fn group_changes_msgs(
|
||||
added_ids: &HashSet<ContactId>,
|
||||
removed_ids: &HashSet<ContactId>,
|
||||
chat_id: ChatId,
|
||||
) -> Result<Vec<(String, SystemMessage)>> {
|
||||
) -> Result<Vec<(String, SystemMessage, Option<ContactId>)>> {
|
||||
let mut group_changes_msgs = Vec::new();
|
||||
if !added_ids.is_empty() {
|
||||
warn!(
|
||||
@@ -2686,6 +2698,7 @@ async fn group_changes_msgs(
|
||||
stock_str::msg_add_member_local(context, contact.get_addr(), ContactId::UNDEFINED)
|
||||
.await,
|
||||
SystemMessage::MemberAddedToGroup,
|
||||
Some(contact.id),
|
||||
));
|
||||
}
|
||||
for contact_id in removed_ids {
|
||||
@@ -2694,6 +2707,7 @@ async fn group_changes_msgs(
|
||||
stock_str::msg_del_member_local(context, contact.get_addr(), ContactId::UNDEFINED)
|
||||
.await,
|
||||
SystemMessage::MemberRemovedFromGroup,
|
||||
Some(contact.id),
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user