fix hashtag and mentions count after fixing encoding and add tests

This commit is contained in:
Mario Vavti
2025-12-12 19:15:28 +01:00
parent 5432819788
commit 2eb51233f6
3 changed files with 16 additions and 6 deletions

View File

@@ -184,8 +184,8 @@ class MessageFilter
}
}
// hashtag count match
if (substr($ruleText, 1, 4) === '>') {
$hashtagLimit = (int)substr($ruleText, 5);
if (substr($ruleText, 1, 1) === '>') {
$hashtagLimit = (int)substr($ruleText, 2);
$hashtagCount = 0;
foreach ($this->tags as $t) {
if ($t['ttype'] == TERM_HASHTAG || $t['ttype'] == TERM_COMMUNITYTAG) {
@@ -206,8 +206,8 @@ class MessageFilter
}
}
// mention count match
if (substr($ruleText, 1, 4) === '>') {
$mentionLimit = (int)substr($ruleText, 5);
if (substr($ruleText, 1, 1) === '>') {
$mentionLimit = (int)substr($ruleText, 2);
$mentionCount = 0;
foreach ($this->tags as $t) {
if ($t['ttype'] == TERM_MENTION) {

View File

@@ -117,6 +117,16 @@ class MessageFilterTest extends UnitTestCase {
'#*',
false
],
'max 1 hashtags (we got 3) in excl' => [
'',
'#>1',
false
],
'max 4 hashtags (we got 3) in excl' => [
'',
'#>4',
true
],
'item.body contains substring hopper in excl' => [
'',
'?body ~= hopper',

View File

@@ -3,7 +3,7 @@
'name' => 'zotlabs/hubzilla',
'pretty_version' => 'dev-10.6RC',
'version' => 'dev-10.6RC',
'reference' => 'c03f543b54f1ad9d4bb6fc0b08cd5d054764c283',
'reference' => '5432819788d7e84b919966d6e8e556919f34b892',
'type' => 'application',
'install_path' => __DIR__ . '/../../',
'aliases' => array(),
@@ -544,7 +544,7 @@
'zotlabs/hubzilla' => array(
'pretty_version' => 'dev-10.6RC',
'version' => 'dev-10.6RC',
'reference' => 'c03f543b54f1ad9d4bb6fc0b08cd5d054764c283',
'reference' => '5432819788d7e84b919966d6e8e556919f34b892',
'type' => 'application',
'install_path' => __DIR__ . '/../../',
'aliases' => array(),