diff options
author | ouwou <26526779+ouwou@users.noreply.github.com> | 2021-12-28 02:58:31 -0500 |
---|---|---|
committer | ouwou <26526779+ouwou@users.noreply.github.com> | 2021-12-28 02:58:31 -0500 |
commit | 6c94e75513ba045d91c690e66eb1b3efe315a96e (patch) | |
tree | 8fb9bffe6ff01c998e064aed67c662a3d05f543d /src | |
parent | 801894abc6b5133c3e6dce0a9f5d9045f0c2c17d (diff) | |
download | abaddon-portaudio-6c94e75513ba045d91c690e66eb1b3efe315a96e.tar.gz abaddon-portaudio-6c94e75513ba045d91c690e66eb1b3efe315a96e.zip |
take mute_config.end_time into account for muted entries
Diffstat (limited to 'src')
-rw-r--r-- | src/discord/discord.cpp | 36 |
1 files changed, 30 insertions, 6 deletions
diff --git a/src/discord/discord.cpp b/src/discord/discord.cpp index ab38fa8..8c5ec93 100644 --- a/src/discord/discord.cpp +++ b/src/discord/discord.cpp @@ -1918,9 +1918,17 @@ void DiscordClient::HandleGatewayUserGuildSettingsUpdate(const GatewayMessage &m UserGuildSettingsUpdateData data = msg.Data; const auto channels = GetChannelsInGuild(data.Settings.GuildID); std::set<Snowflake> now_muted_channels; + const auto now = Snowflake::FromNow(); for (const auto &override : data.Settings.ChannelOverrides) { - if (override.Muted) - now_muted_channels.insert(override.ChannelID); + if (override.Muted) { + if (override.MuteConfig.EndTime.has_value()) { + const auto end = Snowflake::FromISO8601(*override.MuteConfig.EndTime); + if (end > now) + now_muted_channels.insert(override.ChannelID); + } else { + now_muted_channels.insert(override.ChannelID); + } + } } for (const auto &channel_id : channels) { const bool was_muted = IsChannelMuted(channel_id); @@ -2311,12 +2319,28 @@ void DiscordClient::HandleReadyReadState(const ReadyEventData &data) { } void DiscordClient::HandleReadyGuildSettings(const ReadyEventData &data) { + const auto now = Snowflake::FromNow(); for (const auto &entry : data.GuildSettings.Entries) { - if (entry.Muted) - m_muted_guilds.insert(entry.GuildID); + // even if muted is true a guild/channel can be unmuted if the current time passes mute_config.end_time + if (entry.Muted) { + if (entry.MuteConfig.EndTime.has_value()) { + const auto end = Snowflake::FromISO8601(*entry.MuteConfig.EndTime); + if (end > now) + m_muted_guilds.insert(entry.GuildID); + } else { + m_muted_guilds.insert(entry.GuildID); + } + } for (const auto &override : entry.ChannelOverrides) { - if (override.Muted) - m_muted_channels.insert(override.ChannelID); + if (override.Muted) { + if (override.MuteConfig.EndTime.has_value()) { + const auto end = Snowflake::FromISO8601(*override.MuteConfig.EndTime); + if (end > now) + m_muted_channels.insert(override.ChannelID); + } else { + m_muted_channels.insert(override.ChannelID); + } + } } } } |