Skip to content

Commit

Permalink
chore: settings revision (#33703)
Browse files Browse the repository at this point in the history
* fix: getting out early if setting is never

* chore: do not hold the conversation if there is no app
  • Loading branch information
Gustrb authored Oct 22, 2024
1 parent f3ab541 commit eff9fa5
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion apps/meteor/ee/server/patches/shouldTriggerVerificationApp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,14 @@ import { LivechatContacts } from '@rocket.chat/models';
import { shouldTriggerVerificationApp } from '../../../app/livechat/server/lib/contacts/shouldTriggerVerificationApp';
import { settings } from '../../../app/settings/server';

/**
* Theese are the possible values the Livechat_Require_Contact_Verification might assume, they represent:
* - never: the contact verification app should never be triggered, therefore, the conversation will be always put onto the queue
* - once: if the contact was already verified in this channel, there is no need to assign it to the bot again
* - always: assign it to the bot every time
*/
type AvailableLivechatRequireContactVerificationSetting = 'never' | 'once' | 'always';

const runShouldTriggerVerificationApp = async (
_next: any,
contactId: ILivechatContact['_id'],
Expand All @@ -27,8 +35,14 @@ const runShouldTriggerVerificationApp = async (
return true;
}

// There is no configured verification app, so there is no reason to trigger a verification app, since
// none will be able to be assigned
if (settings.get<string>('Livechat_Contact_Verification_App') === '') {
return false;
}

const verificationRequirement = settings.get<AvailableLivechatRequireContactVerificationSetting>('Livechat_Require_Contact_Verification');
const isContactVerified = (contact.channels?.filter((channel) => channel.verified && channel.name === source.type) || []).length > 0;
const verificationRequirement = settings.get<string>('Livechat_Require_Contact_Verification');

// If the contact has never been verified and it needs to be verified at least once, trigger the app
if (!isContactVerified && verificationRequirement === 'once') {
Expand Down

0 comments on commit eff9fa5

Please sign in to comment.