From ee1421d77054f54eb07e2c6e5ad25e9777e1acd6 Mon Sep 17 00:00:00 2001 From: pajlada Date: Sat, 15 Mar 2025 12:33:01 +0100 Subject: [PATCH] chore/more eventsub tests plus some extra info output if we ignore a message (#6079) --- CHANGELOG.md | 2 +- src/providers/twitch/eventsub/Connection.cpp | 3 + .../restricted-bad-type.json | 206 +++++++++++++++++ .../restricted-ban-evader.json | 211 ++++++++++++++++++ 4 files changed, 421 insertions(+), 1 deletion(-) create mode 100644 tests/snapshots/EventSub/channel-suspicious-user-message/restricted-bad-type.json create mode 100644 tests/snapshots/EventSub/channel-suspicious-user-message/restricted-ban-evader.json diff --git a/CHANGELOG.md b/CHANGELOG.md index cb8d4eae..fd1979b7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -47,7 +47,7 @@ - Bugfix: Fixed a thick border on Windows 11. (#5836) - Bugfix: Fixed some windows not immediately closing. (#6054) - Dev: Subscriptions to PubSub channel points redemption topics now use no auth token, making it continue to work during PubSub shutdown. (#5947) -- Dev: Add initial experimental EventSub support. (#5837, #5895, #5897, #5904, #5910, #5903, #5915, #5916, #5930, #5935, #5932, #5943, #5952, #5953, #5968, #5973, #5974, #5980, #5981, #5985, #5990, #5992, #5993, #5996, #5995, #6000, #6001, #6002, #6003, #6005, #6007, #6010, #6008, #6012, #6013, #6015, #6017, #6027, #6028, #6035, #6036, #6040, #6041, #6048, #6058, #6059, #6078) +- Dev: Add initial experimental EventSub support. (#5837, #5895, #5897, #5904, #5910, #5903, #5915, #5916, #5930, #5935, #5932, #5943, #5952, #5953, #5968, #5973, #5974, #5980, #5981, #5985, #5990, #5992, #5993, #5996, #5995, #6000, #6001, #6002, #6003, #6005, #6007, #6010, #6008, #6012, #6013, #6015, #6017, #6027, #6028, #6035, #6036, #6040, #6041, #6048, #6058, #6059, #6078, #6079) - Dev: Remove unneeded platform specifier for toasts. (#5914) - Dev: Cleanly shutdown on `SIGINT`/`SIGTERM` on Linux & macOS. (#6053) - Dev: Highlight checks now use non-capturing groups for the boundaries. (#5784) diff --git a/src/providers/twitch/eventsub/Connection.cpp b/src/providers/twitch/eventsub/Connection.cpp index 272e2257..e83b7659 100644 --- a/src/providers/twitch/eventsub/Connection.cpp +++ b/src/providers/twitch/eventsub/Connection.cpp @@ -278,6 +278,9 @@ void Connection::onChannelSuspiciousUserMessage( if (payload.event.lowTrustStatus != lib::suspicious_users::Status::Restricted) { + qCInfo(LOG) << "Ignoring low trust status message from user" + << payload.event.userLogin.qt() << "because status is" + << static_cast(payload.event.lowTrustStatus); return; } diff --git a/tests/snapshots/EventSub/channel-suspicious-user-message/restricted-bad-type.json b/tests/snapshots/EventSub/channel-suspicious-user-message/restricted-bad-type.json new file mode 100644 index 00000000..d3b5f476 --- /dev/null +++ b/tests/snapshots/EventSub/channel-suspicious-user-message/restricted-bad-type.json @@ -0,0 +1,206 @@ +{ + "input": { + "ban_evasion_evaluation": "unknown", + "broadcaster_user_id": "11148817", + "broadcaster_user_login": "pajlada", + "broadcaster_user_name": "pajlada", + "low_trust_status": "restricted", + "message": { + "fragments": [ + { + "cheermote": null, + "emote": null, + "text": "FeelsDankMan", + "type": "text" + } + ], + "message_id": "4715b69c-a147-4ff8-bbb5-7c830544d809", + "text": "FeelsDankMan" + }, + "shared_ban_channel_ids": null, + "types": [ + "thistypedoesnotexist" + ], + "user_id": "129546453", + "user_login": "nerixyz", + "user_name": "nerixyz" + }, + "output": [ + { + "badgeInfos": { + }, + "badges": [ + ], + "channelName": "pajlada", + "count": 1, + "displayName": "", + "elements": [ + { + "emote": { + "homePage": "https://dashboard.twitch.tv/settings/moderation/automod", + "images": { + "1x": "" + }, + "name": "", + "tooltip": "AutoMod" + }, + "flags": "BadgeChannelAuthority", + "link": { + "type": "None", + "value": "" + }, + "tooltip": "AutoMod", + "trailingSpace": true, + "type": "BadgeElement" + }, + { + "color": "#ff0000ff", + "flags": "Text", + "link": { + "type": "None", + "value": "" + }, + "style": "ChatMediumBold", + "tooltip": "", + "trailingSpace": true, + "type": "TextElement", + "words": [ + "Suspicious", + "User:" + ] + }, + { + "color": "Text", + "flags": "Text", + "link": { + "type": "None", + "value": "" + }, + "style": "ChatMedium", + "tooltip": "", + "trailingSpace": true, + "type": "TextElement", + "words": [ + "Restricted" + ] + } + ], + "flags": "LowTrustUsers|RestrictedMessage|EventSub", + "id": "", + "localizedName": "", + "loginName": "", + "messageText": "Suspicious User: Restricted", + "searchText": "Suspicious User: Restricted", + "serverReceivedTime": "2024-05-14T12:31:47Z", + "timeoutUser": "", + "userID": "", + "usernameColor": "#ff000000" + }, + { + "badgeInfos": { + }, + "badges": [ + ], + "channelName": "pajlada", + "count": 1, + "displayName": "", + "elements": [ + { + "color": "System", + "flags": "ChannelName", + "link": { + "type": "JumpToChannel", + "value": "pajlada" + }, + "style": "ChatMedium", + "tooltip": "", + "trailingSpace": true, + "type": "TextElement", + "words": [ + "#pajlada" + ] + }, + { + "element": { + "color": "System", + "flags": "Timestamp", + "link": { + "type": "None", + "value": "" + }, + "style": "TimestampMedium", + "tooltip": "", + "trailingSpace": true, + "type": "TextElement", + "words": [ + "12:31" + ] + }, + "flags": "Timestamp", + "format": "", + "link": { + "type": "None", + "value": "" + }, + "time": "12:31:47", + "tooltip": "", + "trailingSpace": true, + "type": "TimestampElement" + }, + { + "flags": "ModeratorTools", + "link": { + "type": "None", + "value": "" + }, + "tooltip": "", + "trailingSpace": true, + "type": "TwitchModerationElement" + }, + { + "color": "Text", + "fallbackColor": "Text", + "flags": "Text|Mention", + "link": { + "type": "None", + "value": "" + }, + "style": "ChatMedium", + "tooltip": "", + "trailingSpace": true, + "type": "MentionElement", + "userColor": "Text", + "userLoginName": "nerixyz", + "words": [ + "nerixyz:" + ] + }, + { + "color": "Text", + "flags": "Text", + "link": { + "type": "None", + "value": "" + }, + "style": "ChatMedium", + "tooltip": "", + "trailingSpace": true, + "type": "TextElement", + "words": [ + "FeelsDankMan" + ] + } + ], + "flags": "PubSub|LowTrustUsers|RestrictedMessage|EventSub", + "id": "", + "localizedName": "", + "loginName": "nerixyz", + "messageText": "nerixyz: FeelsDankMan", + "searchText": "nerixyz: FeelsDankMan", + "serverReceivedTime": "2024-05-14T12:31:47Z", + "timeoutUser": "", + "userID": "", + "usernameColor": "#ff000000" + } + ] +} diff --git a/tests/snapshots/EventSub/channel-suspicious-user-message/restricted-ban-evader.json b/tests/snapshots/EventSub/channel-suspicious-user-message/restricted-ban-evader.json new file mode 100644 index 00000000..ecbb21b0 --- /dev/null +++ b/tests/snapshots/EventSub/channel-suspicious-user-message/restricted-ban-evader.json @@ -0,0 +1,211 @@ +{ + "input": { + "ban_evasion_evaluation": "unknown", + "broadcaster_user_id": "11148817", + "broadcaster_user_login": "pajlada", + "broadcaster_user_name": "pajlada", + "low_trust_status": "restricted", + "message": { + "fragments": [ + { + "cheermote": null, + "emote": null, + "text": "FeelsDankMan", + "type": "text" + } + ], + "message_id": "4715b69c-a147-4ff8-bbb5-7c830544d809", + "text": "FeelsDankMan" + }, + "shared_ban_channel_ids": null, + "types": [ + "ban_evader_detector" + ], + "user_id": "129546453", + "user_login": "nerixyz", + "user_name": "nerixyz" + }, + "output": [ + { + "badgeInfos": { + }, + "badges": [ + ], + "channelName": "pajlada", + "count": 1, + "displayName": "", + "elements": [ + { + "emote": { + "homePage": "https://dashboard.twitch.tv/settings/moderation/automod", + "images": { + "1x": "" + }, + "name": "", + "tooltip": "AutoMod" + }, + "flags": "BadgeChannelAuthority", + "link": { + "type": "None", + "value": "" + }, + "tooltip": "AutoMod", + "trailingSpace": true, + "type": "BadgeElement" + }, + { + "color": "#ff0000ff", + "flags": "Text", + "link": { + "type": "None", + "value": "" + }, + "style": "ChatMediumBold", + "tooltip": "", + "trailingSpace": true, + "type": "TextElement", + "words": [ + "Suspicious", + "User:" + ] + }, + { + "color": "Text", + "flags": "Text", + "link": { + "type": "None", + "value": "" + }, + "style": "ChatMedium", + "tooltip": "", + "trailingSpace": true, + "type": "TextElement", + "words": [ + "Restricted.", + "Detected", + "as", + "possible", + "ban", + "evader" + ] + } + ], + "flags": "LowTrustUsers|RestrictedMessage|EventSub", + "id": "", + "localizedName": "", + "loginName": "", + "messageText": "Suspicious User: Restricted. Detected as possible ban evader", + "searchText": "Suspicious User: Restricted. Detected as possible ban evader", + "serverReceivedTime": "2024-05-14T12:31:47Z", + "timeoutUser": "", + "userID": "", + "usernameColor": "#ff000000" + }, + { + "badgeInfos": { + }, + "badges": [ + ], + "channelName": "pajlada", + "count": 1, + "displayName": "", + "elements": [ + { + "color": "System", + "flags": "ChannelName", + "link": { + "type": "JumpToChannel", + "value": "pajlada" + }, + "style": "ChatMedium", + "tooltip": "", + "trailingSpace": true, + "type": "TextElement", + "words": [ + "#pajlada" + ] + }, + { + "element": { + "color": "System", + "flags": "Timestamp", + "link": { + "type": "None", + "value": "" + }, + "style": "TimestampMedium", + "tooltip": "", + "trailingSpace": true, + "type": "TextElement", + "words": [ + "12:31" + ] + }, + "flags": "Timestamp", + "format": "", + "link": { + "type": "None", + "value": "" + }, + "time": "12:31:47", + "tooltip": "", + "trailingSpace": true, + "type": "TimestampElement" + }, + { + "flags": "ModeratorTools", + "link": { + "type": "None", + "value": "" + }, + "tooltip": "", + "trailingSpace": true, + "type": "TwitchModerationElement" + }, + { + "color": "Text", + "fallbackColor": "Text", + "flags": "Text|Mention", + "link": { + "type": "None", + "value": "" + }, + "style": "ChatMedium", + "tooltip": "", + "trailingSpace": true, + "type": "MentionElement", + "userColor": "Text", + "userLoginName": "nerixyz", + "words": [ + "nerixyz:" + ] + }, + { + "color": "Text", + "flags": "Text", + "link": { + "type": "None", + "value": "" + }, + "style": "ChatMedium", + "tooltip": "", + "trailingSpace": true, + "type": "TextElement", + "words": [ + "FeelsDankMan" + ] + } + ], + "flags": "PubSub|LowTrustUsers|RestrictedMessage|EventSub", + "id": "", + "localizedName": "", + "loginName": "nerixyz", + "messageText": "nerixyz: FeelsDankMan", + "searchText": "nerixyz: FeelsDankMan", + "serverReceivedTime": "2024-05-14T12:31:47Z", + "timeoutUser": "", + "userID": "", + "usernameColor": "#ff000000" + } + ] +}