mirror of
https://github.com/twonlyapp/twonly-app.git
synced 2026-06-02 20:42:12 +00:00
improve logging
Some checks failed
Flutter analyze & test / flutter_analyze_and_test (push) Has been cancelled
Some checks failed
Flutter analyze & test / flutter_analyze_and_test (push) Has been cancelled
This commit is contained in:
parent
789bcda34f
commit
c7826ad6dd
7 changed files with 77 additions and 34 deletions
|
|
@ -253,23 +253,19 @@ class MessagesDao extends DatabaseAccessor<TwonlyDB> with _$MessagesDaoMixin {
|
|||
List<String> messageIds,
|
||||
DateTime timestamp,
|
||||
) async {
|
||||
try {
|
||||
await twonlyDB.batch((batch) async {
|
||||
for (final messageId in messageIds) {
|
||||
batch.insert(
|
||||
messageActions,
|
||||
try {
|
||||
await into(messageActions).insertOnConflictUpdate(
|
||||
MessageActionsCompanion(
|
||||
messageId: Value(messageId),
|
||||
contactId: contactId,
|
||||
type: const Value(MessageActionType.openedAt),
|
||||
actionAt: Value(timestamp),
|
||||
),
|
||||
mode: InsertMode.insertOrReplace,
|
||||
);
|
||||
}
|
||||
});
|
||||
} catch (e) {
|
||||
Log.error(e);
|
||||
Log.error('handleMessagesOpened insert failed for $messageId: $e');
|
||||
}
|
||||
}
|
||||
|
||||
for (final messageId in messageIds) {
|
||||
|
|
@ -278,6 +274,7 @@ class MessagesDao extends DatabaseAccessor<TwonlyDB> with _$MessagesDaoMixin {
|
|||
messageId,
|
||||
MessageActionType.openedAt,
|
||||
);
|
||||
final rowsUpdated =
|
||||
await (update(
|
||||
messages,
|
||||
)..where((tbl) => tbl.messageId.equals(messageId))).write(
|
||||
|
|
@ -286,8 +283,11 @@ class MessagesDao extends DatabaseAccessor<TwonlyDB> with _$MessagesDaoMixin {
|
|||
openedByAll: Value(isOpenedByAll ? timestamp : null),
|
||||
),
|
||||
);
|
||||
Log.info(
|
||||
'handleMessagesOpened updated $rowsUpdated rows for message $messageId',
|
||||
);
|
||||
} catch (e) {
|
||||
Log.error(e);
|
||||
Log.error('handleMessagesOpened update failed: $e');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,7 +29,14 @@ class ReactionsDao extends DatabaseAccessor<TwonlyDB> with _$ReactionsDaoMixin {
|
|||
final msg = await twonlyDB.messagesDao
|
||||
.getMessageById(messageId)
|
||||
.getSingleOrNull();
|
||||
if (msg == null || msg.groupId != groupId) return;
|
||||
if (msg == null) {
|
||||
Log.error('updateReaction: Message $messageId not found!');
|
||||
return;
|
||||
}
|
||||
if (msg.groupId != groupId) {
|
||||
Log.error('updateReaction: Message groupId ${msg.groupId} != $groupId');
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
if (remove) {
|
||||
|
|
|
|||
|
|
@ -10,7 +10,10 @@ Future<void> handleReaction(
|
|||
EncryptedContent_Reaction reaction,
|
||||
String receiptId,
|
||||
) async {
|
||||
Log.info('[$receiptId] Got a reaction from $fromUserId (remove=${reaction.remove})');
|
||||
Log.info(
|
||||
'[$receiptId] Got a reaction from for ${reaction.targetMessageId} (remove=${reaction.remove})',
|
||||
);
|
||||
|
||||
await twonlyDB.reactionsDao.updateReaction(
|
||||
fromUserId,
|
||||
reaction.targetMessageId,
|
||||
|
|
|
|||
|
|
@ -350,7 +350,9 @@ Future<void> insertAndSendAskAboutUserMessage(
|
|||
) async {
|
||||
final directChat = await twonlyDB.groupsDao.createOrGetDirectChat(contactId);
|
||||
if (directChat == null) {
|
||||
Log.error('Failed to get or create direct chat group for contact $contactId');
|
||||
Log.error(
|
||||
'Failed to get or create direct chat group for contact $contactId',
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -483,6 +485,17 @@ Future<(Uint8List, Uint8List?)?> sendCipherText(
|
|||
);
|
||||
|
||||
if (receipt != null) {
|
||||
try {
|
||||
final typeKeys = _getEncryptedContentTypes(encryptedContent);
|
||||
Log.info(
|
||||
'sendCipherText: type=[$typeKeys] messageId=$messageId receiptId=${receipt.receiptId}',
|
||||
);
|
||||
} catch (_) {
|
||||
Log.info(
|
||||
'sendCipherText: messageId=$messageId receiptId=${receipt.receiptId}',
|
||||
);
|
||||
}
|
||||
|
||||
final tmp = tryToSendCompleteMessage(
|
||||
receipt: receipt,
|
||||
onlyReturnEncryptedData: onlyReturnEncryptedData,
|
||||
|
|
@ -568,3 +581,21 @@ Future<void> sendContactMyProfileData(int contactId) async {
|
|||
);
|
||||
await sendCipherText(contactId, encryptedContent, blocking: false);
|
||||
}
|
||||
|
||||
String _getEncryptedContentTypes(pb.EncryptedContent content) {
|
||||
final ignoredFields = {
|
||||
'groupId',
|
||||
'isDirectChat',
|
||||
'senderProfileCounter',
|
||||
'senderUserDiscoveryVersion',
|
||||
};
|
||||
|
||||
final types = <String>[];
|
||||
for (final field in content.info_.byName.values) {
|
||||
if (content.hasField(field.tagNumber) &&
|
||||
!ignoredFields.contains(field.name)) {
|
||||
types.add(field.name);
|
||||
}
|
||||
}
|
||||
return types.join(', ');
|
||||
}
|
||||
|
|
|
|||
|
|
@ -212,6 +212,7 @@ class _CameraPreviewViewState extends State<CameraPreviewView> {
|
|||
// Maybe this is the reason?
|
||||
return;
|
||||
} else {
|
||||
await androidVolumeDownSub?.cancel();
|
||||
androidVolumeDownSub = FlutterAndroidVolumeKeydown.stream.listen((
|
||||
event,
|
||||
) {
|
||||
|
|
@ -233,6 +234,7 @@ class _CameraPreviewViewState extends State<CameraPreviewView> {
|
|||
}
|
||||
if (Platform.isAndroid) {
|
||||
await androidVolumeDownSub?.cancel();
|
||||
androidVolumeDownSub = null;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -24,16 +24,16 @@ enum MessageSendState {
|
|||
|
||||
MessageSendState messageSendStateFromMessage(Message msg) {
|
||||
if (msg.senderId == null) {
|
||||
if (msg.openedByAll != null || msg.openedAt != null) {
|
||||
return MessageSendState.sendOpened;
|
||||
}
|
||||
|
||||
/// messages was send by me, look up if every messages was received by the server...
|
||||
if (msg.ackByServer == null) {
|
||||
return MessageSendState.sending;
|
||||
}
|
||||
if (msg.openedAt != null) {
|
||||
return MessageSendState.sendOpened;
|
||||
} else {
|
||||
return MessageSendState.send;
|
||||
}
|
||||
}
|
||||
|
||||
// message received
|
||||
if (msg.openedAt == null) {
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ description: "twonly, a privacy-friendly way to connect with friends through sec
|
|||
|
||||
publish_to: 'none'
|
||||
|
||||
version: 0.2.20+129
|
||||
version: 0.2.21+130
|
||||
|
||||
environment:
|
||||
sdk: ^3.11.0
|
||||
|
|
|
|||
Loading…
Reference in a new issue