summaryrefslogtreecommitdiff
path: root/src/discord/discord.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/discord/discord.cpp')
-rw-r--r--src/discord/discord.cpp23
1 files changed, 22 insertions, 1 deletions
diff --git a/src/discord/discord.cpp b/src/discord/discord.cpp
index 27d162c..09463b8 100644
--- a/src/discord/discord.cpp
+++ b/src/discord/discord.cpp
@@ -874,7 +874,7 @@ void DiscordClient::UnArchiveThread(Snowflake channel_id, sigc::slot<void(Discor
});
}
-void DiscordClient::MarkAsRead(Snowflake channel_id, sigc::slot<void(DiscordError code)> callback) {
+void DiscordClient::MarkChannelAsRead(Snowflake channel_id, sigc::slot<void(DiscordError code)> callback) {
if (m_unread.find(channel_id) == m_unread.end()) return;
const auto iter = m_last_message_id.find(channel_id);
if (iter == m_last_message_id.end()) return;
@@ -886,6 +886,27 @@ void DiscordClient::MarkAsRead(Snowflake channel_id, sigc::slot<void(DiscordErro
});
}
+void DiscordClient::MarkGuildAsRead(Snowflake guild_id, sigc::slot<void(DiscordError code)> callback) {
+ AckBulkData data;
+ const auto channels = GetChannelsInGuild(guild_id);
+ for (const auto &[unread, mention_count] : m_unread) {
+ const auto iter = m_last_message_id.find(unread);
+ if (iter == m_last_message_id.end()) continue;
+ auto &e = data.ReadStates.emplace_back();
+ e.ID = unread;
+ e.LastMessageID = iter->second;
+ }
+
+ if (data.ReadStates.empty()) return;
+
+ m_http.MakePOST("/read-states/ack-bulk", nlohmann::json(data).dump(), [this, callback](const http::response_type &response) {
+ if (CheckCode(response))
+ callback(DiscordError::NONE);
+ else
+ callback(GetCodeFromResponse(response));
+ });
+}
+
void DiscordClient::FetchPinned(Snowflake id, sigc::slot<void(std::vector<Message>, DiscordError code)> callback) {
// return from db if we know the pins have already been requested
if (m_channels_pinned_requested.find(id) != m_channels_pinned_requested.end()) {