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:
bjoern
2025-03-31 18:56:57 +02:00
committed by GitHub
parent e2f9c80cd5
commit 97b0d09ed2
18 changed files with 311 additions and 62 deletions

View File

@@ -936,6 +936,51 @@ impl Message {
self.param.get_cmd()
}
/// Return the contact ID of the profile to open when tapping the info message.
pub async fn get_info_contact_id(&self, context: &Context) -> Result<Option<ContactId>> {
match self.param.get_cmd() {
SystemMessage::GroupNameChanged
| SystemMessage::GroupImageChanged
| SystemMessage::EphemeralTimerChanged => {
if self.from_id != ContactId::INFO {
Ok(Some(self.from_id))
} else {
Ok(None)
}
}
SystemMessage::MemberAddedToGroup | SystemMessage::MemberRemovedFromGroup => {
if let Some(contact_i32) = self.param.get_int(Param::ContactAddedRemoved) {
let contact_id = ContactId::new(contact_i32.try_into()?);
if contact_id == ContactId::SELF
|| Contact::real_exists_by_id(context, contact_id).await?
{
Ok(Some(contact_id))
} else {
Ok(None)
}
} else {
Ok(None)
}
}
SystemMessage::AutocryptSetupMessage
| SystemMessage::SecurejoinMessage
| SystemMessage::LocationStreamingEnabled
| SystemMessage::LocationOnly
| SystemMessage::ChatProtectionEnabled
| SystemMessage::ChatProtectionDisabled
| SystemMessage::InvalidUnencryptedMail
| SystemMessage::SecurejoinWait
| SystemMessage::SecurejoinWaitTimeout
| SystemMessage::MultiDeviceSync
| SystemMessage::WebxdcStatusUpdate
| SystemMessage::WebxdcInfoMessage
| SystemMessage::IrohNodeAddr
| SystemMessage::Unknown => Ok(None),
}
}
/// Returns true if the message is a system message.
pub fn is_system_message(&self) -> bool {
let cmd = self.param.get_cmd();