Fix automod crash (#3716)

This commit is contained in:
pajlada 2022-05-07 20:48:10 +02:00 committed by GitHub
parent f97780d84e
commit 65301a3359
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 25 additions and 18 deletions

View file

@ -7,7 +7,7 @@
- Minor: Adjust large stream thumbnail to 16:9 (#3655) - Minor: Adjust large stream thumbnail to 16:9 (#3655)
- Minor: Fixed being unable to load Twitch Usercards from the `/mentions` tab. (#3623) - Minor: Fixed being unable to load Twitch Usercards from the `/mentions` tab. (#3623)
- Minor: Add information about the user's operating system in the About page. (#3663) - Minor: Add information about the user's operating system in the About page. (#3663)
- Bugfix: Connection to Twitch PubSub now recovers more reliably. (#3643) - Bugfix: Connection to Twitch PubSub now recovers more reliably. (#3643, #3716)
- Minor: Added chatter count for each category in viewer list. (#3683) - Minor: Added chatter count for each category in viewer list. (#3683)
- Minor: Sorted usernames in /vips message to be case-insensitive. (#3696) - Minor: Sorted usernames in /vips message to be case-insensitive. (#3696)
- Minor: Added option to open a user's chat in a new tab from the usercard profile picture context menu. (#3625) - Minor: Added option to open a user's chat in a new tab from the usercard profile picture context menu. (#3625)

View file

@ -332,23 +332,14 @@ void Application::initPubSub()
}); });
}); });
const auto handleAutoModMessage = [&](const auto &action) { this->twitch->pubsub->signals_.moderation.autoModMessageCaught.connect(
auto chan = this->twitch->getChannelOrEmptyByID(action.roomID); [&](const auto &msg, const QString &channelID) {
auto chan = this->twitch->getChannelOrEmptyByID(channelID);
if (chan->isEmpty()) if (chan->isEmpty())
{ {
return; return;
} }
postToThread([chan, action] {
const auto p = makeAutomodMessage(action);
chan->addMessage(p.first);
chan->addMessage(p.second);
});
};
this->twitch->pubsub->signals_.moderation.autoModMessageCaught.connect(
[&](const auto &msg, const QString &channelID) {
switch (msg.type) switch (msg.type)
{ {
case PubSubAutoModQueueMessage::Type::AutoModCaughtMessage: { case PubSubAutoModQueueMessage::Type::AutoModCaughtMessage: {
@ -415,7 +406,11 @@ void Application::initPubSub()
action.target = action.target =
ActionUser{msg.senderUserID, msg.senderUserLogin, ActionUser{msg.senderUserID, msg.senderUserLogin,
senderDisplayName, senderColor}; senderDisplayName, senderColor};
handleAutoModMessage(action); postToThread([chan, action] {
const auto p = makeAutomodMessage(action);
chan->addMessage(p.first);
chan->addMessage(p.second);
});
} }
// "ALLOWED" and "DENIED" statuses remain unimplemented // "ALLOWED" and "DENIED" statuses remain unimplemented
// They are versions of automod_message_(denied|approved) but for mods. // They are versions of automod_message_(denied|approved) but for mods.
@ -430,7 +425,19 @@ void Application::initPubSub()
}); });
this->twitch->pubsub->signals_.moderation.autoModMessageBlocked.connect( this->twitch->pubsub->signals_.moderation.autoModMessageBlocked.connect(
handleAutoModMessage); [&](const auto &action) {
auto chan = this->twitch->getChannelOrEmptyByID(action.roomID);
if (chan->isEmpty())
{
return;
}
postToThread([chan, action] {
const auto p = makeAutomodMessage(action);
chan->addMessage(p.first);
chan->addMessage(p.second);
});
});
this->twitch->pubsub->signals_.moderation.automodUserMessage.connect( this->twitch->pubsub->signals_.moderation.automodUserMessage.connect(
[&](const auto &action) { [&](const auto &action) {