Skip to content
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

Merged
merged 26 commits into from
Dec 18, 2024

Conversation

joeauyeung
Copy link
Contributor

@joeauyeung joeauyeung commented Nov 29, 2024

What does this PR do?

  • Introduces a new checkIfFreeEmailDomain function

  • Adds the option to skip returning the OwnerId of a record if it's a free email domain

  • Fixes #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)

  • I have self-reviewed the code (A decent size PR without self-review might be rejected).
  • I have updated the developer docs in /docs if this PR makes changes that would require a documentation change. If N/A, write N/A here and check the checkbox.
  • I confirm automated tests are in place that prove my fix is effective or that my feature works.

@graphite-app graphite-app bot requested a review from a team November 29, 2024 19:09
@keithwillcode keithwillcode added consumer core area: core, team members only labels Nov 29, 2024
@dosubot dosubot bot added crm-apps area: crm apps, salesforce, hubspot, close.com, sendgrid ✨ feature New feature or request labels Nov 29, 2024
Copy link

linear bot commented Nov 29, 2024

Copy link

graphite-app bot commented Nov 29, 2024

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[
Copy link
Contributor Author

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.

Copy link
Contributor

@Udit-takkar Udit-takkar left a 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) {
Copy link
Member

@hariombalhara hariombalhara Dec 2, 2024

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])) {
Copy link
Member

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

Copy link
Contributor Author

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.

Copy link
Member

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]

Copy link
Member

@hariombalhara hariombalhara left a 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.

@github-actions github-actions bot marked this pull request as draft December 2, 2024 10:53
* 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
Copy link

vercel bot commented Dec 2, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

2 Skipped Deployments
Name Status Preview Comments Updated (UTC)
cal ⬜️ Ignored (Inspect) Visit Preview Dec 16, 2024 7:50pm
calcom-web-canary ⬜️ Ignored (Inspect) Visit Preview Dec 16, 2024 7:50pm

Copy link
Contributor

github-actions bot commented Dec 7, 2024

E2E results are ready!

Copy link
Contributor

@emrysal emrysal left a 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.

@emrysal emrysal dismissed stale reviews from hariombalhara and CarinaWolli December 18, 2024 15:02

Changes addressed

@emrysal emrysal merged commit 8dda418 into main Dec 18, 2024
38 of 39 checks passed
@emrysal emrysal deleted the salesforce-skip-routing-if-free-email branch December 18, 2024 15:02
MuhammadAimanSulaiman pushed a commit to hit-pay/cal.com that referenced this pull request Jan 10, 2025
…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
MuhammadAimanSulaiman pushed a commit to hit-pay/cal.com that referenced this pull request Feb 20, 2025
…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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
consumer core area: core, team members only crm-apps area: crm apps, salesforce, hubspot, close.com, sendgrid ✨ feature New feature or request ❗️ migrations contains migration files ready-for-e2e
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants