deltachat / deltachat-core

Delta.Chat C-Library with e2e chat-over-email functionality & Python bindings
https://c.delta.chat
Other
304 stars 26 forks source link

Chats table should save the timestamp of the last modification #127

Open r10s opened 6 years ago

r10s commented 6 years ago

Updates to chat name, members etc. should take only place if newer than the saved timestamp then

r10s commented 6 years ago

indirectly, this is already tracked: MAX(msgs.timestamp) WHERE chat.id=... should always be the modification time of the chat. We use a similar query when creating the chatlist, so it seems to be fast enough. Maybe this is sufficient. EDIT: may cause problems when messages are deleted. a separate timestamp in the chats-table is probably more reliable.

However, updates to chat name, members, etc. should only take place if the message with the command is newer than the newest message in the chat - wherever the date comes from.

testbird commented 6 years ago

What if some changes are made while some are offline? Shouldn't a member not be added/removed later?

Or, when the offline person answers to an older message, won't the new answer not override the changes from others that were made in the meantime?

Only asking because I do not yet have a full understanding of what the base rule implies.

r10s commented 6 years ago

offline and delayed messages are no problem, its just that message with the most recent timestamp defines the state. This rule is needed as messages may arrive out of order.

Assume the messages A1 and A2 send from Alice do Bob:

A1 was sent at 01:01 and send the chat title to "my fime group" A2 was sent at 01:02 and corrects the chat title to "my fine group"

Bob, for any reasons, receives A2 first and sets the group title to "my fine group" - when he now receives A1 he must not set bad title again. This can be ensured by tracking the message timestams resp. the timestamps of the last modification.

Autocrypt does the same for its key management, btw, see https://autocrypt.org/level1.html#peers

testbird commented 6 years ago

I see.

Maybe the related https://github.com/deltachat/deltachat-android/issues/211 is relevant, if the problem is not just in the displaying of the time.

r10s commented 4 years ago

nb: the idea is to fix this in core-rust by adding missing members to the memberlist on Chat-Group-Member-Added and removing only explicitly mentioned members on Chat-Group-Member-Removed.