diff --git a/src/chat.rs b/src/chat.rs index 389511eef..d93ac9128 100644 --- a/src/chat.rs +++ b/src/chat.rs @@ -1591,7 +1591,7 @@ impl Chat { ); bail!("Cannot set message, contact for {} not found.", self.id); } - } else if self.typ == Chattype::Group + } else if (self.typ == Chattype::Group || self.typ == Chattype::Broadcast) && self.param.get_int(Param::Unpromoted).unwrap_or_default() == 1 { msg.param.set_int(Param::AttachGroupImage, 1); @@ -3427,12 +3427,8 @@ pub async fn set_chat_profile_image( ) -> Result<()> { ensure!(!chat_id.is_special(), "Invalid chat ID"); let mut chat = Chat::load_from_db(context, chat_id).await?; - ensure!( - chat.typ == Chattype::Group || chat.typ == Chattype::Mailinglist, - "Failed to set profile image; group does not exist" - ); /* we should respect this - whatever we send to the group, it gets discarded anyway! */ - if !is_contact_in_chat(context, chat_id, ContactId::SELF).await? { + if !chat.is_self_in_chat(context).await? { context.emit_event(EventType::ErrorSelfNotInGroup( "Cannot set chat profile image; self not in group.".into(), )); @@ -3453,7 +3449,7 @@ pub async fn set_chat_profile_image( msg.text = stock_str::msg_grp_img_changed(context, ContactId::SELF).await; } chat.update_param(context).await?; - if chat.is_promoted() && !chat.is_mailing_list() { + if chat.is_promoted() && !chat.is_mailing_list() && chat.typ != Chattype::Broadcast { msg.id = send_msg(context, chat_id, &mut msg).await?; context.emit_msgs_changed(chat_id, msg.id); } diff --git a/src/param.rs b/src/param.rs index d0f3bb1aa..203eb39d2 100644 --- a/src/param.rs +++ b/src/param.rs @@ -119,7 +119,7 @@ pub enum Param { /// For MDN-sending job MsgId = b'I', - /// For Groups + /// For Groups and Broadcast Lists /// /// An unpromoted group has not had any messages sent to it and thus only exists on the /// creator's device. Any changes made to an unpromoted group do not need to send diff --git a/src/receive_imf.rs b/src/receive_imf.rs index 58a094c91..a674119b1 100644 --- a/src/receive_imf.rs +++ b/src/receive_imf.rs @@ -2050,6 +2050,28 @@ async fn apply_mailinglist_changes( if chat.typ != Chattype::Mailinglist { return Ok(()); } + + let mut send_event_chat_modified = false; + + if let Some(avatar_action) = &mime_parser.group_avatar { + info!(context, "Mailinglist-avatar change for {chat_id}."); + if chat + .param + .update_timestamp(Param::AvatarTimestamp, sent_timestamp)? + { + match avatar_action { + AvatarAction::Change(profile_image) => { + chat.param.set(Param::ProfileImage, profile_image); + } + AvatarAction::Delete => { + chat.param.remove(Param::ProfileImage); + } + }; + chat.update_param(context).await?; + send_event_chat_modified = true; + } + } + let listid = &chat.grpid; let new_name = compute_mailinglist_name(mailinglist_header, listid, mime_parser); @@ -2063,6 +2085,10 @@ async fn apply_mailinglist_changes( .sql .execute("UPDATE chats SET name=? WHERE id=?;", (new_name, chat_id)) .await?; + send_event_chat_modified = true; + } + + if send_event_chat_modified { context.emit_event(EventType::ChatModified(chat_id)); }