@@ -2137,8 +2137,8 @@ async fn apply_group_changes(
2137
2137
. filter ( |t| * t <= mime_parser. timestamp_sent )
2138
2138
. is_some ( ) ;
2139
2139
// Whether to rebuild the member list from scratch.
2140
- let recreate_member_list = {
2141
- // Always recreate membership list if SELF has been added. The older versions of DC
2140
+ let reset_chat = {
2141
+ // Always recreate member list etc. if SELF has been added. The older versions of DC
2142
2142
// don't always set "In-Reply-To" to the latest message they sent, but to the latest
2143
2143
// delivered message (so it's a race), so we have this heuristic here.
2144
2144
self_added
@@ -2222,9 +2222,15 @@ async fn apply_group_changes(
2222
2222
info ! ( context, "Ignoring addition of {added_addr:?} to {chat_id}." ) ;
2223
2223
}
2224
2224
better_msg. get_or_insert_with ( Default :: default) ;
2225
- } else if let Some ( old_name) = mime_parser
2225
+ }
2226
+
2227
+ if let Some ( old_name) = mime_parser
2226
2228
. get_header ( HeaderDef :: ChatGroupNameChanged )
2227
2229
. map ( |s| s. trim ( ) )
2230
+ . or ( match reset_chat {
2231
+ true => Some ( chat. name . as_str ( ) ) ,
2232
+ false => None ,
2233
+ } )
2228
2234
{
2229
2235
if let Some ( grpname) = mime_parser
2230
2236
. get_header ( HeaderDef :: ChatGroupName )
@@ -2248,10 +2254,17 @@ async fn apply_group_changes(
2248
2254
. await ?;
2249
2255
send_event_chat_modified = true ;
2250
2256
}
2251
-
2252
- better_msg = Some ( stock_str:: msg_grp_name ( context, old_name, grpname, from_id) . await ) ;
2257
+ if mime_parser
2258
+ . get_header ( HeaderDef :: ChatGroupNameChanged )
2259
+ . is_some ( )
2260
+ {
2261
+ better_msg. get_or_insert (
2262
+ stock_str:: msg_grp_name ( context, old_name, grpname, from_id) . await ,
2263
+ ) ;
2264
+ }
2253
2265
}
2254
- } else if let Some ( value) = mime_parser. get_header ( HeaderDef :: ChatContent ) {
2266
+ }
2267
+ if let ( Some ( value) , None ) = ( mime_parser. get_header ( HeaderDef :: ChatContent ) , & better_msg) {
2255
2268
if value == "group-avatar-changed" {
2256
2269
if let Some ( avatar_action) = & mime_parser. group_avatar {
2257
2270
// this is just an explicit message containing the group-avatar,
@@ -2280,7 +2293,7 @@ async fn apply_group_changes(
2280
2293
let mut added_ids = HashSet :: < ContactId > :: new ( ) ;
2281
2294
let mut removed_ids = HashSet :: < ContactId > :: new ( ) ;
2282
2295
2283
- if !recreate_member_list {
2296
+ if !reset_chat {
2284
2297
if sync_member_list {
2285
2298
added_ids = new_members. difference ( & chat_contacts) . copied ( ) . collect ( ) ;
2286
2299
} else if let Some ( added_id) = added_id {
@@ -2303,7 +2316,7 @@ async fn apply_group_changes(
2303
2316
if let Some ( removed_id) = removed_id {
2304
2317
new_members. remove ( & removed_id) ;
2305
2318
}
2306
- if recreate_member_list {
2319
+ if reset_chat {
2307
2320
if self_added {
2308
2321
// ... then `better_msg` is already set.
2309
2322
} else if chat. blocked == Blocked :: Request || !chat_contacts. contains ( & ContactId :: SELF )
@@ -2364,7 +2377,7 @@ async fn apply_group_changes(
2364
2377
}
2365
2378
if sync_member_list {
2366
2379
let mut ts = mime_parser. timestamp_sent ;
2367
- if recreate_member_list {
2380
+ if reset_chat {
2368
2381
// Reject all older membership changes. See `allow_member_list_changes` to know how
2369
2382
// this works.
2370
2383
ts += timestamp_sent_tolerance;
0 commit comments