DmitrMakeev commited on
Commit
c4c9979
1 Parent(s): cf83044

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +19 -4
app.py CHANGED
@@ -1574,6 +1574,24 @@ def add_or_update_contact(contact_data):
1574
  conn.commit()
1575
  conn.close()
1576
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1577
  @app.route('/add_data_ver_cur', methods=['GET'])
1578
  def add_data_ver_cur():
1579
  global current_curator_index
@@ -1590,7 +1608,7 @@ def add_data_ver_cur():
1590
  user_data['curator'] = curators[current_curator_index]
1591
 
1592
  if veref_on_off == "1":
1593
- phone_verification_response = verify_phone_number(user_data.get('phone', ''))
1594
  if phone_verification_response is not None:
1595
  user_data['ws_st'] = phone_verification_response
1596
 
@@ -1616,9 +1634,6 @@ def add_data_ver_cur():
1616
 
1617
 
1618
 
1619
-
1620
-
1621
-
1622
  DATABASE2 = 'data_gc.db'
1623
 
1624
  def verify_phone_number(phone_number):
 
1574
  conn.commit()
1575
  conn.close()
1576
 
1577
+ def verify_phone_number_test(phone_number):
1578
+ full_url_ver = f"{wa_url}{wa_ak}{ws_url_ver}{wa_api_key}"
1579
+ payload = {"phoneNumber": phone_number}
1580
+ headers = {'Content-Type': 'application/json'}
1581
+
1582
+ logging.debug(f"Sending request to {full_url_ver} with payload: {payload}")
1583
+
1584
+ response = requests.post(full_url_ver, headers=headers, json=payload)
1585
+
1586
+ if response.status_code == 200:
1587
+ response_body = response.json()
1588
+ logging.debug(f"Response from API: {response_body}")
1589
+ return response_body.get('existsWhatsapp', 'false')
1590
+ else:
1591
+ logging.error(f"API request failed with status code {response.status_code}: {response.text}")
1592
+ return "Error"
1593
+
1594
+
1595
  @app.route('/add_data_ver_cur', methods=['GET'])
1596
  def add_data_ver_cur():
1597
  global current_curator_index
 
1608
  user_data['curator'] = curators[current_curator_index]
1609
 
1610
  if veref_on_off == "1":
1611
+ phone_verification_response = verify_phone_number_test(user_data.get('phone', ''))
1612
  if phone_verification_response is not None:
1613
  user_data['ws_st'] = phone_verification_response
1614
 
 
1634
 
1635
 
1636
 
 
 
 
1637
  DATABASE2 = 'data_gc.db'
1638
 
1639
  def verify_phone_number(phone_number):