-
Notifications
You must be signed in to change notification settings - Fork 8.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Salesforce skip ownership check if attendee email is a free domain #17916
Conversation
…n check is enabled
Graphite Automations"Add consumer team as reviewer" took an action on this PR • (11/29/24)1 reviewer was added to this PR based on Keith Williams's automation. "Add foundation team as reviewer" took an action on this PR • (12/04/24)1 reviewer was added to this PR based on Keith Williams's automation. |
|
||
if (firstDigit) { | ||
const arrayOfEmailDomains = | ||
freeEmailDomainsThatStartWithANumberObject[ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since the number of email domains were so small. Rather than going through the whole binary search algo, just straight look for the domain in the array.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The new option "If attendee has a free email domain, skip the ownership check and round robin as normal" is only display when "If attendee exists in Salesforce, book directly with the owner" is enabled. is this expected behaviour?
Screen.Recording.2024-11-30.at.1.24.41.AM.mov
@@ -1073,4 +1074,12 @@ export default class SalesforceCRMService implements CRM { | |||
if (companyValue === onBookingWriteToRecordFields[companyFieldName]) return; | |||
return companyValue; | |||
} | |||
|
|||
private attendeeHasFreeEmailDomain(attendeeEmail: string) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Better name would be something like shouldSkipAttendee
or shouldConsiderAttendee
(and then use negation of it)
Right now it gives a sense that attendee has free email domain if it is true but it could be that he has free email domain but the organizer still wants him to be considered.
@@ -392,7 +393,7 @@ export default class SalesforceCRMService implements CRM { | |||
|
|||
if (!records.length) records = results.records as ContactRecord[]; | |||
|
|||
if (includeOwner || forRoundRobinSkip) { | |||
if ((includeOwner || forRoundRobinSkip) && !this.attendeeHasFreeEmailDomain(emails[0])) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: I think instead of doing emails[0]. We should have it stored as booker or similar and then use that variable to make code more readable and consistent
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Emails come from the CalendarEvent.attendees
type which is used throughout the code base. If we were to make this change I'd want to do it in a separate PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh I meant, storing it in a variable, so at the top of the fn, we should do
const booker = attendees[0]
and then we use booker
everywhere which is much more logical then using attendees[0]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall looks good, have some nit comments but one requirement to move the list to DB.
* Add requiresConfirmationForFreeEmail to db * Add option to event type settings * Get requiresConfirmationForFreeEmail for event type page * Include requiresConfirmationForFreeEmail in fetching event type * Pass bookerEmail to `getRequiresConfirmationFlags` * Add free email domain check to `determineRequiresConfirmation` * Add `requiresConfirmationForFreeEmail` to types
The latest updates on your projects. Learn more about Vercel for Git ↗︎ 2 Skipped Deployments
|
E2E results are ready! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me, in the future as an improvement we can implement more caching but I reckon that's not mission critical rn.
Changes addressed
…ain (calcom#17916) * Add email domain array * Create numbered email domain object * Check email domain * Rename function * Add tests * Frontend enable skip ownership check if free email domain * Backend ignore adding ownership to return records if free email domain check is enabled * feat: Only require confirmation for free email domains (calcom#17917) * Add requiresConfirmationForFreeEmail to db * Add option to event type settings * Get requiresConfirmationForFreeEmail for event type page * Include requiresConfirmationForFreeEmail in fetching event type * Pass bookerEmail to `getRequiresConfirmationFlags` * Add free email domain check to `determineRequiresConfirmation` * Add `requiresConfirmationForFreeEmail` to types * Add severity to Watchlist table * Add migration for watchlist severity * Add `getEmailDomainInWatchlist` method to watchlist repository * Use watchlist repository to check for free email domain * Mock watchlist repository in test * Update test * Rename method * Add severity to blocked list * Move check free email domain to async * Type checks * Adjust for promise returned * Fix tests * Fix * Fix tests
…ain (calcom#17916) * Add email domain array * Create numbered email domain object * Check email domain * Rename function * Add tests * Frontend enable skip ownership check if free email domain * Backend ignore adding ownership to return records if free email domain check is enabled * feat: Only require confirmation for free email domains (calcom#17917) * Add requiresConfirmationForFreeEmail to db * Add option to event type settings * Get requiresConfirmationForFreeEmail for event type page * Include requiresConfirmationForFreeEmail in fetching event type * Pass bookerEmail to `getRequiresConfirmationFlags` * Add free email domain check to `determineRequiresConfirmation` * Add `requiresConfirmationForFreeEmail` to types * Add severity to Watchlist table * Add migration for watchlist severity * Add `getEmailDomainInWatchlist` method to watchlist repository * Use watchlist repository to check for free email domain * Mock watchlist repository in test * Update test * Rename method * Add severity to blocked list * Move check free email domain to async * Type checks * Adjust for promise returned * Fix tests * Fix * Fix tests
What does this PR do?
Introduces a new
checkIfFreeEmailDomain
functionAdds the option to skip returning the
OwnerId
of a record if it's a free email domainFixes #XXXX (GitHub issue number)
Fixes CAL-4810(Linear issue number - should be visible at the bottom of the GitHub issue description)
Mandatory Tasks (DO NOT REMOVE)