Skip to content

Commit 48759e6

Browse files
committed
Do not treat tombstones as recipients
1 parent 45b0d07 commit 48759e6

File tree

1 file changed

+20
-13
lines changed

1 file changed

+20
-13
lines changed

src/mimefactory.rs

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -163,28 +163,35 @@ impl MimeFactory {
163163
context
164164
.sql
165165
.query_map(
166-
"SELECT c.authname, c.addr, c.id \
167-
FROM chats_contacts cc \
168-
LEFT JOIN contacts c ON cc.contact_id=c.id \
169-
WHERE cc.chat_id=? AND cc.contact_id>9;",
166+
"SELECT c.authname, c.addr, c.id, cc.add_timestamp, cc.remove_timestamp
167+
FROM chats_contacts cc
168+
LEFT JOIN contacts c ON cc.contact_id=c.id
169+
WHERE cc.chat_id=? AND cc.contact_id>9",
170170
(msg.chat_id,),
171171
|row| {
172172
let authname: String = row.get(0)?;
173173
let addr: String = row.get(1)?;
174174
let id: ContactId = row.get(2)?;
175-
Ok((authname, addr, id))
175+
let add_timestamp: i64 = row.get(3)?;
176+
let remove_timestamp: i64 = row.get(4)?;
177+
Ok((authname, addr, id, add_timestamp, remove_timestamp))
176178
},
177179
|rows| {
178180
for row in rows {
179-
let (authname, addr, id) = row?;
180-
if !recipients_contain_addr(&recipients, &addr) {
181-
let name = match attach_profile_data {
182-
true => authname,
183-
false => "".to_string(),
184-
};
185-
recipients.push((name, addr));
181+
let (authname, addr, id, add_timestamp, remove_timestamp) = row?;
182+
if add_timestamp >= remove_timestamp {
183+
if !recipients_contain_addr(&recipients, &addr) {
184+
let name = match attach_profile_data {
185+
true => authname,
186+
false => "".to_string(),
187+
};
188+
recipients.push((name, addr));
189+
}
190+
recipient_ids.insert(id);
191+
} else {
192+
// Row is a tombstone,
193+
// member is not actually part of the group.
186194
}
187-
recipient_ids.insert(id);
188195
}
189196
Ok(())
190197
},

0 commit comments

Comments
 (0)