mirror of
https://github.com/chatmail/core.git
synced 2026-05-05 22:36:30 +03:00
feat: Group and broadcast channel descriptions (#7829)
fix https://github.com/chatmail/core/issues/7766 Implementation notes: - Descriptions are only sent with member additions, when the description is changed, and when promoting a previously-unpromoted group, in order not to waste bandwith. - Descriptions are not loaded everytime a chat object is loaded, because they are only needed for the profile. Instead, they are in their own table, and can be loaded with their own JsonRPC call. --------- Co-authored-by: iequidoo <117991069+iequidoo@users.noreply.github.com>
This commit is contained in:
@@ -663,7 +663,7 @@ impl MimeFactory {
|
||||
|
||||
if msg
|
||||
.param
|
||||
.get_bool(Param::AttachGroupImage)
|
||||
.get_bool(Param::AttachChatAvatarAndDescription)
|
||||
.unwrap_or_default()
|
||||
{
|
||||
return chat.param.get(Param::ProfileImage).map(Into::into);
|
||||
@@ -1669,6 +1669,12 @@ impl MimeFactory {
|
||||
mail_builder::headers::text::Text::new(old_name).into(),
|
||||
));
|
||||
}
|
||||
SystemMessage::GroupDescriptionChanged => {
|
||||
headers.push((
|
||||
"Chat-Group-Description-Changed",
|
||||
mail_builder::headers::text::Text::new("").into(),
|
||||
));
|
||||
}
|
||||
SystemMessage::GroupImageChanged => {
|
||||
headers.push((
|
||||
"Chat-Content",
|
||||
@@ -1683,6 +1689,26 @@ impl MimeFactory {
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
|
||||
if command == SystemMessage::GroupDescriptionChanged
|
||||
|| command == SystemMessage::MemberAddedToGroup
|
||||
|| msg
|
||||
.param
|
||||
.get_bool(Param::AttachChatAvatarAndDescription)
|
||||
.unwrap_or_default()
|
||||
{
|
||||
let description = chat::get_chat_description(context, chat.id).await?;
|
||||
headers.push((
|
||||
"Chat-Group-Description",
|
||||
mail_builder::headers::text::Text::new(description.clone()).into(),
|
||||
));
|
||||
if let Some(ts) = chat.param.get_i64(Param::GroupDescriptionTimestamp) {
|
||||
headers.push((
|
||||
"Chat-Group-Description-Timestamp",
|
||||
mail_builder::headers::text::Text::new(ts.to_string()).into(),
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
match command {
|
||||
|
||||
Reference in New Issue
Block a user