From e01110c7393d5071ea271f1978b3a2ece59415ad Mon Sep 17 00:00:00 2001 From: ouwou <26526779+ouwou@users.noreply.github.com> Date: Thu, 5 Aug 2021 23:50:15 -0400 Subject: add thread stuff to audit log --- windows/guildsettings/auditlogpane.cpp | 64 ++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) (limited to 'windows/guildsettings/auditlogpane.cpp') diff --git a/windows/guildsettings/auditlogpane.cpp b/windows/guildsettings/auditlogpane.cpp index 5745d17..9c7cdd0 100644 --- a/windows/guildsettings/auditlogpane.cpp +++ b/windows/guildsettings/auditlogpane.cpp @@ -537,6 +537,70 @@ void GuildSettingsAuditLogPane::OnAuditLogFetch(const AuditLogData &data) { ""; } } break; + case AuditLogActionType::THREAD_CREATE: { + const auto channel = discord.GetChannel(entry.TargetID); + markup = user_markup + + " created a thread " + + (channel.has_value() + ? Glib::Markup::escape_text(*channel->Name) + : Glib::ustring(*entry.GetNewFromKey("name"))) + + ""; + if (entry.Changes.has_value()) { + for (const auto &change : *entry.Changes) { + if (change.Key == "name") + extra_markup.push_back("Set the name to " + Glib::Markup::escape_text(change.NewValue->get()) + ""); + else if (change.Key == "archived") + extra_markup.push_back(change.NewValue->get() ? "Archived the thread" : "Unarchived the thread"); + else if (change.Key == "auto_archive_duration") + extra_markup.push_back("Set auto archive duration to "s + std::to_string(change.NewValue->get()) + " minutes"s); + else if (change.Key == "rate_limit_per_user" && change.NewValue.has_value()) { + const int secs = change.NewValue->get(); + if (secs == 0) + extra_markup.push_back("Disabled slowmode"); + else + extra_markup.push_back("Set slowmode to " + + std::to_string(secs) + " seconds"); + } else if (change.Key == "locked") + extra_markup.push_back(change.NewValue->get() ? "Locked the thread, restricting it to only be unarchived by moderators" : "Unlocked the thread, allowing it to be unarchived by non-moderators"); + } + } + } break; + case AuditLogActionType::THREAD_UPDATE: { + const auto channel = discord.GetChannel(entry.TargetID); + markup = user_markup + + " made changes to the thread " + + (channel.has_value() + ? Glib::Markup::escape_text(*channel->Name) + : Glib::ustring(entry.TargetID)) + + ""; + for (const auto &change : *entry.Changes) { + if (change.Key == "name") + extra_markup.push_back( + "Changed the name from " + + Glib::Markup::escape_text(change.OldValue->get()) + + " to " + + Glib::Markup::escape_text(change.NewValue->get()) + + ""); + else if (change.Key == "auto_archive_duration") + extra_markup.push_back("Set auto archive duration to "s + std::to_string(change.NewValue->get()) + " minutes"s); + else if (change.Key == "rate_limit_per_user" && change.NewValue.has_value()) { + const int secs = change.NewValue->get(); + if (secs == 0) + extra_markup.push_back("Disabled slowmode"); + else + extra_markup.push_back("Set slowmode to " + + std::to_string(secs) + + " seconds"); + } else if (change.Key == "locked") + extra_markup.push_back(change.NewValue->get() ? "Locked the thread, restricting it to only be unarchived by moderators" : "Unlocked the thread, allowing it to be unarchived by non-moderators"); + else if (change.Key == "archived") + extra_markup.push_back(change.NewValue->get() ? "Archived the thread" : "Unarchived the thread"); + } + } break; + case AuditLogActionType::THREAD_DELETE: { + markup = user_markup + + " deleted the thread " + Glib::Markup::escape_text(*entry.GetOldFromKey("name")) + ""; + } break; default: markup = "Unknown action"; break; -- cgit v1.2.3