Skip to content

Commit

Permalink
feat: gmeet creation done
Browse files Browse the repository at this point in the history
  • Loading branch information
Sayantan-s committed Jul 9, 2024
1 parent ca70137 commit 85b28bc
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 30 deletions.
17 changes: 15 additions & 2 deletions api/db/models/meeting.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from peewee import CharField,UUIDField, TextField, DateTimeField, ForeignKeyField
from peewee import CharField,UUIDField, TextField, DateTimeField, ForeignKeyField, IntegerField
from playhouse.postgres_ext import ArrayField
from . import BaseModel
from datetime import datetime
from .user import User
Expand All @@ -8,7 +9,19 @@

class Meeting(BaseModel):
id = UUIDField(primary_key=True, default=uuid.uuid4)
meeting_name = TextField(column_name='meeting_name')

provider = CharField(column_name='provider')
meeting_id = TextField(column_name='meeting_id')
topic = TextField(column_name='topic')
agenda = TextField(column_name='agenda')
duration = IntegerField(column_name='duration')
organizer = TextField(column_name='organizer')
attendees = ArrayField(CharField, column_name='attendees')

meeting_link = TextField(column_name='meeting_link')
meeting_start_time = DateTimeField(column_name='meeting_start_time')
meeting_end_time = DateTimeField(column_name='meeting_end_time')

created_at = DateTimeField(default=datetime.utcnow, column_name='created_at')
updated_at = DateTimeField(default=datetime.utcnow, column_name='updated_at')
created_by = CharField(default='system', column_name='created_by')
Expand Down
53 changes: 27 additions & 26 deletions api/integrations/meetings/gmeet.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,37 +32,38 @@ def get_access_token():

def create(self):
creds: Credentials = GmeetMeeting.get_access_token()
try:
service = build("calendar", "v3", credentials=creds)
service = build("calendar", "v3", credentials=creds)

start = datetime.datetime.utcnow().isoformat() + "Z"
now = datetime.datetime.fromisoformat(start[:-1])
later = now + datetime.timedelta(minutes=30)
end = later.isoformat() + "Z"

event = {
"start": {"dateTime": start},
"end": {"dateTime": end},
"attendees": [{"email": "[email protected]"}],
"conferenceData": {
"createRequest": {
"requestId": "sample123",
"conferenceSolutionKey": {"type": "hangoutsMeet"}
}
},
"summary": "Testing < > Summary",
"description": "Testing < > Description"
}
events_result = (
epoch_time = self.meeting.config.epoch / 1000

start_time = datetime.datetime.utcfromtimestamp(epoch_time)
end_time = start_time + datetime.timedelta(minutes=self.meeting.config.duration)

start,end = (start_time.isoformat() + "Z", end_time.isoformat() + "Z")

attendees = [{ "email": attendee } for attendee in self.meeting.invitees ]

event = {
"start": {"dateTime": start},
"end": {"dateTime": end},
"attendees": attendees,
"conferenceData": {
"createRequest": {
"requestId": "sample123",
"conferenceSolutionKey": {"type": "hangoutsMeet"}
}
},
"summary": self.meeting.config.topic,
"description": self.meeting.config.agenda
}

events_result = (
service.events()
.insert(calendarId="primary", sendNotifications=False, body=event, conferenceDataVersion=1)
.insert(calendarId="primary", sendNotifications=True, body=event, conferenceDataVersion=1)
.execute()
)

return events_result

except HttpError as error:
print(f"An error occurred: {error}")
return {**events_result, "start_time": start_time, "end_time": end_time}

def add_participant(self):
print('Zoom participant added')
22 changes: 20 additions & 2 deletions api/services/meeting.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,25 @@ def create(meeting_input: CreateMeetingModel):
meeting_construct = MeetingService.__meeting_provider_instance[meeting_input.meetingProvider]
meeting: Union[ZoomMeeting, GmeetMeeting] = meeting_construct(meeting_input)
meeting_metadata = meeting.create()
# Meeting.create(meeting_name="Hello world!")
return meeting_metadata
meeting_start_time = meeting_metadata['start_time']
meeting_end_time = meeting_metadata['end_time']
hangoutLink= meeting_metadata["hangoutLink"]
meeting_id = meeting_metadata['id']
res = Meeting.create(
provider = meeting_input.meetingProvider,
meeting_id = meeting_id,
topic=meeting_input.config.topic,
agenda=meeting_input.config.agenda,
duration=meeting_input.config.duration,
organizer=meeting_input.scheduler,
attendees=meeting_input.invitees,
meeting_link=hangoutLink,
meeting_start_time=meeting_start_time,
meeting_end_time=meeting_end_time,
created_by="5eb0056e-b35b-444c-bbf1-04592188a37f",
updated_by="5eb0056e-b35b-444c-bbf1-04592188a37f",
user_id="5eb0056e-b35b-444c-bbf1-04592188a37f"
)
return { "meeting_link": hangoutLink, "gmeet_id": meeting_id, "meeting_id": str(res.id) }


0 comments on commit 85b28bc

Please sign in to comment.