Fix snitch test to actually insert a log entry that the bot will send
This commit is contained in:
@@ -275,22 +275,22 @@ def register(app):
|
|||||||
contact = contacts[0]
|
contact = contacts[0]
|
||||||
test_message = f"🧪 This is a test snitch notification for {contact.get('contact_name')}. If you're receiving this, the snitch system is working!"
|
test_message = f"🧪 This is a test snitch notification for {contact.get('contact_name')}. If you're receiving this, the snitch system is working!"
|
||||||
|
|
||||||
# Send to the contact (not the current user)
|
# Insert into snitch_log so the bot will pick it up and send it
|
||||||
if contact.get("contact_type") == "discord":
|
log_data = {
|
||||||
# For Discord, we need the bot to send the DM
|
"user_uuid": user_uuid,
|
||||||
# Store in a queue for the bot to pick up
|
"contact_id": contact.get("id"),
|
||||||
# For now, return success but note it requires bot implementation
|
"medication_id": None, # Test snitch, no actual medication
|
||||||
return flask.jsonify(
|
"trigger_reason": "test",
|
||||||
{
|
"snitch_count_today": 1,
|
||||||
"success": True,
|
"message_content": test_message,
|
||||||
"message": f"Test queued for {contact.get('contact_name')} (Discord: {contact.get('contact_value')}). Note: Actual Discord DM delivery requires bot implementation.",
|
"sent_at": datetime.utcnow(),
|
||||||
}
|
"delivered": False, # Bot will pick this up and send it
|
||||||
)
|
}
|
||||||
else:
|
postgres.insert("snitch_log", log_data)
|
||||||
# For email/SMS, would use external providers
|
|
||||||
return flask.jsonify(
|
return flask.jsonify(
|
||||||
{
|
{
|
||||||
"success": True,
|
"success": True,
|
||||||
"message": f"Test configured for {contact.get('contact_name')} via {contact.get('contact_type')}. Note: {contact.get('contact_type')} delivery requires external provider setup.",
|
"message": f"✅ Test snitch sent to {contact.get('contact_name')}! Check their Discord DMs in the next 30 seconds.",
|
||||||
}
|
}
|
||||||
), 200
|
), 200
|
||||||
|
|||||||
Reference in New Issue
Block a user