mirror of
https://github.com/twonlyapp/twonly-app.git
synced 2026-01-15 10:58:40 +00:00
fixing the problem
This commit is contained in:
parent
b2426a9ec5
commit
79caf95afe
5 changed files with 40 additions and 7 deletions
|
|
@ -45,7 +45,7 @@ class MessageRetransmissionDao extends DatabaseAccessor<TwonlyDatabase>
|
||||||
.write(updatedValues);
|
.write(updatedValues);
|
||||||
}
|
}
|
||||||
|
|
||||||
Future resetAckStatusForAllMessages() async {
|
Future resetAckStatusForAllMessages(int fromUserId) async {
|
||||||
final deletedCount = await (delete(messageRetransmissions)
|
final deletedCount = await (delete(messageRetransmissions)
|
||||||
..where((m) =>
|
..where((m) =>
|
||||||
m.willNotGetACKByUser.equals(true) &
|
m.willNotGetACKByUser.equals(true) &
|
||||||
|
|
@ -55,7 +55,9 @@ class MessageRetransmissionDao extends DatabaseAccessor<TwonlyDatabase>
|
||||||
Log.info('$deletedCount faulty retransmission messages where deleted.');
|
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) &
|
||||||
|
m.contactId.equals(fromUserId)))
|
||||||
.write(
|
.write(
|
||||||
MessageRetransmissionsCompanion(
|
MessageRetransmissionsCompanion(
|
||||||
acknowledgeByServerAt: Value(null),
|
acknowledgeByServerAt: Value(null),
|
||||||
|
|
|
||||||
|
|
@ -24,13 +24,20 @@ Future tryTransmitMessages() async {
|
||||||
|
|
||||||
if (retransIds.isEmpty) return;
|
if (retransIds.isEmpty) return;
|
||||||
|
|
||||||
|
bool filterPreKeys = false;
|
||||||
|
|
||||||
|
if (retransIds.length > 100) {
|
||||||
|
filterPreKeys = true; // just a workaround until I can fix the real issue :/
|
||||||
|
}
|
||||||
|
|
||||||
for (final retransId in retransIds) {
|
for (final retransId in retransIds) {
|
||||||
sendRetransmitMessage(retransId);
|
sendRetransmitMessage(retransId, filterPreKeys: filterPreKeys);
|
||||||
//twonlyDB.messageRetransmissionDao.deleteRetransmissionById(retransId);
|
//twonlyDB.messageRetransmissionDao.deleteRetransmissionById(retransId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Future sendRetransmitMessage(int retransId) async {
|
Future sendRetransmitMessage(int retransId,
|
||||||
|
{bool filterPreKeys = false}) async {
|
||||||
MessageRetransmission? retrans = await twonlyDB.messageRetransmissionDao
|
MessageRetransmission? retrans = await twonlyDB.messageRetransmissionDao
|
||||||
.getRetransmissionById(retransId)
|
.getRetransmissionById(retransId)
|
||||||
.getSingleOrNull();
|
.getSingleOrNull();
|
||||||
|
|
@ -47,6 +54,14 @@ Future sendRetransmitMessage(int retransId) async {
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
if (filterPreKeys && json.kind == MessageKind.pushKey) {
|
||||||
|
if (!retrans.willNotGetACKByUser) {
|
||||||
|
Log.error("Why is willNotGetACKByUser false????");
|
||||||
|
}
|
||||||
|
Log.info("Filtering preKeys: ${json.kind} to ${retrans.contactId}");
|
||||||
|
await twonlyDB.messageRetransmissionDao.deleteRetransmissionById(retransId);
|
||||||
|
return;
|
||||||
|
}
|
||||||
Log.info("Retransmitting: ${json.kind} to ${retrans.contactId}");
|
Log.info("Retransmitting: ${json.kind} to ${retrans.contactId}");
|
||||||
// if (json.kind
|
// if (json.kind
|
||||||
// .contains(MessageKind.pushKey.name)) {
|
// .contains(MessageKind.pushKey.name)) {
|
||||||
|
|
@ -87,6 +102,7 @@ Future sendRetransmitMessage(int retransId) async {
|
||||||
bool retry = true;
|
bool retry = true;
|
||||||
|
|
||||||
if (resp.isError) {
|
if (resp.isError) {
|
||||||
|
Log.error("Could not retransmit message.");
|
||||||
if (resp.error == ErrorCode.UserIdNotFound) {
|
if (resp.error == ErrorCode.UserIdNotFound) {
|
||||||
retry = false;
|
retry = false;
|
||||||
if (retrans.messageId != null) {
|
if (retrans.messageId != null) {
|
||||||
|
|
@ -116,7 +132,12 @@ Future sendRetransmitMessage(int retransId) async {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!retry) {
|
if (!retry) {
|
||||||
if (retrans.willNotGetACKByUser) {
|
if (!retrans.willNotGetACKByUser && json.kind == MessageKind.pushKey) {
|
||||||
|
Log.error("Why is willNotGetACKByUser false????");
|
||||||
|
}
|
||||||
|
if (retrans.willNotGetACKByUser ||
|
||||||
|
json.kind == MessageKind.pushKey ||
|
||||||
|
json.kind == MessageKind.ack) {
|
||||||
await twonlyDB.messageRetransmissionDao
|
await twonlyDB.messageRetransmissionDao
|
||||||
.deleteRetransmissionById(retransId);
|
.deleteRetransmissionById(retransId);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -131,7 +131,8 @@ Future<client.Response> handleNewMessage(int fromUserId, Uint8List body) async {
|
||||||
lastSignalDecryptMessage = DateTime.now();
|
lastSignalDecryptMessage = DateTime.now();
|
||||||
await twonlyDB.signalDao.deleteAllPreKeysByContactId(fromUserId);
|
await twonlyDB.signalDao.deleteAllPreKeysByContactId(fromUserId);
|
||||||
await requestNewPrekeysForContact(fromUserId);
|
await requestNewPrekeysForContact(fromUserId);
|
||||||
await twonlyDB.messageRetransmissionDao.resetAckStatusForAllMessages();
|
await twonlyDB.messageRetransmissionDao
|
||||||
|
.resetAckStatusForAllMessages(fromUserId);
|
||||||
tryTransmitMessages();
|
tryTransmitMessages();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,14 @@
|
||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
|
|
||||||
import 'package:fixnum/fixnum.dart';
|
import 'package:fixnum/fixnum.dart';
|
||||||
|
import 'package:flutter/foundation.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
|
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
|
||||||
import 'package:twonly/globals.dart';
|
import 'package:twonly/globals.dart';
|
||||||
import 'package:twonly/src/constants/secure_storage_keys.dart';
|
import 'package:twonly/src/constants/secure_storage_keys.dart';
|
||||||
import 'package:twonly/src/model/protobuf/push_notification/push_notification.pbserver.dart';
|
import 'package:twonly/src/model/protobuf/push_notification/push_notification.pbserver.dart';
|
||||||
|
import 'package:twonly/src/services/api/messages.dart';
|
||||||
import 'package:twonly/src/services/notifications/pushkeys.notifications.dart';
|
import 'package:twonly/src/services/notifications/pushkeys.notifications.dart';
|
||||||
import 'package:twonly/src/views/components/alert_dialog.dart';
|
import 'package:twonly/src/views/components/alert_dialog.dart';
|
||||||
import 'package:twonly/src/services/fcm.service.dart';
|
import 'package:twonly/src/services/fcm.service.dart';
|
||||||
|
|
@ -27,6 +29,13 @@ class NotificationView extends StatelessWidget {
|
||||||
ListTile(
|
ListTile(
|
||||||
title: Text(context.lang.settingsNotifyTroubleshooting),
|
title: Text(context.lang.settingsNotifyTroubleshooting),
|
||||||
subtitle: Text(context.lang.settingsNotifyTroubleshootingDesc),
|
subtitle: Text(context.lang.settingsNotifyTroubleshootingDesc),
|
||||||
|
onLongPress: (kDebugMode)
|
||||||
|
? () async {
|
||||||
|
await twonlyDB.messageRetransmissionDao
|
||||||
|
.resetAckStatusForAllMessages(537506372);
|
||||||
|
tryTransmitMessages();
|
||||||
|
}
|
||||||
|
: null,
|
||||||
onTap: () async {
|
onTap: () async {
|
||||||
await initFCMAfterAuthenticated();
|
await initFCMAfterAuthenticated();
|
||||||
String? storedToken = await FlutterSecureStorage()
|
String? storedToken = await FlutterSecureStorage()
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ description: "twonly, a privacy-friendly way to connect with friends through sec
|
||||||
# Prevent accidental publishing to pub.dev.
|
# Prevent accidental publishing to pub.dev.
|
||||||
publish_to: 'none'
|
publish_to: 'none'
|
||||||
|
|
||||||
version: 0.0.40+40
|
version: 0.0.43+43
|
||||||
|
|
||||||
environment:
|
environment:
|
||||||
sdk: ^3.6.0
|
sdk: ^3.6.0
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue