mirror of https://gitlab.com/litecord/litecord.git
storage: assert channel type is valid on more places
This commit is contained in:
parent
ddf78d94e4
commit
7ac38212a3
|
|
@ -431,8 +431,7 @@ class Storage:
|
||||||
drow["last_message_id"] = last_msg
|
drow["last_message_id"] = last_msg
|
||||||
|
|
||||||
return {**row, **drow}
|
return {**row, **drow}
|
||||||
|
elif chan_type == ChannelType.GUILD_VOICE:
|
||||||
if chan_type == ChannelType.GUILD_VOICE:
|
|
||||||
vrow = await self.db.fetchrow(
|
vrow = await self.db.fetchrow(
|
||||||
"""
|
"""
|
||||||
SELECT bitrate, user_limit
|
SELECT bitrate, user_limit
|
||||||
|
|
@ -443,9 +442,9 @@ class Storage:
|
||||||
)
|
)
|
||||||
|
|
||||||
return {**row, **dict(vrow)}
|
return {**row, **dict(vrow)}
|
||||||
|
else:
|
||||||
# this only exists to trick mypy. this codepath is unreachable
|
# this only exists to trick mypy. this codepath is unreachable
|
||||||
raise RuntimeError("Unreachable code path.")
|
raise AssertionError("Unreachable code path.")
|
||||||
|
|
||||||
async def get_chan_type(self, channel_id: int) -> Optional[int]:
|
async def get_chan_type(self, channel_id: int) -> Optional[int]:
|
||||||
"""Get the channel type integer, given channel ID."""
|
"""Get the channel type integer, given channel ID."""
|
||||||
|
|
@ -603,7 +602,9 @@ class Storage:
|
||||||
drow["last_message_id"] = await self.chan_last_message_str(channel_id)
|
drow["last_message_id"] = await self.chan_last_message_str(channel_id)
|
||||||
return drow
|
return drow
|
||||||
|
|
||||||
return None
|
raise RuntimeError(
|
||||||
|
f"Data Inconsistency: Channel type {ctype} is not properly handled"
|
||||||
|
)
|
||||||
|
|
||||||
async def get_channel_ids(self, guild_id: int) -> List[int]:
|
async def get_channel_ids(self, guild_id: int) -> List[int]:
|
||||||
"""Get all channel IDs in a guild."""
|
"""Get all channel IDs in a guild."""
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue