twilio small cleanup
This commit is contained in:
@@ -32,7 +32,7 @@ def send_alert_sms(to_phone: str, room_title: str, room_link: str = None, client
|
||||
|
||||
# --- BUILD SMS CONTENT ---
|
||||
body = (
|
||||
f"Alert: A technical issue occurred with your equipment/microwave. "
|
||||
f"Alert: A technical issue occurred with your SmartWave equipment/microwave. "
|
||||
f"A support chat room '{room_title}' has been created to assist you.\n\n"
|
||||
)
|
||||
|
||||
|
||||
+10
-9
@@ -214,6 +214,8 @@ def alert():
|
||||
room_title = f"Support - {client_name}"
|
||||
room_link = None
|
||||
webex_status = "skipped"
|
||||
# --- TWILIO SMS LOGIC ---
|
||||
sms_sent = False
|
||||
|
||||
three_minutes_ago = datetime.now(timezone.utc) - timedelta(minutes=3)
|
||||
|
||||
@@ -265,16 +267,8 @@ def alert():
|
||||
current_app.logger.exception("Failed to create Webex support room")
|
||||
webex_status = f"creation_failed: {str(e)}"
|
||||
|
||||
# Update document with room details
|
||||
if webex_room_id:
|
||||
alert_collection.update_one(
|
||||
{"_id": saved_alert.inserted_id},
|
||||
{"$set": {"webex_room_id": webex_room_id, "webex_room_title": room_title, "webex_room_link": room_link}}
|
||||
)
|
||||
|
||||
# --- SEND SMS ---
|
||||
sms_sent = False
|
||||
if client_phone and not SAVEUP_TWILIO_API_TOKEN:
|
||||
if webex_room_id and client_phone and not SAVEUP_TWILIO_API_TOKEN:
|
||||
sms_sent = send_alert_sms(
|
||||
to_phone=client_phone,
|
||||
room_title=room_title,
|
||||
@@ -282,6 +276,13 @@ def alert():
|
||||
client_email=client_email
|
||||
)
|
||||
|
||||
# Update document with room and sms details
|
||||
if webex_room_id:
|
||||
alert_collection.update_one(
|
||||
{"_id": saved_alert.inserted_id},
|
||||
{"$set": {"webex_room_id": webex_room_id, "webex_room_title": room_title, "webex_room_link": room_link, "sms_sent": sms_sent}}
|
||||
)
|
||||
else: # Just save the sms
|
||||
alert_collection.update_one(
|
||||
{"_id": saved_alert.inserted_id},
|
||||
{"$set": {"sms_sent": sms_sent}}
|
||||
|
||||
Reference in New Issue
Block a user