update stream url if its changed
This commit is contained in:
parent
900d3c1cfe
commit
796acd1b4e
2
.vscode/settings.json
vendored
2
.vscode/settings.json
vendored
@ -1,6 +1,6 @@
|
||||
{
|
||||
"[python]": {
|
||||
"editor.defaultFormatter": "ms-python.black-formatter"
|
||||
"editor.defaultFormatter": "mikoz.black-py"
|
||||
},
|
||||
"python.formatting.provider": "none"
|
||||
}
|
@ -88,6 +88,7 @@ def validate_account() -> Tuple[Response, int]:
|
||||
password = data.get("password")
|
||||
expiry_date = data.get("expiry_date")
|
||||
stream = data.get("stream")
|
||||
stream_url = data.get("streamURL")
|
||||
|
||||
if not all([username, password]):
|
||||
return jsonify({"message": "Missing required fields"}), 400
|
||||
@ -97,19 +98,45 @@ def validate_account() -> Tuple[Response, int]:
|
||||
result = single_account_check(account_data, stream_urls)
|
||||
|
||||
if result:
|
||||
if expiry_date and stream and int(result["data"]["user_info"]["exp_date"]) != expiry_date:
|
||||
if result["url"] != stream_url:
|
||||
from ktvmanager.lib.database import update_stream_url
|
||||
|
||||
update_stream_url(result["url"], stream_url)
|
||||
return (
|
||||
jsonify({"message": "Account is valid and updated", "data": result}),
|
||||
200,
|
||||
)
|
||||
|
||||
if (
|
||||
expiry_date
|
||||
and stream
|
||||
and int(result["data"]["user_info"]["exp_date"]) != expiry_date
|
||||
):
|
||||
from ktvmanager.lib.database import update_expiry_date
|
||||
|
||||
update_expiry_date(
|
||||
username, stream, result["data"]["user_info"]["exp_date"]
|
||||
)
|
||||
return jsonify({"message": "Account is valid and updated", "data": result}), 200
|
||||
return (
|
||||
jsonify({"message": "Account is valid and updated", "data": result}),
|
||||
200,
|
||||
)
|
||||
|
||||
if int(result.get("data", {}).get("user_info", {}).get("max_connections")) and data.get("max_connections") and int(result["data"]["user_info"]["max_connections"]) != data.get("max_connections"):
|
||||
if (
|
||||
int(result.get("data", {}).get("user_info", {}).get("max_connections"))
|
||||
and data.get("max_connections")
|
||||
and int(result["data"]["user_info"]["max_connections"])
|
||||
!= data.get("max_connections")
|
||||
):
|
||||
from ktvmanager.lib.database import update_max_connections
|
||||
|
||||
update_max_connections(
|
||||
username, stream, int(result["data"]["user_info"]["max_connections"])
|
||||
)
|
||||
return jsonify({"message": "Account is valid and updated", "data": result}), 200
|
||||
return (
|
||||
jsonify({"message": "Account is valid and updated", "data": result}),
|
||||
200,
|
||||
)
|
||||
|
||||
return jsonify({"message": "Account is valid", "data": result}), 200
|
||||
else:
|
||||
|
@ -167,6 +167,18 @@ def update_max_connections(username: str, stream: str, max_connections: int) ->
|
||||
_execute_query(query, params)
|
||||
|
||||
|
||||
def update_stream_url(new_stream: str, old_stream: str) -> None:
|
||||
"""Updates the stream URL of an account.
|
||||
|
||||
Args:
|
||||
new_stream: The stream of the account.
|
||||
old_stream: The new stream URL.
|
||||
"""
|
||||
query = "UPDATE userAccounts SET streamURL = %s WHERE streamURL = %s"
|
||||
params = (new_stream, old_stream)
|
||||
_execute_query(query, params)
|
||||
|
||||
|
||||
def delete_account(user_id: int) -> Response:
|
||||
"""Deletes an account for a user.
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user