Compare commits

..

No commits in common. "51138c9d505b920f42dfcad85dc216a7f2f714c7" and "001cf43cd70a063ae17c2b0248ffc96f9afbe4e4" have entirely different histories.

4 changed files with 14 additions and 17 deletions

View File

@ -1,5 +1,5 @@
[tool.bumpversion] [tool.bumpversion]
current_version = "1.2.13" current_version = "1.2.12"
commit = true commit = true
tag = true tag = true
tag_name = "{new_version}" tag_name = "{new_version}"

View File

@ -1 +1 @@
1.2.13 1.2.12

View File

@ -222,18 +222,14 @@ def save_push_subscription(user_id: int, subscription_json: str) -> None:
_execute_query(query, params) _execute_query(query, params)
def get_push_subscriptions(user_id: Optional[int] = None) -> List[Dict[str, Any]]: def get_push_subscriptions(user_id: int) -> List[Dict[str, Any]]:
"""Retrieves all push subscriptions for a given user ID, or all if no user_id is provided. """Retrieves all push subscriptions for a given user ID.
Args: Args:
user_id: The ID of the user (optional). user_id: The ID of the user.
Returns: Returns:
A list of push subscriptions. A list of push subscriptions.
""" """
if user_id:
query = "SELECT * FROM push_subscriptions WHERE user_id = %s" query = "SELECT * FROM push_subscriptions WHERE user_id = %s"
return _execute_query(query, (user_id,)) return _execute_query(query, (user_id,))
else:
query = "SELECT * FROM push_subscriptions"
return _execute_query(query)

View File

@ -223,15 +223,16 @@ def send_expiry_notifications_route(username: str, password: str) -> Response:
@api_blueprint.route("/send-test-notification", methods=["POST"]) @api_blueprint.route("/send-test-notification", methods=["POST"])
@requires_basic_auth @requires_basic_auth
def send_test_notification_route(username: str, password: str) -> Response: def send_test_notification_route(username: str, password: str) -> Response:
"""Sends a test push notification to all users.""" """Sends a test push notification to the user."""
data = request.get_json() user_id = get_user_id_from_username(username)
message = data.get("message", "Ktv Test") if data else "Ktv Test" if not user_id:
return jsonify({"message": "User not found"}), 404
subscriptions = get_push_subscriptions() # Get all subscriptions subscriptions = get_push_subscriptions(user_id)
if not subscriptions: if not subscriptions:
return jsonify({"message": "No push subscriptions found."}), 404 return jsonify({"message": "No push subscriptions found for this user."}), 404
message_body = json.dumps({"title": "KTVManager", "body": message}) message_body = json.dumps({"title": "Test Notification", "body": "This is a test notification."})
for sub in subscriptions: for sub in subscriptions:
try: try: