diff options
author | ouwou <26526779+ouwou@users.noreply.github.com> | 2021-12-01 03:42:15 -0500 |
---|---|---|
committer | ouwou <26526779+ouwou@users.noreply.github.com> | 2021-12-01 03:42:15 -0500 |
commit | 8e11dd97e9effa0b4abf9945ad3ec3fee9d9ec5d (patch) | |
tree | 6fb6764ea4aa90c0700c6c046a5c6cd0af82866f /src/abaddon.cpp | |
parent | 2690febf20aecbe3ddc52d9574b9f19c8b93171c (diff) | |
download | abaddon-portaudio-8e11dd97e9effa0b4abf9945ad3ec3fee9d9ec5d.tar.gz abaddon-portaudio-8e11dd97e9effa0b4abf9945ad3ec3fee9d9ec5d.zip |
dont make requests for inaccessible channels
Diffstat (limited to 'src/abaddon.cpp')
-rw-r--r-- | src/abaddon.cpp | 32 |
1 files changed, 20 insertions, 12 deletions
diff --git a/src/abaddon.cpp b/src/abaddon.cpp index f6c9ef5..2b0cda0 100644 --- a/src/abaddon.cpp +++ b/src/abaddon.cpp @@ -512,6 +512,9 @@ void Abaddon::ActionChannelOpened(Snowflake id) { const auto channel = m_discord.GetChannel(id); if (!channel.has_value()) return; + + const bool can_access = channel->IsDM() || m_discord.HasChannelPermission(m_discord.GetUserData().ID, id, Permission::VIEW_CHANNEL); + if (channel->Type == ChannelType::GUILD_TEXT || channel->Type == ChannelType::GUILD_NEWS) m_main_window->set_title(std::string(APP_TITLE) + " - #" + *channel->Name); else { @@ -527,23 +530,28 @@ void Abaddon::ActionChannelOpened(Snowflake id) { } m_main_window->UpdateChatActiveChannel(id); if (m_channels_requested.find(id) == m_channels_requested.end()) { - m_discord.FetchMessagesInChannel(id, [this, id](const std::vector<Message> &msgs) { - m_main_window->UpdateChatWindowContents(); - m_channels_requested.insert(id); - }); + // dont fire requests we know will fail + if (can_access) { + m_discord.FetchMessagesInChannel(id, [this, id](const std::vector<Message> &msgs) { + m_main_window->UpdateChatWindowContents(); + m_channels_requested.insert(id); + }); + } } else { m_main_window->UpdateChatWindowContents(); } - if (channel->IsThread()) { - m_discord.SendThreadLazyLoad(id); - if (channel->ThreadMetadata->IsArchived) - m_main_window->GetChatWindow()->SetTopic("This thread is archived. Sending a message will unarchive it"); - } else if (channel->Type != ChannelType::DM && channel->Type != ChannelType::GROUP_DM && channel->GuildID.has_value()) { - m_discord.SendLazyLoad(id); + if (can_access) { + if (channel->IsThread()) { + m_discord.SendThreadLazyLoad(id); + if (channel->ThreadMetadata->IsArchived) + m_main_window->GetChatWindow()->SetTopic("This thread is archived. Sending a message will unarchive it"); + } else if (channel->Type != ChannelType::DM && channel->Type != ChannelType::GROUP_DM && channel->GuildID.has_value()) { + m_discord.SendLazyLoad(id); - if (m_discord.IsVerificationRequired(*channel->GuildID)) - ShowGuildVerificationGateDialog(*channel->GuildID); + if (m_discord.IsVerificationRequired(*channel->GuildID)) + ShowGuildVerificationGateDialog(*channel->GuildID); + } } } |