feat(eventsub): implement (shared-chat-)ban (#5985)
This commit is contained in:
@@ -73,52 +73,8 @@ void Connection::onChannelBan(
|
||||
const lib::payload::channel_ban::v1::Payload &payload)
|
||||
{
|
||||
(void)metadata;
|
||||
|
||||
auto roomID = QString::fromStdString(payload.event.broadcasterUserID);
|
||||
|
||||
BanAction action{};
|
||||
|
||||
if (!getApp()->isTest())
|
||||
{
|
||||
action.timestamp = std::chrono::steady_clock::now();
|
||||
}
|
||||
action.roomID = roomID;
|
||||
action.source = ActionUser{
|
||||
.id = QString::fromStdString(payload.event.moderatorUserID),
|
||||
.login = QString::fromStdString(payload.event.moderatorUserLogin),
|
||||
.displayName = QString::fromStdString(payload.event.moderatorUserName),
|
||||
};
|
||||
action.target = ActionUser{
|
||||
.id = QString::fromStdString(payload.event.userID),
|
||||
.login = QString::fromStdString(payload.event.userLogin),
|
||||
.displayName = QString::fromStdString(payload.event.userName),
|
||||
};
|
||||
action.reason = QString::fromStdString(payload.event.reason);
|
||||
if (payload.event.isPermanent)
|
||||
{
|
||||
action.duration = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
auto timeoutDuration = payload.event.timeoutDuration();
|
||||
auto timeoutDurationInSeconds =
|
||||
std::chrono::duration_cast<std::chrono::seconds>(timeoutDuration)
|
||||
.count();
|
||||
action.duration = timeoutDurationInSeconds;
|
||||
}
|
||||
|
||||
auto chan = getApp()->getTwitch()->getChannelOrEmptyByID(roomID);
|
||||
|
||||
runInGuiThread([action{std::move(action)}, chan{std::move(chan)}] {
|
||||
auto time = QDateTime::currentDateTime();
|
||||
if (getApp()->isTest())
|
||||
{
|
||||
time = QDateTime::fromSecsSinceEpoch(0).toUTC();
|
||||
}
|
||||
MessageBuilder msg(action, time);
|
||||
msg->flags.set(MessageFlag::PubSub);
|
||||
chan->addOrReplaceTimeout(msg.release(), QDateTime::currentDateTime());
|
||||
});
|
||||
qCDebug(LOG) << "On channel ban event for channel"
|
||||
<< payload.event.broadcasterUserLogin.c_str();
|
||||
}
|
||||
|
||||
void Connection::onStreamOnline(
|
||||
|
||||
Reference in New Issue
Block a user