Allow non-message phrases to be highlighted by self (#3835)

* All non-phrase highlights can now trigger on messages from self

New state:
Allows self highlights: Subscription, Whisper, User, Badge
Does not allow self highlights: Message

* Add changelog entry

* fix PR number in changelog
This commit is contained in:
pajlada
2022-06-26 12:43:34 +02:00
committed by GitHub
parent 881986d86f
commit 8bdfbf7b87
5 changed files with 68 additions and 26 deletions
+34 -1
View File
@@ -245,6 +245,16 @@ static QString DEFAULT_SETTINGS = R"!(
"soundUrl": "",
"color": "#7fffffff"
},
{
"pattern": "testaccount_420",
"showInMentions": false,
"alert": false,
"sound": false,
"regex": false,
"case": false,
"soundUrl": "",
"color": "#6fffffff"
},
{
"pattern": "gempir",
"showInMentions": true,
@@ -497,6 +507,27 @@ TEST_F(HighlightControllerTest, A)
},
},
},
{
// TEST CASE: Message phrase from sender should be ignored (so showInMentions false), but since it's a user highlight, it should set a color
{
// input
MessageParseArgs{}, // no special args
{}, // no badges
"testaccount_420", // sender name
"!testmanxd", // original message
},
{
// expected
true, // state
{
false, // alert
false, // playsound
boost::none, // custom sound url
std::make_shared<QColor>("#6fffffff"), // color
false,
},
},
},
};
for (const auto &[input, expected] : tests)
@@ -504,7 +535,9 @@ TEST_F(HighlightControllerTest, A)
auto [isMatch, matchResult] = this->controller->check(
input.args, input.badges, input.senderName, input.originalMessage);
EXPECT_EQ(isMatch, expected.state);
EXPECT_EQ(isMatch, expected.state)
<< qUtf8Printable(input.senderName) << ": "
<< qUtf8Printable(input.originalMessage);
EXPECT_EQ(matchResult, expected.result);
}
}