Skip to content

Commit 69dd8fe

Browse files
committed
Add some comments
1 parent 5081406 commit 69dd8fe

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

src/self_reporting.rs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,12 @@ async fn get_self_report(context: &Context, last_selfreport_time: i64) -> Result
192192
let chat_numbers = context
193193
.sql
194194
.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
195201
"SELECT c.protected, m.param, m.msgrmsg
196202
FROM chats c
197203
JOIN msgs m
@@ -200,10 +206,10 @@ async fn get_self_report(context: &Context, last_selfreport_time: i64) -> Result
200206
SELECT id
201207
FROM msgs
202208
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
207213
WHERE c.id>9
208214
AND (c.blocked=0 OR c.blocked=2)
209215
AND IFNULL(m.timestamp,c.created_timestamp) > ?

0 commit comments

Comments
 (0)