mirror of
https://github.com/twonlyapp/twonly-app.git
synced 2026-01-15 13:08:42 +00:00
starting with group states
This commit is contained in:
parent
d40e33b247
commit
09cb0552c0
3 changed files with 49 additions and 12 deletions
|
|
@ -270,12 +270,13 @@ class MessagesDao extends DatabaseAccessor<TwonlyDB> with _$MessagesDaoMixin {
|
||||||
actionAt: Value(timestamp),
|
actionAt: Value(timestamp),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
if (await haveAllMembers(messageId, MessageActionType.openedAt)) {
|
// Directly show as message opened as soon as one person has opened it
|
||||||
|
// if (await haveAllMembers(messageId, MessageActionType.openedAt)) {
|
||||||
await twonlyDB.messagesDao.updateMessageId(
|
await twonlyDB.messagesDao.updateMessageId(
|
||||||
messageId,
|
messageId,
|
||||||
MessagesCompanion(openedAt: Value(DateTime.now())),
|
MessagesCompanion(openedAt: Value(DateTime.now())),
|
||||||
);
|
);
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> handleMessageAckByServer(
|
Future<void> handleMessageAckByServer(
|
||||||
|
|
@ -291,12 +292,13 @@ class MessagesDao extends DatabaseAccessor<TwonlyDB> with _$MessagesDaoMixin {
|
||||||
actionAt: Value(timestamp),
|
actionAt: Value(timestamp),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
if (await haveAllMembers(messageId, MessageActionType.ackByServerAt)) {
|
// 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(
|
await twonlyDB.messagesDao.updateMessageId(
|
||||||
messageId,
|
messageId,
|
||||||
MessagesCompanion(ackByServer: Value(DateTime.now())),
|
MessagesCompanion(ackByServer: Value(DateTime.now())),
|
||||||
);
|
);
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<bool> haveAllMembers(
|
Future<bool> haveAllMembers(
|
||||||
|
|
|
||||||
10
lib/src/model/protobuf/client/groups.proto
Normal file
10
lib/src/model/protobuf/client/groups.proto
Normal 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;
|
||||||
|
}
|
||||||
|
|
@ -44,6 +44,31 @@ message EncryptedContent {
|
||||||
optional PushKeys pushKeys = 11;
|
optional PushKeys pushKeys = 11;
|
||||||
optional Reaction reaction = 12;
|
optional Reaction reaction = 12;
|
||||||
optional TextMessage textMessage = 13;
|
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 {
|
message TextMessage {
|
||||||
string senderMessageId = 1;
|
string senderMessageId = 1;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue