bump version

This commit is contained in:
otsmr 2025-06-23 13:46:54 +02:00
parent ac88c70230
commit 5727b3ae4e
6 changed files with 42 additions and 6 deletions

View file

@ -33,7 +33,7 @@ android {
defaultConfig { defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId = "eu.twonly.testing" applicationId = "eu.twonly"
multiDexEnabled true multiDexEnabled true
// You can update the following values to match your application needs. // You can update the following values to match your application needs.
// For more information, see: https://flutter.dev/to/review-gradle-config. // For more information, see: https://flutter.dev/to/review-gradle-config.

View file

@ -40,6 +40,20 @@ Future sendRetransmitMessage(int retransId) async {
return; return;
} }
MessageJson json = MessageJson.fromJson(
jsonDecode(
utf8.decode(
gzip.decode(retrans.plaintextContent),
),
),
);
Log.info("Retransmitting: ${json.kind} to ${retrans.contactId}");
// if (json.kind
// .contains(MessageKind.pushKey.name)) {
// await twonlyDB.messageRetransmissionDao.deleteRetransmissionById(retransId);
// return;
// }
Contact? contact = await twonlyDB.contactsDao Contact? contact = await twonlyDB.contactsDao
.getContactByUserId(retrans.contactId) .getContactByUserId(retrans.contactId)
.getSingleOrNull(); .getSingleOrNull();

View file

@ -80,9 +80,11 @@ Future<client.Response> handleNewMessage(int fromUserId, Uint8List body) async {
return client.Response()..ok = ok; return client.Response()..ok = ok;
} }
Log.info("Got: ${message.kind}"); Log.info("Got: ${message.kind} from $fromUserId");
if (message.kind != MessageKind.ack && message.retransId != null) { if (message.kind != MessageKind.ack &&
message.kind != MessageKind.pushKey &&
message.retransId != null) {
Log.info("Sending ACK for ${message.kind}"); Log.info("Sending ACK for ${message.kind}");
/// ACK every message /// ACK every message

View file

@ -20,6 +20,20 @@ import 'package:twonly/src/utils/log.dart';
Future setupNotificationWithUsers({bool force = false}) async { Future setupNotificationWithUsers({bool force = false}) 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
// and create new push keys with all users.
PushUser? pushUser = pushUsers.firstWhereOrNull((x) => x.userId == 0);
if (pushUser == null) {
Log.info("Clearing push keys");
await setPushKeys(SecureStorageKeys.receivingPushKeys, []);
pushUsers = await getPushKeys(SecureStorageKeys.receivingPushKeys);
pushUsers.add(PushUser(
userId: Int64(0),
displayName: "NoUser",
pushKeys: [],
));
}
var wasChanged = false; var wasChanged = false;
final random = Random.secure(); final random = Random.secure();
@ -49,8 +63,12 @@ Future setupNotificationWithUsers({bool force = false}) async {
pushUser.pushKeys.add(lastKey); pushUser.pushKeys.add(lastKey);
pushUser.pushKeys.add(pushKey); pushUser.pushKeys.add(pushKey);
wasChanged = true; wasChanged = true;
Log.info("Creating new pushkey for ${contact.userId}");
} }
} else { } else {
Log.info(
"User ${contact.userId} not yet in pushkeys. Creating a new user.",
);
wasChanged = true; wasChanged = true;
/// Insert a new push user /// Insert a new push user
@ -61,6 +79,7 @@ Future setupNotificationWithUsers({bool force = false}) async {
); );
await sendNewPushKey(contact.userId, pushKey); await sendNewPushKey(contact.userId, pushKey);
pushUsers.add(PushUser( pushUsers.add(PushUser(
userId: Int64(contact.userId),
displayName: getContactDisplayName(contact), displayName: getContactDisplayName(contact),
blocked: contact.blocked, blocked: contact.blocked,
pushKeys: [pushKey], pushKeys: [pushKey],
@ -88,6 +107,7 @@ Future sendNewPushKey(int userId, PushKey pushKey) async {
pushKey.createdAtUnixTimestamp.toInt(), pushKey.createdAtUnixTimestamp.toInt(),
), ),
), ),
willNotGetACKByUser: true, // hot fix, this can be removed later...
); );
} }
@ -99,6 +119,7 @@ Future updatePushUser(Contact contact) async {
if (pushUser == null) { if (pushUser == null) {
pushKeys.add(PushUser( pushKeys.add(PushUser(
userId: Int64(contact.userId),
displayName: getContactDisplayName(contact), displayName: getContactDisplayName(contact),
pushKeys: [], pushKeys: [],
blocked: contact.blocked, blocked: contact.blocked,

View file

@ -26,9 +26,9 @@ DateTime lastSignedPreKeyRequest = DateTime.now().subtract(Duration(hours: 1));
Future requestNewPrekeysForContact(int contactId) async { Future requestNewPrekeysForContact(int contactId) async {
if (lastPreKeyRequest if (lastPreKeyRequest
.isAfter(DateTime.now().subtract(Duration(seconds: 60)))) { .isAfter(DateTime.now().subtract(Duration(seconds: 60)))) {
Log.info("last pre request was 60s before");
return; return;
} }
Log.info("Requesting new PREKEYS for $contactId");
lastPreKeyRequest = DateTime.now(); lastPreKeyRequest = DateTime.now();
requestNewKeys.protect(() async { requestNewKeys.protect(() async {
final otherKeys = await apiService.getPreKeysByUserId(contactId); final otherKeys = await apiService.getPreKeysByUserId(contactId);
@ -54,7 +54,6 @@ Future requestNewPrekeysForContact(int contactId) async {
Future<SignalContactPreKey?> getPreKeyByContactId(int contactId) async { Future<SignalContactPreKey?> getPreKeyByContactId(int contactId) async {
int count = await twonlyDB.signalDao.countPreKeysByContactId(contactId); int count = await twonlyDB.signalDao.countPreKeysByContactId(contactId);
if (count < 10) { if (count < 10) {
Log.info("Requesting new prekeys: $count < 10");
requestNewPrekeysForContact(contactId); requestNewPrekeysForContact(contactId);
} }
return twonlyDB.signalDao.popPreKeyByContactId(contactId); return twonlyDB.signalDao.popPreKeyByContactId(contactId);

View file

@ -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.37+37 version: 0.0.40+40
environment: environment:
sdk: ^3.6.0 sdk: ^3.6.0