forked from OpenGamers/abaddon
handle initial muted state for threads
This commit is contained in:
@@ -13,6 +13,8 @@ void from_json(const nlohmann::json &j, ThreadMemberObject &m) {
|
|||||||
JS_O("user_id", m.UserID);
|
JS_O("user_id", m.UserID);
|
||||||
JS_D("join_timestamp", m.JoinTimestamp);
|
JS_D("join_timestamp", m.JoinTimestamp);
|
||||||
JS_D("flags", m.Flags);
|
JS_D("flags", m.Flags);
|
||||||
|
JS_O("muted", m.IsMuted);
|
||||||
|
JS_ON("mute_config", m.MuteConfig);
|
||||||
}
|
}
|
||||||
|
|
||||||
void from_json(const nlohmann::json &j, ChannelData &m) {
|
void from_json(const nlohmann::json &j, ChannelData &m) {
|
||||||
|
|||||||
@@ -49,9 +49,19 @@ struct ThreadMetadataData {
|
|||||||
friend void from_json(const nlohmann::json &j, ThreadMetadataData &m);
|
friend void from_json(const nlohmann::json &j, ThreadMetadataData &m);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct MuteConfigData {
|
||||||
|
std::optional<std::string> EndTime; // nullopt is encoded as null
|
||||||
|
int SelectedTimeWindow;
|
||||||
|
|
||||||
|
friend void from_json(const nlohmann::json &j, MuteConfigData &m);
|
||||||
|
friend void to_json(nlohmann::json &j, const MuteConfigData &m);
|
||||||
|
};
|
||||||
|
|
||||||
struct ThreadMemberObject {
|
struct ThreadMemberObject {
|
||||||
std::optional<Snowflake> ThreadID;
|
std::optional<Snowflake> ThreadID;
|
||||||
std::optional<Snowflake> UserID;
|
std::optional<Snowflake> UserID;
|
||||||
|
std::optional<bool> IsMuted;
|
||||||
|
std::optional<MuteConfigData> MuteConfig;
|
||||||
std::string JoinTimestamp;
|
std::string JoinTimestamp;
|
||||||
int Flags;
|
int Flags;
|
||||||
|
|
||||||
|
|||||||
@@ -2389,10 +2389,14 @@ void DiscordClient::HandleReadyGuildSettings(const ReadyEventData &data) {
|
|||||||
// i dont like this implementation for muted categories but its rather simple and doesnt use a horriiible amount of ram
|
// i dont like this implementation for muted categories but its rather simple and doesnt use a horriiible amount of ram
|
||||||
|
|
||||||
std::unordered_map<Snowflake, std::vector<Snowflake>> category_children;
|
std::unordered_map<Snowflake, std::vector<Snowflake>> category_children;
|
||||||
for (const auto &guild : data.Guilds)
|
for (const auto &guild : data.Guilds) {
|
||||||
for (const auto &channel : *guild.Channels)
|
for (const auto &channel : *guild.Channels)
|
||||||
if (channel.ParentID.has_value() && !channel.IsThread())
|
if (channel.ParentID.has_value() && !channel.IsThread())
|
||||||
category_children[*channel.ParentID].push_back(channel.ID);
|
category_children[*channel.ParentID].push_back(channel.ID);
|
||||||
|
for (const auto &thread : *guild.Threads)
|
||||||
|
if (thread.ThreadMember.has_value() && thread.ThreadMember->IsMuted.has_value() && *thread.ThreadMember->IsMuted)
|
||||||
|
m_muted_channels.insert(thread.ID);
|
||||||
|
}
|
||||||
|
|
||||||
const auto now = Snowflake::FromNow();
|
const auto now = Snowflake::FromNow();
|
||||||
for (const auto &entry : data.GuildSettings.Entries) {
|
for (const auto &entry : data.GuildSettings.Entries) {
|
||||||
|
|||||||
@@ -244,14 +244,6 @@ struct ReadStateData {
|
|||||||
friend void from_json(const nlohmann::json &j, ReadStateData &m);
|
friend void from_json(const nlohmann::json &j, ReadStateData &m);
|
||||||
};
|
};
|
||||||
|
|
||||||
struct MuteConfigData {
|
|
||||||
std::optional<std::string> EndTime; // nullopt is encoded as null
|
|
||||||
int SelectedTimeWindow;
|
|
||||||
|
|
||||||
friend void from_json(const nlohmann::json &j, MuteConfigData &m);
|
|
||||||
friend void to_json(nlohmann::json &j, const MuteConfigData &m);
|
|
||||||
};
|
|
||||||
|
|
||||||
struct UserGuildSettingsChannelOverride {
|
struct UserGuildSettingsChannelOverride {
|
||||||
bool Muted;
|
bool Muted;
|
||||||
MuteConfigData MuteConfig;
|
MuteConfigData MuteConfig;
|
||||||
|
|||||||
Reference in New Issue
Block a user