]> git.mxchange.org Git - friendica.git/commitdiff
Channels: Larger fields, better error handling
authorMichael <heluecht@pirati.ca>
Sat, 14 Oct 2023 18:39:35 +0000 (18:39 +0000)
committerMichael <heluecht@pirati.ca>
Sat, 14 Oct 2023 18:39:35 +0000 (18:39 +0000)
database.sql
doc/database/db_channel.md
src/Content/Conversation/Factory/Timeline.php
src/Module/Conversation/Network.php
src/Module/Conversation/Timeline.php
src/Module/Settings/Channels.php
static/dbstructure.config.php
view/lang/C/messages.po
view/templates/settings/channels.tpl

index ec7adc5c7a324ffef71546fe65e5411672a688cd..05fbe131f7c8e3c0ad9478f4efec59a94cdd6117 100644 (file)
@@ -1,6 +1,6 @@
 -- ------------------------------------------
 -- Friendica 2023.09-rc (Giant Rhubarb)
--- DB_UPDATE_VERSION 1536
+-- DB_UPDATE_VERSION 1537
 -- ------------------------------------------
 
 
@@ -502,9 +502,9 @@ CREATE TABLE IF NOT EXISTS `channel` (
        `description` varchar(64) COMMENT 'Channel description',
        `circle` int COMMENT 'Circle or channel that this channel is based on',
        `access-key` varchar(1) COMMENT 'Access key',
-       `include-tags` varchar(255) COMMENT 'Comma separated list of tags that will be included in the channel',
-       `exclude-tags` varchar(255) COMMENT 'Comma separated list of tags that aren\'t allowed in the channel',
-       `full-text-search` varchar(255) COMMENT 'Full text search pattern, see https://mariadb.com/kb/en/full-text-index-overview/#in-boolean-mode',
+       `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',
+       `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',
         PRIMARY KEY(`id`),
         INDEX `uid` (`uid`),
index e37aa93d11adade535c47d6f0490777853943e6c..9b9486fa328c295222d2387c021d8306e3387425 100644 (file)
@@ -14,9 +14,9 @@ Fields
 | description      | Channel description                                                                               | varchar(64)        | YES  |     | NULL    |                |
 | circle           | Circle or channel that this channel is based on                                                   | int                | YES  |     | NULL    |                |
 | access-key       | Access key                                                                                        | varchar(1)         | YES  |     | NULL    |                |
-| include-tags     | Comma separated list of tags that will be included in the channel                                 | varchar(255)       | YES  |     | NULL    |                |
-| exclude-tags     | Comma separated list of tags that aren't allowed in the channel                                   | varchar(255)       | YES  |     | NULL    |                |
-| full-text-search | Full text search pattern, see https://mariadb.com/kb/en/full-text-index-overview/#in-boolean-mode | varchar(255)       | 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    |                |
+| 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    |                |
 
 Indexes
index a726762fd54388c9861ad560edd36463f06ca0b0..233488c2818451af3d79234d41bd6d14e7c180ea 100644 (file)
@@ -21,8 +21,6 @@
 
 namespace Friendica\Content\Conversation\Factory;
 
-use Friendica\Capabilities\ICanCreateFromTableRow;
-use Friendica\Content\Conversation\Entity\Timeline as TimelineEntity;
 use Friendica\Content\Conversation\Repository\UserDefinedChannel;
 use Friendica\Core\Config\Capability\IManageConfigValues;
 use Friendica\Core\L10n;
index 24e3e578913a8a83b262e93b6bf85b79ecefb74b..5be78fc11e43d58aa777f7023cc5a74852ee5de8 100644 (file)
@@ -139,14 +139,6 @@ class Network extends Timeline
 
                $o = '';
 
-               if ($this->channel->isTimeline($this->selectedTab) || $this->userDefinedChannel->isTimeline($this->selectedTab, $this->session->getLocalUserId())) {
-                       $items = $this->getChannelItems();
-               } elseif ($this->community->isTimeline($this->selectedTab)) {
-                       $items = $this->getCommunityItems();
-               } else {
-                       $items = $this->getItems();
-               }
-
                $this->page['aside'] .= Circle::sidebarWidget($module, $module . '/circle', 'standard', $this->circleId);
                $this->page['aside'] .= GroupManager::widget($module . '/group', $this->session->getLocalUserId(), $this->groupContactId);
                $this->page['aside'] .= Widget::postedByYear($module . '/archive', $this->session->getLocalUserId(), false);
@@ -244,7 +236,19 @@ class Network extends Timeline
                        $o .= Profile::getEventsReminderHTML();
                }
 
