Skip to content

Commit

Permalink
fix: optimize chat.list
Browse files Browse the repository at this point in the history
  • Loading branch information
Aman035 committed Feb 14, 2024
1 parent 3fd2a51 commit 09a2b6b
Showing 1 changed file with 6 additions and 31 deletions.
37 changes: 6 additions & 31 deletions packages/restapi/src/lib/chat/helpers/inbox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,51 +41,26 @@ export const getInboxLists = async (
pgpHelper = PGP.PGPHelper
): Promise<IFeeds[]> => {
const {
lists,
lists: feeds,
user,
toDecrypt,
pgpPrivateKey,
env = Constants.ENV.PROD,
} = options || {};

const connectedUser = await getUser({ account: pCAIP10ToWallet(user), env });
const feeds: IFeeds[] = [];
for (const list of lists) {
let message;
if (list.threadhash !== null) {
message = await getCID(list.threadhash, { env });
}
// This is for groups that are created without any message
else {
message = {
encType: 'PlainText',
encryptedSecret: '',
fromCAIP10: '',
fromDID: '',
link: '',
messageContent: '',
messageType: '',
sigType: '',
signature: '',
toCAIP10: '',
toDID: '',
};
}
feeds.push({
...list,
msg: message,
groupInformation: list.groupInformation,
if (toDecrypt) {
const connectedUser = await getUser({
account: pCAIP10ToWallet(user),
env,
});
}

if (toDecrypt)
return decryptFeeds({
feeds,
connectedUser,
pgpPrivateKey,
pgpHelper,
env,
});
}
return feeds;
};

Expand Down

0 comments on commit 09a2b6b

Please sign in to comment.