diff --git a/litecord/blueprints/admin_api/__init__.py b/litecord/blueprints/admin_api/__init__.py index d209cf9..32710ce 100644 --- a/litecord/blueprints/admin_api/__init__.py +++ b/litecord/blueprints/admin_api/__init__.py @@ -18,5 +18,7 @@ along with this program. If not, see . """ from .voice import bp as voice +from .features import bp as features +from .guilds import bp as guilds -__all__ = ['voice'] +__all__ = ['voice', 'features', 'guilds'] diff --git a/litecord/blueprints/admin_api/features.py b/litecord/blueprints/admin_api/features.py new file mode 100644 index 0000000..ca14309 --- /dev/null +++ b/litecord/blueprints/admin_api/features.py @@ -0,0 +1,49 @@ +""" + +Litecord +Copyright (C) 2018-2019 Luna Mendes + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, version 3 of the License. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . + +""" + +from quart import Blueprint, current_app as app + +from litecord.auth import admin_check +from litecord.errors import BadRequest + +bp = Blueprint('features_admin', __name__) + +FEATURES = [ + '' +] + +@bp.route('//', methods=['PUT']) +async def insert_feature(guild_id: int, feature: str): + """Insert a feature on a guild.""" + await admin_check() + + # TODO + if feature not in FEATURES: + raise BadRequest('invalid feature') + + return '', 204 + + +@bp.route('//', methods=['DELETE']) +async def remove_feature(guild_id: int, feature: str): + """Remove a feature from a guild""" + await admin_check() + # TODO + await app.db + return '', 204 diff --git a/litecord/blueprints/admin_api/guilds.py b/litecord/blueprints/admin_api/guilds.py new file mode 100644 index 0000000..d779c02 --- /dev/null +++ b/litecord/blueprints/admin_api/guilds.py @@ -0,0 +1,33 @@ +""" + +Litecord +Copyright (C) 2018-2019 Luna Mendes + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, version 3 of the License. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . + +""" + +from quart import Blueprint, jsonify, current_app as app + +from litecord.auth import admin_check + +bp = Blueprint('guilds_admin', __name__) + +@bp.route('/', methods=['GET']) +async def get_guild(guild_id: int): + """Get a basic guild payload.""" + await admin_check() + + return jsonify( + await app.storage.get_guild(guild_id) + ) diff --git a/run.py b/run.py index 398896d..8441f28 100644 --- a/run.py +++ b/run.py @@ -57,7 +57,8 @@ from litecord.blueprints.user import ( from litecord.blueprints.user.billing_job import payment_job from litecord.blueprints.admin_api import ( - voice as voice_admin + voice as voice_admin, features as features_admin, + guilds as guilds_admin ) from litecord.blueprints.admin_api.voice import guild_region_check @@ -143,7 +144,9 @@ def set_blueprints(app_): nodeinfo: -1, static: -1, - voice_admin: '/admin/voice' + voice_admin: '/admin/voice', + features_admin: '/admin/features', + guilds_admin: '/admin/guilds' } for bp, suffix in bps.items():