Skip to content

Commit

Permalink
fix: update message thread on events
Browse files Browse the repository at this point in the history
  • Loading branch information
lotharking committed Feb 7, 2025
1 parent e8d858d commit 9db8b54
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions packages/main/src/events/MessageEvents.ts
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,6 @@ export const messageEvents = async (agent: ServiceAgent, config: ServerConfig) =
config.logger.debug(`CredentialStateChangedEvent received. Record id:
${JSON.stringify(payload.credentialRecord.id)}, state: ${JSON.stringify(payload.credentialRecord.state)}`)
const record = payload.credentialRecord
const flowRecord = await agent.genericRecords.findById(record.threadId)

if (record.state === CredentialState.ProposalReceived) {
const credentialProposalMessage = await agent.credentials.findProposalMessage(record.id)
Expand All @@ -355,7 +354,7 @@ export const messageEvents = async (agent: ServiceAgent, config: ServerConfig) =
const message = new CredentialReceptionMessage({
connectionId: record.connectionId!,
id: record.id,
threadId: (flowRecord?.getTag('messageId') as string) ?? record.threadId,
threadId: record.threadId,
state:
record.errorMessage === 'issuance-abandoned: e.msg.refused'
? CredentialState.Declined
Expand Down Expand Up @@ -529,8 +528,10 @@ const sendMessageReceivedEvent = async (
timestamp: Date,
config: ServerConfig,
) => {
const recordId = await agent.genericRecords.findById(message.id)
if (recordId?.getTag('messageId') as string) message.id = recordId?.getTag('messageId') as string
if (message.threadId) {
const recordId = await agent.genericRecords.findById(message.threadId)
message.threadId = (recordId?.getTag('messageId') as string) ?? message.threadId
}
const body = new MessageReceived({
timestamp,
message: message,
Expand Down

0 comments on commit 9db8b54

Please sign in to comment.