From 8b1e3fb06e181281dfe7997ec7d1ed4f6e0764e1 Mon Sep 17 00:00:00 2001 From: Visual Date: Mon, 30 Mar 2020 15:07:48 +0000 Subject: [PATCH 01/21] Fixed lazy channel reloading due to missing .bits. attribute --- litecord/common/guilds.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/litecord/common/guilds.py b/litecord/common/guilds.py index 25fe555..a45784d 100644 --- a/litecord/common/guilds.py +++ b/litecord/common/guilds.py @@ -158,7 +158,7 @@ async def _subscribe_users_new_channel(guild_id: int, channel_id: int) -> None: continue perms = await get_permissions(state.user_id, channel_id) - if perms.read_messages: + if perms.bits.read_messages: users_to_sub.append(state.user_id) for session_id in app.dispatcher.guild.state[guild_id]: From b098044a4b03463a6162efb4073a7ed42a3f3762 Mon Sep 17 00:00:00 2001 From: Visual Date: Mon, 30 Mar 2020 15:26:04 +0000 Subject: [PATCH 02/21] Fixed lazy role position updating due to not making sure that blacklisted id exists in state --- litecord/blueprints/guild/roles.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/litecord/blueprints/guild/roles.py b/litecord/blueprints/guild/roles.py index 1709756..ce39197 100644 --- a/litecord/blueprints/guild/roles.py +++ b/litecord/blueprints/guild/roles.py @@ -65,7 +65,7 @@ async def _role_update_dispatch(role_id: int, guild_id: int): """Dispatch a GUILD_ROLE_UPDATE with updated information on a role.""" role = await app.storage.get_role(role_id, guild_id) - await maybe_lazy_guild_dispatch(guild_id, "role_pos_upd", role) + await maybe_lazy_guild_dispatch(guild_id, "role_position_update", role) await app.dispatcher.guild.dispatch( guild_id, ("GUILD_ROLE_UPDATE", {"guild_id": str(guild_id), "role": role}) @@ -170,7 +170,8 @@ def gen_pairs( } for blacklisted_id in blacklist: - preferred_state.pop(blacklisted_id) + if blacklisted_id in preferred_state.keys(): + preferred_state.pop(blacklisted_id) # for each change, we must find a matching change # in the same list, so we can make a swap pair @@ -310,3 +311,4 @@ async def delete_guild_role(guild_id, role_id): ) return "", 204 + From 261753e399b5727664238ed9b216defba4ac6343 Mon Sep 17 00:00:00 2001 From: Visual Date: Mon, 30 Mar 2020 17:13:39 +0000 Subject: [PATCH 03/21] Removed and fixed broken checks --- litecord/images.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/litecord/images.py b/litecord/images.py index 6b01327..a28bd48 100644 --- a/litecord/images.py +++ b/litecord/images.py @@ -333,7 +333,7 @@ class IconManager: *args, ) - if not icon_row: + if icon_row is None: return None icon = Icon(icon_row["key"], icon_row["hash"], icon_row["mime"]) @@ -371,9 +371,6 @@ class IconManager: # get an extension for the given data uri extension = get_ext(mime) - if "bsize" in kwargs and len(raw_data) > kwargs["bsize"]: - return _invalid(kwargs) - # size management is different for gif files # as they're composed of multiple frames. if "size" in kwargs and mime == "image/gif": @@ -529,3 +526,4 @@ class IconManager: await self.delete(old_icon) return await self.put(scope, key, new_icon_data, **kwargs) + From 0eccf157505ec777f430e6ca9dff023b7bafeb39 Mon Sep 17 00:00:00 2001 From: Visual Date: Mon, 30 Mar 2020 17:14:43 +0000 Subject: [PATCH 04/21] Fixed broken check --- litecord/blueprints/icons.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/litecord/blueprints/icons.py b/litecord/blueprints/icons.py index a01509e..ef38700 100644 --- a/litecord/blueprints/icons.py +++ b/litecord/blueprints/icons.py @@ -31,7 +31,7 @@ async def send_icon(scope, key, icon_hash, **kwargs): """Send an icon.""" icon = await app.icons.generic_get(scope, key, icon_hash, **kwargs) - if not icon: + if icon is None: return "", 404 return await send_file(icon.as_path) @@ -44,8 +44,6 @@ def splitext_(filepath): @bp.route("/emojis/", methods=["GET"]) async def _get_raw_emoji(emoji_file): - # emoji = app.icons.get_emoji(emoji_id, ext=ext) - # just a test file for now emoji_id, ext = splitext_(emoji_file) return await send_icon("emoji", emoji_id, None, ext=ext) @@ -110,3 +108,4 @@ async def _get_guild_splash(guild_id: int, icon_file: str): async def _get_guild_banner(guild_id: int, icon_file: str): icon_hash, ext = splitext_(icon_file) return await send_icon("banner", guild_id, icon_hash, ext=ext) + From fdb2afcd3666428664612f1711d18ab1a35bd10d Mon Sep 17 00:00:00 2001 From: Visual Date: Mon, 30 Mar 2020 17:16:43 +0000 Subject: [PATCH 05/21] Fixed broken check & query --- litecord/blueprints/guild/emoji.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/litecord/blueprints/guild/emoji.py b/litecord/blueprints/guild/emoji.py index db53c07..9f6bcf2 100644 --- a/litecord/blueprints/guild/emoji.py +++ b/litecord/blueprints/guild/emoji.py @@ -105,7 +105,7 @@ async def _put_emoji(guild_id): size=(128, 128), ) - if not icon: + if icon is None: return "", 400 # TODO: better way to detect animated emoji rather than just gifs, @@ -172,10 +172,11 @@ async def _del_emoji(guild_id, emoji_id): await app.db.execute( """ DELETE FROM guild_emoji - WHERE id = $2 + WHERE id = $1 """, emoji_id, ) await _dispatch_emojis(guild_id) return "", 204 + From 83721d45258291abc22753e8f10cc9163a22e52b Mon Sep 17 00:00:00 2001 From: George Tsatsis Date: Mon, 30 Mar 2020 20:33:08 +0300 Subject: [PATCH 06/21] Fix server update problems (string where supposed to be int) --- litecord/blueprints/guilds.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/litecord/blueprints/guilds.py b/litecord/blueprints/guilds.py index 546fe01..ec331c6 100644 --- a/litecord/blueprints/guilds.py +++ b/litecord/blueprints/guilds.py @@ -346,7 +346,7 @@ async def _update_guild(guild_id): SET {field} = $1 WHERE id = $2 """, - j[field], + int(j[field]), guild_id, ) From 324cf6d4fac1cb0fb0f7e82a4843d1e321aee283 Mon Sep 17 00:00:00 2001 From: George Tsatsis Date: Mon, 30 Mar 2020 20:57:29 +0300 Subject: [PATCH 07/21] Create rules channel --- litecord/blueprints/guilds.py | 4 ++-- litecord/storage.py | 2 +- manage/cmd/migration/scripts/5_add_rules_channel_id.sql | 1 + 3 files changed, 4 insertions(+), 3 deletions(-) create mode 100644 manage/cmd/migration/scripts/5_add_rules_channel_id.sql diff --git a/litecord/blueprints/guilds.py b/litecord/blueprints/guilds.py index ec331c6..74ea3e8 100644 --- a/litecord/blueprints/guilds.py +++ b/litecord/blueprints/guilds.py @@ -316,9 +316,9 @@ async def _update_guild(guild_id): guild_id, ) - channel_fields = ["afk_channel_id", "system_channel_id"] + channel_fields = ["afk_channel_id", "system_channel_id", "rules_channel_id"] for field in [f for f in channel_fields if f in j]: - # setting to null should remove the link between the afk/sys channel + # setting to null should remove the link between the afk/sys/rules channel # to the guild. if j[field] is None: await app.db.execute( diff --git a/litecord/storage.py b/litecord/storage.py index 4c22980..8bf3586 100644 --- a/litecord/storage.py +++ b/litecord/storage.py @@ -201,7 +201,7 @@ class Storage: explicit_content_filter, mfa_level, embed_enabled, embed_channel_id::text, widget_enabled, widget_channel_id::text, - system_channel_id::text, features, + system_channel_id::text, rules_channel_id::text, features, banner, description FROM guilds WHERE guilds.id = $1 diff --git a/manage/cmd/migration/scripts/5_add_rules_channel_id.sql b/manage/cmd/migration/scripts/5_add_rules_channel_id.sql new file mode 100644 index 0000000..efb74bb --- /dev/null +++ b/manage/cmd/migration/scripts/5_add_rules_channel_id.sql @@ -0,0 +1 @@ +ALTER TABLE guilds ADD COLUMN rules_channel_id int \ No newline at end of file From 93958a0943f964ffc4a09e1b3e60a63d8149f64b Mon Sep 17 00:00:00 2001 From: George Tsatsis Date: Mon, 30 Mar 2020 21:02:20 +0300 Subject: [PATCH 08/21] add rules_channel_id to schemas --- litecord/schemas.py | 1 + 1 file changed, 1 insertion(+) diff --git a/litecord/schemas.py b/litecord/schemas.py index 1d65837..2e88661 100644 --- a/litecord/schemas.py +++ b/litecord/schemas.py @@ -292,6 +292,7 @@ GUILD_UPDATE = { "owner_id": {"type": "snowflake", "required": False}, "system_channel_id": {"type": "snowflake", "required": False, "nullable": True}, "features": {"type": "list", "required": False, "schema": {"type": "string"}}, + "rules_channel_id": {"type": "snowflake", "required": False, "nullable": True}, } From d9940b9d3f2c305fc2737643a1f153515e64d48c Mon Sep 17 00:00:00 2001 From: George Tsatsis Date: Mon, 30 Mar 2020 21:07:17 +0300 Subject: [PATCH 09/21] Make rules_channel_id a bigint --- manage/cmd/migration/scripts/5_add_rules_channel_id.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manage/cmd/migration/scripts/5_add_rules_channel_id.sql b/manage/cmd/migration/scripts/5_add_rules_channel_id.sql index efb74bb..1ea4c9e 100644 --- a/manage/cmd/migration/scripts/5_add_rules_channel_id.sql +++ b/manage/cmd/migration/scripts/5_add_rules_channel_id.sql @@ -1 +1 @@ -ALTER TABLE guilds ADD COLUMN rules_channel_id int \ No newline at end of file +ALTER TABLE guilds ADD COLUMN rules_channel_id bigint \ No newline at end of file From 92489d0f438796654915e49b9a37c7de2d985f50 Mon Sep 17 00:00:00 2001 From: George Tsatsis Date: Mon, 30 Mar 2020 22:19:12 +0300 Subject: [PATCH 10/21] Add public updates channel (to server, not channel type) --- litecord/blueprints/guilds.py | 4 ++-- litecord/schemas.py | 1 + litecord/storage.py | 2 +- .../cmd/migration/scripts/6_add_public_updates_channel_id.sql | 1 + 4 files changed, 5 insertions(+), 3 deletions(-) create mode 100644 manage/cmd/migration/scripts/6_add_public_updates_channel_id.sql diff --git a/litecord/blueprints/guilds.py b/litecord/blueprints/guilds.py index 74ea3e8..e1b9a39 100644 --- a/litecord/blueprints/guilds.py +++ b/litecord/blueprints/guilds.py @@ -316,9 +316,9 @@ async def _update_guild(guild_id): guild_id, ) - channel_fields = ["afk_channel_id", "system_channel_id", "rules_channel_id"] + channel_fields = ["afk_channel_id", "system_channel_id", "rules_channel_id", "public_updates_channel_id"] for field in [f for f in channel_fields if f in j]: - # setting to null should remove the link between the afk/sys/rules channel + # setting to null should remove the link between the afk/sys/rules/public updates channel # to the guild. if j[field] is None: await app.db.execute( diff --git a/litecord/schemas.py b/litecord/schemas.py index 2e88661..8cf9b09 100644 --- a/litecord/schemas.py +++ b/litecord/schemas.py @@ -293,6 +293,7 @@ GUILD_UPDATE = { "system_channel_id": {"type": "snowflake", "required": False, "nullable": True}, "features": {"type": "list", "required": False, "schema": {"type": "string"}}, "rules_channel_id": {"type": "snowflake", "required": False, "nullable": True}, + "public_updates_channel_id": {"type": "snowflake", "required": False, "nullable": True}, } diff --git a/litecord/storage.py b/litecord/storage.py index 8bf3586..e91bc58 100644 --- a/litecord/storage.py +++ b/litecord/storage.py @@ -201,7 +201,7 @@ class Storage: explicit_content_filter, mfa_level, embed_enabled, embed_channel_id::text, widget_enabled, widget_channel_id::text, - system_channel_id::text, rules_channel_id::text, features, + system_channel_id::text, rules_channel_id::text, public_updates_channel_id::text, features, banner, description FROM guilds WHERE guilds.id = $1 diff --git a/manage/cmd/migration/scripts/6_add_public_updates_channel_id.sql b/manage/cmd/migration/scripts/6_add_public_updates_channel_id.sql new file mode 100644 index 0000000..a26bf17 --- /dev/null +++ b/manage/cmd/migration/scripts/6_add_public_updates_channel_id.sql @@ -0,0 +1 @@ +ALTER TABLE guilds ADD COLUMN public_updates_channel_id bigint \ No newline at end of file From 2aadcc2360c1112a65f70551e8673b21ea592fb9 Mon Sep 17 00:00:00 2001 From: George Tsatsis Date: Mon, 30 Mar 2020 22:49:58 +0300 Subject: [PATCH 11/21] When server has no features, it would not submit changes. --- litecord/storage.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/litecord/storage.py b/litecord/storage.py index e91bc58..5ab71b6 100644 --- a/litecord/storage.py +++ b/litecord/storage.py @@ -1310,5 +1310,6 @@ class Storage: """, guild_id, ) - + if features is None: + return False return feature.upper() in features From be089fe4dc8c2f7340073ce4d35562d568dcf2de Mon Sep 17 00:00:00 2001 From: George Tsatsis Date: Tue, 31 Mar 2020 00:31:50 +0300 Subject: [PATCH 12/21] Add PUBLIC to guild enums --- litecord/enums.py | 1 + 1 file changed, 1 insertion(+) diff --git a/litecord/enums.py b/litecord/enums.py index 0a2ddf3..78a394b 100644 --- a/litecord/enums.py +++ b/litecord/enums.py @@ -242,6 +242,7 @@ class Feature(EasyEnum): vanity = "VANITY_URL" emoji = "MORE_EMOJI" verified = "VERIFIED" + public = "PUBLIC" # unknown commerce = "COMMERCE" From 4ff1916ebec5e3c7ad27c1ed38b5ad0b602ade34 Mon Sep 17 00:00:00 2001 From: George Tsatsis Date: Tue, 31 Mar 2020 01:04:58 +0300 Subject: [PATCH 13/21] Add preferred_locale field --- litecord/blueprints/guilds.py | 1 + litecord/schemas.py | 1 + litecord/storage.py | 2 +- manage/cmd/migration/scripts/7_add_prefered_locale.sql | 1 + 4 files changed, 4 insertions(+), 1 deletion(-) create mode 100644 manage/cmd/migration/scripts/7_add_prefered_locale.sql diff --git a/litecord/blueprints/guilds.py b/litecord/blueprints/guilds.py index e1b9a39..02d1bf9 100644 --- a/litecord/blueprints/guilds.py +++ b/litecord/blueprints/guilds.py @@ -303,6 +303,7 @@ async def _update_guild(guild_id): "explicit_content_filter", "afk_timeout", "description", + "preferred_locale" ] for field in [f for f in fields if f in j]: diff --git a/litecord/schemas.py b/litecord/schemas.py index 8cf9b09..4a8cc04 100644 --- a/litecord/schemas.py +++ b/litecord/schemas.py @@ -294,6 +294,7 @@ GUILD_UPDATE = { "features": {"type": "list", "required": False, "schema": {"type": "string"}}, "rules_channel_id": {"type": "snowflake", "required": False, "nullable": True}, "public_updates_channel_id": {"type": "snowflake", "required": False, "nullable": True}, + "preferred_locale": {"type": "string", "required": False, "nullable": True}, } diff --git a/litecord/storage.py b/litecord/storage.py index 5ab71b6..76eae62 100644 --- a/litecord/storage.py +++ b/litecord/storage.py @@ -202,7 +202,7 @@ class Storage: embed_enabled, embed_channel_id::text, widget_enabled, widget_channel_id::text, system_channel_id::text, rules_channel_id::text, public_updates_channel_id::text, features, - banner, description + banner, description, preferred_locale FROM guilds WHERE guilds.id = $1 """, diff --git a/manage/cmd/migration/scripts/7_add_prefered_locale.sql b/manage/cmd/migration/scripts/7_add_prefered_locale.sql new file mode 100644 index 0000000..ce76150 --- /dev/null +++ b/manage/cmd/migration/scripts/7_add_prefered_locale.sql @@ -0,0 +1 @@ +ALTER TABLE guilds ADD COLUMN preferred_locale text; \ No newline at end of file From d786edffec0ba8aab3df66087aae4c048a899606 Mon Sep 17 00:00:00 2001 From: George Tsatsis Date: Tue, 31 Mar 2020 01:11:57 +0300 Subject: [PATCH 14/21] Add discovery_splash --- litecord/blueprints/guilds.py | 9 ++++++++- litecord/schemas.py | 1 + litecord/storage.py | 2 +- manage/cmd/migration/scripts/8_add_discovery_splash.sql | 1 + 4 files changed, 11 insertions(+), 2 deletions(-) create mode 100644 manage/cmd/migration/scripts/8_add_discovery_splash.sql diff --git a/litecord/blueprints/guilds.py b/litecord/blueprints/guilds.py index 02d1bf9..a5b0853 100644 --- a/litecord/blueprints/guilds.py +++ b/litecord/blueprints/guilds.py @@ -297,13 +297,20 @@ async def _update_guild(guild_id): await _guild_update_icon("banner", guild_id, j["banner"]) + if to_update(j, guild, "discovery_splash"): + if not await app.storage.has_feature(guild_id, "PUBLIC"): + raise BadRequest("guild does not have PUBLIC feature") + + await _guild_update_icon("discovery_splash", guild_id, j["discovery_splash"]) + fields = [ "verification_level", "default_message_notifications", "explicit_content_filter", "afk_timeout", "description", - "preferred_locale" + "preferred_locale", + "discovery_splash" ] for field in [f for f in fields if f in j]: diff --git a/litecord/schemas.py b/litecord/schemas.py index 4a8cc04..7134007 100644 --- a/litecord/schemas.py +++ b/litecord/schemas.py @@ -295,6 +295,7 @@ GUILD_UPDATE = { "rules_channel_id": {"type": "snowflake", "required": False, "nullable": True}, "public_updates_channel_id": {"type": "snowflake", "required": False, "nullable": True}, "preferred_locale": {"type": "string", "required": False, "nullable": True}, + "discovery_splash": {"type": "string", "required": False, "nullable": True}, } diff --git a/litecord/storage.py b/litecord/storage.py index 76eae62..6d70f99 100644 --- a/litecord/storage.py +++ b/litecord/storage.py @@ -202,7 +202,7 @@ class Storage: embed_enabled, embed_channel_id::text, widget_enabled, widget_channel_id::text, system_channel_id::text, rules_channel_id::text, public_updates_channel_id::text, features, - banner, description, preferred_locale + banner, description, preferred_locale, discovery_splash FROM guilds WHERE guilds.id = $1 """, diff --git a/manage/cmd/migration/scripts/8_add_discovery_splash.sql b/manage/cmd/migration/scripts/8_add_discovery_splash.sql new file mode 100644 index 0000000..405b864 --- /dev/null +++ b/manage/cmd/migration/scripts/8_add_discovery_splash.sql @@ -0,0 +1 @@ +ALTER TABLE guilds ADD COLUMN discovery_splash text; \ No newline at end of file From 45b4431c4c0781cba77769a462ffa24293d1db64 Mon Sep 17 00:00:00 2001 From: George Tsatsis Date: Tue, 31 Mar 2020 03:35:00 +0300 Subject: [PATCH 15/21] Add discovery_splash to sql definitions for image uploading --- litecord/images.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/litecord/images.py b/litecord/images.py index a28bd48..97e9d92 100644 --- a/litecord/images.py +++ b/litecord/images.py @@ -181,6 +181,7 @@ def _gen_update_sql(scope: str) -> str: "user": "avatar", "guild": "icon", "splash": "splash", + "discovery_splash": "discovery_splash", "banner": "banner", "channel-icons": "icon", }[scope] @@ -189,6 +190,7 @@ def _gen_update_sql(scope: str) -> str: "user": "users", "guild": "guilds", "splash": "guilds", + "discovery_splash": "guilds", "banner": "guilds", "channel-icons": "group_dm_channels", }[scope] From bdc576b777b4b8c9b10354b51c16422abff41ed2 Mon Sep 17 00:00:00 2001 From: George Tsatsis Date: Tue, 31 Mar 2020 03:50:34 +0300 Subject: [PATCH 16/21] Remove splash as a field --- litecord/blueprints/guilds.py | 1 - 1 file changed, 1 deletion(-) diff --git a/litecord/blueprints/guilds.py b/litecord/blueprints/guilds.py index a5b0853..9c92cf8 100644 --- a/litecord/blueprints/guilds.py +++ b/litecord/blueprints/guilds.py @@ -310,7 +310,6 @@ async def _update_guild(guild_id): "afk_timeout", "description", "preferred_locale", - "discovery_splash" ] for field in [f for f in fields if f in j]: From 6b14d41c931f1310dd5355933d89d6000ef2d9d0 Mon Sep 17 00:00:00 2001 From: George Tsatsis Date: Tue, 31 Mar 2020 04:08:56 +0300 Subject: [PATCH 17/21] Possibly fix discovery-splashes icon get --- litecord/blueprints/icons.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/litecord/blueprints/icons.py b/litecord/blueprints/icons.py index ef38700..5c68100 100644 --- a/litecord/blueprints/icons.py +++ b/litecord/blueprints/icons.py @@ -109,3 +109,7 @@ async def _get_guild_banner(guild_id: int, icon_file: str): icon_hash, ext = splitext_(icon_file) return await send_icon("banner", guild_id, icon_hash, ext=ext) +@bp.route("/discovery-splashes//", methods=["GET"]) +async def _get_guild_banner(guild_id: int, icon_file: str): + icon_hash, ext = splitext_(icon_file) + return await send_icon("discovery-splash", guild_id, icon_hash, ext=ext) \ No newline at end of file From 6b3d3c881aaa37e0630b3534e3c097cf169a7870 Mon Sep 17 00:00:00 2001 From: George Tsatsis Date: Tue, 31 Mar 2020 04:10:05 +0300 Subject: [PATCH 18/21] Copy-paste fail (Change func name) --- litecord/blueprints/icons.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/litecord/blueprints/icons.py b/litecord/blueprints/icons.py index 5c68100..756f533 100644 --- a/litecord/blueprints/icons.py +++ b/litecord/blueprints/icons.py @@ -110,6 +110,6 @@ async def _get_guild_banner(guild_id: int, icon_file: str): return await send_icon("banner", guild_id, icon_hash, ext=ext) @bp.route("/discovery-splashes//", methods=["GET"]) -async def _get_guild_banner(guild_id: int, icon_file: str): +async def _get_discovery_splash(guild_id: int, icon_file: str): icon_hash, ext = splitext_(icon_file) return await send_icon("discovery-splash", guild_id, icon_hash, ext=ext) \ No newline at end of file From 49ff11da48e1bcd971cd86de5ab392907b08abdf Mon Sep 17 00:00:00 2001 From: George Tsatsis Date: Tue, 31 Mar 2020 04:18:28 +0300 Subject: [PATCH 19/21] Looking back, it wasn't a dash, but rather, an underscore. --- litecord/blueprints/icons.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/litecord/blueprints/icons.py b/litecord/blueprints/icons.py index 756f533..9f4dbb5 100644 --- a/litecord/blueprints/icons.py +++ b/litecord/blueprints/icons.py @@ -112,4 +112,4 @@ async def _get_guild_banner(guild_id: int, icon_file: str): @bp.route("/discovery-splashes//", methods=["GET"]) async def _get_discovery_splash(guild_id: int, icon_file: str): icon_hash, ext = splitext_(icon_file) - return await send_icon("discovery-splash", guild_id, icon_hash, ext=ext) \ No newline at end of file + return await send_icon("discovery_splash", guild_id, icon_hash, ext=ext) \ No newline at end of file From 46468f512ba53ecf79a2b12b723293aec78d0081 Mon Sep 17 00:00:00 2001 From: George Tsatsis Date: Tue, 31 Mar 2020 22:14:13 +0300 Subject: [PATCH 20/21] As per !61#note_314891420 --- manage/cmd/migration/scripts/5_add_rules_channel_id.sql | 2 +- .../cmd/migration/scripts/6_add_public_updates_channel_id.sql | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/manage/cmd/migration/scripts/5_add_rules_channel_id.sql b/manage/cmd/migration/scripts/5_add_rules_channel_id.sql index 1ea4c9e..25845da 100644 --- a/manage/cmd/migration/scripts/5_add_rules_channel_id.sql +++ b/manage/cmd/migration/scripts/5_add_rules_channel_id.sql @@ -1 +1 @@ -ALTER TABLE guilds ADD COLUMN rules_channel_id bigint \ No newline at end of file +ALTER TABLE guilds ADD COLUMN rules_channel_id bigint; \ No newline at end of file diff --git a/manage/cmd/migration/scripts/6_add_public_updates_channel_id.sql b/manage/cmd/migration/scripts/6_add_public_updates_channel_id.sql index a26bf17..3c8b72a 100644 --- a/manage/cmd/migration/scripts/6_add_public_updates_channel_id.sql +++ b/manage/cmd/migration/scripts/6_add_public_updates_channel_id.sql @@ -1 +1 @@ -ALTER TABLE guilds ADD COLUMN public_updates_channel_id bigint \ No newline at end of file +ALTER TABLE guilds ADD COLUMN public_updates_channel_id bigint; \ No newline at end of file From 82eb6345d1af52bf6a591b8705b3a6e4daa34eaa Mon Sep 17 00:00:00 2001 From: George Tsatsis Date: Tue, 31 Mar 2020 22:17:51 +0300 Subject: [PATCH 21/21] Coerce snowflakes into int --- litecord/blueprints/guilds.py | 2 +- litecord/schemas.py | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/litecord/blueprints/guilds.py b/litecord/blueprints/guilds.py index 9c92cf8..4b88a7b 100644 --- a/litecord/blueprints/guilds.py +++ b/litecord/blueprints/guilds.py @@ -339,7 +339,7 @@ async def _update_guild(guild_id): continue - chan = await app.storage.get_channel(int(j[field])) + chan = await app.storage.get_channel(j[field]) if chan is None: raise BadRequest("invalid channel id") diff --git a/litecord/schemas.py b/litecord/schemas.py index 7134007..1dc35b1 100644 --- a/litecord/schemas.py +++ b/litecord/schemas.py @@ -287,13 +287,13 @@ GUILD_UPDATE = { "verification_level": {"type": "verification_level", "required": False}, "default_message_notifications": {"type": "msg_notifications", "required": False}, "explicit_content_filter": {"type": "explicit", "required": False}, - "afk_channel_id": {"type": "snowflake", "required": False, "nullable": True}, + "afk_channel_id": {"type": "snowflake", "coerce": int, "required": False, "nullable": True}, "afk_timeout": {"type": "number", "required": False}, - "owner_id": {"type": "snowflake", "required": False}, - "system_channel_id": {"type": "snowflake", "required": False, "nullable": True}, + "owner_id": {"type": "snowflake", "coerce": int, "required": False}, + "system_channel_id": {"type": "snowflake", "coerce": int, "required": False, "nullable": True}, "features": {"type": "list", "required": False, "schema": {"type": "string"}}, - "rules_channel_id": {"type": "snowflake", "required": False, "nullable": True}, - "public_updates_channel_id": {"type": "snowflake", "required": False, "nullable": True}, + "rules_channel_id": {"type": "snowflake", "coerce": int, "required": False, "nullable": True}, + "public_updates_channel_id": {"type": "snowflake", "coerce": int, "required": False, "nullable": True}, "preferred_locale": {"type": "string", "required": False, "nullable": True}, "discovery_splash": {"type": "string", "required": False, "nullable": True}, }