mirror of
https://github.com/chatmail/core.git
synced 2026-04-29 11:26:29 +03:00
use language of receiver for protection-messages, show correct sender
This commit is contained in:
29
src/chat.rs
29
src/chat.rs
@@ -226,14 +226,14 @@ impl ChatId {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
// adds or sends out a protection-info-message
|
/// returns a stock message saying that protection status gas changed.
|
||||||
pub(crate) async fn add_protection_msg(
|
pub(crate) async fn get_protection_msg(
|
||||||
self,
|
self,
|
||||||
context: &Context,
|
context: &Context,
|
||||||
protect: ProtectionStatus,
|
protect: ProtectionStatus,
|
||||||
promote: bool,
|
from_id: u32,
|
||||||
) -> Result<(), Error> {
|
) -> String {
|
||||||
let msg_text = context
|
context
|
||||||
.stock_system_msg(
|
.stock_system_msg(
|
||||||
match protect {
|
match protect {
|
||||||
ProtectionStatus::Protected => StockMessage::ProtectionEnabled,
|
ProtectionStatus::Protected => StockMessage::ProtectionEnabled,
|
||||||
@@ -241,9 +241,20 @@ impl ChatId {
|
|||||||
},
|
},
|
||||||
"",
|
"",
|
||||||
"",
|
"",
|
||||||
DC_CONTACT_ID_SELF as u32,
|
from_id,
|
||||||
)
|
)
|
||||||
.await;
|
.await
|
||||||
|
}
|
||||||
|
|
||||||
|
/// adds or sends out a protection-info-message
|
||||||
|
pub(crate) async fn add_protection_msg(
|
||||||
|
self,
|
||||||
|
context: &Context,
|
||||||
|
protect: ProtectionStatus,
|
||||||
|
promote: bool,
|
||||||
|
from_id: u32,
|
||||||
|
) -> Result<(), Error> {
|
||||||
|
let msg_text = self.get_protection_msg(context, protect, from_id).await;
|
||||||
|
|
||||||
if promote {
|
if promote {
|
||||||
let mut msg = Message::default();
|
let mut msg = Message::default();
|
||||||
@@ -261,6 +272,7 @@ impl ChatId {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Set protection and sends or adds a message.
|
||||||
pub async fn set_protection(
|
pub async fn set_protection(
|
||||||
self,
|
self,
|
||||||
context: &Context,
|
context: &Context,
|
||||||
@@ -275,7 +287,8 @@ impl ChatId {
|
|||||||
return Err(e);
|
return Err(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
self.add_protection_msg(context, protect, chat.is_promoted()).await
|
self.add_protection_msg(context, protect, chat.is_promoted(), DC_CONTACT_ID_SELF)
|
||||||
|
.await
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Archives or unarchives a chat.
|
/// Archives or unarchives a chat.
|
||||||
|
|||||||
@@ -712,6 +712,20 @@ async fn add_parts(
|
|||||||
// hour, only the message about the change to 1
|
// hour, only the message about the change to 1
|
||||||
// week is left.
|
// week is left.
|
||||||
ephemeral_timer = EphemeralTimer::Disabled;
|
ephemeral_timer = EphemeralTimer::Disabled;
|
||||||
|
} else if mime_parser.is_system_message == SystemMessage::ChatProtectionEnabled {
|
||||||
|
set_better_msg(
|
||||||
|
mime_parser,
|
||||||
|
chat_id
|
||||||
|
.get_protection_msg(context, ProtectionStatus::Protected, from_id)
|
||||||
|
.await,
|
||||||
|
);
|
||||||
|
} else if mime_parser.is_system_message == SystemMessage::ChatProtectionDisabled {
|
||||||
|
set_better_msg(
|
||||||
|
mime_parser,
|
||||||
|
chat_id
|
||||||
|
.get_protection_msg(context, ProtectionStatus::Unprotected, from_id)
|
||||||
|
.await,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// change chat protection
|
// change chat protection
|
||||||
@@ -1240,7 +1254,9 @@ async fn create_or_lookup_group(
|
|||||||
recreate_member_list = true;
|
recreate_member_list = true;
|
||||||
|
|
||||||
if create_protected == ProtectionStatus::Protected {
|
if create_protected == ProtectionStatus::Protected {
|
||||||
chat_id.add_protection_msg(context, ProtectionStatus::Protected, false).await?;
|
chat_id
|
||||||
|
.add_protection_msg(context, ProtectionStatus::Protected, false, from_id)
|
||||||
|
.await?;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user