mirror of
https://github.com/hubHarmony/servii-backend.git
synced 2024-11-17 21:40:31 +00:00
commit
3f154b93e4
1
app.py
1
app.py
@ -90,6 +90,7 @@ route_handlers = {
|
|||||||
'SetSubdomain': generic_executor.set_subdomain,
|
'SetSubdomain': generic_executor.set_subdomain,
|
||||||
'FetchServers': generic_executor.fetch_servers,
|
'FetchServers': generic_executor.fetch_servers,
|
||||||
'FetchLogs': generic_executor.fetch_logs,
|
'FetchLogs': generic_executor.fetch_logs,
|
||||||
|
'FetchFilenames': generic_executor.fetch_players_status,
|
||||||
'FetchHistory': generic_executor.fetch_history,
|
'FetchHistory': generic_executor.fetch_history,
|
||||||
'FetchPlayersStatus': generic_executor.fetch_players_status,
|
'FetchPlayersStatus': generic_executor.fetch_players_status,
|
||||||
'AccountCreate': generic_executor.account_create,
|
'AccountCreate': generic_executor.account_create,
|
||||||
|
@ -120,6 +120,37 @@ def fetch_players_status(user: UserRecord, name: str) -> tuple[HTTPStatus, Union
|
|||||||
file_manager.log_error(type(e).__name__, str(e))
|
file_manager.log_error(type(e).__name__, str(e))
|
||||||
return HTTPStatus.INTERNAL_SERVER_ERROR, "Unknown error."
|
return HTTPStatus.INTERNAL_SERVER_ERROR, "Unknown error."
|
||||||
|
|
||||||
|
def fetch_file_names(user: UserRecord, name: str) -> tuple[HTTPStatus, Union[dict[str, list[str]], str]]:
|
||||||
|
user_id: str = user.uid
|
||||||
|
server_path: str = f"users/{user_id}/{name}"
|
||||||
|
plugins_dir: str = f"{server_path}/plugins"
|
||||||
|
datapacks_dir: str = f"{server_path}/world/datapacks"
|
||||||
|
|
||||||
|
file_names = {
|
||||||
|
"plugins": [],
|
||||||
|
"datapacks": []
|
||||||
|
}
|
||||||
|
|
||||||
|
try:
|
||||||
|
#plugins
|
||||||
|
if os.path.exists(plugins_dir):
|
||||||
|
file_names["plugins"] = os.listdir(plugins_dir)
|
||||||
|
else:
|
||||||
|
return HTTPStatus.NOT_FOUND, f"Plugins directory not found for server '{name}'."
|
||||||
|
|
||||||
|
#datapacks
|
||||||
|
if os.path.exists(datapacks_dir):
|
||||||
|
file_names["datapacks"] = os.listdir(datapacks_dir)
|
||||||
|
else:
|
||||||
|
return HTTPStatus.NOT_FOUND, f"Datapacks directory not found for server '{name}'."
|
||||||
|
|
||||||
|
return HTTPStatus.OK, file_names
|
||||||
|
|
||||||
|
except Exception as e:
|
||||||
|
file_manager.log_error(type(e).__name__, str(e))
|
||||||
|
return HTTPStatus.INTERNAL_SERVER_ERROR, f"Error fetching file names: {str(e)}"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def account_create(user: UserRecord) -> tuple[HTTPStatus, Union[str, None]]:
|
def account_create(user: UserRecord) -> tuple[HTTPStatus, Union[str, None]]:
|
||||||
if firebase_manager.user_field_exists(user.uid):
|
if firebase_manager.user_field_exists(user.uid):
|
||||||
|
Loading…
Reference in New Issue
Block a user