From e8c158da8167fd464175475c214b677ff6db1e37 Mon Sep 17 00:00:00 2001 From: Luna Date: Mon, 18 Mar 2019 04:54:23 -0300 Subject: [PATCH] add 15_drop_nullable_webhook_avatar.sql - webhooks: quickfix to webhook_check --- litecord/blueprints/webhooks.py | 2 +- .../cmd/migration/scripts/15_drop_nullable_webhook_avatar.sql | 2 ++ schema.sql | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) create mode 100644 manage/cmd/migration/scripts/15_drop_nullable_webhook_avatar.sql diff --git a/litecord/blueprints/webhooks.py b/litecord/blueprints/webhooks.py index 36a686f..9db64fa 100644 --- a/litecord/blueprints/webhooks.py +++ b/litecord/blueprints/webhooks.py @@ -73,7 +73,7 @@ async def get_webhook(webhook_id: int, *, async def _webhook_check(channel_id): user_id = await token_check() - await channel_check(user_id, channel_id, ChannelType.GUILD_TEXT) + await channel_check(user_id, channel_id, only=ChannelType.GUILD_TEXT) await channel_perm_check(user_id, channel_id, 'manage_webhooks') return user_id diff --git a/manage/cmd/migration/scripts/15_drop_nullable_webhook_avatar.sql b/manage/cmd/migration/scripts/15_drop_nullable_webhook_avatar.sql new file mode 100644 index 0000000..a6e110f --- /dev/null +++ b/manage/cmd/migration/scripts/15_drop_nullable_webhook_avatar.sql @@ -0,0 +1,2 @@ +ALTER TABLE webhooks ALTER COLUMN avatar DROP NOT NULL; +ALTER TABLE webhooks ALTER COLUMN avatar SET DEFAULT NULL; diff --git a/schema.sql b/schema.sql index 32fa564..6437028 100644 --- a/schema.sql +++ b/schema.sql @@ -542,7 +542,7 @@ CREATE TABLE IF NOT EXISTS webhooks ( creator_id bigint REFERENCES users (id), name text NOT NULL, - avatar text NOT NULL, + avatar text DEFAULT NULL, -- Yes, we store the webhook's token -- since they aren't users and there's no /api/login for them.