@@ -2059,58 +2059,16 @@ async fn create_group(
2059
2059
chat_id_blocked = create_blocked;
2060
2060
2061
2061
// Create initial member list.
2062
- if let Some ( chat_group_member_timestamps) = mime_parser. chat_group_member_timestamps ( ) {
2063
- let expected_timestamps_count = to_ids. len ( ) + past_ids. len ( ) ;
2064
- if chat_group_member_timestamps. len ( ) == expected_timestamps_count {
2065
- context
2066
- . sql
2067
- . transaction ( |transaction| {
2068
- let mut add_statement = transaction. prepare (
2069
- "INSERT INTO chats_contacts (chat_id, contact_id, add_timestamp)
2070
- VALUES (?1, ?2, ?3)
2071
- ON CONFLICT (chat_id, contact_id)
2072
- DO UPDATE SET add_timestamp=MAX(add_timestamp, ?3)" ,
2073
- ) ?;
2074
-
2075
- for ( contact_id, ts) in iter:: zip (
2076
- to_ids. iter ( ) ,
2077
- chat_group_member_timestamps. iter ( ) . take ( to_ids. len ( ) ) ,
2078
- ) {
2079
- add_statement. execute ( ( chat_id, contact_id, ts) ) ?;
2080
- }
2081
-
2082
- let mut remove_statement = transaction. prepare (
2083
- "UPDATE chats_contacts
2084
- SET remove_timestamp=MAX(remove_timestamp, ?)
2085
- WHERE chat_id=? AND contact_id=?" ,
2086
- ) ?;
2087
-
2088
- for ( contact_id, ts) in iter:: zip (
2089
- past_ids. iter ( ) ,
2090
- chat_group_member_timestamps. iter ( ) . skip ( to_ids. len ( ) ) ,
2091
- ) {
2092
- remove_statement. execute ( ( ts, chat_id, contact_id) ) ?;
2093
- }
2094
-
2095
- if !to_ids. contains ( & from_id) {
2096
- add_statement. execute ( (
2097
- chat_id,
2098
- from_id,
2099
- mime_parser. timestamp_sent ,
2100
- ) ) ?;
2101
- }
2102
-
2103
- Ok ( ( ) )
2104
- } )
2105
- . await ?;
2106
- } else {
2107
- warn ! (
2108
- context,
2109
- "Chat-Group-Member-Timestamps has wrong number of timestamps, got {}, expected {}." ,
2110
- chat_group_member_timestamps. len( ) ,
2111
- expected_timestamps_count
2112
- ) ;
2062
+ if let Some ( mut chat_group_member_timestamps) = mime_parser. chat_group_member_timestamps ( ) {
2063
+ let mut new_to_ids = to_ids. to_vec ( ) ;
2064
+ if !new_to_ids. contains ( & from_id) {
2065
+ new_to_ids. insert ( 0 , from_id) ;
2066
+ chat_group_member_timestamps. insert ( 0 , mime_parser. timestamp_sent ) ;
2113
2067
}
2068
+
2069
+ update_chats_contacts_timestamps (
2070
+ context, new_chat_id, None ,
2071
+ & new_to_ids, past_ids, & chat_group_member_timestamps) . await ?;
2114
2072
} else {
2115
2073
let mut members = vec ! [ ContactId :: SELF ] ;
2116
2074
if !from_id. is_special ( ) {
0 commit comments