rohanshaw commited on
Commit
ce92098
·
verified ·
1 Parent(s): a23150c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +23 -0
app.py CHANGED
@@ -297,6 +297,29 @@ async def admin_push(title: str = Body(...), body: str = Body(...)):
297
  send_push(token_entry["token"], title, body)
298
  return {"message": "Notifications sent"}
299
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
300
 
301
 
302
  @app.get("/", status_code=status.HTTP_200_OK)
 
297
  send_push(token_entry["token"], title, body)
298
  return {"message": "Notifications sent"}
299
 
300
+ @app.post("/api/app/parked")
301
+ async def user_parked(requestBody: InAppEventNotification = Body(...)):
302
+ send_push(requestBody.token, "WhereIParked", "You parked your car. Timer started!", "app")
303
+ return {"message": "Notification sent"}
304
+
305
+
306
+ @app.post("/api/app/clear-location")
307
+ async def user_cleared(requestBody: InAppEventNotification = Body(...)):
308
+ send_push(requestBody.token, "WhereIParked", "Parking location cleared. Safe drive!", "app")
309
+ return {"message": "Notification sent"}
310
+
311
+ @app.post("/api/app/park-duration")
312
+ async def park_duration(requestBody: InAppEventNotification = Body(...), duration = str):
313
+ send_push(requestBody.token, "Reminder", "You’ve been parked for over " + duration + " minutes!", "app")
314
+ return {"message": "Notification sent"}
315
+
316
+ @app.post("/admin/app/push")
317
+ async def admin_push(title: str = Body(...), body: str = Body(...)):
318
+ tokens = await db.fcmtokens.find().to_list(length=None)
319
+ for token_entry in tokens:
320
+ send_push(token_entry["token"], title, body, "app")
321
+ return {"message": "Notifications sent"}
322
+
323
 
324
 
325
  @app.get("/", status_code=status.HTTP_200_OK)