-               $o .= $this->conversation->render($items, Conversation::MODE_NETWORK, false, false, $this->getOrder(), $this->session->getLocalUserId());
+               try {
+                       if ($this->channel->isTimeline($this->selectedTab) || $this->userDefinedChannel->isTimeline($this->selectedTab, $this->session->getLocalUserId())) {
+                               $items = $this->getChannelItems();
+                       } elseif ($this->community->isTimeline($this->selectedTab)) {
+                               $items = $this->getCommunityItems();
+                       } else {
+                               $items = $this->getItems();
+                       }
+       
+                       $o .= $this->conversation->render($items, Conversation::MODE_NETWORK, false, false, $this->getOrder(), $this->session->getLocalUserId());
+               } catch (\Exception $e) {
+                       $o .= $this->l10n->t('Error %d (%s) while fetching the timeline.', $e->getCode(), $e->getMessage());
+               }
 
                if ($this->pConfig->get($this->session->getLocalUserId(), 'system', 'infinite_scroll')) {
                        $o .= HTML::scrollLoader();
index eb362eba7bb2812ad2bb740a0d6c8705f1008fa5..d15fefe3e06aa111bea25b39ec9bf4852af9bfde 100644 (file)
@@ -346,6 +346,10 @@ class Timeline extends BaseModule
 
                $items = [];
                $result = $this->database->select('post-engagement', ['uri-id', 'created', 'owner-id', 'comments', 'activities'], $condition, $params);
+               if ($this->database->errorNo()) {
+                       throw new \Exception($this->database->errorMessage(), $this->database->errorNo());
+               }
+
                while ($item = $this->database->fetch($result)) {
                        $items[$item['uri-id']] = $item;
                }
index 55938e06f9119777c4e1c35e3c7c90ba0f451362..112f06492265d07fc41033365ff3b2275af52ebd 100644 (file)
@@ -71,7 +71,7 @@ class Channels extends BaseSettings
                                'circle'           => (int)$request['new_circle'],
                                'include-tags'     => $this->cleanTags($request['new_include_tags']),
                                'exclude-tags'     => $this->cleanTags($request['new_exclude_tags']),
-                               'full-text-search' => $this->cleanTags($request['new_text_search']),
+                               'full-text-search' => $request['new_text_search'],
                                'media-type'       => ($request['new_image'] ? 1 : 0) | ($request['new_video'] ? 2 : 0) | ($request['new_audio'] ? 4 : 0),
                        ]);
                        $saved = $this->channel->save($channel);
@@ -95,7 +95,7 @@ class Channels extends BaseSettings
                                'circle'           => (int)$request['circle'][$id],
                                'include-tags'     => $this->cleanTags($request['include_tags'][$id]),
                                'exclude-tags'     => $this->cleanTags($request['exclude_tags'][$id]),
-                               'full-text-search' => $this->cleanTags($request['text_search'][$id]),
+                               'full-text-search' => $request['text_search'][$id],
                                'media-type'       => ($request['image'][$id] ? 1 : 0) | ($request['video'][$id] ? 2 : 0) | ($request['audio'][$id] ? 4 : 0),
                        ]);
                        $saved = $this->channel->save($channel);
@@ -131,8 +131,8 @@ class Channels extends BaseSettings
                                'description'  => ["description[$channel->code]", $this->t("Description"), $channel->description],
                                'access_key'   => ["access_key[$channel->code]", $this->t("Access Key"), $channel->accessKey],
                                'circle'       => ["circle[$channel->code]", $this->t('Circle/Channel'), $channel->circle, '', $circles],
-                               'include_tags' => ["include_tags[$channel->code]", $this->t("Include Tags"), $channel->includeTags],
-                               'exclude_tags' => ["exclude_tags[$channel->code]", $this->t("Exclude Tags"), $channel->excludeTags],
+                               '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)],
                                '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],
@@ -180,7 +180,7 @@ class Channels extends BaseSettings
                foreach ($tagitems as $tag) {
                        $tag = trim($tag, '# ');
                        if (!empty($tag)) {
-                               $tags[] = $tag;
+                               $tags[] = preg_replace('#\s#u', '', $tag);
                        }
                }
                return implode(',', $tags);
index 3439b901d39e90295749c996cd4c4cd372b5f572..b7a37708cd76d84ff3ac06e5e61009f4eb4ce972 100644 (file)
@@ -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', 1536);
+       define('DB_UPDATE_VERSION', 1537);
 }
 
 return [
@@ -560,9 +560,9 @@ return [
                        "description" => ["type" => "varchar(64)", "comment" => "Channel description"],
                        "circle" => ["type" => "int", "comment" => "Circle or channel that this channel is based on"],
                        "access-key" => ["type" => "varchar(1)", "comment" => "Access key"],
-                       "include-tags" => ["type" => "varchar(255)", "comment" => "Comma separated list of tags that will be included in the channel"],
-                       "exclude-tags" => ["type" => "varchar(255)", "comment" => "Comma separated list of tags that aren't allowed in the channel"],
-                       "full-text-search" => ["type" => "varchar(255)", "comment" => "Full text search pattern, see https://mariadb.com/kb/en/full-text-index-overview/#in-boolean-mode"],
+                       "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"],
+                       "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"],
                ],
                "indexes" => [
index 2a478519d8554c51e7f2f3e166b7b64cb30f4c48..df6411a9ffe49426e7478719184a3866c3b70e91 100644 (file)
@@ -8,7 +8,7 @@ msgid ""
 msgstr ""
 "Project-Id-Version: 2023.09-rc\n"
 "Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2023-10-11 20:35+0000\n"
+"POT-Creation-Date: 2023-10-14 18:38+0000\n"
 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
 "Language-Team: LANGUAGE <LL@li.org>\n"
@@ -2205,11 +2205,11 @@ msgstr ""
 msgid "Encrypted content"
 msgstr ""
 
-#: src/Content/Text/BBCode.php:1957
+#: src/Content/Text/BBCode.php:1953
 msgid "Invalid source protocol"
 msgstr ""
 
-#: src/Content/Text/BBCode.php:1976
+#: src/Content/Text/BBCode.php:1972
 msgid "Invalid link protocol"
 msgstr ""
 
@@ -5961,7 +5961,7 @@ msgid "Contact not found."
 msgstr ""
 
 #: src/Module/Circle.php:102 src/Module/Contact/Contacts.php:66
-#: src/Module/Conversation/Network.php:240
+#: src/Module/Conversation/Network.php:232
 msgid "Invalid contact."
 msgstr ""
 
@@ -6747,16 +6747,21 @@ msgstr ""
 msgid "Not available."
 msgstr ""
 
-#: src/Module/Conversation/Network.php:226
+#: src/Module/Conversation/Network.php:218
 msgid "No such circle"
 msgstr ""
 
-#: src/Module/Conversation/Network.php:230
+#: src/Module/Conversation/Network.php:222
 #, php-format
 msgid "Circle: %s"
 msgstr ""
 
-#: src/Module/Conversation/Network.php:325
+#: src/Module/Conversation/Network.php:250
+#, php-format
+msgid "Error %d (%s) while fetching the timeline."
+msgstr ""
+
+#: src/Module/Conversation/Network.php:329
 msgid "Network feed not available."
 msgstr ""
 
index 16bb510d6c5f36844507cdd3f7ae10c43c56da1e..27defffdb00391ca33b8fd7dbbfd48ceeddb4dc9 100644 (file)
@@ -8,9 +8,9 @@
        {{include file="field_input.tpl" field=$description}}
        {{include file="field_input.tpl" field=$access_key}}
        {{include file="field_select.tpl" field=$circle}}
-       {{include file="field_input.tpl" field=$include_tags}}
-       {{include file="field_input.tpl" field=$exclude_tags}}
-       {{include file="field_input.tpl" field=$text_search}}
+       {{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_checkbox.tpl" field=$image}}
        {{include file="field_checkbox.tpl" field=$video}}
        {{include file="field_checkbox.tpl" field=$audio}}
@@ -28,9 +28,9 @@
                        {{include file="field_input.tpl" field=$e.description}}
                        {{include file="field_input.tpl" field=$e.access_key}}
                        {{include file="field_select.tpl" field=$e.circle}}
-                       {{include file="field_input.tpl" field=$e.include_tags}}
-                       {{include file="field_input.tpl" field=$e.exclude_tags}}
-                       {{include file="field_input.tpl" field=$e.text_search}}
+                       {{include file="field_textarea.tpl" field=$e.include_tags}}
+                       {{include file="field_textarea.tpl" field=$e.exclude_tags}}
+                       {{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}}
                        {{include file="field_checkbox.tpl" field=$e.audio}}