decryptSpaceFeeds function

Future<List<SpaceFeeds>> decryptSpaceFeeds({
  1. required List<SpaceFeeds> feeds,
  2. required User connectedUser,
  3. required String pgpPrivateKey,
})

Implementation

Future<List<SpaceFeeds>> decryptSpaceFeeds({
  required List<SpaceFeeds> feeds,
  required User connectedUser,
  required String pgpPrivateKey,
}) async {
  final updatedFeeds = <SpaceFeeds>[];

  for (var feed in feeds) {
    final msg = feed.msg!;

    if (msg.encType != 'PlainText') {
      feed.msg = await decryptAndVerifyMessage(
        pgpPublicKey: connectedUser.publicKey!,
        message: msg,
        pgpPrivateKey: pgpPrivateKey,
      );
      updatedFeeds.add(feed);
    } else {
      updatedFeeds.add(feed);
    }
  }

  return updatedFeeds;
}