Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 24 additions & 3 deletions src/events/CredentialEvents.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,33 @@ export const credentialEvents = async (agent: Agent, config: ServerConfig) => {
}

if (record?.connectionId) {
const connectionRecord = await agent.connections.findById(record.connectionId!)
let connectionRecord
if (event.metadata.contextCorrelationId && event.metadata.contextCorrelationId !== 'default') {
await (agent as Agent<RestMultiTenantAgentModules>).modules.tenants.withTenantAgent(
{ tenantId: body.contextCorrelationId as string },
async (tenantAgent) => {
connectionRecord = await tenantAgent.connections.findById(record.connectionId ? record.connectionId : '')
},
)
} else {
connectionRecord = await agent.connections.getById(record.connectionId)
}
body.outOfBandId = connectionRecord?.outOfBandId
}

const data = await agent.credentials.getFormatData(record.id)
body.credentialData = data
let formatData = null
if (event.metadata.contextCorrelationId && event.metadata.contextCorrelationId !== 'default') {
await (agent as Agent<RestMultiTenantAgentModules>).modules.tenants.withTenantAgent(
{ tenantId: body.contextCorrelationId as string },
async (tenantAgent) => {
formatData = await tenantAgent.credentials.getFormatData(record.id)
},
)
} else {
formatData = await agent.credentials.getFormatData(record.id)
}

body.credentialData = formatData

if (config.webhookUrl) {
await sendWebhookEvent(config.webhookUrl + '/credentials', body, agent.config.logger)
Expand Down
Loading