refactor(eventsub): use variants for sum types (#5930)
This commit is contained in:
@@ -1,163 +1,13 @@
|
||||
// WARNING: This file is automatically generated. Any changes will be lost.
|
||||
#include "twitch-eventsub-ws/chrono.hpp" // IWYU pragma: keep
|
||||
#include "twitch-eventsub-ws/detail/errors.hpp"
|
||||
#include "twitch-eventsub-ws/detail/variant.hpp" // IWYU pragma: keep
|
||||
#include "twitch-eventsub-ws/payloads/channel-moderate-v2.hpp"
|
||||
|
||||
#include <boost/json.hpp>
|
||||
|
||||
namespace chatterino::eventsub::lib::payload::channel_moderate::v2 {
|
||||
|
||||
boost::json::result_for<Action, boost::json::value>::type tag_invoke(
|
||||
boost::json::try_value_to_tag<Action> /* tag */,
|
||||
const boost::json::value &jvRoot)
|
||||
{
|
||||
if (!jvRoot.is_string())
|
||||
{
|
||||
EVENTSUB_BAIL_HERE(error::Kind::ExpectedString);
|
||||
}
|
||||
std::string_view eString(jvRoot.get_string());
|
||||
|
||||
using namespace std::string_view_literals;
|
||||
if (eString == "ban"sv)
|
||||
{
|
||||
return Action::Ban;
|
||||
}
|
||||
if (eString == "timeout"sv)
|
||||
{
|
||||
return Action::Timeout;
|
||||
}
|
||||
if (eString == "unban"sv)
|
||||
{
|
||||
return Action::Unban;
|
||||
}
|
||||
if (eString == "untimeout"sv)
|
||||
{
|
||||
return Action::Untimeout;
|
||||
}
|
||||
if (eString == "clear"sv)
|
||||
{
|
||||
return Action::Clear;
|
||||
}
|
||||
if (eString == "emoteonly"sv)
|
||||
{
|
||||
return Action::Emoteonly;
|
||||
}
|
||||
if (eString == "emoteonlyoff"sv)
|
||||
{
|
||||
return Action::Emoteonlyoff;
|
||||
}
|
||||
if (eString == "followers"sv)
|
||||
{
|
||||
return Action::Followers;
|
||||
}
|
||||
if (eString == "followersoff"sv)
|
||||
{
|
||||
return Action::Followersoff;
|
||||
}
|
||||
if (eString == "uniquechat"sv)
|
||||
{
|
||||
return Action::Uniquechat;
|
||||
}
|
||||
if (eString == "uniquechatoff"sv)
|
||||
{
|
||||
return Action::Uniquechatoff;
|
||||
}
|
||||
if (eString == "slow"sv)
|
||||
{
|
||||
return Action::Slow;
|
||||
}
|
||||
if (eString == "slowoff"sv)
|
||||
{
|
||||
return Action::Slowoff;
|
||||
}
|
||||
if (eString == "subscribers"sv)
|
||||
{
|
||||
return Action::Subscribers;
|
||||
}
|
||||
if (eString == "subscribersoff"sv)
|
||||
{
|
||||
return Action::Subscribersoff;
|
||||
}
|
||||
if (eString == "unraid"sv)
|
||||
{
|
||||
return Action::Unraid;
|
||||
}
|
||||
if (eString == "delete"sv)
|
||||
{
|
||||
return Action::DeleteMessage;
|
||||
}
|
||||
if (eString == "unvip"sv)
|
||||
{
|
||||
return Action::Unvip;
|
||||
}
|
||||
if (eString == "vip"sv)
|
||||
{
|
||||
return Action::Vip;
|
||||
}
|
||||
if (eString == "raid"sv)
|
||||
{
|
||||
return Action::Raid;
|
||||
}
|
||||
if (eString == "add_blocked_term"sv)
|
||||
{
|
||||
return Action::AddBlockedTerm;
|
||||
}
|
||||
if (eString == "add_permitted_term"sv)
|
||||
{
|
||||
return Action::AddPermittedTerm;
|
||||
}
|
||||
if (eString == "remove_blocked_term"sv)
|
||||
{
|
||||
return Action::RemoveBlockedTerm;
|
||||
}
|
||||
if (eString == "remove_permitted_term"sv)
|
||||
{
|
||||
return Action::RemovePermittedTerm;
|
||||
}
|
||||
if (eString == "mod"sv)
|
||||
{
|
||||
return Action::Mod;
|
||||
}
|
||||
if (eString == "unmod"sv)
|
||||
{
|
||||
return Action::Unmod;
|
||||
}
|
||||
if (eString == "approve_unban_request"sv)
|
||||
{
|
||||
return Action::ApproveUnbanRequest;
|
||||
}
|
||||
if (eString == "deny_unban_request"sv)
|
||||
{
|
||||
return Action::DenyUnbanRequest;
|
||||
}
|
||||
if (eString == "warn"sv)
|
||||
{
|
||||
return Action::Warn;
|
||||
}
|
||||
if (eString == "shared_chat_ban"sv)
|
||||
{
|
||||
return Action::SharedChatBan;
|
||||
}
|
||||
if (eString == "shared_chat_timeout"sv)
|
||||
{
|
||||
return Action::SharedChatTimeout;
|
||||
}
|
||||
if (eString == "shared_chat_unban"sv)
|
||||
{
|
||||
return Action::SharedChatUnban;
|
||||
}
|
||||
if (eString == "shared_chat_untimeout"sv)
|
||||
{
|
||||
return Action::SharedChatUntimeout;
|
||||
}
|
||||
if (eString == "shared_chat_delete"sv)
|
||||
{
|
||||
return Action::SharedChatDelete;
|
||||
}
|
||||
|
||||
EVENTSUB_BAIL_HERE(error::Kind::UnknownEnumValue);
|
||||
}
|
||||
|
||||
boost::json::result_for<Followers, boost::json::value>::type tag_invoke(
|
||||
boost::json::try_value_to_tag<Followers> /* tag */,
|
||||
const boost::json::value &jvRoot)
|
||||
@@ -191,6 +41,13 @@ boost::json::result_for<Followers, boost::json::value>::type tag_invoke(
|
||||
};
|
||||
}
|
||||
|
||||
boost::json::result_for<FollowersOff, boost::json::value>::type tag_invoke(
|
||||
boost::json::try_value_to_tag<FollowersOff> /* tag */,
|
||||
const boost::json::value & /* jvRoot */)
|
||||
{
|
||||
return FollowersOff{};
|
||||
}
|
||||
|
||||
boost::json::result_for<Slow, boost::json::value>::type tag_invoke(
|
||||
boost::json::try_value_to_tag<Slow> /* tag */,
|
||||
const boost::json::value &jvRoot)
|
||||
@@ -221,6 +78,13 @@ boost::json::result_for<Slow, boost::json::value>::type tag_invoke(
|
||||
};
|
||||
}
|
||||
|
||||
boost::json::result_for<SlowOff, boost::json::value>::type tag_invoke(
|
||||
boost::json::try_value_to_tag<SlowOff> /* tag */,
|
||||
const boost::json::value & /* jvRoot */)
|
||||
{
|
||||
return SlowOff{};
|
||||
}
|
||||
|
||||
boost::json::result_for<Vip, boost::json::value>::type tag_invoke(
|
||||
boost::json::try_value_to_tag<Vip> /* tag */,
|
||||
const boost::json::value &jvRoot)
|
||||
@@ -515,6 +379,13 @@ boost::json::result_for<Ban, boost::json::value>::type tag_invoke(
|
||||
};
|
||||
}
|
||||
|
||||
boost::json::result_for<SharedChatBan, boost::json::value>::type tag_invoke(
|
||||
boost::json::try_value_to_tag<SharedChatBan> /* tag */,
|
||||
const boost::json::value & /* jvRoot */)
|
||||
{
|
||||
return SharedChatBan{};
|
||||
}
|
||||
|
||||
boost::json::result_for<Unban, boost::json::value>::type tag_invoke(
|
||||
boost::json::try_value_to_tag<Unban> /* tag */,
|
||||
const boost::json::value &jvRoot)
|
||||
@@ -571,6 +442,13 @@ boost::json::result_for<Unban, boost::json::value>::type tag_invoke(
|
||||
};
|
||||
}
|
||||
|
||||
boost::json::result_for<SharedChatUnban, boost::json::value>::type tag_invoke(
|
||||
boost::json::try_value_to_tag<SharedChatUnban> /* tag */,
|
||||
const boost::json::value & /* jvRoot */)
|
||||
{
|
||||
return SharedChatUnban{};
|
||||
}
|
||||
|
||||
boost::json::result_for<Timeout, boost::json::value>::type tag_invoke(
|
||||
boost::json::try_value_to_tag<Timeout> /* tag */,
|
||||
const boost::json::value &jvRoot)
|
||||
@@ -655,6 +533,13 @@ boost::json::result_for<Timeout, boost::json::value>::type tag_invoke(
|
||||
};
|
||||
}
|
||||
|
||||
boost::json::result_for<SharedChatTimeout, boost::json::value>::type tag_invoke(
|
||||
boost::json::try_value_to_tag<SharedChatTimeout> /* tag */,
|
||||
const boost::json::value & /* jvRoot */)
|
||||
{
|
||||
return SharedChatTimeout{};
|
||||
}
|
||||
|
||||
boost::json::result_for<Untimeout, boost::json::value>::type tag_invoke(
|
||||
boost::json::try_value_to_tag<Untimeout> /* tag */,
|
||||
const boost::json::value &jvRoot)
|
||||
@@ -711,6 +596,13 @@ boost::json::result_for<Untimeout, boost::json::value>::type tag_invoke(
|
||||
};
|
||||
}
|
||||
|
||||
boost::json::result_for<SharedChatUntimeout, boost::json::value>::type
|
||||
tag_invoke(boost::json::try_value_to_tag<SharedChatUntimeout> /* tag */,
|
||||
const boost::json::value & /* jvRoot */)
|
||||
{
|
||||
return SharedChatUntimeout{};
|
||||
}
|
||||
|
||||
boost::json::result_for<Raid, boost::json::value>::type tag_invoke(
|
||||
boost::json::try_value_to_tag<Raid> /* tag */,
|
||||
const boost::json::value &jvRoot)
|
||||
@@ -923,6 +815,13 @@ boost::json::result_for<Delete, boost::json::value>::type tag_invoke(
|
||||
};
|
||||
}
|
||||
|
||||
boost::json::result_for<SharedChatDelete, boost::json::value>::type tag_invoke(
|
||||
boost::json::try_value_to_tag<SharedChatDelete> /* tag */,
|
||||
const boost::json::value & /* jvRoot */)
|
||||
{
|
||||
return SharedChatDelete{};
|
||||
}
|
||||
|
||||
boost::json::result_for<AutomodTerms, boost::json::value>::type tag_invoke(
|
||||
boost::json::try_value_to_tag<AutomodTerms> /* tag */,
|
||||
const boost::json::value &jvRoot)
|
||||
@@ -993,6 +892,34 @@ boost::json::result_for<AutomodTerms, boost::json::value>::type tag_invoke(
|
||||
};
|
||||
}
|
||||
|
||||
boost::json::result_for<AddBlockedTerm, boost::json::value>::type tag_invoke(
|
||||
boost::json::try_value_to_tag<AddBlockedTerm> /* tag */,
|
||||
const boost::json::value & /* jvRoot */)
|
||||
{
|
||||
return AddBlockedTerm{};
|
||||
}
|
||||
|
||||
boost::json::result_for<AddPermittedTerm, boost::json::value>::type tag_invoke(
|
||||
boost::json::try_value_to_tag<AddPermittedTerm> /* tag */,
|
||||
const boost::json::value & /* jvRoot */)
|
||||
{
|
||||
return AddPermittedTerm{};
|
||||
}
|
||||
|
||||
boost::json::result_for<RemoveBlockedTerm, boost::json::value>::type tag_invoke(
|
||||
boost::json::try_value_to_tag<RemoveBlockedTerm> /* tag */,
|
||||
const boost::json::value & /* jvRoot */)
|
||||
{
|
||||
return RemoveBlockedTerm{};
|
||||
}
|
||||
|
||||
boost::json::result_for<RemovePermittedTerm, boost::json::value>::type
|
||||
tag_invoke(boost::json::try_value_to_tag<RemovePermittedTerm> /* tag */,
|
||||
const boost::json::value & /* jvRoot */)
|
||||
{
|
||||
return RemovePermittedTerm{};
|
||||
}
|
||||
|
||||
boost::json::result_for<UnbanRequest, boost::json::value>::type tag_invoke(
|
||||
boost::json::try_value_to_tag<UnbanRequest> /* tag */,
|
||||
const boost::json::value &jvRoot)
|
||||
@@ -1080,6 +1007,20 @@ boost::json::result_for<UnbanRequest, boost::json::value>::type tag_invoke(
|
||||
};
|
||||
}
|
||||
|
||||
boost::json::result_for<ApproveUnbanRequest, boost::json::value>::type
|
||||
tag_invoke(boost::json::try_value_to_tag<ApproveUnbanRequest> /* tag */,
|
||||
const boost::json::value & /* jvRoot */)
|
||||
{
|
||||
return ApproveUnbanRequest{};
|
||||
}
|
||||
|
||||
boost::json::result_for<DenyUnbanRequest, boost::json::value>::type tag_invoke(
|
||||
boost::json::try_value_to_tag<DenyUnbanRequest> /* tag */,
|
||||
const boost::json::value & /* jvRoot */)
|
||||
{
|
||||
return DenyUnbanRequest{};
|
||||
}
|
||||
|
||||
boost::json::result_for<Warn, boost::json::value>::type tag_invoke(
|
||||
boost::json::try_value_to_tag<Warn> /* tag */,
|
||||
const boost::json::value &jvRoot)
|
||||
@@ -1163,6 +1104,55 @@ boost::json::result_for<Warn, boost::json::value>::type tag_invoke(
|
||||
};
|
||||
}
|
||||
|
||||
boost::json::result_for<Clear, boost::json::value>::type tag_invoke(
|
||||
boost::json::try_value_to_tag<Clear> /* tag */,
|
||||
const boost::json::value & /* jvRoot */)
|
||||
{
|
||||
return Clear{};
|
||||
}
|
||||
|
||||
boost::json::result_for<EmoteOnly, boost::json::value>::type tag_invoke(
|
||||
boost::json::try_value_to_tag<EmoteOnly> /* tag */,
|
||||
const boost::json::value & /* jvRoot */)
|
||||
{
|
||||
return EmoteOnly{};
|
||||
}
|
||||
|
||||
boost::json::result_for<EmoteOnlyOff, boost::json::value>::type tag_invoke(
|
||||
boost::json::try_value_to_tag<EmoteOnlyOff> /* tag */,
|
||||
const boost::json::value & /* jvRoot */)
|
||||
{
|
||||
return EmoteOnlyOff{};
|
||||
}
|
||||
|
||||
boost::json::result_for<Uniquechat, boost::json::value>::type tag_invoke(
|
||||
boost::json::try_value_to_tag<Uniquechat> /* tag */,
|
||||
const boost::json::value & /* jvRoot */)
|
||||
{
|
||||
return Uniquechat{};
|
||||
}
|
||||
|
||||
boost::json::result_for<UniquechatOff, boost::json::value>::type tag_invoke(
|
||||
boost::json::try_value_to_tag<UniquechatOff> /* tag */,
|
||||
const boost::json::value & /* jvRoot */)
|
||||
{
|
||||
return UniquechatOff{};
|
||||
}
|
||||
|
||||
boost::json::result_for<Subscribers, boost::json::value>::type tag_invoke(
|
||||
boost::json::try_value_to_tag<Subscribers> /* tag */,
|
||||
const boost::json::value & /* jvRoot */)
|
||||
{
|
||||
return Subscribers{};
|
||||
}
|
||||
|
||||
boost::json::result_for<SubscribersOff, boost::json::value>::type tag_invoke(
|
||||
boost::json::try_value_to_tag<SubscribersOff> /* tag */,
|
||||
const boost::json::value & /* jvRoot */)
|
||||
{
|
||||
return SubscribersOff{};
|
||||
}
|
||||
|
||||
boost::json::result_for<Event, boost::json::value>::type tag_invoke(
|
||||
boost::json::try_value_to_tag<Event> /* tag */,
|
||||
const boost::json::value &jvRoot)
|
||||
@@ -1311,293 +1301,299 @@ boost::json::result_for<Event, boost::json::value>::type tag_invoke(
|
||||
return moderatorUserName.error();
|
||||
}
|
||||
|
||||
static_assert(
|
||||
std::is_trivially_copyable_v<
|
||||
std::remove_reference_t<decltype(std::declval<Event>().action)>>);
|
||||
const auto *jvaction = root.if_contains("action");
|
||||
if (jvaction == nullptr)
|
||||
const auto *jvactionTag = root.if_contains("action");
|
||||
if (jvactionTag == nullptr)
|
||||
{
|
||||
EVENTSUB_BAIL_HERE(error::Kind::FieldMissing);
|
||||
}
|
||||
|
||||
auto action = boost::json::try_value_to<Action>(*jvaction);
|
||||
|
||||
if (action.has_error())
|
||||
auto actionTagRes =
|
||||
boost::json::try_value_to<boost::json::string>(*jvactionTag);
|
||||
if (actionTagRes.has_error())
|
||||
{
|
||||
return action.error();
|
||||
return actionTagRes.error();
|
||||
}
|
||||
|
||||
static_assert(std::is_trivially_copyable_v<std::remove_reference_t<
|
||||
decltype(std::declval<Event>().followers)>>);
|
||||
std::optional<Followers> followers = std::nullopt;
|
||||
const auto *jvfollowers = root.if_contains("followers");
|
||||
if (jvfollowers != nullptr && !jvfollowers->is_null())
|
||||
std::string_view actionTag = *actionTagRes;
|
||||
decltype(std::declval<Event>().action) action;
|
||||
if (actionTag == Ban::TAG)
|
||||
{
|
||||
auto tfollowers = boost::json::try_value_to<Followers>(*jvfollowers);
|
||||
|
||||
if (tfollowers.has_error())
|
||||
const auto *actionVal = root.if_contains(detail::fieldFor<Ban>());
|
||||
if (!actionVal)
|
||||
{
|
||||
return tfollowers.error();
|
||||
EVENTSUB_BAIL_HERE(error::Kind::FieldMissing);
|
||||
}
|
||||
followers = tfollowers.value();
|
||||
auto actionBan = boost::json::try_value_to<Ban>(*actionVal);
|
||||
if (actionBan.has_error())
|
||||
{
|
||||
return actionBan.error();
|
||||
}
|
||||
action.emplace<Ban>(std::move(actionBan.value()));
|
||||
}
|
||||
|
||||
static_assert(
|
||||
std::is_trivially_copyable_v<
|
||||
std::remove_reference_t<decltype(std::declval<Event>().slow)>>);
|
||||
std::optional<Slow> slow = std::nullopt;
|
||||
const auto *jvslow = root.if_contains("slow");
|
||||
if (jvslow != nullptr && !jvslow->is_null())
|
||||
else if (actionTag == Timeout::TAG)
|
||||
{
|
||||
auto tslow = boost::json::try_value_to<Slow>(*jvslow);
|
||||
|
||||
if (tslow.has_error())
|
||||
const auto *actionVal = root.if_contains(detail::fieldFor<Timeout>());
|
||||
if (!actionVal)
|
||||
{
|
||||
return tslow.error();
|
||||
EVENTSUB_BAIL_HERE(error::Kind::FieldMissing);
|
||||
}
|
||||
slow = tslow.value();
|
||||
auto actionTimeout = boost::json::try_value_to<Timeout>(*actionVal);
|
||||
if (actionTimeout.has_error())
|
||||
{
|
||||
return actionTimeout.error();
|
||||
}
|
||||
action.emplace<Timeout>(std::move(actionTimeout.value()));
|
||||
}
|
||||
|
||||
std::optional<Vip> vip = std::nullopt;
|
||||
const auto *jvvip = root.if_contains("vip");
|
||||
if (jvvip != nullptr && !jvvip->is_null())
|
||||
else if (actionTag == Unban::TAG)
|
||||
{
|
||||
auto tvip = boost::json::try_value_to<Vip>(*jvvip);
|
||||
|
||||
if (tvip.has_error())
|
||||
const auto *actionVal = root.if_contains(detail::fieldFor<Unban>());
|
||||
if (!actionVal)
|
||||
{
|
||||
return tvip.error();
|
||||
EVENTSUB_BAIL_HERE(error::Kind::FieldMissing);
|
||||
}
|
||||
vip = std::move(tvip.value());
|
||||
auto actionUnban = boost::json::try_value_to<Unban>(*actionVal);
|
||||
if (actionUnban.has_error())
|
||||
{
|
||||
return actionUnban.error();
|
||||
}
|
||||
action.emplace<Unban>(std::move(actionUnban.value()));
|
||||
}
|
||||
|
||||
std::optional<Unvip> unvip = std::nullopt;
|
||||
const auto *jvunvip = root.if_contains("unvip");
|
||||
if (jvunvip != nullptr && !jvunvip->is_null())
|
||||
else if (actionTag == Untimeout::TAG)
|
||||
{
|
||||
auto tunvip = boost::json::try_value_to<Unvip>(*jvunvip);
|
||||
|
||||
if (tunvip.has_error())
|
||||
const auto *actionVal = root.if_contains(detail::fieldFor<Untimeout>());
|
||||
if (!actionVal)
|
||||
{
|
||||
return tunvip.error();
|
||||
EVENTSUB_BAIL_HERE(error::Kind::FieldMissing);
|
||||
}
|
||||
unvip = std::move(tunvip.value());
|
||||
auto actionUntimeout = boost::json::try_value_to<Untimeout>(*actionVal);
|
||||
if (actionUntimeout.has_error())
|
||||
{
|
||||
return actionUntimeout.error();
|
||||
}
|
||||
action.emplace<Untimeout>(std::move(actionUntimeout.value()));
|
||||
}
|
||||
|
||||
std::optional<Unmod> unmod = std::nullopt;
|
||||
const auto *jvunmod = root.if_contains("unmod");
|
||||
if (jvunmod != nullptr && !jvunmod->is_null())
|
||||
else if (actionTag == Clear::TAG)
|
||||
{
|
||||
auto tunmod = boost::json::try_value_to<Unmod>(*jvunmod);
|
||||
|
||||
if (tunmod.has_error())
|
||||
{
|
||||
return tunmod.error();
|
||||
}
|
||||
unmod = std::move(tunmod.value());
|
||||
action.emplace<Clear>();
|
||||
}
|
||||
|
||||
std::optional<Ban> ban = std::nullopt;
|
||||
const auto *jvban = root.if_contains("ban");
|
||||
if (jvban != nullptr && !jvban->is_null())
|
||||
else if (actionTag == EmoteOnly::TAG)
|
||||
{
|
||||
auto tban = boost::json::try_value_to<Ban>(*jvban);
|
||||
|
||||
if (tban.has_error())
|
||||
{
|
||||
return tban.error();
|
||||
}
|
||||
ban = std::move(tban.value());
|
||||
action.emplace<EmoteOnly>();
|
||||
}
|
||||
|
||||
std::optional<Unban> unban = std::nullopt;
|
||||
const auto *jvunban = root.if_contains("unban");
|
||||
if (jvunban != nullptr && !jvunban->is_null())
|
||||
else if (actionTag == EmoteOnlyOff::TAG)
|
||||
{
|
||||
auto tunban = boost::json::try_value_to<Unban>(*jvunban);
|
||||
|
||||
if (tunban.has_error())
|
||||
{
|
||||
return tunban.error();
|
||||
}
|
||||
unban = std::move(tunban.value());
|
||||
action.emplace<EmoteOnlyOff>();
|
||||
}
|
||||
|
||||
std::optional<Timeout> timeout = std::nullopt;
|
||||
const auto *jvtimeout = root.if_contains("timeout");
|
||||
if (jvtimeout != nullptr && !jvtimeout->is_null())
|
||||
else if (actionTag == Followers::TAG)
|
||||
{
|
||||
auto ttimeout = boost::json::try_value_to<Timeout>(*jvtimeout);
|
||||
|
||||
if (ttimeout.has_error())
|
||||
const auto *actionVal = root.if_contains(detail::fieldFor<Followers>());
|
||||
if (!actionVal)
|
||||
{
|
||||
return ttimeout.error();
|
||||
EVENTSUB_BAIL_HERE(error::Kind::FieldMissing);
|
||||
}
|
||||
timeout = std::move(ttimeout.value());
|
||||
auto actionFollowers = boost::json::try_value_to<Followers>(*actionVal);
|
||||
if (actionFollowers.has_error())
|
||||
{
|
||||
return actionFollowers.error();
|
||||
}
|
||||
action.emplace<Followers>(actionFollowers.value());
|
||||
}
|
||||
|
||||
std::optional<Untimeout> untimeout = std::nullopt;
|
||||
const auto *jvuntimeout = root.if_contains("untimeout");
|
||||
if (jvuntimeout != nullptr && !jvuntimeout->is_null())
|
||||
else if (actionTag == FollowersOff::TAG)
|
||||
{
|
||||
auto tuntimeout = boost::json::try_value_to<Untimeout>(*jvuntimeout);
|
||||
|
||||
if (tuntimeout.has_error())
|
||||
{
|
||||
return tuntimeout.error();
|
||||
}
|
||||
untimeout = std::move(tuntimeout.value());
|
||||
action.emplace<FollowersOff>();
|
||||
}
|
||||
|
||||
std::optional<Raid> raid = std::nullopt;
|
||||
const auto *jvraid = root.if_contains("raid");
|
||||
if (jvraid != nullptr && !jvraid->is_null())
|
||||
else if (actionTag == Uniquechat::TAG)
|
||||
{
|
||||
auto traid = boost::json::try_value_to<Raid>(*jvraid);
|
||||
|
||||
if (traid.has_error())
|
||||
{
|
||||
return traid.error();
|
||||
}
|
||||
raid = std::move(traid.value());
|
||||
action.emplace<Uniquechat>();
|
||||
}
|
||||
|
||||
std::optional<Unraid> unraid = std::nullopt;
|
||||
const auto *jvunraid = root.if_contains("unraid");
|
||||
if (jvunraid != nullptr && !jvunraid->is_null())
|
||||
else if (actionTag == UniquechatOff::TAG)
|
||||
{
|
||||
auto tunraid = boost::json::try_value_to<Unraid>(*jvunraid);
|
||||
|
||||
if (tunraid.has_error())
|
||||
{
|
||||
return tunraid.error();
|
||||
}
|
||||
unraid = std::move(tunraid.value());
|
||||
action.emplace<UniquechatOff>();
|
||||
}
|
||||
|
||||
std::optional<Delete> deleteMessage = std::nullopt;
|
||||
const auto *jvdeleteMessage = root.if_contains("delete");
|
||||
if (jvdeleteMessage != nullptr && !jvdeleteMessage->is_null())
|
||||
else if (actionTag == Slow::TAG)
|
||||
{
|
||||
auto tdeleteMessage =
|
||||
boost::json::try_value_to<Delete>(*jvdeleteMessage);
|
||||
|
||||
if (tdeleteMessage.has_error())
|
||||
const auto *actionVal = root.if_contains(detail::fieldFor<Slow>());
|
||||
if (!actionVal)
|
||||
{
|
||||
return tdeleteMessage.error();
|
||||
EVENTSUB_BAIL_HERE(error::Kind::FieldMissing);
|
||||
}
|
||||
deleteMessage = std::move(tdeleteMessage.value());
|
||||
auto actionSlow = boost::json::try_value_to<Slow>(*actionVal);
|
||||
if (actionSlow.has_error())
|
||||
{
|
||||
return actionSlow.error();
|
||||
}
|
||||
action.emplace<Slow>(actionSlow.value());
|
||||
}
|
||||
|
||||
std::optional<AutomodTerms> automodTerms = std::nullopt;
|
||||
const auto *jvautomodTerms = root.if_contains("automod_terms");
|
||||
if (jvautomodTerms != nullptr && !jvautomodTerms->is_null())
|
||||
else if (actionTag == SlowOff::TAG)
|
||||
{
|
||||
auto tautomodTerms =
|
||||
boost::json::try_value_to<AutomodTerms>(*jvautomodTerms);
|
||||
|
||||
if (tautomodTerms.has_error())
|
||||
{
|
||||
return tautomodTerms.error();
|
||||
}
|
||||
automodTerms = std::move(tautomodTerms.value());
|
||||
action.emplace<SlowOff>();
|
||||
}
|
||||
|
||||
std::optional<UnbanRequest> unbanRequest = std::nullopt;
|
||||
const auto *jvunbanRequest = root.if_contains("unban_request");
|
||||
if (jvunbanRequest != nullptr && !jvunbanRequest->is_null())
|
||||
else if (actionTag == Subscribers::TAG)
|
||||
{
|
||||
auto tunbanRequest =
|
||||
boost::json::try_value_to<UnbanRequest>(*jvunbanRequest);
|
||||
|
||||
if (tunbanRequest.has_error())
|
||||
{
|
||||
return tunbanRequest.error();
|
||||
}
|
||||
unbanRequest = std::move(tunbanRequest.value());
|
||||
action.emplace<Subscribers>();
|
||||
}
|
||||
|
||||
std::optional<Warn> warn = std::nullopt;
|
||||
const auto *jvwarn = root.if_contains("warn");
|
||||
if (jvwarn != nullptr && !jvwarn->is_null())
|
||||
else if (actionTag == SubscribersOff::TAG)
|
||||
{
|
||||
auto twarn = boost::json::try_value_to<Warn>(*jvwarn);
|
||||
|
||||
if (twarn.has_error())
|
||||
{
|
||||
return twarn.error();
|
||||
}
|
||||
warn = std::move(twarn.value());
|
||||
action.emplace<SubscribersOff>();
|
||||
}
|
||||
|
||||
std::optional<Ban> sharedChatBan = std::nullopt;
|
||||
const auto *jvsharedChatBan = root.if_contains("shared_chat_ban");
|
||||
if (jvsharedChatBan != nullptr && !jvsharedChatBan->is_null())
|
||||
else if (actionTag == Unraid::TAG)
|
||||
{
|
||||
auto tsharedChatBan = boost::json::try_value_to<Ban>(*jvsharedChatBan);
|
||||
|
||||
if (tsharedChatBan.has_error())
|
||||
const auto *actionVal = root.if_contains(detail::fieldFor<Unraid>());
|
||||
if (!actionVal)
|
||||
{
|
||||
return tsharedChatBan.error();
|
||||
EVENTSUB_BAIL_HERE(error::Kind::FieldMissing);
|
||||
}
|
||||
sharedChatBan = std::move(tsharedChatBan.value());
|
||||
auto actionUnraid = boost::json::try_value_to<Unraid>(*actionVal);
|
||||
if (actionUnraid.has_error())
|
||||
{
|
||||
return actionUnraid.error();
|
||||
}
|
||||
action.emplace<Unraid>(std::move(actionUnraid.value()));
|
||||
}
|
||||
|
||||
std::optional<Unban> sharedChatUnban = std::nullopt;
|
||||
const auto *jvsharedChatUnban = root.if_contains("shared_chat_unban");
|
||||
if (jvsharedChatUnban != nullptr && !jvsharedChatUnban->is_null())
|
||||
else if (actionTag == Delete::TAG)
|
||||
{
|
||||
auto tsharedChatUnban =
|
||||
boost::json::try_value_to<Unban>(*jvsharedChatUnban);
|
||||
|
||||
if (tsharedChatUnban.has_error())
|
||||
const auto *actionVal = root.if_contains(detail::fieldFor<Delete>());
|
||||
if (!actionVal)
|
||||
{
|
||||
return tsharedChatUnban.error();
|
||||
EVENTSUB_BAIL_HERE(error::Kind::FieldMissing);
|
||||
}
|
||||
sharedChatUnban = std::move(tsharedChatUnban.value());
|
||||
auto actionDelete = boost::json::try_value_to<Delete>(*actionVal);
|
||||
if (actionDelete.has_error())
|
||||
{
|
||||
return actionDelete.error();
|
||||
}
|
||||
action.emplace<Delete>(std::move(actionDelete.value()));
|
||||
}
|
||||
|
||||
std::optional<Timeout> sharedChatTimeout = std::nullopt;
|
||||
const auto *jvsharedChatTimeout = root.if_contains("shared_chat_timeout");
|
||||
if (jvsharedChatTimeout != nullptr && !jvsharedChatTimeout->is_null())
|
||||
else if (actionTag == Unvip::TAG)
|
||||
{
|
||||
auto tsharedChatTimeout =
|
||||
boost::json::try_value_to<Timeout>(*jvsharedChatTimeout);
|
||||
|
||||
if (tsharedChatTimeout.has_error())
|
||||
const auto *actionVal = root.if_contains(detail::fieldFor<Unvip>());
|
||||
if (!actionVal)
|
||||
{
|
||||
return tsharedChatTimeout.error();
|
||||
EVENTSUB_BAIL_HERE(error::Kind::FieldMissing);
|
||||
}
|
||||
sharedChatTimeout = std::move(tsharedChatTimeout.value());
|
||||
auto actionUnvip = boost::json::try_value_to<Unvip>(*actionVal);
|
||||
if (actionUnvip.has_error())
|
||||
{
|
||||
return actionUnvip.error();
|
||||
}
|
||||
action.emplace<Unvip>(std::move(actionUnvip.value()));
|
||||
}
|
||||
|
||||
std::optional<Untimeout> sharedChatUntimeout = std::nullopt;
|
||||
const auto *jvsharedChatUntimeout =
|
||||
root.if_contains("shared_chat_untimeout");
|
||||
if (jvsharedChatUntimeout != nullptr && !jvsharedChatUntimeout->is_null())
|
||||
else if (actionTag == Vip::TAG)
|
||||
{
|
||||
auto tsharedChatUntimeout =
|
||||
boost::json::try_value_to<Untimeout>(*jvsharedChatUntimeout);
|
||||
|
||||
if (tsharedChatUntimeout.has_error())
|
||||
const auto *actionVal = root.if_contains(detail::fieldFor<Vip>());
|
||||
if (!actionVal)
|
||||
{
|
||||
return tsharedChatUntimeout.error();
|
||||
EVENTSUB_BAIL_HERE(error::Kind::FieldMissing);
|
||||
}
|
||||
sharedChatUntimeout = std::move(tsharedChatUntimeout.value());
|
||||
auto actionVip = boost::json::try_value_to<Vip>(*actionVal);
|
||||
if (actionVip.has_error())
|
||||
{
|
||||
return actionVip.error();
|
||||
}
|
||||
action.emplace<Vip>(std::move(actionVip.value()));
|
||||
}
|
||||
|
||||
std::optional<Delete> sharedChatDelete = std::nullopt;
|
||||
const auto *jvsharedChatDelete = root.if_contains("shared_chat_delete");
|
||||
if (jvsharedChatDelete != nullptr && !jvsharedChatDelete->is_null())
|
||||
else if (actionTag == Raid::TAG)
|
||||
{
|
||||
auto tsharedChatDelete =
|
||||
boost::json::try_value_to<Delete>(*jvsharedChatDelete);
|
||||
|
||||
if (tsharedChatDelete.has_error())
|
||||
const auto *actionVal = root.if_contains(detail::fieldFor<Raid>());
|
||||
if (!actionVal)
|
||||
{
|
||||
return tsharedChatDelete.error();
|
||||
EVENTSUB_BAIL_HERE(error::Kind::FieldMissing);
|
||||
}
|
||||
sharedChatDelete = std::move(tsharedChatDelete.value());
|
||||
auto actionRaid = boost::json::try_value_to<Raid>(*actionVal);
|
||||
if (actionRaid.has_error())
|
||||
{
|
||||
return actionRaid.error();
|
||||
}
|
||||
action.emplace<Raid>(std::move(actionRaid.value()));
|
||||
}
|
||||
else if (actionTag == AddBlockedTerm::TAG)
|
||||
{
|
||||
action.emplace<AddBlockedTerm>();
|
||||
}
|
||||
else if (actionTag == AddPermittedTerm::TAG)
|
||||
{
|
||||
action.emplace<AddPermittedTerm>();
|
||||
}
|
||||
else if (actionTag == RemoveBlockedTerm::TAG)
|
||||
{
|
||||
action.emplace<RemoveBlockedTerm>();
|
||||
}
|
||||
else if (actionTag == RemovePermittedTerm::TAG)
|
||||
{
|
||||
action.emplace<RemovePermittedTerm>();
|
||||
}
|
||||
else if (actionTag == Mod::TAG)
|
||||
{
|
||||
const auto *actionVal = root.if_contains(detail::fieldFor<Mod>());
|
||||
if (!actionVal)
|
||||
{
|
||||
EVENTSUB_BAIL_HERE(error::Kind::FieldMissing);
|
||||
}
|
||||
auto actionMod = boost::json::try_value_to<Mod>(*actionVal);
|
||||
if (actionMod.has_error())
|
||||
{
|
||||
return actionMod.error();
|
||||
}
|
||||
action.emplace<Mod>(std::move(actionMod.value()));
|
||||
}
|
||||
else if (actionTag == Unmod::TAG)
|
||||
{
|
||||
const auto *actionVal = root.if_contains(detail::fieldFor<Unmod>());
|
||||
if (!actionVal)
|
||||
{
|
||||
EVENTSUB_BAIL_HERE(error::Kind::FieldMissing);
|
||||
}
|
||||
auto actionUnmod = boost::json::try_value_to<Unmod>(*actionVal);
|
||||
if (actionUnmod.has_error())
|
||||
{
|
||||
return actionUnmod.error();
|
||||
}
|
||||
action.emplace<Unmod>(std::move(actionUnmod.value()));
|
||||
}
|
||||
else if (actionTag == ApproveUnbanRequest::TAG)
|
||||
{
|
||||
action.emplace<ApproveUnbanRequest>();
|
||||
}
|
||||
else if (actionTag == DenyUnbanRequest::TAG)
|
||||
{
|
||||
action.emplace<DenyUnbanRequest>();
|
||||
}
|
||||
else if (actionTag == Warn::TAG)
|
||||
{
|
||||
const auto *actionVal = root.if_contains(detail::fieldFor<Warn>());
|
||||
if (!actionVal)
|
||||
{
|
||||
EVENTSUB_BAIL_HERE(error::Kind::FieldMissing);
|
||||
}
|
||||
auto actionWarn = boost::json::try_value_to<Warn>(*actionVal);
|
||||
if (actionWarn.has_error())
|
||||
{
|
||||
return actionWarn.error();
|
||||
}
|
||||
action.emplace<Warn>(std::move(actionWarn.value()));
|
||||
}
|
||||
else if (actionTag == SharedChatBan::TAG)
|
||||
{
|
||||
action.emplace<SharedChatBan>();
|
||||
}
|
||||
else if (actionTag == SharedChatTimeout::TAG)
|
||||
{
|
||||
action.emplace<SharedChatTimeout>();
|
||||
}
|
||||
else if (actionTag == SharedChatUnban::TAG)
|
||||
{
|
||||
action.emplace<SharedChatUnban>();
|
||||
}
|
||||
else if (actionTag == SharedChatUntimeout::TAG)
|
||||
{
|
||||
action.emplace<SharedChatUntimeout>();
|
||||
}
|
||||
else if (actionTag == SharedChatDelete::TAG)
|
||||
{
|
||||
action.emplace<SharedChatDelete>();
|
||||
}
|
||||
else
|
||||
{
|
||||
action.emplace<std::string>(actionTag);
|
||||
}
|
||||
|
||||
return Event{
|
||||
@@ -1610,27 +1606,7 @@ boost::json::result_for<Event, boost::json::value>::type tag_invoke(
|
||||
.moderatorUserID = std::move(moderatorUserID.value()),
|
||||
.moderatorUserLogin = std::move(moderatorUserLogin.value()),
|
||||
.moderatorUserName = std::move(moderatorUserName.value()),
|
||||
.action = action.value(),
|
||||
.followers = followers,
|
||||
.slow = slow,
|
||||
.vip = std::move(vip),
|
||||
.unvip = std::move(unvip),
|
||||
.unmod = std::move(unmod),
|
||||
.ban = std::move(ban),
|
||||
.unban = std::move(unban),
|
||||
.timeout = std::move(timeout),
|
||||
.untimeout = std::move(untimeout),
|
||||
.raid = std::move(raid),
|
||||
.unraid = std::move(unraid),
|
||||
.deleteMessage = std::move(deleteMessage),
|
||||
.automodTerms = std::move(automodTerms),
|
||||
.unbanRequest = std::move(unbanRequest),
|
||||
.warn = std::move(warn),
|
||||
.sharedChatBan = std::move(sharedChatBan),
|
||||
.sharedChatUnban = std::move(sharedChatUnban),
|
||||
.sharedChatTimeout = std::move(sharedChatTimeout),
|
||||
.sharedChatUntimeout = std::move(sharedChatUntimeout),
|
||||
.sharedChatDelete = std::move(sharedChatDelete),
|
||||
.action = std::move(action),
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user