diff --git a/app/classes/web/routes/api/api_handlers.py b/app/classes/web/routes/api/api_handlers.py index 3eb159b8..43d21d08 100644 --- a/app/classes/web/routes/api/api_handlers.py +++ b/app/classes/web/routes/api/api_handlers.py @@ -50,6 +50,7 @@ from app.classes.web.routes.api.users.user.permissions import ( from app.classes.web.routes.api.users.user.pfp import ApiUsersUserPfpHandler from app.classes.web.routes.api.users.user.public import ApiUsersUserPublicHandler from app.classes.web.routes.api.crafty.config.index import ApiCraftyConfigIndexHandler +from app.classes.web.routes.api.crafty.clogs.index import ApiCraftyLogIndexHandler def api_handlers(handler_args): @@ -70,6 +71,11 @@ def api_handlers(handler_args): ApiCraftyConfigIndexHandler, handler_args, ), + ( + r"/api/v2/crafty/logs/([a-z0-9_]+)/?", + ApiCraftyLogIndexHandler, + handler_args, + ), # User routes ( r"/api/v2/users/?", diff --git a/app/classes/web/routes/api/crafty/clogs/index.py b/app/classes/web/routes/api/crafty/clogs/index.py new file mode 100644 index 00000000..97a24a34 --- /dev/null +++ b/app/classes/web/routes/api/crafty/clogs/index.py @@ -0,0 +1,34 @@ +from app.classes.web.base_api_handler import BaseApiHandler + + +class ApiCraftyLogIndexHandler(BaseApiHandler): + def get(self, log_type: str): + auth_data = self.authenticate_user() + if not auth_data: + return + ( + _, + _, + _, + superuser, + _, + ) = auth_data + + if not superuser: + return self.finish_json(400, {"status": "error", "error": "NOT_AUTHORIZED"}) + + log_types = ["audit", "session", "schedule"] + if log_type not in log_types: + raise NotImplementedError + + if log_type == "audit": + return self.finish_json( + 200, + {"status": "ok", "data": self.controller.management.get_activity_log()}, + ) + + if log_type == "session": + raise NotImplementedError + + if log_type == "schedule": + raise NotImplementedError