From 5d2974596563400cb5f004069d62ce170f329597 Mon Sep 17 00:00:00 2001 From: serafettin Date: Thu, 25 Jan 2024 16:59:32 +0100 Subject: [PATCH] iterate --- api/src/controllers/index.js | 2 +- api/src/services/index.js | 19 ++++++++++++++++++- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/api/src/controllers/index.js b/api/src/controllers/index.js index 7418a8fa..f76d8d63 100644 --- a/api/src/controllers/index.js +++ b/api/src/controllers/index.js @@ -11,7 +11,7 @@ export const getIndexById = async (req, res, next) => { const pkpSession = await getPKPSession(req.session, index); if(pkpSession){ const roles = getRolesFromSession(pkpSession); - Object.assign(index, roles); + Object.assign(index, {roles}); } } diff --git a/api/src/services/index.js b/api/src/services/index.js index 8b227627..936455ed 100644 --- a/api/src/services/index.js +++ b/api/src/services/index.js @@ -27,8 +27,9 @@ export class IndexService { try { let didPayload = ""; + if (this.did) { - didPayload = `did(first:10, account: "${this.did.id}") { + didPayload = `did(first:10, account: "${this.did.parent}") { edges { node { id @@ -73,8 +74,24 @@ export class IndexService { const index = data.node; + + if(index.did && index.did.edges && index.did.edges.length > 0){ + const did = {}; + index.did.edges.forEach((edge) => { + if(edge.node.type === "owner"){ + did.isOwnerVisible = edge.node.deletedAt === null; + } + if(edge.node.type === "starred"){ + did.isStarred = edge.node.deletedAt === null; + } + }); + index.did = did; + } + index.ownerDID = await getOwnerProfile(index.signerPublicKey); + + return index; } catch (error) {