mirror of
https://github.com/chatmail/core.git
synced 2026-05-05 06:16:30 +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:
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user