From 3fe4991fcf14642c3748c0e7d2760bb664712263 Mon Sep 17 00:00:00 2001 From: Michael Date: Tue, 30 Jan 2024 10:05:05 +0000 Subject: [PATCH 1/5] Filter user defined channels by size --- database.sql | 5 ++++- doc/database/db_channel.md | 2 ++ doc/database/db_post-engagement.md | 1 + src/Content/Conversation/Entity/Timeline.php | 10 ++++++++- .../Factory/UserDefinedChannel.php | 2 ++ .../Repository/UserDefinedChannel.php | 2 ++ src/Model/Post/Engagement.php | 22 +++++++++++++++++-- src/Module/Conversation/Timeline.php | 8 +++++++ src/Module/Settings/Channels.php | 8 +++++++ static/dbstructure.config.php | 5 ++++- view/templates/settings/channels.tpl | 4 ++++ .../frio/templates/settings/channels.tpl | 4 ++++ 12 files changed, 68 insertions(+), 5 deletions(-) diff --git a/database.sql b/database.sql index 3e74e28dcb..da167e2c41 100644 --- a/database.sql +++ b/database.sql @@ -1,6 +1,6 @@ -- ------------------------------------------ -- Friendica 2024.03-dev (Yellow Archangel) --- DB_UPDATE_VERSION 1548 +-- DB_UPDATE_VERSION 1549 -- ------------------------------------------ @@ -502,6 +502,8 @@ CREATE TABLE IF NOT EXISTS `channel` ( `access-key` varchar(1) COMMENT 'Access key', `include-tags` varchar(1023) COMMENT 'Comma separated list of tags that will be included in the channel', `exclude-tags` varchar(1023) COMMENT 'Comma separated list of tags that aren\'t allowed in the channel', + `min-size` int unsigned COMMENT 'Minimum post size', + `max-size` int unsigned COMMENT 'Maximum post size', `full-text-search` varchar(1023) COMMENT 'Full text search pattern, see https://mariadb.com/kb/en/full-text-index-overview/#in-boolean-mode', `media-type` smallint unsigned COMMENT 'Filtered media types', `languages` mediumtext COMMENT 'Desired languages', @@ -1346,6 +1348,7 @@ CREATE TABLE IF NOT EXISTS `post-engagement` ( `media-type` tinyint NOT NULL DEFAULT 0 COMMENT 'Type of media in a bit array (1 = image, 2 = video, 4 = audio', `language` varchar(128) COMMENT 'Language information about this post', `searchtext` mediumtext COMMENT 'Simplified text for the full text search', + `size` int unsigned COMMENT 'Body size', `created` datetime COMMENT '', `restricted` boolean NOT NULL DEFAULT '0' COMMENT 'If true, this post is either unlisted or not from a federated network', `comments` mediumint unsigned COMMENT 'Number of comments', diff --git a/doc/database/db_channel.md b/doc/database/db_channel.md index 5b0636dc80..4a469b4ee3 100644 --- a/doc/database/db_channel.md +++ b/doc/database/db_channel.md @@ -16,6 +16,8 @@ Fields | access-key | Access key | varchar(1) | YES | | NULL | | | include-tags | Comma separated list of tags that will be included in the channel | varchar(1023) | YES | | NULL | | | exclude-tags | Comma separated list of tags that aren't allowed in the channel | varchar(1023) | YES | | NULL | | +| min-size | Minimum post size | int unsigned | YES | | NULL | | +| max-size | Maximum post size | int unsigned | YES | | NULL | | | full-text-search | Full text search pattern, see https://mariadb.com/kb/en/full-text-index-overview/#in-boolean-mode | varchar(1023) | YES | | NULL | | | media-type | Filtered media types | smallint unsigned | YES | | NULL | | | languages | Desired languages | mediumtext | YES | | NULL | | diff --git a/doc/database/db_post-engagement.md b/doc/database/db_post-engagement.md index e63f170b76..027ae56a79 100644 --- a/doc/database/db_post-engagement.md +++ b/doc/database/db_post-engagement.md @@ -14,6 +14,7 @@ Fields | media-type | Type of media in a bit array (1 = image, 2 = video, 4 = audio | tinyint | NO | | 0 | | | language | Language information about this post | varchar(128) | YES | | NULL | | | searchtext | Simplified text for the full text search | mediumtext | YES | | NULL | | +| size | Body size | int unsigned | YES | | NULL | | | created | | datetime | YES | | NULL | | | restricted | If true, this post is either unlisted or not from a federated network | boolean | NO | | 0 | | | comments | Number of comments | mediumint unsigned | YES | | NULL | | diff --git a/src/Content/Conversation/Entity/Timeline.php b/src/Content/Conversation/Entity/Timeline.php index a27d9fb98f..47d6e8db47 100644 --- a/src/Content/Conversation/Entity/Timeline.php +++ b/src/Content/Conversation/Entity/Timeline.php @@ -30,6 +30,8 @@ namespace Friendica\Content\Conversation\Entity; * @property-read int $uid User of the channel * @property-read string $includeTags The tags to include in the channel * @property-read string $excludeTags The tags to exclude in the channel + * @property-read int $minSize Minimum content size + * @property-read int $maxSize Maximum content size * @property-read string $fullTextSearch full text search pattern * @property-read int $mediaType Media types that are included in the channel * @property-read array $languages Channel languages @@ -57,6 +59,10 @@ class Timeline extends \Friendica\BaseEntity protected $includeTags; /** @var string */ protected $excludeTags; + /** @var int */ + protected $minSize; + /** @var int */ + protected $maxSize; /** @var string */ protected $fullTextSearch; /** @var int */ @@ -68,7 +74,7 @@ class Timeline extends \Friendica\BaseEntity /** @var bool */ protected $valid; - public function __construct(string $code = null, string $label = null, string $description = null, string $accessKey = null, string $path = null, int $uid = null, string $includeTags = null, string $excludeTags = null, string $fullTextSearch = null, int $mediaType = null, int $circle = null, array $languages = null, bool $publish = null, bool $valid = null) + public function __construct(string $code = null, string $label = null, string $description = null, string $accessKey = null, string $path = null, int $uid = null, string $includeTags = null, string $excludeTags = null, string $fullTextSearch = null, int $mediaType = null, int $circle = null, array $languages = null, bool $publish = null, bool $valid = null, int $minSize = null, int $maxSize = null) { $this->code = $code; $this->label = $label; @@ -78,6 +84,8 @@ class Timeline extends \Friendica\BaseEntity $this->uid = $uid; $this->includeTags = $includeTags; $this->excludeTags = $excludeTags; + $this->minSize = $minSize; + $this->maxSize = $maxSize; $this->fullTextSearch = $fullTextSearch; $this->mediaType = $mediaType; $this->circle = $circle; diff --git a/src/Content/Conversation/Factory/UserDefinedChannel.php b/src/Content/Conversation/Factory/UserDefinedChannel.php index 08a092205c..f3b5f65a14 100644 --- a/src/Content/Conversation/Factory/UserDefinedChannel.php +++ b/src/Content/Conversation/Factory/UserDefinedChannel.php @@ -52,6 +52,8 @@ final class UserDefinedChannel extends Timeline implements ICanCreateFromTableRo $row['languages'] ?? null, $row['publish'] ?? null, $row['valid'] ?? null, + $row['min-size'] ?? null, + $row['max-size'] ?? null, ); } } diff --git a/src/Content/Conversation/Repository/UserDefinedChannel.php b/src/Content/Conversation/Repository/UserDefinedChannel.php index c47991ac4e..6515bc7196 100644 --- a/src/Content/Conversation/Repository/UserDefinedChannel.php +++ b/src/Content/Conversation/Repository/UserDefinedChannel.php @@ -130,6 +130,8 @@ class UserDefinedChannel extends \Friendica\BaseRepository 'circle' => $Channel->circle, 'include-tags' => $Channel->includeTags, 'exclude-tags' => $Channel->excludeTags, + 'min-size' => $Channel->minSize, + 'max-size' => $Channel->maxSize, 'full-text-search' => $Channel->fullTextSearch, 'media-type' => $Channel->mediaType, 'languages' => serialize($Channel->languages), diff --git a/src/Model/Post/Engagement.php b/src/Model/Post/Engagement.php index 64f796ccc7..e787aec408 100644 --- a/src/Model/Post/Engagement.php +++ b/src/Model/Post/Engagement.php @@ -38,7 +38,8 @@ use Friendica\Util\DateTimeFormat; class Engagement { - const KEYWORDS = ['source', 'server', 'from', 'to', 'group', 'application', 'tag', 'network', 'platform', 'visibility', 'language']; + const KEYWORDS = ['source', 'server', 'from', 'to', 'group', 'application', 'tag', 'network', 'platform', 'visibility', 'language']; + const SHORTCUTS = ['lang' => 'language', 'net' => 'network', 'relay' => 'application']; /** * Store engagement data from an item array @@ -101,6 +102,7 @@ class Engagement 'media-type' => $mediatype, 'language' => $parent['language'], 'searchtext' => $searchtext, + 'size' => self::getContentSize($parent), 'created' => $parent['created'], 'restricted' => !in_array($item['network'], Protocol::FEDERATED) || ($parent['private'] != Item::PUBLIC), 'comments' => DBA::count('post', ['parent-uri-id' => $item['parent-uri-id'], 'gravity' => Item::GRAVITY_COMMENT]), @@ -125,6 +127,18 @@ class Engagement return ($ret && !$exists) ? $engagement['uri-id'] : 0; } + private static function getContentSize(array $item): int + { + $body = ' ' . $item['title'] . ' ' . $item['content-warning'] . ' ' . $item['body']; + $body = BBCode::removeAttachment($body); + $body = BBCode::removeSharedData($body); + $body = preg_replace('/[^@!#]\[url\=.*?\].*?\[\/url\]/ism', '', $body); + $body = BBCode::removeLinks($body); + $msg = BBCode::toPlaintext($body, false); + + return mb_strlen($msg); + } + public static function getSearchTextForActivity(string $content, int $author_id, array $tags, array $receivers): string { $author = Contact::getById($author_id); @@ -347,7 +361,11 @@ class Engagement public static function escapeKeywords(string $fullTextSearch): string { - foreach (Engagement::KEYWORDS as $keyword) { + foreach (SELF::SHORTCUTS as $search => $replace) { + $fullTextSearch = preg_replace('~' . $search . ':(.[\w\*@\.-]+)~', $replace . ':$1', $fullTextSearch); + } + + foreach (self::KEYWORDS as $keyword) { $fullTextSearch = preg_replace('~(' . $keyword . '):(.[\w\*@\.-]+)~', '"$1_$2"', $fullTextSearch); } return $fullTextSearch; diff --git a/src/Module/Conversation/Timeline.php b/src/Module/Conversation/Timeline.php index 1b375d099d..d0f8f09736 100644 --- a/src/Module/Conversation/Timeline.php +++ b/src/Module/Conversation/Timeline.php @@ -427,6 +427,14 @@ class Timeline extends BaseModule $condition = DBA::mergeConditions($condition, array_merge(["NOT `uri-id` IN (SELECT `uri-id` FROM `post-tag` INNER JOIN `tag` ON `tag`.`id` = `post-tag`.`tid` WHERE `post-tag`.`type` = 1 AND `name` IN (" . $placeholders . "))"], $search)); } + if (!is_null($channel->minSize)) { + $condition = DBA::mergeConditions($condition, ["`size` >= ?", $channel->minSize]); + } + + if (!is_null($channel->maxSize)) { + $condition = DBA::mergeConditions($condition, ["`size` <= ?", $channel->maxSize]); + } + if (!empty($channel->mediaType)) { $condition = DBA::mergeConditions($condition, ["`media-type` & ?", $channel->mediaType]); } diff --git a/src/Module/Settings/Channels.php b/src/Module/Settings/Channels.php index 34ba0d1d80..a1b5949ede 100644 --- a/src/Module/Settings/Channels.php +++ b/src/Module/Settings/Channels.php @@ -83,6 +83,8 @@ class Channels extends BaseSettings 'circle' => (int)$request['new_circle'], 'include-tags' => Strings::cleanTags($request['new_include_tags']), 'exclude-tags' => Strings::cleanTags($request['new_exclude_tags']), + 'min-size' => $request['new_min_size'] != '' ? (int)$request['new_min_size'] : null, + 'max-size' => $request['new_max_size'] != '' ? (int)$request['new_max_size'] : null, 'full-text-search' => $request['new_text_search'], 'media-type' => ($request['new_image'] ? 1 : 0) | ($request['new_video'] ? 2 : 0) | ($request['new_audio'] ? 4 : 0), 'languages' => $request['new_languages'], @@ -112,6 +114,8 @@ class Channels extends BaseSettings 'circle' => (int)$request['circle'][$id], 'include-tags' => Strings::cleanTags($request['include_tags'][$id]), 'exclude-tags' => Strings::cleanTags($request['exclude_tags'][$id]), + 'min-size' => $request['min_size'][$id] != '' ? (int)$request['min_size'][$id] : null, + 'max-size' => $request['max_size'][$id] != '' ? (int)$request['max_size'][$id] : null, 'full-text-search' => $request['text_search'][$id], 'media-type' => ($request['image'][$id] ? 1 : 0) | ($request['video'][$id] ? 2 : 0) | ($request['audio'][$id] ? 4 : 0), 'languages' => $request['languages'][$id], @@ -181,6 +185,8 @@ class Channels extends BaseSettings 'circle' => ["circle[$channel->code]", $this->t('Circle/Channel'), $channel->circle, '', $circles], 'include_tags' => ["include_tags[$channel->code]", $this->t("Include Tags"), str_replace(',', ', ', $channel->includeTags)], 'exclude_tags' => ["exclude_tags[$channel->code]", $this->t("Exclude Tags"), str_replace(',', ', ', $channel->excludeTags)], + 'min_size' => ["min_size[$channel->code]", $this->t("Minimum Size"), $channel->minSize], + 'max_size' => ["max_size[$channel->code]", $this->t("Maximum Size"), $channel->maxSize], 'text_search' => ["text_search[$channel->code]", $this->t("Full Text Search"), $channel->fullTextSearch], 'image' => ["image[$channel->code]", $this->t("Images"), $channel->mediaType & 1], 'video' => ["video[$channel->code]", $this->t("Videos"), $channel->mediaType & 2], @@ -200,6 +206,8 @@ class Channels extends BaseSettings 'circle' => ['new_circle', $this->t('Circle/Channel'), 0, $this->t('Select a circle or channel, that your channel should be based on.'), $circles], 'include_tags' => ["new_include_tags", $this->t("Include Tags"), '', $this->t('Comma separated list of tags. A post will be used when it contains any of the listed tags.')], 'exclude_tags' => ["new_exclude_tags", $this->t("Exclude Tags"), '', $this->t('Comma separated list of tags. If a post contain any of these tags, then it will not be part of nthis channel.')], + 'min_size' => ["new_min_size", $this->t("Minimum Size"), '', $this->t('Minimum post size. Leave empty for no minimum size. The size is calculated without links, attached posts, mentions or hashtags.')], + 'max_size' => ["new_max_size", $this->t("Maximum Size"), '', $this->t('Maximum post size. Leave empty for no maximum size. The size is calculated without links, attached posts, mentions or hashtags.')], 'text_search' => ["new_text_search", $this->t("Full Text Search"), '', $this->t('Search terms for the body, supports the "boolean mode" operators from MariaDB. See the help for a complete list of operators and additional keywords: %s', 'help/Channels')], 'image' => ['new_image', $this->t("Images"), false, $this->t("Check to display images in the channel.")], 'video' => ["new_video", $this->t("Videos"), false, $this->t("Check to display videos in the channel.")], diff --git a/static/dbstructure.config.php b/static/dbstructure.config.php index 5595a752b2..a75403fcd9 100644 --- a/static/dbstructure.config.php +++ b/static/dbstructure.config.php @@ -56,7 +56,7 @@ use Friendica\Database\DBA; // This file is required several times during the test in DbaDefinition which justifies this condition if (!defined('DB_UPDATE_VERSION')) { - define('DB_UPDATE_VERSION', 1548); + define('DB_UPDATE_VERSION', 1549); } return [ @@ -560,6 +560,8 @@ return [ "access-key" => ["type" => "varchar(1)", "comment" => "Access key"], "include-tags" => ["type" => "varchar(1023)", "comment" => "Comma separated list of tags that will be included in the channel"], "exclude-tags" => ["type" => "varchar(1023)", "comment" => "Comma separated list of tags that aren't allowed in the channel"], + "min-size" => ["type" => "int unsigned", "comment" => "Minimum post size"], + "max-size" => ["type" => "int unsigned", "comment" => "Maximum post size"], "full-text-search" => ["type" => "varchar(1023)", "comment" => "Full text search pattern, see https://mariadb.com/kb/en/full-text-index-overview/#in-boolean-mode"], "media-type" => ["type" => "smallint unsigned", "comment" => "Filtered media types"], "languages" => ["type" => "mediumtext", "comment" => "Desired languages"], @@ -1367,6 +1369,7 @@ return [ "media-type" => ["type" => "tinyint", "not null" => "1", "default" => "0", "comment" => "Type of media in a bit array (1 = image, 2 = video, 4 = audio"], "language" => ["type" => "varchar(128)", "comment" => "Language information about this post"], "searchtext" => ["type" => "mediumtext", "comment" => "Simplified text for the full text search"], + "size" => ["type" => "int unsigned", "comment" => "Body size"], "created" => ["type" => "datetime", "comment" => ""], "restricted" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "If true, this post is either unlisted or not from a federated network"], "comments" => ["type" => "mediumint unsigned", "comment" => "Number of comments"], diff --git a/view/templates/settings/channels.tpl b/view/templates/settings/channels.tpl index 44260a2336..903989cff6 100644 --- a/view/templates/settings/channels.tpl +++ b/view/templates/settings/channels.tpl @@ -11,6 +11,8 @@ {{include file="field_textarea.tpl" field=$include_tags}} {{include file="field_textarea.tpl" field=$exclude_tags}} {{include file="field_textarea.tpl" field=$text_search}} + {{include file="field_input.tpl" field=$min_size}} + {{include file="field_input.tpl" field=$max_size}} {{include file="field_checkbox.tpl" field=$image}} {{include file="field_checkbox.tpl" field=$video}} {{include file="field_checkbox.tpl" field=$audio}} @@ -31,6 +33,8 @@ {{include file="field_select.tpl" field=$e.circle}} {{include file="field_textarea.tpl" field=$e.include_tags}} {{include file="field_textarea.tpl" field=$e.exclude_tags}} + {{include file="field_input.tpl" field=$e.min_size}} + {{include file="field_input.tpl" field=$e.max_size}} {{include file="field_textarea.tpl" field=$e.text_search}} {{include file="field_checkbox.tpl" field=$e.image}} {{include file="field_checkbox.tpl" field=$e.video}} diff --git a/view/theme/frio/templates/settings/channels.tpl b/view/theme/frio/templates/settings/channels.tpl index 932783e1dc..1ec246978c 100644 --- a/view/theme/frio/templates/settings/channels.tpl +++ b/view/theme/frio/templates/settings/channels.tpl @@ -18,6 +18,8 @@ {{include file="field_select.tpl" field=$circle}} {{include file="field_textarea.tpl" field=$include_tags}} {{include file="field_textarea.tpl" field=$exclude_tags}} + {{include file="field_input.tpl" field=$min_size}} + {{include file="field_input.tpl" field=$max_size}} {{include file="field_textarea.tpl" field=$text_search}} {{include file="field_checkbox.tpl" field=$image}} {{include file="field_checkbox.tpl" field=$video}} @@ -48,6 +50,8 @@ {{include file="field_select.tpl" field=$e.circle}} {{include file="field_textarea.tpl" field=$e.include_tags}} {{include file="field_textarea.tpl" field=$e.exclude_tags}} + {{include file="field_input.tpl" field=$e.min_size}} + {{include file="field_input.tpl" field=$e.max_size}} {{include file="field_textarea.tpl" field=$e.text_search}} {{include file="field_checkbox.tpl" field=$e.image}} {{include file="field_checkbox.tpl" field=$e.video}} From d6632bb0eac86b9eebbfbd474e6b17db448bd03c Mon Sep 17 00:00:00 2001 From: Michael Date: Tue, 30 Jan 2024 10:14:03 +0000 Subject: [PATCH 2/5] Updated messages.po --- view/lang/C/messages.po | 160 ++++++++++++++++++++++------------------ 1 file changed, 90 insertions(+), 70 deletions(-) diff --git a/view/lang/C/messages.po b/view/lang/C/messages.po index 56df494ec1..b03334d1b2 100644 --- a/view/lang/C/messages.po +++ b/view/lang/C/messages.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: 2024.03-dev\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-01-29 06:46+0000\n" +"POT-Creation-Date: 2024-01-30 10:12+0000\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -67,7 +67,7 @@ msgstr "" #: src/Module/Register.php:206 src/Module/Register.php:245 #: src/Module/Search/Directory.php:37 src/Module/Settings/Account.php:50 #: src/Module/Settings/Account.php:386 src/Module/Settings/Channels.php:62 -#: src/Module/Settings/Channels.php:131 src/Module/Settings/Delegation.php:90 +#: src/Module/Settings/Channels.php:135 src/Module/Settings/Delegation.php:90 #: src/Module/Settings/Display.php:90 src/Module/Settings/Display.php:197 #: src/Module/Settings/Profile/Photo/Crop.php:165 #: src/Module/Settings/Profile/Photo/Index.php:112 @@ -382,7 +382,7 @@ msgstr "" #: mod/notes.php:57 src/Content/Text/HTML.php:860 #: src/Module/Admin/Storage.php:142 src/Module/Filer/SaveTag.php:74 -#: src/Module/Post/Edit.php:129 src/Module/Settings/Channels.php:213 +#: src/Module/Post/Edit.php:129 src/Module/Settings/Channels.php:221 msgid "Save" msgstr "" @@ -794,12 +794,12 @@ msgstr "" #: src/BaseModule.php:439 src/Content/Conversation/Factory/Channel.php:46 #: src/Content/Widget.php:239 src/Core/ACL.php:195 src/Module/Contact.php:414 #: src/Module/PermissionTooltip.php:141 src/Module/PermissionTooltip.php:163 -#: src/Module/Settings/Channels.php:148 +#: src/Module/Settings/Channels.php:152 msgid "Followers" msgstr "" #: src/BaseModule.php:444 src/Content/Widget.php:240 src/Module/Contact.php:417 -#: src/Module/Settings/Channels.php:147 +#: src/Module/Settings/Channels.php:151 msgid "Following" msgstr "" @@ -1559,7 +1559,7 @@ msgid "Posts from accounts that are followed by accounts that you follow" msgstr "" #: src/Content/Conversation/Factory/Channel.php:48 -#: src/Module/Settings/Channels.php:185 src/Module/Settings/Channels.php:204 +#: src/Module/Settings/Channels.php:191 src/Module/Settings/Channels.php:212 msgid "Images" msgstr "" @@ -1568,7 +1568,7 @@ msgid "Posts with images" msgstr "" #: src/Content/Conversation/Factory/Channel.php:49 -#: src/Module/Settings/Channels.php:187 src/Module/Settings/Channels.php:206 +#: src/Module/Settings/Channels.php:193 src/Module/Settings/Channels.php:214 msgid "Audio" msgstr "" @@ -1577,7 +1577,7 @@ msgid "Posts with audio" msgstr "" #: src/Content/Conversation/Factory/Channel.php:50 -#: src/Module/Settings/Channels.php:186 src/Module/Settings/Channels.php:205 +#: src/Module/Settings/Channels.php:192 src/Module/Settings/Channels.php:213 msgid "Videos" msgstr "" @@ -1594,7 +1594,7 @@ msgid "Posts from local users on this server" msgstr "" #: src/Content/Conversation/Factory/Community.php:47 -#: src/Module/Settings/Channels.php:140 src/Module/Settings/Channels.php:145 +#: src/Module/Settings/Channels.php:144 src/Module/Settings/Channels.php:149 msgid "Global Community" msgstr "" @@ -1778,7 +1778,7 @@ msgstr "" msgid "Create new group" msgstr "" -#: src/Content/Item.php:332 src/Model/Item.php:3244 +#: src/Content/Item.php:332 src/Model/Item.php:3246 msgid "event" msgstr "" @@ -1786,7 +1786,7 @@ msgstr "" msgid "status" msgstr "" -#: src/Content/Item.php:341 src/Model/Item.php:3246 +#: src/Content/Item.php:341 src/Model/Item.php:3248 #: src/Module/Post/Tag/Add.php:123 msgid "photo" msgstr "" @@ -1854,8 +1854,8 @@ msgstr "" msgid "Ignore %s server" msgstr "" -#: src/Content/Item.php:443 src/Module/Settings/Channels.php:188 -#: src/Module/Settings/Channels.php:207 src/Object/Post.php:509 +#: src/Content/Item.php:443 src/Module/Settings/Channels.php:194 +#: src/Module/Settings/Channels.php:215 src/Object/Post.php:509 msgid "Languages" msgstr "" @@ -2058,7 +2058,7 @@ msgstr "" msgid "Terms of Service of this Friendica instance" msgstr "" -#: src/Content/Nav.php:306 src/Module/Settings/Channels.php:146 +#: src/Content/Nav.php:306 src/Module/Settings/Channels.php:150 #: view/theme/frio/theme.php:239 msgid "Network" msgstr "" @@ -2199,8 +2199,8 @@ msgid "" "%2$s %3$s" msgstr "" -#: src/Content/Text/BBCode.php:1005 src/Model/Item.php:3977 -#: src/Model/Item.php:3983 src/Model/Item.php:3984 +#: src/Content/Text/BBCode.php:1005 src/Model/Item.php:3979 +#: src/Model/Item.php:3985 src/Model/Item.php:3986 msgid "Link to source" msgstr "" @@ -2385,7 +2385,7 @@ msgid "All" msgstr "" #: src/Content/Widget.php:592 src/Module/Admin/Site.php:472 -#: src/Module/BaseSettings.php:125 src/Module/Settings/Channels.php:209 +#: src/Module/BaseSettings.php:125 src/Module/Settings/Channels.php:217 #: src/Module/Settings/Display.php:315 msgid "Channels" msgstr "" @@ -2867,7 +2867,7 @@ msgstr "" msgid "Could not connect to database." msgstr "" -#: src/Core/L10n.php:444 src/Model/Item.php:2288 +#: src/Core/L10n.php:444 src/Model/Item.php:2290 msgid "Undetermined" msgstr "" @@ -3429,91 +3429,91 @@ msgstr "" msgid "Happy Birthday %s" msgstr "" -#: src/Model/Item.php:2295 +#: src/Model/Item.php:2297 #, php-format msgid "%s (%s - %s): %s" msgstr "" -#: src/Model/Item.php:2297 +#: src/Model/Item.php:2299 #, php-format msgid "%s (%s): %s" msgstr "" -#: src/Model/Item.php:2300 +#: src/Model/Item.php:2302 #, php-format msgid "Detected languages in this post:\\n%s" msgstr "" -#: src/Model/Item.php:3248 +#: src/Model/Item.php:3250 msgid "activity" msgstr "" -#: src/Model/Item.php:3250 +#: src/Model/Item.php:3252 msgid "comment" msgstr "" -#: src/Model/Item.php:3253 src/Module/Post/Tag/Add.php:123 +#: src/Model/Item.php:3255 src/Module/Post/Tag/Add.php:123 msgid "post" msgstr "" -#: src/Model/Item.php:3423 -#, php-format -msgid "%s is blocked" -msgstr "" - #: src/Model/Item.php:3425 #, php-format -msgid "%s is ignored" +msgid "%s is blocked" msgstr "" #: src/Model/Item.php:3427 #, php-format +msgid "%s is ignored" +msgstr "" + +#: src/Model/Item.php:3429 +#, php-format msgid "Content from %s is collapsed" msgstr "" -#: src/Model/Item.php:3431 +#: src/Model/Item.php:3433 #, php-format msgid "Content warning: %s" msgstr "" -#: src/Model/Item.php:3884 +#: src/Model/Item.php:3886 msgid "bytes" msgstr "" -#: src/Model/Item.php:3915 +#: src/Model/Item.php:3917 #, php-format msgid "%2$s (%3$d%%, %1$d vote)" msgid_plural "%2$s (%3$d%%, %1$d votes)" msgstr[0] "" msgstr[1] "" -#: src/Model/Item.php:3917 +#: src/Model/Item.php:3919 #, php-format msgid "%2$s (%1$d vote)" msgid_plural "%2$s (%1$d votes)" msgstr[0] "" msgstr[1] "" -#: src/Model/Item.php:3922 +#: src/Model/Item.php:3924 #, php-format msgid "%d voter. Poll end: %s" msgid_plural "%d voters. Poll end: %s" msgstr[0] "" msgstr[1] "" -#: src/Model/Item.php:3924 +#: src/Model/Item.php:3926 #, php-format msgid "%d voter." msgid_plural "%d voters." msgstr[0] "" msgstr[1] "" -#: src/Model/Item.php:3926 +#: src/Model/Item.php:3928 #, php-format msgid "Poll end: %s" msgstr "" -#: src/Model/Item.php:3960 src/Model/Item.php:3961 +#: src/Model/Item.php:3962 src/Model/Item.php:3963 msgid "View on separate page" msgstr "" @@ -6171,7 +6171,7 @@ msgstr "" #: src/Module/Moderation/Blocklist/Server/Index.php:116 #: src/Module/Moderation/Item/Delete.php:67 src/Module/Register.php:148 #: src/Module/Security/TwoFactor/Verify.php:101 -#: src/Module/Settings/Channels.php:178 src/Module/Settings/Channels.php:197 +#: src/Module/Settings/Channels.php:182 src/Module/Settings/Channels.php:203 #: src/Module/Settings/TwoFactor/Index.php:161 #: src/Module/Settings/TwoFactor/Verify.php:158 msgid "Required" @@ -7424,7 +7424,7 @@ msgstr "" #: src/Module/Friendica.php:102 #: src/Module/Moderation/Blocklist/Server/Index.php:87 #: src/Module/Moderation/Blocklist/Server/Index.php:111 -#: src/Module/Settings/Channels.php:216 +#: src/Module/Settings/Channels.php:224 msgid "Reason for the block" msgstr "" @@ -8172,7 +8172,7 @@ msgstr "" #: src/Module/Moderation/Blocklist/Server/Index.php:86 #: src/Module/Moderation/Blocklist/Server/Index.php:110 -#: src/Module/Settings/Channels.php:215 +#: src/Module/Settings/Channels.php:223 msgid "Blocked server domain pattern" msgstr "" @@ -10146,100 +10146,120 @@ msgstr "" msgid "No Addon settings configured" msgstr "" -#: src/Module/Settings/Channels.php:138 +#: src/Module/Settings/Channels.php:142 msgid "" "This page can be used to define the channels that will automatically be " "reshared by your account." msgstr "" -#: src/Module/Settings/Channels.php:143 +#: src/Module/Settings/Channels.php:147 msgid "This page can be used to define your own channels." msgstr "" -#: src/Module/Settings/Channels.php:170 +#: src/Module/Settings/Channels.php:174 msgid "Publish" msgstr "" -#: src/Module/Settings/Channels.php:170 +#: src/Module/Settings/Channels.php:174 msgid "" "When selected, the channel results are reshared. This only works for public " "ActivityPub posts from the public timeline or the user defined circles." msgstr "" -#: src/Module/Settings/Channels.php:178 src/Module/Settings/Channels.php:197 +#: src/Module/Settings/Channels.php:182 src/Module/Settings/Channels.php:203 #: src/Module/Settings/Display.php:338 msgid "Label" msgstr "" -#: src/Module/Settings/Channels.php:179 src/Module/Settings/Channels.php:198 +#: src/Module/Settings/Channels.php:183 src/Module/Settings/Channels.php:204 #: src/Module/Settings/Display.php:339 #: src/Module/Settings/TwoFactor/AppSpecific.php:137 msgid "Description" msgstr "" -#: src/Module/Settings/Channels.php:180 src/Module/Settings/Channels.php:199 +#: src/Module/Settings/Channels.php:184 src/Module/Settings/Channels.php:205 msgid "Access Key" msgstr "" -#: src/Module/Settings/Channels.php:181 src/Module/Settings/Channels.php:200 +#: src/Module/Settings/Channels.php:185 src/Module/Settings/Channels.php:206 msgid "Circle/Channel" msgstr "" -#: src/Module/Settings/Channels.php:182 src/Module/Settings/Channels.php:201 +#: src/Module/Settings/Channels.php:186 src/Module/Settings/Channels.php:207 msgid "Include Tags" msgstr "" -#: src/Module/Settings/Channels.php:183 src/Module/Settings/Channels.php:202 +#: src/Module/Settings/Channels.php:187 src/Module/Settings/Channels.php:208 msgid "Exclude Tags" msgstr "" -#: src/Module/Settings/Channels.php:184 src/Module/Settings/Channels.php:203 +#: src/Module/Settings/Channels.php:188 src/Module/Settings/Channels.php:209 +msgid "Minimum Size" +msgstr "" + +#: src/Module/Settings/Channels.php:189 src/Module/Settings/Channels.php:210 +msgid "Maximum Size" +msgstr "" + +#: src/Module/Settings/Channels.php:190 src/Module/Settings/Channels.php:211 msgid "Full Text Search" msgstr "" -#: src/Module/Settings/Channels.php:188 src/Module/Settings/Channels.php:207 +#: src/Module/Settings/Channels.php:194 src/Module/Settings/Channels.php:215 msgid "Select all languages that you want to see in this channel." msgstr "" -#: src/Module/Settings/Channels.php:190 +#: src/Module/Settings/Channels.php:196 msgid "Delete channel" msgstr "" -#: src/Module/Settings/Channels.php:190 +#: src/Module/Settings/Channels.php:196 msgid "Check to delete this entry from the channel list" msgstr "" -#: src/Module/Settings/Channels.php:197 +#: src/Module/Settings/Channels.php:203 msgid "Short name for the channel. It is displayed on the channels widget." msgstr "" -#: src/Module/Settings/Channels.php:198 +#: src/Module/Settings/Channels.php:204 msgid "This should describe the content of the channel in a few word." msgstr "" -#: src/Module/Settings/Channels.php:199 +#: src/Module/Settings/Channels.php:205 msgid "" "When you want to access this channel via an access key, you can define it " "here. Pay attention to not use an already used one." msgstr "" -#: src/Module/Settings/Channels.php:200 +#: src/Module/Settings/Channels.php:206 msgid "Select a circle or channel, that your channel should be based on." msgstr "" -#: src/Module/Settings/Channels.php:201 +#: src/Module/Settings/Channels.php:207 msgid "" "Comma separated list of tags. A post will be used when it contains any of " "the listed tags." msgstr "" -#: src/Module/Settings/Channels.php:202 +#: src/Module/Settings/Channels.php:208 msgid "" "Comma separated list of tags. If a post contain any of these tags, then it " "will not be part of nthis channel." msgstr "" -#: src/Module/Settings/Channels.php:203 +#: src/Module/Settings/Channels.php:209 +msgid "" +"Minimum post size. Leave empty for no minimum size. The size is calculated " +"without links, attached posts, mentions or hashtags." +msgstr "" + +#: src/Module/Settings/Channels.php:210 +msgid "" +"Maximum post size. Leave empty for no maximum size. The size is calculated " +"without links, attached posts, mentions or hashtags." +msgstr "" + +#: src/Module/Settings/Channels.php:211 #, php-format msgid "" "Search terms for the body, supports the \"boolean mode\" operators from " @@ -10247,35 +10267,35 @@ msgid "" "keywords: %s" msgstr "" -#: src/Module/Settings/Channels.php:204 +#: src/Module/Settings/Channels.php:212 msgid "Check to display images in the channel." msgstr "" -#: src/Module/Settings/Channels.php:205 +#: src/Module/Settings/Channels.php:213 msgid "Check to display videos in the channel." msgstr "" -#: src/Module/Settings/Channels.php:206 +#: src/Module/Settings/Channels.php:214 msgid "Check to display audio in the channel." msgstr "" -#: src/Module/Settings/Channels.php:211 +#: src/Module/Settings/Channels.php:219 msgid "Add new entry to the channel list" msgstr "" -#: src/Module/Settings/Channels.php:212 +#: src/Module/Settings/Channels.php:220 msgid "Add" msgstr "" -#: src/Module/Settings/Channels.php:214 +#: src/Module/Settings/Channels.php:222 msgid "Current Entries in the channel list" msgstr "" -#: src/Module/Settings/Channels.php:217 +#: src/Module/Settings/Channels.php:225 msgid "Delete entry from the channel list" msgstr "" -#: src/Module/Settings/Channels.php:218 +#: src/Module/Settings/Channels.php:226 msgid "Delete entry from the channel list?" msgstr "" From 1e3cfca58d15d33bb09cea7fd0f6b546f90260da Mon Sep 17 00:00:00 2001 From: Michael Date: Tue, 30 Jan 2024 11:14:41 +0000 Subject: [PATCH 3/5] search term alternatives added --- src/Model/Post/Engagement.php | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/Model/Post/Engagement.php b/src/Model/Post/Engagement.php index e787aec408..6727ce5051 100644 --- a/src/Model/Post/Engagement.php +++ b/src/Model/Post/Engagement.php @@ -38,8 +38,12 @@ use Friendica\Util\DateTimeFormat; class Engagement { - const KEYWORDS = ['source', 'server', 'from', 'to', 'group', 'application', 'tag', 'network', 'platform', 'visibility', 'language']; - const SHORTCUTS = ['lang' => 'language', 'net' => 'network', 'relay' => 'application']; + const KEYWORDS = ['source', 'server', 'from', 'to', 'group', 'application', 'tag', 'network', 'platform', 'visibility', 'language']; + const SHORTCUTS = ['lang' => 'language', 'net' => 'network', 'relay' => 'application']; + const ALTERNATIVES = ['source:news' => 'source:service', 'source:relay' => 'source:application', + 'network:activitypub' => 'network:apub', 'network:friendica' => 'network:dfrn', 'network:diaspora' => 'network:dspr', + 'network:ostatus' => 'network:stat', 'network:ostatus' => 'network:stat', 'network:pumpio' => 'network:pump', + 'network:discourse' => 'network:dscs', 'network:tumblr' => 'network:tmbl', 'network:bluesky' => 'network:bsky']; /** * Store engagement data from an item array @@ -365,6 +369,10 @@ class Engagement $fullTextSearch = preg_replace('~' . $search . ':(.[\w\*@\.-]+)~', $replace . ':$1', $fullTextSearch); } + foreach (SELF::ALTERNATIVES as $search => $replace) { + $fullTextSearch = str_replace($search, $replace, $fullTextSearch); + } + foreach (self::KEYWORDS as $keyword) { $fullTextSearch = preg_replace('~(' . $keyword . '):(.[\w\*@\.-]+)~', '"$1_$2"', $fullTextSearch); } From d29d7c40cdabc1ad29198a1f9803f37c1a22b2f8 Mon Sep 17 00:00:00 2001 From: Michael Date: Tue, 30 Jan 2024 11:55:36 +0000 Subject: [PATCH 4/5] Alternatives are added to the documentation --- doc/Channels.md | 26 +++++++++++++------------- src/Model/Post/Engagement.php | 3 +-- 2 files changed, 14 insertions(+), 15 deletions(-) diff --git a/doc/Channels.md b/doc/Channels.md index 0af469a3a1..3e952db93e 100644 --- a/doc/Channels.md +++ b/doc/Channels.md @@ -56,36 +56,36 @@ Each channel is defined by these values: Additional keywords for the full text search --- -Additionally to the search for content, there are additional keywords that can be used in the full text search: +Additionally to the search for content, there are additional keywords that can be used in the full text search. Alternatives are presented via "|". * from - Use "from:nickname" or "from:nickname@domain.tld" to search for posts from a specific author. * to - Use "from:nickname" or "from:nickname@domain.tld" to search for posts with the given contact as receiver. * group - Use "group:nickname" or "group:nickname@domain.tld" to search for group post of the given group. -* application - Use "application:nickname" or "application:nickname@domain.tld" to search for posts that had been reshared by the given relay application. +* application | relay - Use "application:nickname" or "application:nickname@domain.tld" to search for posts that had been reshared by the given relay application. * server - Use "server:hostname" to search for posts from a specific server. In the case of group postings, the search text contains both the hostname of the group server and the author's hostname. * source - The ActivityPub type of the post source. Use this for example to include or exclude group posts or posts from services (aka bots). * source:person - The post is created by a regular user account. * source:organization - The post is created by an organisation. * source:group - The post is created by or distributed via a group. - * source:service - The posts originates from a service account. This source type is often used to mark bot accounts. - * source:application - The post is created by an application. This is most likely unused in the fediverse for post creation. + * source:service | source:news - The posts originates from a service account. This source type is often used to mark bot accounts. + * source:application | source:relay - The post is created by an application. This is most likely unused in the fediverse for post creation. * tag - Use "tag:tagname" to search for a specific tag. -* network - Use this to include or exclude some networks from your channel. - * network:apub - ActivityPub (Used by the systems in the Fediverse) - * network:dfrn - Legacy Friendica protocol. Nowayday Friendica mostly uses ActivityPub. - * network:dspr - The Diaspora protocol is mainly used by Diaspora itself. Some other systems support the protocol as well like Hubzilla, Socialhome or Ganggo. +* network | net - Use this to include or exclude some networks from your channel. + * network:apub | network:activitypub - ActivityPub (Used by the systems in the Fediverse) + * network:dfrn | network:friendica - Legacy Friendica protocol. Nowayday Friendica mostly uses ActivityPub. + * network:dspr | network:diaspora - The Diaspora protocol is mainly used by Diaspora itself. Some other systems support the protocol as well like Hubzilla, Socialhome or Ganggo. * network:feed - RSS/Atom feeds * network:mail - Mails that had been imported via IMAP. - * network:stat - The OStatus protocol is mainly used by old GNU Social installations. - * network:dscs - Posts that are received by the Discourse connector. - * network:tmbl - Posts that are received by the Tumblr connector. - * network:bsky - Posts that are received by the Bluesky connector. + * network:stat | network:ostatus - The OStatus protocol is mainly used by old GNU Social installations. + * network:dscs | network:discourse - Posts that are received by the Discourse connector. + * network:tmbl | network:tumblr - Posts that are received by the Tumblr connector. + * network:bsky | network:bluesky - Posts that are received by the Bluesky connector. * platform - Use this to include or exclude some platforms from your channel, e.g. "+platform:friendica". In the case of group postings, the search text contains both the platform of the group server and the author's platform. * visibility - You have the choice between different visibilities. You can only see unlisted or private posts that you have the access for. * visibility:public * visibility:unlisted * visibility:private -* language - Use "language:code" to search for posts with the given language in the [ISO 639-1](https://en.wikipedia.org/wiki/ISO_639-1) format. +* language | lang - Use "language:code" to search for posts with the given language in the [ISO 639-1](https://en.wikipedia.org/wiki/ISO_639-1) format. Remember that you can combine these kerywords. So for example you can create a channel with all posts that talk about the Fediverse - that aren't posted in the Fediverse with the search terms: "fediverse -network:apub -network:dfrn" \ No newline at end of file diff --git a/src/Model/Post/Engagement.php b/src/Model/Post/Engagement.php index 6727ce5051..a460ba85b3 100644 --- a/src/Model/Post/Engagement.php +++ b/src/Model/Post/Engagement.php @@ -41,8 +41,7 @@ class Engagement const KEYWORDS = ['source', 'server', 'from', 'to', 'group', 'application', 'tag', 'network', 'platform', 'visibility', 'language']; const SHORTCUTS = ['lang' => 'language', 'net' => 'network', 'relay' => 'application']; const ALTERNATIVES = ['source:news' => 'source:service', 'source:relay' => 'source:application', - 'network:activitypub' => 'network:apub', 'network:friendica' => 'network:dfrn', 'network:diaspora' => 'network:dspr', - 'network:ostatus' => 'network:stat', 'network:ostatus' => 'network:stat', 'network:pumpio' => 'network:pump', + 'network:activitypub' => 'network:apub', 'network:friendica' => 'network:dfrn', 'network:diaspora' => 'network:dspr', 'network:ostatus' => 'network:stat', 'network:discourse' => 'network:dscs', 'network:tumblr' => 'network:tmbl', 'network:bluesky' => 'network:bsky']; /** From 5a59dff8176c532884b1833a85f49086710ba225 Mon Sep 17 00:00:00 2001 From: Michael Vogel Date: Tue, 30 Jan 2024 16:20:44 +0100 Subject: [PATCH 5/5] Update doc/Channels.md Co-authored-by: Hypolite Petovan --- doc/Channels.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/doc/Channels.md b/doc/Channels.md index 3e952db93e..3f9e474918 100644 --- a/doc/Channels.md +++ b/doc/Channels.md @@ -56,7 +56,8 @@ Each channel is defined by these values: Additional keywords for the full text search --- -Additionally to the search for content, there are additional keywords that can be used in the full text search. Alternatives are presented via "|". +Additionally to the search for content, there are keywords that can be used in the full text search. +Alternatives are presented with "|". * from - Use "from:nickname" or "from:nickname@domain.tld" to search for posts from a specific author. * to - Use "from:nickname" or "from:nickname@domain.tld" to search for posts with the given contact as receiver.