mirror of
https://github.com/twonlyapp/twonly-app.git
synced 2026-01-15 09:28:41 +00:00
fix non opening messages
This commit is contained in:
parent
767e9129e1
commit
4af2ef8260
3 changed files with 27 additions and 2 deletions
|
|
@ -104,6 +104,16 @@ class MessagesDao extends DatabaseAccessor<TwonlyDatabase>
|
|||
.write(updates);
|
||||
}
|
||||
|
||||
Future openedAllNonMediaMessagesFromOtherUser(int contactId) {
|
||||
final updates = MessagesCompanion(openedAt: Value(DateTime.now()));
|
||||
return (update(messages)
|
||||
..where((t) =>
|
||||
t.contactId.equals(contactId) &
|
||||
t.openedAt.isNull() &
|
||||
t.kind.equals(MessageKind.media.name).not()))
|
||||
.write(updates);
|
||||
}
|
||||
|
||||
Future updateMessageByOtherUser(
|
||||
int userId, int messageId, MessagesCompanion updatedValues) {
|
||||
return (update(messages)
|
||||
|
|
@ -161,4 +171,11 @@ class MessagesDao extends DatabaseAccessor<TwonlyDatabase>
|
|||
SingleOrNullSelectable<Message> getMessageByMessageId(int messageId) {
|
||||
return select(messages)..where((t) => t.messageId.equals(messageId));
|
||||
}
|
||||
|
||||
SingleOrNullSelectable<Message> getMessageByOtherMessageId(
|
||||
int fromUserId, int messageId) {
|
||||
return select(messages)
|
||||
..where((t) =>
|
||||
t.messageOtherId.equals(messageId) & t.contactId.equals(fromUserId));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -181,8 +181,6 @@ Future sendTextMessage(
|
|||
|
||||
Future notifyContactAboutOpeningMessage(
|
||||
int fromUserId, int messageOtherId) async {
|
||||
//await DbMessages.userOpenedOtherMessage(fromUserId, messageOtherId);
|
||||
|
||||
encryptAndSendMessage(
|
||||
null,
|
||||
fromUserId,
|
||||
|
|
|
|||
|
|
@ -181,6 +181,16 @@ Future<client.Response> handleNewMessage(int fromUserId, Uint8List body) async {
|
|||
message.messageId!,
|
||||
update,
|
||||
);
|
||||
final openedMessage = await twonlyDatabase.messagesDao
|
||||
.getMessageByMessageId(message.messageId!)
|
||||
.getSingleOrNull();
|
||||
if (openedMessage != null &&
|
||||
openedMessage.kind == MessageKind.textMessage) {
|
||||
await twonlyDatabase.messagesDao.openedAllNonMediaMessagesFromOtherUser(
|
||||
fromUserId,
|
||||
);
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case MessageKind.rejectRequest:
|
||||
|
|
|
|||
Loading…
Reference in a new issue