mirror of
https://github.com/hubHarmony/servii-backend.git
synced 2024-11-17 21:40:31 +00:00
[+] Reordered generic_executor.py
This commit is contained in:
parent
1b1df35a14
commit
315acec4a2
@ -139,9 +139,29 @@ def account_create(user: UserRecord) -> tuple[HTTPStatus, Union[str, None]]:
|
||||
return HTTPStatus.INTERNAL_SERVER_ERROR, "Error creating account."
|
||||
|
||||
|
||||
allowed_frameworks: list[str] = ["paper", "spigot", "bukkit"]
|
||||
def account_delete(user: UserRecord) -> tuple[HTTPStatus, Union[str, None]]:
|
||||
user_id = user.uid
|
||||
try:
|
||||
dns_record_id = firebase_manager.get_user_field(user_id, "cloudflare_entry")
|
||||
if dns_record_id is None:
|
||||
return HTTPStatus.IM_A_TEAPOT, "Cloudflare 'dns_record_id' not found in Firestore."
|
||||
cloudflare_manager.delete_cloudflare_dns(dns_record_id)
|
||||
except Exception as e:
|
||||
return HTTPStatus.NOT_MODIFIED, f"Account deletion failed. {str(e)}"
|
||||
try:
|
||||
firebase_manager.delete_user(user_id)
|
||||
except Exception as e:
|
||||
return HTTPStatus.EXPECTATION_FAILED, f"Database deletion failed | {e}"
|
||||
try:
|
||||
file_manager.delete_non_empty_folder("users/" + user_id)
|
||||
return HTTPStatus.OK, f"Successfully deleted user '{user_id}'."
|
||||
except Exception as e:
|
||||
file_manager.log_error(type(e).__name__, str(e))
|
||||
return HTTPStatus.INTERNAL_SERVER_ERROR, f"Error deleting user '{user_id}' on the server."
|
||||
|
||||
|
||||
allowed_frameworks: list[str] = ["paper", "spigot", "bukkit"]
|
||||
|
||||
def server_create(user: UserRecord, name: str, version: str, framework: str = "paper") -> (
|
||||
tuple)[HTTPStatus, Union[str, None]]:
|
||||
if framework not in allowed_frameworks:
|
||||
@ -191,27 +211,6 @@ def server_delete(name: str, user: UserRecord) -> tuple[HTTPStatus, Union[str, N
|
||||
return HTTPStatus.INTERNAL_SERVER_ERROR, None
|
||||
|
||||
|
||||
def account_delete(user: UserRecord) -> tuple[HTTPStatus, Union[str, None]]:
|
||||
user_id = user.uid
|
||||
try:
|
||||
dns_record_id = firebase_manager.get_user_field(user_id, "cloudflare_entry")
|
||||
if dns_record_id is None:
|
||||
return HTTPStatus.IM_A_TEAPOT, "Cloudflare 'dns_record_id' not found in Firestore."
|
||||
cloudflare_manager.delete_cloudflare_dns(dns_record_id)
|
||||
except Exception as e:
|
||||
return HTTPStatus.NOT_MODIFIED, f"Account deletion failed. {str(e)}"
|
||||
try:
|
||||
firebase_manager.delete_user(user_id)
|
||||
except Exception as e:
|
||||
return HTTPStatus.EXPECTATION_FAILED, f"Database deletion failed | {e}"
|
||||
try:
|
||||
file_manager.delete_non_empty_folder("users/" + user_id)
|
||||
return HTTPStatus.OK, f"Successfully deleted user '{user_id}'."
|
||||
except Exception as e:
|
||||
file_manager.log_error(type(e).__name__, str(e))
|
||||
return HTTPStatus.INTERNAL_SERVER_ERROR, f"Error deleting user '{user_id}' on the server."
|
||||
|
||||
|
||||
def server_run(user: UserRecord, name: str) -> tuple[HTTPStatus, Union[str, None]]:
|
||||
user_id = user.uid
|
||||
mc_manager.set_cooldown(user_id=user_id)
|
||||
|
Loading…
Reference in New Issue
Block a user