Skip to content

Commit

Permalink
fixed twilio routes
Browse files Browse the repository at this point in the history
  • Loading branch information
jermxt committed Oct 16, 2022
1 parent ca18b59 commit de54912
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions backend/twilio_routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,14 @@

manager = Manager()
queue = manager.dict() # phonenum : bool[]
waitTime = 10
waitTime = 30

# post body: {"username": USERNAME, "friends" : ["username1", ...]}
@twilio_bp.route('/activateAlarm/', methods=['POST'])
def explode():
data = request.json
print(data['username'])
print("------")
session = Session()
data['friends'] = session.query(User.oncall).filter_by(username=data['username']).first()
data['friends'] = data['friends'][0]
Expand Down Expand Up @@ -69,7 +71,7 @@ def childProcess(data, queue, manager):
print("----")
if queue[phoneNum].pop(0):
break
if len(queue[phoneNum]) == 0:
if phoneNum in queue and len(queue[phoneNum]) == 0:
del queue[phoneNum]
session.close()

Expand Down Expand Up @@ -97,13 +99,13 @@ def logResponse():
if 'yes' in body.lower() and phoneNum in queue:
count = 0
while count < len(queue[phoneNum]) and not queue[phoneNum][count]:
print("ok")
print(queue[phoneNum][count])
#print("ok")
#print(queue[phoneNum][count])
queue[phoneNum][count] = True
count +=1
resp.message("Thank you!")
print(queue)
print("^^^^^^^^^")
elif 'no' in body.lower():
#print(queue)
#print("^^^^^^^^^")
elif 'no' in body.lower() and phoneNum in queue:
resp.message("Aww, we'll try the next friend")
return str(resp)

0 comments on commit de54912

Please sign in to comment.