starting with group states

This commit is contained in:
otsmr 2025-10-30 00:13:31 +01:00
parent d40e33b247
commit 09cb0552c0
3 changed files with 49 additions and 12 deletions

View file

@ -270,12 +270,13 @@ class MessagesDao extends DatabaseAccessor<TwonlyDB> with _$MessagesDaoMixin {
actionAt: Value(timestamp),
),
);
if (await haveAllMembers(messageId, MessageActionType.openedAt)) {
await twonlyDB.messagesDao.updateMessageId(
messageId,
MessagesCompanion(openedAt: Value(DateTime.now())),
);
}
// Directly show as message opened as soon as one person has opened it
// if (await haveAllMembers(messageId, MessageActionType.openedAt)) {
await twonlyDB.messagesDao.updateMessageId(
messageId,
MessagesCompanion(openedAt: Value(DateTime.now())),
);
// }
}
Future<void> handleMessageAckByServer(
@ -291,12 +292,13 @@ class MessagesDao extends DatabaseAccessor<TwonlyDB> with _$MessagesDaoMixin {
actionAt: Value(timestamp),
),
);
if (await haveAllMembers(messageId, MessageActionType.ackByServerAt)) {
await twonlyDB.messagesDao.updateMessageId(
messageId,
MessagesCompanion(ackByServer: Value(DateTime.now())),
);
}
// if (await haveAllMembers(messageId, MessageActionType.ackByServerAt)) {
/// always update the state, so it will be shown as soon as one member gets the message
await twonlyDB.messagesDao.updateMessageId(
messageId,
MessagesCompanion(ackByServer: Value(DateTime.now())),
);
// }
}
Future<bool> haveAllMembers(

View file

@ -0,0 +1,10 @@
syntax = "proto3";
// Stored encrypted on the server in the members columns.
message GroupState {
repeated int64 memberIds = 1;
repeated int64 adminIds = 2;
string groupName = 3;
optional int64 deleteMessagesAfterMilliseconds = 4;
bytes _padding = 5;
}

View file

@ -44,6 +44,31 @@ message EncryptedContent {
optional PushKeys pushKeys = 11;
optional Reaction reaction = 12;
optional TextMessage textMessage = 13;
optional NewGroup newGroup = 14;
optional JoinGroup joinGroup = 15;
optional GroupUpdate groupUpdate = 16;
message NewGroup {
// key for the state stored on the server
string groupId = 1;
string stateId = 2;
bytes stateKey = 3;
bytes groupPublicKey = 4;
}
message JoinGroup {
// key for the state stored on the server
string groupId = 1;
bytes groupPublicKey = 4;
}
message GroupUpdate {
optional int64 removedAdmin = 1;
optional int64 removedUser = 2;
optional int64 groupName = 3;
optional int64 deleteMessagesAfterMilliseconds = 4;
}
message TextMessage {
string senderMessageId = 1;