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: google meet no show #17271

Draft
wants to merge 11 commits into
base: main
Choose a base branch
from
Draft

feat: google meet no show #17271

wants to merge 11 commits into from

Conversation

Udit-takkar
Copy link
Contributor

@Udit-takkar Udit-takkar commented Oct 23, 2024

What does this PR do?

Mandatory Tasks (DO NOT REMOVE)

  • I have self-reviewed the code (A decent size PR without self-review might be rejected).
  • N/A 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.
  • N/A I confirm automated tests are in place that prove my fix is effective or that my feature works.

How should this be tested?

  1. Connect google calendar and install google meet
  2. Create a event type and add webhook events after hosts don't join google meet, after guests don't join google meet.
  3. Book a meeting and check Task Table

If you also want to test triggerHostNoShow then in L63 packages/features/bookings/lib/handleNewBooking/scheduleNoShowTriggers.ts add this code


import { triggerHostNoShow } from "@calcom/features/tasker/tasks/triggerNoShow/triggerHostNoShow";

await triggerHostNoShow(
      JSON.stringify({
        triggerEvent: WebhookTriggerEvents.AFTER_HOSTS_GOOGLE_MEET_NO_SHOW,
        bookingId: booking.id,
        webhook: {
          ...subscribersHostsNoShowStarted[0],
          time: subscribersHostsNoShowStarted[0].time,
          timeUnit: subscribersHostsNoShowStarted[0].timeUnit,
        },
        destinationCalendar,
      })
    );

Copy link

vercel bot commented Oct 23, 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 Oct 24, 2024 1:19pm
calcom-web-canary ⬜️ Ignored (Inspect) Visit Preview Oct 24, 2024 1:19pm

Copy link
Contributor

github-actions bot commented Oct 23, 2024

Hey there and thank you for opening this pull request! 👋🏼

We require pull request titles to follow the Conventional Commits specification and it looks like your proposed title needs to be adjusted.

Details:

@github-actions github-actions bot added the ❗️ migrations contains migration files label Oct 23, 2024
@keithwillcode keithwillcode added core area: core, team members only enterprise area: enterprise, audit log, organisation, SAML, SSO labels Oct 23, 2024
Copy link

linear bot commented Oct 23, 2024

@github-actions github-actions bot added calendar-apps area: calendar, google calendar, outlook, lark, microsoft 365, apple calendar consumer High priority Created by Linear-GitHub Sync ✨ feature New feature or request labels Oct 23, 2024
Copy link

New and removed dependencies detected. Learn more about Socket for GitHub ↗︎

Package New capabilities Transitives Size Publisher
npm/[email protected] None 0 221 kB dcode

View full report↗︎

Comment on lines +5 to +8
export const SCOPE_USERINFO_EMAIL = "https://www.googleapis.com/auth/userinfo.email";

export const REQUIRED_SCOPES = [SCOPE_CALENDAR_READONLY, SCOPE_CALENDAR_EVENT];
export const SCOPE_USER_CONTACTS = "https://www.googleapis.com/auth/contacts.readonly";
export const SCOPE_OTHER_USER_CONTACTS = "https://www.googleapis.com/auth/contacts.other.readonly";
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need these scope to fetch user's workspace accounts email.

@@ -1,7 +1,18 @@
export const SCOPE_USERINFO_PROFILE = "https://www.googleapis.com/auth/userinfo.profile";
export const SCOPE_CALENDAR_READONLY = "https://www.googleapis.com/auth/calendar.readonly";
export const SCOPE_CALENDAR_EVENT = "https://www.googleapis.com/auth/calendar.events";
export const GOOGLE_MEET_API = "https://www.googleapis.com/auth/meetings.space.readonly";
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need this scope to fetch details about meeting and fetch participants

Comment on lines +61 to +63
// TODO: is this correct?
const destinationCalendar = destinationCalendars?.find((cal) => cal.userId === organizerUser.id);

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we need the destination calendar of the organizer (that created the google meet url).

Comment on lines +206 to +231
if (
!!dailyVideoReference &&
(booking.location === DailyLocationType || booking.location?.trim() === "" || !booking.location)
) {
const meetingDetails = await getMeetingSessionsFromRoomName(dailyVideoReference.uid);

const allParticipants = meetingDetails.data.flatMap((meeting) => meeting.participants);

const hostsThatDidntJoinTheCall = hosts.filter(
(host) => !checkIfUserJoinedTheCall(host.id, allParticipants)
);

const numberOfHostsThatJoined = hosts.length - hostsThatDidntJoinTheCall.length;

const didGuestJoinTheCall = meetingDetails.data.some(
(meeting) => meeting.max_participants < numberOfHostsThatJoined
);

return {
hostsThatDidntJoinTheCall,
booking,
numberOfHostsThatJoined,
webhook,
didGuestJoinTheCall,
triggerEvent,
};
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is same as before

Comment on lines +680 to +687
const googleAuth = new GoogleAuth({
authClient: new OAuth2Client({
credentials: {
access_token: token.access_token,
},
}),
});

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was throwing type error when i used the Google auth client in this class so i had to create this one

const spaceName = spaceInfo[0].name;

const conferenceRecords = [];
for await (const response of meetClient.listConferenceRecordsAsync()) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

meetClient.listConferenceRecordsAsync() returns all conference records which were created by the user. conference record refers to a meeting.

const conferenceRecords = [];
for await (const response of meetClient.listConferenceRecordsAsync()) {
if (response.space === spaceName) {
conferenceRecords.push(response);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we only want the conference record on our meeting url

Comment on lines +723 to +726
const response = await fetch(
`https://people.googleapis.com/v1/people/${
participant.signedinUser?.user?.split("/")[1]
}?personFields=emailAddresses`,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fetch email here by id

@Udit-takkar Udit-takkar marked this pull request as ready for review October 24, 2024 13:35
@dosubot dosubot bot added the app-store area: app store, apps, calendar integrations, google calendar, outlook, lark, apple calendar label Oct 24, 2024
@dosubot dosubot bot added this to the v4.7 milestone Oct 24, 2024
@graphite-app graphite-app bot requested a review from a team October 24, 2024 13:36
Copy link

graphite-app bot commented Oct 24, 2024

Graphite Automations

"Add consumer team as reviewer" took an action on this PR • (10/24/24)

1 reviewer was added to this PR based on Keith Williams's automation.

@@ -77,6 +77,14 @@ export default function EditOAuthClientWebhooks() {
value: WebhookTriggerEvents.AFTER_GUESTS_CAL_VIDEO_NO_SHOW,
label: "after_guests_cal_video_no_show",
},
{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should these be separate per video type? Seems like it should be AFTER_HOSTS_NO_SHOW and AFTER_GUESTS_NO_SHOW no matter which video type they used.

const noShowPromises: Promise<any>[] = [];

const subscribersHostsNoShowStarted = await getWebhooks({
const hostNoShowTriggerEvent = isDailyVideoLocation
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My previous comment applies here. This list will continue to grow larger and larger for the more video integrations we detect no shows for. Do we absolutely have to do this?

@Udit-takkar Udit-takkar marked this pull request as draft October 25, 2024 07:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
app-store area: app store, apps, calendar integrations, google calendar, outlook, lark, apple calendar calendar-apps area: calendar, google calendar, outlook, lark, microsoft 365, apple calendar consumer core area: core, team members only enterprise area: enterprise, audit log, organisation, SAML, SSO ✨ feature New feature or request High priority Created by Linear-GitHub Sync ❗️ migrations contains migration files ready-for-e2e
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[CAL-4501] track no shows with google meet
3 participants