rohanshaw commited on
Commit
af0be63
·
verified ·
1 Parent(s): 62bdf1a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -8
app.py CHANGED
@@ -286,48 +286,48 @@ async def save_token(token_model: TokenModel):
286
 
287
  @app.post("/api/parked")
288
  async def user_parked(requestBody: InAppEventNotification = Body(...)):
289
- send_push(requestBody.token, "WhereIParked", "You parked your car. Timer started!")
290
  return {"message": "Notification sent"}
291
 
292
 
293
  @app.post("/api/clear-location")
294
  async def user_cleared(requestBody: InAppEventNotification = Body(...)):
295
- send_push(requestBody.token, "WhereIParked", "Parking location cleared. Safe drive!")
296
  return {"message": "Notification sent"}
297
 
298
  @app.post("/api/park-duration")
299
  async def park_duration(requestBody: InAppEventNotification = Body(...), duration = str):
300
- send_push(requestBody.token, "Reminder", "You’ve been parked for over " + duration + " minutes!")
301
  return {"message": "Notification sent"}
302
 
303
  @app.post("/admin/push")
304
  async def admin_push(title: str = Body(...), body: str = Body(...)):
305
  tokens = await db.fcmtokens.find().to_list(length=None)
306
  for token_entry in tokens:
307
- send_push(token_entry["token"], title, body)
308
  return {"message": "Notifications sent"}
309
 
310
  @app.post("/api/app/parked")
311
  async def app_user_parked(requestBody: InAppEventNotification = Body(...)):
312
- send_push(requestBody.token, "WhereIParked", "You parked your car. Timer started!", "app")
313
  return {"message": "Notification sent"}
314
 
315
 
316
  @app.post("/api/app/clear-location")
317
  async def app_user_cleared(requestBody: InAppEventNotification = Body(...)):
318
- send_push(requestBody.token, "WhereIParked", "Parking location cleared. Safe drive!", "app")
319
  return {"message": "Notification sent"}
320
 
321
  @app.post("/api/app/park-duration")
322
  async def app_park_duration(requestBody: InAppEventNotification = Body(...), duration = str):
323
- send_push(requestBody.token, "Reminder", "You’ve been parked for over " + duration + " minutes!", "app")
324
  return {"message": "Notification sent"}
325
 
326
  @app.post("/admin/app/push")
327
  async def app_admin_push(title: str = Body(...), body: str = Body(...)):
328
  tokens = await db.fcmtokens.find().to_list(length=None)
329
  for token_entry in tokens:
330
- send_push(token_entry["token"], title, body, "app")
331
  return {"message": "Notifications sent"}
332
 
333
 
 
286
 
287
  @app.post("/api/parked")
288
  async def user_parked(requestBody: InAppEventNotification = Body(...)):
289
+ await send_push(requestBody.token, "WhereIParked", "You parked your car. Timer started!")
290
  return {"message": "Notification sent"}
291
 
292
 
293
  @app.post("/api/clear-location")
294
  async def user_cleared(requestBody: InAppEventNotification = Body(...)):
295
+ await send_push(requestBody.token, "WhereIParked", "Parking location cleared. Safe drive!")
296
  return {"message": "Notification sent"}
297
 
298
  @app.post("/api/park-duration")
299
  async def park_duration(requestBody: InAppEventNotification = Body(...), duration = str):
300
+ await send_push(requestBody.token, "Reminder", "You’ve been parked for over " + duration + " minutes!")
301
  return {"message": "Notification sent"}
302
 
303
  @app.post("/admin/push")
304
  async def admin_push(title: str = Body(...), body: str = Body(...)):
305
  tokens = await db.fcmtokens.find().to_list(length=None)
306
  for token_entry in tokens:
307
+ await send_push(token_entry["token"], title, body)
308
  return {"message": "Notifications sent"}
309
 
310
  @app.post("/api/app/parked")
311
  async def app_user_parked(requestBody: InAppEventNotification = Body(...)):
312
+ await send_push(requestBody.token, "WhereIParked", "You parked your car. Timer started!", "app")
313
  return {"message": "Notification sent"}
314
 
315
 
316
  @app.post("/api/app/clear-location")
317
  async def app_user_cleared(requestBody: InAppEventNotification = Body(...)):
318
+ await send_push(requestBody.token, "WhereIParked", "Parking location cleared. Safe drive!", "app")
319
  return {"message": "Notification sent"}
320
 
321
  @app.post("/api/app/park-duration")
322
  async def app_park_duration(requestBody: InAppEventNotification = Body(...), duration = str):
323
+ await send_push(requestBody.token, "Reminder", "You’ve been parked for over " + duration + " minutes!", "app")
324
  return {"message": "Notification sent"}
325
 
326
  @app.post("/admin/app/push")
327
  async def app_admin_push(title: str = Body(...), body: str = Body(...)):
328
  tokens = await db.fcmtokens.find().to_list(length=None)
329
  for token_entry in tokens:
330
+ await send_push(token_entry["token"], title, body, "app")
331
  return {"message": "Notifications sent"}
332
 
333