From 4334c9420b3d919a557253439415137a4f2ebb6a Mon Sep 17 00:00:00 2001 From: cmdeck2 <32135661+CMDisme@users.noreply.github.com> Date: Fri, 16 Feb 2024 11:26:39 -0500 Subject: [PATCH] Fixed getting archived threads Used get_active_threads as a template to properly implement threads_get_public_archived and threads_get_private_archived --- src/dpp/cluster/thread.cpp | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/src/dpp/cluster/thread.cpp b/src/dpp/cluster/thread.cpp index 8e8ab147e3..45b500e961 100644 --- a/src/dpp/cluster/thread.cpp +++ b/src/dpp/cluster/thread.cpp @@ -70,7 +70,20 @@ void cluster::threads_get_private_archived(snowflake channel_id, time_t before_t {"before", before_timestamp}, {"limit", limit}, }); - rest_request_list(this, API_PATH "/channels", std::to_string(channel_id), "/threads/archived/private" + parameters, m_get, "", callback); + this->post_rest(API_PATH "/channels", std::to_string(channel_id), "/threads/archived/private" + parameters, m_get, "", [this, callback](json &j, const http_request_completion_t& http) { + std::unordered_map list; + confirmation_callback_t e(this, confirmation(), http); + if (!e.is_error()) { + if (j.contains("threads")) { + for (auto &curr_item: j["threads"]) { + list[snowflake_not_null(&curr_item, "id")].fill_from_json(&curr_item); + } + } + } + if (callback) { + callback(confirmation_callback_t(this, list, http)); + } + }); } void cluster::threads_get_public_archived(snowflake channel_id, time_t before_timestamp, uint16_t limit, command_completion_event_t callback) { @@ -78,7 +91,20 @@ void cluster::threads_get_public_archived(snowflake channel_id, time_t before_ti {"before", before_timestamp}, {"limit", limit}, }); - rest_request_list(this, API_PATH "/channels", std::to_string(channel_id), "/threads/archived/public" + parameters, m_get, "", callback); + this->post_rest(API_PATH "/channels", std::to_string(channel_id), "/threads/archived/public" + parameters, m_get, "", [this, callback](json &j, const http_request_completion_t& http) { + std::unordered_map list; + confirmation_callback_t e(this, confirmation(), http); + if (!e.is_error()) { + if (j.contains("threads")) { + for (auto &curr_item: j["threads"]) { + list[snowflake_not_null(&curr_item, "id")].fill_from_json(&curr_item); + } + } + } + if (callback) { + callback(confirmation_callback_t(this, list, http)); + } + }); } void cluster::thread_member_get(const snowflake thread_id, const snowflake user_id, command_completion_event_t callback) {