feat(eventsub): Add support for channel.moderate Warn (#5932)

* fix(eventsub): Be less strict with strings & vectors

String foo from `{"foo":null}` is now accepted, and returns an empty string
std::vector<String> foo from `{"foo":null}` is now accepted, and returns an empty array
This commit is contained in:
pajlada
2025-02-09 12:21:16 +01:00
committed by GitHub
parent 88341517dc
commit b01f50856d
11 changed files with 211 additions and 96 deletions
+13 -4
View File
@@ -164,12 +164,12 @@ void Connection::onChannelModerate(
const auto now = QDateTime::currentDateTime();
std::visit(
[&](auto &&oAction) {
using Action = std::remove_cvref_t<decltype(oAction)>;
[&](auto &&action) {
using Action = std::remove_cvref_t<decltype(action)>;
if constexpr (std::is_same_v<
Action, lib::payload::channel_moderate::v2::Vip>)
{
auto msg = makeVipMessage(channel, now, payload.event, oAction);
auto msg = makeVipMessage(channel, now, payload.event, action);
runInGuiThread([channel, msg] {
channel->addMessage(msg, MessageContext::Original);
});
@@ -179,7 +179,16 @@ void Connection::onChannelModerate(
lib::payload::channel_moderate::v2::Unvip>)
{
auto msg =
makeUnvipMessage(channel, now, payload.event, oAction);
makeUnvipMessage(channel, now, payload.event, action);
runInGuiThread([channel, msg] {
channel->addMessage(msg, MessageContext::Original);
});
}
else if constexpr (std::is_same_v<
Action,
lib::payload::channel_moderate::v2::Warn>)
{
auto msg = makeWarnMessage(channel, now, payload.event, action);
runInGuiThread([channel, msg] {
channel->addMessage(msg, MessageContext::Original);
});