m8chaa commited on
Commit
c9e4e4b
·
verified ·
1 Parent(s): 2810149

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -12
app.py CHANGED
@@ -331,18 +331,20 @@ async def check_user_doc(user_id: str = Form(...)):
331
  user = user_ref.get()
332
  if user.exists:
333
  return {"dbUserExists": True}
334
- new_transaction_ref = transactions_collection_ref.document(user_id)
335
- new_transaction_ref.set({
336
- "no_sms": 0,
337
- "no_contacts": 0,
338
- "no_receipts": 0,
339
- "no_business_cards": 0,
340
- "purchased_credit": {
341
- "image_detection": 100,
342
- "sync_data": 500,
343
- },
344
- "uid": user_id,
345
- })
 
 
346
  return {"dbUserExists": False}
347
 
348
 
 
331
  user = user_ref.get()
332
  if user.exists:
333
  return {"dbUserExists": True}
334
+ transaction_ref = transactions_collection_ref.document(user_id)
335
+ transaction = transaction_ref.get()
336
+ if not transaction.exists:
337
+ transaction_ref.set({
338
+ "no_sms": 0,
339
+ "no_contacts": 0,
340
+ "no_receipts": 0,
341
+ "no_business_cards": 0,
342
+ "purchased_credit": {
343
+ "image_detection": 100,
344
+ "sync_data": 500,
345
+ },
346
+ "uid": user_id,
347
+ })
348
  return {"dbUserExists": False}
349
 
350