Compare commits
2 Commits
950da26958
...
001cf43cd7
Author | SHA1 | Date | |
---|---|---|---|
001cf43cd7 | |||
c3ab41dd6a |
@ -1,5 +1,5 @@
|
||||
[tool.bumpversion]
|
||||
current_version = "1.2.11"
|
||||
current_version = "1.2.12"
|
||||
commit = true
|
||||
tag = true
|
||||
tag_name = "{new_version}"
|
||||
|
@ -217,4 +217,27 @@ def send_expiry_notifications_route(username: str, password: str) -> Response:
|
||||
"""
|
||||
from ktvmanager.account_checker import send_expiry_notifications
|
||||
send_expiry_notifications()
|
||||
return jsonify({"message": "Expiry notifications sent."})
|
||||
return jsonify({"message": "Expiry notifications sent."})
|
||||
|
||||
|
||||
@api_blueprint.route("/send-test-notification", methods=["POST"])
|
||||
@requires_basic_auth
|
||||
def send_test_notification_route(username: str, password: str) -> Response:
|
||||
"""Sends a test push notification to the user."""
|
||||
user_id = get_user_id_from_username(username)
|
||||
if not user_id:
|
||||
return jsonify({"message": "User not found"}), 404
|
||||
|
||||
subscriptions = get_push_subscriptions(user_id)
|
||||
if not subscriptions:
|
||||
return jsonify({"message": "No push subscriptions found for this user."}), 404
|
||||
|
||||
message_body = json.dumps({"title": "Test Notification", "body": "This is a test notification."})
|
||||
|
||||
for sub in subscriptions:
|
||||
try:
|
||||
send_notification(json.loads(sub['subscription_json']), message_body)
|
||||
except Exception as e:
|
||||
print(f"Error sending notification to subscription ID {sub.get('id', 'N/A')}: {e}")
|
||||
|
||||
return jsonify({"message": f"Test notification sent to {len(subscriptions)} subscription(s)."})
|
Loading…
x
Reference in New Issue
Block a user