mirror of
https://github.com/chatmail/core.git
synced 2026-04-28 02:46:29 +03:00
add/send info-message on protection changes
This commit is contained in:
@@ -3460,7 +3460,8 @@ int dc_msg_is_forwarded (const dc_msg_t* msg);
|
||||
/**
|
||||
* Check if the message is an informational message, created by the
|
||||
* device or by another users. Such messages are not "typed" by the user but
|
||||
* created due to other actions, eg. dc_set_chat_name(), dc_set_chat_profile_image()
|
||||
* created due to other actions,
|
||||
* eg. dc_set_chat_name(), dc_set_chat_profile_image(), dc_set_chat_protection()
|
||||
* or dc_add_contact_to_chat().
|
||||
*
|
||||
* These messages are typically shown in the center of the chat view,
|
||||
@@ -4973,8 +4974,10 @@ void dc_event_unref(dc_event_t* event);
|
||||
#define DC_STR_BAD_TIME_MSG_BODY 85
|
||||
#define DC_STR_UPDATE_REMINDER_MSG_BODY 86
|
||||
#define DC_STR_ERROR_NO_NETWORK 87
|
||||
#define DC_STR_PROTECTION_ENABLED 88
|
||||
#define DC_STR_PROTECTION_DISABLED 89
|
||||
|
||||
#define DC_STR_COUNT 87
|
||||
#define DC_STR_COUNT 89
|
||||
|
||||
/*
|
||||
* @}
|
||||
|
||||
28
src/chat.rs
28
src/chat.rs
@@ -221,7 +221,33 @@ impl ChatId {
|
||||
|
||||
context.emit_event(EventType::ChatModified(self));
|
||||
|
||||
if send_to_others {}
|
||||
// make sure, the receivers will get all keys
|
||||
reset_gossiped_timestamp(context, self).await?;
|
||||
|
||||
// add info message
|
||||
let msg_text = context
|
||||
.stock_system_msg(
|
||||
match protect {
|
||||
ProtectionStatus::Protected => StockMessage::ProtectionEnabled,
|
||||
ProtectionStatus::Unprotected => StockMessage::ProtectionDisabled,
|
||||
},
|
||||
"",
|
||||
"",
|
||||
DC_CONTACT_ID_SELF as u32,
|
||||
)
|
||||
.await;
|
||||
if send_to_others {
|
||||
let mut msg = Message::default();
|
||||
msg.viewtype = Viewtype::Text;
|
||||
msg.text = Some(msg_text);
|
||||
msg.param.set_cmd(match protect {
|
||||
ProtectionStatus::Protected => SystemMessage::ChatProtectionEnabled,
|
||||
ProtectionStatus::Unprotected => SystemMessage::ChatProtectionDisabled,
|
||||
});
|
||||
send_msg(context, self, &mut msg).await?;
|
||||
} else {
|
||||
add_info_msg(context, self, msg_text).await;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -846,6 +846,18 @@ impl<'a, 'b> MimeFactory<'a, 'b> {
|
||||
};
|
||||
}
|
||||
}
|
||||
SystemMessage::ChatProtectionEnabled => {
|
||||
protected_headers.push(Header::new(
|
||||
"Chat-Content".to_string(),
|
||||
"protection-enabled".to_string(),
|
||||
));
|
||||
}
|
||||
SystemMessage::ChatProtectionDisabled => {
|
||||
protected_headers.push(Header::new(
|
||||
"Chat-Content".to_string(),
|
||||
"protection-disabled".to_string(),
|
||||
));
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
|
||||
|
||||
@@ -86,6 +86,10 @@ pub enum SystemMessage {
|
||||
|
||||
/// Chat ephemeral message timer is changed.
|
||||
EphemeralTimerChanged = 10,
|
||||
|
||||
// Chat protection state changed
|
||||
ChatProtectionEnabled = 11,
|
||||
ChatProtectionDisabled = 12,
|
||||
}
|
||||
|
||||
impl Default for SystemMessage {
|
||||
|
||||
@@ -233,6 +233,12 @@ pub enum StockMessage {
|
||||
fallback = "Could not find your mail server.\n\nPlease check your internet connection."
|
||||
))]
|
||||
ErrorNoNetwork = 87,
|
||||
|
||||
#[strum(props(fallback = "Chat protection enabled."))]
|
||||
ProtectionEnabled = 88,
|
||||
|
||||
#[strum(props(fallback = "Chat protection disabled."))]
|
||||
ProtectionDisabled = 89,
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
Reference in New Issue
Block a user