-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgetinvites.py
More file actions
22 lines (21 loc) · 796 Bytes
/
getinvites.py
File metadata and controls
22 lines (21 loc) · 796 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import firebase_admin
from firebase_admin import credentials, db
def get_invite(mentor_email):
if not firebase_admin._apps:
cred = credentials.Certificate("credentials.json")
firebase_admin.initialize_app(cred, {"databaseURL": "https://limble-30e8a-default-rtdb.asia-southeast1.firebasedatabase.app/"})
ref = db.reference('/')
user_ref = ref.child("mentor")
details = user_ref.get()
invites_list = None # Initialize invites_list as None
flag=0
for i in details:
if mentor_email == details[i]["email"]:
if "invites" in details[i]:
flag=1 # Check if "invites" key exists
invites_list = details[i]["invites"]
break
if flag==1:
return invites_list
else:
return []