Skip to content

Commit 104f72a

Browse files
authored
fix: resolve data error on issuance using shared agent (credebl#332)
* fix/get formatted data error Signed-off-by: sujitaw <sujit.sutar@ayanworks.com> * fix/ellipse comments Signed-off-by: sujitaw <sujit.sutar@ayanworks.com> --------- Signed-off-by: sujitaw <sujit.sutar@ayanworks.com>
1 parent a8165c4 commit 104f72a

File tree

1 file changed

+24
-3
lines changed

1 file changed

+24
-3
lines changed

src/events/CredentialEvents.ts

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,33 @@ export const credentialEvents = async (agent: Agent, config: ServerConfig) => {
1919
}
2020

2121
if (record?.connectionId) {
22-
const connectionRecord = await agent.connections.findById(record.connectionId!)
22+
let connectionRecord
23+
if (event.metadata.contextCorrelationId && event.metadata.contextCorrelationId !== 'default') {
24+
await (agent as Agent<RestMultiTenantAgentModules>).modules.tenants.withTenantAgent(
25+
{ tenantId: body.contextCorrelationId as string },
26+
async (tenantAgent) => {
27+
connectionRecord = await tenantAgent.connections.findById(record.connectionId ? record.connectionId : '')
28+
},
29+
)
30+
} else {
31+
connectionRecord = await agent.connections.getById(record.connectionId)
32+
}
2333
body.outOfBandId = connectionRecord?.outOfBandId
2434
}
2535

26-
const data = await agent.credentials.getFormatData(record.id)
27-
body.credentialData = data
36+
let formatData = null
37+
if (event.metadata.contextCorrelationId && event.metadata.contextCorrelationId !== 'default') {
38+
await (agent as Agent<RestMultiTenantAgentModules>).modules.tenants.withTenantAgent(
39+
{ tenantId: body.contextCorrelationId as string },
40+
async (tenantAgent) => {
41+
formatData = await tenantAgent.credentials.getFormatData(record.id)
42+
},
43+
)
44+
} else {
45+
formatData = await agent.credentials.getFormatData(record.id)
46+
}
47+
48+
body.credentialData = formatData
2849

2950
if (config.webhookUrl) {
3051
await sendWebhookEvent(config.webhookUrl + '/credentials', body, agent.config.logger)

0 commit comments

Comments
 (0)