diff --git a/api/routes/snitch.py b/api/routes/snitch.py index 8c72316..b38a731 100644 --- a/api/routes/snitch.py +++ b/api/routes/snitch.py @@ -275,22 +275,22 @@ def register(app): 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!" - # Send to the contact (not the current user) - if contact.get("contact_type") == "discord": - # For Discord, we need the bot to send the DM - # Store in a queue for the bot to pick up - # For now, return success but note it requires bot implementation - return flask.jsonify( - { - "success": True, - "message": f"Test queued for {contact.get('contact_name')} (Discord: {contact.get('contact_value')}). Note: Actual Discord DM delivery requires bot implementation.", - } - ) - else: - # For email/SMS, would use external providers - return flask.jsonify( - { - "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.", - } - ), 200 + # Insert into snitch_log so the bot will pick it up and send it + log_data = { + "user_uuid": user_uuid, + "contact_id": contact.get("id"), + "medication_id": None, # Test snitch, no actual medication + "trigger_reason": "test", + "snitch_count_today": 1, + "message_content": test_message, + "sent_at": datetime.utcnow(), + "delivered": False, # Bot will pick this up and send it + } + postgres.insert("snitch_log", log_data) + + return flask.jsonify( + { + "success": True, + "message": f"✅ Test snitch sent to {contact.get('contact_name')}! Check their Discord DMs in the next 30 seconds.", + } + ), 200