forked from OpenGamers/abaddon
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 {
|
bool DiscordClient::IsThreadJoined(Snowflake thread_id) const {
|
||||||
return std::find(m_joined_threads.begin(), m_joined_threads.end(), thread_id) != m_joined_threads.end();
|
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<Snowflake> GetUsersInThread(Snowflake id) const;
|
||||||
std::vector<ChannelData> GetActiveThreads(Snowflake channel_id) const;
|
std::vector<ChannelData> GetActiveThreads(Snowflake channel_id) const;
|
||||||
void GetArchivedPublicThreads(Snowflake channel_id, sigc::slot<void(DiscordError, const ArchivedThreadsResponseData &)> callback);
|
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 IsThreadJoined(Snowflake thread_id) const;
|
||||||
bool HasGuildPermission(Snowflake user_id, Snowflake guild_id, Permission perm) 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;
|
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() {
|
void ArchivedThreadsList::InvalidateFilter() {
|
||||||
m_list.invalidate_filter();
|
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) {
|
for (const auto &thread : data.Threads) {
|
||||||
auto row = Gtk::manage(new ThreadListRow(thread));
|
auto row = Gtk::manage(new ThreadListRow(thread));
|
||||||
row->show();
|
row->show();
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ public:
|
|||||||
private:
|
private:
|
||||||
Gtk::ListBox m_list;
|
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>;
|
using type_signal_thread_open = sigc::signal<void, Snowflake>;
|
||||||
type_signal_thread_open m_signal_thread_open;
|
type_signal_thread_open m_signal_thread_open;
|
||||||
|
|||||||
Reference in New Issue
Block a user