mirror of https://gitlab.com/litecord/litecord.git
admin_api.guilds: add PATCH /api/v6/admin/guilds/:id
currently does not do anything else other than updating and returning the guild, as we don't store the availability of it on the database as of rn.
This commit is contained in:
parent
36ad9db0ef
commit
3dc2e01c28
|
|
@ -132,6 +132,17 @@ Returns empty body with 204 status code on success.
|
|||
|
||||
Returns a partial guild object.
|
||||
|
||||
### PATCH `/guilds/<guild_id>`
|
||||
|
||||
Update a single guild.
|
||||
|
||||
Dispatches `GUILD_UPDATE` to subscribers of the guild, returns the guild object
|
||||
on success.
|
||||
|
||||
| field | type | description |
|
||||
| --: | :-- | :-- |
|
||||
| unavailable | bool | if the guild is unavailable |
|
||||
|
||||
## Guild features
|
||||
|
||||
The currently supported features are:
|
||||
|
|
|
|||
|
|
@ -50,3 +50,7 @@ USER_CREATE = {
|
|||
INSTANCE_INVITE = {
|
||||
'max_uses': {'type': 'integer', 'required': True}
|
||||
}
|
||||
|
||||
GUILD_UPDATE = {
|
||||
'unavailable': {'type': 'boolean', 'required': False}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,9 +17,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
|
||||
"""
|
||||
|
||||
from quart import Blueprint, jsonify, current_app as app
|
||||
from quart import Blueprint, jsonify, current_app as app, request
|
||||
|
||||
from litecord.auth import admin_check
|
||||
# from litecord.schemas import validate
|
||||
# from litecord.admin_schemas import GUILD_UPDATE
|
||||
|
||||
bp = Blueprint('guilds_admin', __name__)
|
||||
|
||||
|
|
@ -31,3 +33,17 @@ async def get_guild(guild_id: int):
|
|||
return jsonify(
|
||||
await app.storage.get_guild(guild_id)
|
||||
)
|
||||
|
||||
@bp.route('/<int:guild_id>', methods=['PATCH'])
|
||||
async def update_guild(guild_id: int):
|
||||
await admin_check()
|
||||
|
||||
# j = validate(await request.get_json(), GUILD_UPDATE)
|
||||
|
||||
# TODO: add guild availability update, we don't store it, should we?
|
||||
# TODO: what happens to the other guild attributes when its
|
||||
# unavailable? do they vanish?
|
||||
|
||||
guild = await app.storage.get_guild(guild_id)
|
||||
await app.dispatcher.dispatch_guild(guild_id, 'GUILD_UPDATE', guild)
|
||||
return jsonify(guild)
|
||||
|
|
|
|||
Loading…
Reference in New Issue