From 7ffded5b1373444cf3442d759a3bd8ae0940bd7d Mon Sep 17 00:00:00 2001 From: ouwou <26526779+ouwou@users.noreply.github.com> Date: Wed, 11 Aug 2021 03:32:09 -0400 Subject: rest of view threads window --- discord/discord.cpp | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'discord/discord.cpp') diff --git a/discord/discord.cpp b/discord/discord.cpp index aa363f5..7dfacc0 100644 --- a/discord/discord.cpp +++ b/discord/discord.cpp @@ -249,8 +249,22 @@ std::set DiscordClient::GetChannelsInGuild(Snowflake id) const { return {}; } -std::vector DiscordClient::GetPublicThreads(Snowflake channel_id) const { - return m_store.GetThreads(channel_id); +// there is an endpoint for this but it should be synced before this is called anyways +std::vector DiscordClient::GetActiveThreads(Snowflake channel_id) const { + return m_store.GetActiveThreads(channel_id); +} + +void DiscordClient::GetArchivedPublicThreads(Snowflake channel_id, sigc::slot callback) { + m_http.MakeGET("/channels/" + std::to_string(channel_id) + "/threads/archived/public", [this, callback](const http::response_type &r) { + if (CheckCode(r)) { + const auto data = nlohmann::json::parse(r.text).get(); + for (const auto &thread : data.Threads) + m_store.SetChannel(thread.ID, thread); + callback(DiscordError::NONE, data); + } else { + callback(GetCodeFromResponse(r), {}); + } + }); } bool DiscordClient::IsThreadJoined(Snowflake thread_id) const { -- cgit v1.2.3