DmitrMakeev
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -1525,24 +1525,7 @@ mapp_templates = {
|
|
1525 |
|
1526 |
DATABASE_NAME3 = 'data_gc.db'
|
1527 |
|
1528 |
-
def
|
1529 |
-
full_url_ver = f"{wa_url}{wa_ak}{ws_url_ver}{wa_api_key}"
|
1530 |
-
payload = {"phoneNumber": phone_number}
|
1531 |
-
headers = {'Content-Type': 'application/json'}
|
1532 |
-
|
1533 |
-
logging.debug(f"Sending request to {full_url_ver} with payload: {payload}")
|
1534 |
-
|
1535 |
-
response = requests.post(full_url_ver, headers=headers, json=payload)
|
1536 |
-
|
1537 |
-
if response.status_code == 200:
|
1538 |
-
response_body = response.json()
|
1539 |
-
logging.debug(f"Response from API: {response_body}")
|
1540 |
-
return response_body.get('existsWhatsapp', 'false')
|
1541 |
-
else:
|
1542 |
-
logging.error(f"API request failed with status code {response.status_code}: {response.text}")
|
1543 |
-
return "Error"
|
1544 |
-
|
1545 |
-
def add_or_update_contact_v2(contact_data):
|
1546 |
conn = sqlite3.connect(DATABASE_NAME3)
|
1547 |
cursor = conn.cursor()
|
1548 |
|
@@ -1583,6 +1566,8 @@ def add_or_update_contact_v2(contact_data):
|
|
1583 |
conn.commit()
|
1584 |
conn.close()
|
1585 |
|
|
|
|
|
1586 |
@app.route('/add_data_ver_cur', methods=['GET'])
|
1587 |
def add_data_ver_cur():
|
1588 |
global current_curator_index
|
@@ -1606,17 +1591,17 @@ def add_data_ver_cur():
|
|
1606 |
logging.error("Phone number is empty")
|
1607 |
return jsonify({'status': 'error', 'message': 'Phone number is empty'}), 400
|
1608 |
|
1609 |
-
phone_verification_response =
|
1610 |
if phone_verification_response is not None:
|
1611 |
user_data['ws_st'] = phone_verification_response
|
1612 |
|
1613 |
try:
|
1614 |
-
|
1615 |
if curator_on_off == "1":
|
1616 |
current_curator_index = (current_curator_index + 1) % len(curators)
|
1617 |
|
1618 |
# Отправка данных в Google Forms
|
1619 |
-
|
1620 |
|
1621 |
return jsonify({'status': 'success', 'message': f'User added with curator {user_data.get("curator", "not assigned")}'})
|
1622 |
except Exception as e:
|
|
|
1525 |
|
1526 |
DATABASE_NAME3 = 'data_gc.db'
|
1527 |
|
1528 |
+
def add_or_update_contact(contact_data):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1529 |
conn = sqlite3.connect(DATABASE_NAME3)
|
1530 |
cursor = conn.cursor()
|
1531 |
|
|
|
1566 |
conn.commit()
|
1567 |
conn.close()
|
1568 |
|
1569 |
+
|
1570 |
+
|
1571 |
@app.route('/add_data_ver_cur', methods=['GET'])
|
1572 |
def add_data_ver_cur():
|
1573 |
global current_curator_index
|
|
|
1591 |
logging.error("Phone number is empty")
|
1592 |
return jsonify({'status': 'error', 'message': 'Phone number is empty'}), 400
|
1593 |
|
1594 |
+
phone_verification_response = verify_phone_number(phone_number)
|
1595 |
if phone_verification_response is not None:
|
1596 |
user_data['ws_st'] = phone_verification_response
|
1597 |
|
1598 |
try:
|
1599 |
+
add_or_update_contact(user_data)
|
1600 |
if curator_on_off == "1":
|
1601 |
current_curator_index = (current_curator_index + 1) % len(curators)
|
1602 |
|
1603 |
# Отправка данных в Google Forms
|
1604 |
+
send_to_google_forms(user_data, gog_url)
|
1605 |
|
1606 |
return jsonify({'status': 'success', 'message': f'User added with curator {user_data.get("curator", "not assigned")}'})
|
1607 |
except Exception as e:
|