decryptConversation function

Future<List<Message>> decryptConversation({
  1. required List<Message> messages,
  2. required User? connectedUser,
  3. required String pgpPrivateKey,
})

Implementation

Future<List<Message>> decryptConversation({
  required List<Message> messages,
  required User? connectedUser,
  required String pgpPrivateKey,
}) async {
  final updatedMessages = <Message>[];

  for (var msg in messages) {
    if (msg.encType != 'PlainText') {
      msg = await decryptAndVerifyMessage(
        pgpPrivateKey: pgpPrivateKey,
        pgpPublicKey: connectedUser!.publicKey!,
        message: msg,
      );
    }
    updatedMessages.add(msg);
  }

  return updatedMessages;
}