Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix deserializing old forum channels on GUILD_CREATE missing some fields #1439

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changes/1439.bugfix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix deserializing old forum channels on `GUILD_CREATE` missing some fields.
5 changes: 3 additions & 2 deletions hikari/impl/entity_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -1191,9 +1191,10 @@ def deserialize_guild_forum_channel(
position=int(payload["position"]),
available_tags=available_tags,
flags=channel_models.ChannelFlag(payload["flags"]),
default_layout=channel_models.ForumLayoutType(payload["default_forum_layout"]),
# Discord may send None here for old channels, but they are just NOT_SET
default_layout=channel_models.ForumLayoutType(payload.get("default_forum_layout", 0)),
# Discord may send None here for old channels, but they are just LATEST_ACTIVITY
default_sort_order=channel_models.ForumSortOrderType(payload["default_sort_order"] or 0),
default_sort_order=channel_models.ForumSortOrderType(payload.get("default_sort_order") or 0),
default_reaction_emoji_id=reaction_emoji_id,
default_reaction_emoji_name=reaction_emoji_name,
)
Expand Down
4 changes: 4 additions & 0 deletions tests/hikari/impl/test_entity_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -2074,6 +2074,8 @@ def test_deserialize_guild_forum_channel_with_unset_fields(self, entity_factory_
del guild_forum_channel_payload["default_auto_archive_duration"]
del guild_forum_channel_payload["default_thread_rate_limit_per_user"]
del guild_forum_channel_payload["rate_limit_per_user"]
del guild_forum_channel_payload["default_sort_order"]
del guild_forum_channel_payload["default_forum_layout"]

forum_channel = entity_factory_impl.deserialize_guild_forum_channel(guild_forum_channel_payload)

Expand All @@ -2085,6 +2087,8 @@ def test_deserialize_guild_forum_channel_with_unset_fields(self, entity_factory_
assert forum_channel.default_auto_archive_duration == datetime.timedelta(minutes=1440)
assert forum_channel.default_thread_rate_limit_per_user == datetime.timedelta(minutes=0)
assert forum_channel.rate_limit_per_user == datetime.timedelta(minutes=0)
assert forum_channel.default_sort_order == channel_models.ForumSortOrderType.LATEST_ACTIVITY
assert forum_channel.default_layout == channel_models.ForumLayoutType.NOT_SET

def test_serialize_forum_tag(self, entity_factory_impl):
tag = channel_models.ForumTag(id=snowflakes.Snowflake(123), name="test", moderated=True, emoji=None)
Expand Down