mirror of
https://github.com/celisej567/abaddon.git
synced 2026-09-06 20:15:19 +03:00
add fetching private archived threads
This commit is contained in:
@@ -292,6 +292,19 @@ void DiscordClient::GetArchivedPublicThreads(Snowflake channel_id, sigc::slot<vo
|
||||
});
|
||||
}
|
||||
|
||||
void DiscordClient::GetArchivedPrivateThreads(Snowflake channel_id, sigc::slot<void(DiscordError, const ArchivedThreadsResponseData &)> callback) {
|
||||
m_http.MakeGET("/channels/" + std::to_string(channel_id) + "/users/@me/threads/archived/private", [this, callback](const http::response_type &r) {
|
||||
if (CheckCode(r)) {
|
||||
const auto data = nlohmann::json::parse(r.text).get<ArchivedThreadsResponseData>();
|
||||
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 {
|
||||
return std::find(m_joined_threads.begin(), m_joined_threads.end(), thread_id) != m_joined_threads.end();
|
||||
}
|
||||
|
||||
@@ -81,6 +81,7 @@ public:
|
||||
std::vector<Snowflake> GetUsersInThread(Snowflake id) const;
|
||||
std::vector<ChannelData> GetActiveThreads(Snowflake channel_id) const;
|
||||
void GetArchivedPublicThreads(Snowflake channel_id, sigc::slot<void(DiscordError, const ArchivedThreadsResponseData &)> callback);
|
||||
void GetArchivedPrivateThreads(Snowflake channel_id, sigc::slot<void(DiscordError, const ArchivedThreadsResponseData &)> callback);
|
||||
|
||||
bool IsThreadJoined(Snowflake thread_id) const;
|
||||
bool HasGuildPermission(Snowflake user_id, Snowflake guild_id, Permission perm) const;
|
||||
|
||||
@@ -129,14 +129,15 @@ ArchivedThreadsList::ArchivedThreadsList(const ChannelData &channel, const Gtk::
|
||||
return false;
|
||||
});
|
||||
|
||||
Abaddon::Get().GetDiscordClient().GetArchivedPublicThreads(channel.ID, sigc::mem_fun(*this, &ArchivedThreadsList::OnPublicFetched));
|
||||
Abaddon::Get().GetDiscordClient().GetArchivedPublicThreads(channel.ID, sigc::mem_fun(*this, &ArchivedThreadsList::OnThreadsFetched));
|
||||
Abaddon::Get().GetDiscordClient().GetArchivedPrivateThreads(channel.ID, sigc::mem_fun(*this, &ArchivedThreadsList::OnThreadsFetched));
|
||||
}
|
||||
|
||||
void ArchivedThreadsList::InvalidateFilter() {
|
||||
m_list.invalidate_filter();
|
||||
}
|
||||
|
||||
void ArchivedThreadsList::OnPublicFetched(DiscordError code, const ArchivedThreadsResponseData &data) {
|
||||
void ArchivedThreadsList::OnThreadsFetched(DiscordError code, const ArchivedThreadsResponseData &data) {
|
||||
for (const auto &thread : data.Threads) {
|
||||
auto row = Gtk::manage(new ThreadListRow(thread));
|
||||
row->show();
|
||||
|
||||
@@ -27,7 +27,7 @@ public:
|
||||
private:
|
||||
Gtk::ListBox m_list;
|
||||
|
||||
void OnPublicFetched(DiscordError code, const ArchivedThreadsResponseData &data);
|
||||
void OnThreadsFetched(DiscordError code, const ArchivedThreadsResponseData &data);
|
||||
|
||||
using type_signal_thread_open = sigc::signal<void, Snowflake>;
|
||||
type_signal_thread_open m_signal_thread_open;
|
||||
|
||||
Reference in New Issue
Block a user