Skip to content

Commit

Permalink
fix: update consent on message send if unknown
Browse files Browse the repository at this point in the history
  • Loading branch information
rygine committed Nov 1, 2023
1 parent 1c6576f commit 6300658
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/conversations/Conversation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,13 @@ export class ConversationV1<ContentTypes>
}))
)

// if the conversation consent state is unknown, we assume the user has
// consented to the conversation by sending a message into it
if (this.consentState === 'unknown') {
// add conversation to the allow list
await this.allow()
}

return DecodedMessage.fromV1Message(
msg,
content,
Expand Down Expand Up @@ -615,6 +622,13 @@ export class ConversationV2<ContentTypes>
])
const contentType = options?.contentType || ContentTypeText

// if the conversation consent state is unknown, we assume the user has
// consented to the conversation by sending a message into it
if (this.consentState === 'unknown') {
// add conversation to the allow list
await this.allow()
}

return DecodedMessage.fromV2Message(
msg,
content,
Expand Down

0 comments on commit 6300658

Please sign in to comment.