getInboxList function
Implementation
Future<List<Feeds>> getInboxList({
required List<Feeds> feedsList,
required String accountAddress,
required String? pgpPrivateKey,
required bool toDecrypt,
}) async {
final List<Feeds> feedsOutputlist = [];
for (var feed in feedsList) {
Message? message;
if (feed.threadhash != null) {
message = await getCID(cid: feed.threadhash!);
}
// This is for groups that are created without any message
message ??= Message(
encType: 'PlainText',
encryptedSecret: '',
fromCAIP10: '',
fromDID: '',
link: '',
messageContent: '',
messageType: '',
sigType: '',
signature: '',
toCAIP10: '',
toDID: '',
);
feed.msg = message;
feedsOutputlist.add(feed);
}
if (toDecrypt) {
final connectedUser =
await getUser(address: pCAIP10ToWallet(accountAddress));
if (connectedUser == null) {
throw Exception('Cannot find user');
}
if (pgpPrivateKey == null) {
throw Exception('Private cannot be null');
}
return decryptFeeds(
feeds: feedsOutputlist,
connectedUser: connectedUser,
pgpPrivateKey: pgpPrivateKey,
);
}
return feedsOutputlist;
}