Fix datetime import and add database migration script

This commit is contained in:
2026-02-16 20:21:07 -06:00
parent 35f51e6d27
commit 6e875186b4
2 changed files with 97 additions and 3 deletions

View File

@@ -5,6 +5,7 @@ api/routes/snitch.py - API endpoints for snitch system
import flask
import jwt
import os
from datetime import datetime
import core.postgres as postgres
import core.snitch as snitch_core
@@ -85,7 +86,7 @@ def register(app):
"require_consent": data.get("require_consent", True),
"consent_given": data.get("consent_given", False),
"snitch_cooldown_hours": data.get("snitch_cooldown_hours", 4),
"updated_at": flask.datetime.utcnow(),
"updated_at": datetime.utcnow(),
}
# Check if settings exist
@@ -95,7 +96,7 @@ def register(app):
postgres.update("snitch_settings", update_data, {"user_uuid": user_uuid})
else:
update_data["user_uuid"] = user_uuid
update_data["created_at"] = flask.datetime.utcnow()
update_data["created_at"] = datetime.utcnow()
postgres.insert("snitch_settings", update_data)
return flask.jsonify({"success": True}), 200
@@ -167,7 +168,7 @@ def register(app):
"priority": data.get("priority", 1),
"notify_all": data.get("notify_all", False),
"is_active": data.get("is_active", True),
"created_at": flask.datetime.utcnow(),
"created_at": datetime.utcnow(),
}
result = postgres.insert("snitch_contacts", contact_data)