forked from OpenGamers/abaddon
handle initial muted state for threads
This commit is contained in:
parent
dfd642bb82
commit
2328c8bafe
|
@ -13,6 +13,8 @@ void from_json(const nlohmann::json &j, ThreadMemberObject &m) {
|
|||
JS_O("user_id", m.UserID);
|
||||
JS_D("join_timestamp", m.JoinTimestamp);
|
||||
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) {
|
||||
|
|
|
@ -49,9 +49,19 @@ struct ThreadMetadataData {
|
|||
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 {
|
||||
std::optional<Snowflake> ThreadID;
|
||||
std::optional<Snowflake> UserID;
|
||||
std::optional<bool> IsMuted;
|
||||
std::optional<MuteConfigData> MuteConfig;
|
||||
std::string JoinTimestamp;
|
||||
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
|
||||
|
||||
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)
|
||||
if (channel.ParentID.has_value() && !channel.IsThread())
|
||||
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();
|
||||
for (const auto &entry : data.GuildSettings.Entries) {
|
||||
|
|
|
@ -244,14 +244,6 @@ struct ReadStateData {
|
|||
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 {
|
||||
bool Muted;
|
||||
MuteConfigData MuteConfig;
|
||||
|
|
Loading…
Reference in New Issue
Block a user