mirror of
https://github.com/twonlyapp/twonly-app.git
synced 2026-01-15 12:48:41 +00:00
delete faulty messages
This commit is contained in:
parent
5e7567416f
commit
b2426a9ec5
4 changed files with 18 additions and 5 deletions
|
|
@ -45,7 +45,15 @@ class MessageRetransmissionDao extends DatabaseAccessor<TwonlyDatabase>
|
||||||
.write(updatedValues);
|
.write(updatedValues);
|
||||||
}
|
}
|
||||||
|
|
||||||
Future resetAckStatusForAllMessages() {
|
Future resetAckStatusForAllMessages() async {
|
||||||
|
final deletedCount = await (delete(messageRetransmissions)
|
||||||
|
..where((m) =>
|
||||||
|
m.willNotGetACKByUser.equals(true) &
|
||||||
|
m.acknowledgeByServerAt.isNotNull()))
|
||||||
|
.go();
|
||||||
|
if (deletedCount > 0) {
|
||||||
|
Log.info('$deletedCount faulty retransmission messages where deleted.');
|
||||||
|
}
|
||||||
return ((update(messageRetransmissions))
|
return ((update(messageRetransmissions))
|
||||||
..where((m) => m.willNotGetACKByUser.equals(false)))
|
..where((m) => m.willNotGetACKByUser.equals(false)))
|
||||||
.write(
|
.write(
|
||||||
|
|
|
||||||
|
|
@ -222,7 +222,7 @@ Future<client.Response> handleNewMessage(int fromUserId, Uint8List body) async {
|
||||||
if (lastPushKeyRequest
|
if (lastPushKeyRequest
|
||||||
.isBefore(DateTime.now().subtract(Duration(seconds: 60)))) {
|
.isBefore(DateTime.now().subtract(Duration(seconds: 60)))) {
|
||||||
lastPushKeyRequest = DateTime.now();
|
lastPushKeyRequest = DateTime.now();
|
||||||
setupNotificationWithUsers(force: true);
|
setupNotificationWithUsers(forceContact: fromUserId);
|
||||||
}
|
}
|
||||||
|
|
||||||
case MessageKind.pushKey:
|
case MessageKind.pushKey:
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,8 @@ import 'package:twonly/src/services/api/messages.dart';
|
||||||
import 'package:twonly/src/utils/log.dart';
|
import 'package:twonly/src/utils/log.dart';
|
||||||
|
|
||||||
/// This function must be called after the database is setup
|
/// This function must be called after the database is setup
|
||||||
Future setupNotificationWithUsers({bool force = false}) async {
|
Future setupNotificationWithUsers(
|
||||||
|
{bool force = false, int? forceContact}) async {
|
||||||
var pushUsers = await getPushKeys(SecureStorageKeys.receivingPushKeys);
|
var pushUsers = await getPushKeys(SecureStorageKeys.receivingPushKeys);
|
||||||
|
|
||||||
// HotFIX: Search for user with id 0 if not there remove all
|
// HotFIX: Search for user with id 0 if not there remove all
|
||||||
|
|
@ -51,7 +52,9 @@ Future setupNotificationWithUsers({bool force = false}) async {
|
||||||
final createdAt = DateTime.fromMillisecondsSinceEpoch(
|
final createdAt = DateTime.fromMillisecondsSinceEpoch(
|
||||||
lastKey.createdAtUnixTimestamp.toInt());
|
lastKey.createdAtUnixTimestamp.toInt());
|
||||||
|
|
||||||
if (force || createdAt.isBefore(timeBefore)) {
|
if (force ||
|
||||||
|
(forceContact == contact.userId) ||
|
||||||
|
createdAt.isBefore(timeBefore)) {
|
||||||
final pushKey = PushKey(
|
final pushKey = PushKey(
|
||||||
id: lastKey.id + random.nextInt(5),
|
id: lastKey.id + random.nextInt(5),
|
||||||
key: List<int>.generate(32, (index) => random.nextInt(256)),
|
key: List<int>.generate(32, (index) => random.nextInt(256)),
|
||||||
|
|
|
||||||
|
|
@ -95,7 +95,9 @@ class _SearchUsernameView extends State<AddNewUserView> {
|
||||||
if (added > 0) {
|
if (added > 0) {
|
||||||
if (await createNewSignalSession(res.value.userdata)) {
|
if (await createNewSignalSession(res.value.userdata)) {
|
||||||
// before notifying the other party, add
|
// before notifying the other party, add
|
||||||
await setupNotificationWithUsers();
|
await setupNotificationWithUsers(
|
||||||
|
forceContact: res.value.userdata.userId.toInt(),
|
||||||
|
);
|
||||||
await encryptAndSendMessageAsync(
|
await encryptAndSendMessageAsync(
|
||||||
null,
|
null,
|
||||||
res.value.userdata.userId.toInt(),
|
res.value.userdata.userId.toInt(),
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue