]> git.mxchange.org Git - friendica.git/commitdiff
New search keyword "language"
authorMichael <heluecht@pirati.ca>
Wed, 17 Jan 2024 20:25:49 +0000 (20:25 +0000)
committerMichael <heluecht@pirati.ca>
Wed, 17 Jan 2024 20:25:49 +0000 (20:25 +0000)
doc/Channels.md
src/Model/Post/Engagement.php

index de3f6718d84e086a0dce81c5232474f516b7b73e..5c206c7896b425cf30c0508f48eb3262f6e48834 100644 (file)
@@ -80,6 +80,7 @@ Additionally to the search for content, there are additional keywords that can b
     * 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. 
 
 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
index 5047d71dd2418d67ffb194c5e9d72afb879dd6f4..1d1fa11124d373f66b5726a24afe18b598e4d1ac 100644 (file)
@@ -24,7 +24,6 @@ namespace Friendica\Model\Post;
 use Friendica\Content\Text\BBCode;
 use Friendica\Core\Logger;
 use Friendica\Core\Protocol;
-use Friendica\Database\Database;
 use Friendica\Database\DBA;
 use Friendica\DI;
 use Friendica\Model\Contact;
@@ -39,7 +38,7 @@ use Friendica\Util\DateTimeFormat;
 
 class Engagement
 {
-       const KEYWORDS = ['source', 'server', 'from', 'to', 'group', 'tag', 'network', 'platform', 'visibility'];
+       const KEYWORDS = ['source', 'server', 'from', 'to', 'group', 'tag', 'network', 'platform', 'visibility', 'language'];
 
        /**
         * Store engagement data from an item array
@@ -204,26 +203,26 @@ class Engagement
 
                switch ($item['private']) {
                        case Item::PUBLIC:
-                               $body .= ' visibility:public';
+                               $body .= ' visibility_public';
                                break;
                        case Item::UNLISTED:
-                               $body .= ' visibility:unlisted';
+                               $body .= ' visibility_unlisted';
                                break;
                        case Item::PRIVATE:
-                               $body .= ' visibility:private';
+                               $body .= ' visibility_private';
                                break;
                }
 
                if (in_array(Contact::TYPE_COMMUNITY, [$item['author-contact-type'], $item['owner-contact-type']])) {
-                       $body .= ' source:group';
+                       $body .= ' source_group';
                } elseif ($item['author-contact-type'] == Contact::TYPE_PERSON) {
-                       $body .= ' source:person';
+                       $body .= ' source_person';
                } elseif ($item['author-contact-type'] == Contact::TYPE_NEWS) {
-                       $body .= ' source:service';
+                       $body .= ' source_service';
                } elseif ($item['author-contact-type'] == Contact::TYPE_ORGANISATION) {
-                       $body .= ' source:organization';
+                       $body .= ' source_organization';
                } elseif ($item['author-contact-type'] == Contact::TYPE_RELAY) {
-                       $body .= ' source:application';
+                       $body .= ' source_application';
                }
 
                if ($item['author-contact-type'] == Contact::TYPE_COMMUNITY) {
@@ -257,6 +256,11 @@ class Engagement
                        $body .= ' tag_' . $tag;
                }
 
+               if (!empty($item['language'])) {
+                       $languages = json_decode($item['language'], true);
+                       $body .= ' language_' . array_key_first($languages);
+               }
+
                $body .= ' ' . $item['title'] . ' ' . $item['content-warning'] . ' ' . $item['body'];
 
                return BBCode::toSearchText($body, $item['uri-id']);