@@ -192,6 +192,12 @@ async fn get_self_report(context: &Context, last_selfreport_time: i64) -> Result
192
192
let chat_numbers = context
193
193
. sql
194
194
. query_map (
195
+ // For all chats, query:
196
+ // - Whether it's protected, i.e. has a green checkmark
197
+ // and only allows messages with verified encryption
198
+ // - Whether the latest message is encrypted (stored in the param)
199
+ // - Whether the latest message was sent by Delta Chat (stored in msgrmsg)
200
+ // TODO: Maybe should only query incoming messages, because outgoing messages are always sent by DC
195
201
"SELECT c.protected, m.param, m.msgrmsg
196
202
FROM chats c
197
203
JOIN msgs m
@@ -200,10 +206,10 @@ async fn get_self_report(context: &Context, last_selfreport_time: i64) -> Result
200
206
SELECT id
201
207
FROM msgs
202
208
WHERE chat_id=c.id
203
- AND hidden=0
204
- AND download_state=?
205
- AND to_id!=?
206
- ORDER BY timestamp DESC, id DESC LIMIT 1)
209
+ AND hidden=0 -- Some control messages are hidden, i.e. not actually shown to the user
210
+ AND download_state=? -- If a message isn't fully downloaded, we don't know whether it's encrypted
211
+ AND to_id!=? -- Some messages are informational messages, rather than actual message content
212
+ ORDER BY timestamp DESC, id DESC LIMIT 1) -- Only query the latest message
207
213
WHERE c.id>9
208
214
AND (c.blocked=0 OR c.blocked=2)
209
215
AND IFNULL(m.timestamp,c.created_timestamp) > ?
0 commit comments