Skip to content

Commit

Permalink
fix(enmeshed): avoid error when accepting an already active relationship
Browse files Browse the repository at this point in the history
  • Loading branch information
hugotiburtino committed Oct 16, 2024
1 parent 61f19cf commit 6c102f5
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions packages/server/src/internals/server/enmeshed-middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -467,14 +467,17 @@ function createEnmeshedWebhookMiddleware(
ConnectorRelationshipStatus.Rejected as string,
].includes(auditLogEntry.newStatus)
) {
const acceptRelationshipResponse =
await client.relationships.acceptRelationship(data.id)
if (acceptRelationshipResponse.isError) {
handleConnectorError({
error: acceptRelationshipResponse.error,
message: 'Failed while accepting relationship request',
})
if (data.status !== (ConnectorRelationshipStatus.Active as string)) {
const acceptRelationshipResponse =
await client.relationships.acceptRelationship(data.id)
if (acceptRelationshipResponse.isError) {
handleConnectorError({
error: acceptRelationshipResponse.error,
message: 'Failed while accepting relationship request',
})
}
}

if (!sessionId) {
await sendWelcomeMessage({ relationship: data, client })
await sendAttributesChangeRequest({ relationship: data, client })
Expand Down

0 comments on commit 6c102f5

Please sign in to comment.