-
Notifications
You must be signed in to change notification settings - Fork 0
/
functions.py
78 lines (63 loc) · 2.28 KB
/
functions.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
import smtplib
import random
import requests
from constants import EMAIL_ID, EMAIL_PASSWORD, GOOGLE_DISCOVERY_URL
from email.message import EmailMessage
from db import User, Rooms
def generateRoomID():
roomID = "".join([chr(random.randint(97, 122)) for _ in range(16)])
return roomID
# Login
def get_google_provider_cfg():
return requests.get(GOOGLE_DISCOVERY_URL).json()
def invite_user(room_id, participant_email):
# Ask user to join the room immediately
room = Rooms.getRoomByID(room_id)
room_name = room["name"]
interviewer_email = room["creator"]
meet_link = room["meeting_link"]
interviewer_name = User.getUserByEmail(interviewer_email, {"name": 1})[
"name"
]
msg = EmailMessage()
msg["Subject"] = (
"%s invited you to join the meeting. Join Now!" % interviewer_name
)
msg["From"] = EMAIL_ID
msg["To"] = participant_email
msg.set_content(
f"""
{interviewer_name} invited you to join the {room_name} meeting using the below link right now. Please join as soon as possible.
Meeting Link: {meet_link}
On behalf of {interviewer_name} ({interviewer_email}),
Receptionist.tech
"""
)
with smtplib.SMTP_SSL("smtp.gmail.com", 465) as smtp:
smtp.login(EMAIL_ID, EMAIL_PASSWORD)
smtp.send_message(msg)
def notify_user(room_id, participant_email):
# Alert user to be ready to join the room next. Experimental feature.
room = Rooms.getRoomByID(room_id)
room_name = room["name"]
interviewer_email = room["creator"]
meet_link = room["meeting_link"]
interviewer_name = User.getUserByEmail(interviewer_email, {"name": 1})[
"name"
]
msg = EmailMessage()
msg["Subject"] = "You are up next. Get ready!"
msg["From"] = EMAIL_ID
msg["To"] = participant_email
msg.set_content(
f"""
You are the next person in {room_name}'s participant queue. You can find the meeting link below. Get ready!
Meeting Link: {meet_link}
Further you will be notified when {interviewer_name} invites you to join the meeting.
On behalf of {interviewer_name} ({interviewer_email}),
Receptionist.tech
"""
)
with smtplib.SMTP_SSL("smtp.gmail.com", 465) as smtp:
smtp.login(EMAIL_ID, EMAIL_PASSWORD)
smtp.send_message(msg)