Fix snitch test to not send to wrong user, implement Discord DM sending for snitches

This commit is contained in:
2026-02-16 21:16:33 -06:00
parent 1d79516794
commit 98706702da
2 changed files with 72 additions and 12 deletions

View File

@@ -275,20 +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!"
# Use notification system for test
import core.notifications as notifications
user_settings = notifications.getNotificationSettings(user_uuid)
if user_settings:
notifications._sendToEnabledChannels(
user_settings, test_message, user_uuid=user_uuid
)
# 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 sent to {contact.get('contact_name')} via {contact.get('contact_type')}",
"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
else:
return flask.jsonify({"error": "No notification settings configured"}), 400