Channels: Larger fields, better error handling

This commit is contained in:
Michael 2023-10-14 18:39:35 +00:00
parent e558a83783
commit be394b573d
9 changed files with 51 additions and 40 deletions

View File

@ -1,6 +1,6 @@
-- ------------------------------------------ -- ------------------------------------------
-- Friendica 2023.09-rc (Giant Rhubarb) -- 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', `description` varchar(64) COMMENT 'Channel description',
`circle` int COMMENT 'Circle or channel that this channel is based on', `circle` int COMMENT 'Circle or channel that this channel is based on',
`access-key` varchar(1) COMMENT 'Access key', `access-key` varchar(1) COMMENT 'Access key',
`include-tags` varchar(255) COMMENT 'Comma separated list of tags that will be included in the channel', `include-tags` varchar(1023) 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', `exclude-tags` varchar(1023) 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', `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', `media-type` smallint unsigned COMMENT 'Filtered media types',
PRIMARY KEY(`id`), PRIMARY KEY(`id`),
INDEX `uid` (`uid`), INDEX `uid` (`uid`),

View File

@ -14,9 +14,9 @@ Fields
| description | Channel description | varchar(64) | YES | | NULL | | | description | Channel description | varchar(64) | YES | | NULL | |
| circle | Circle or channel that this channel is based on | int | YES | | NULL | | | circle | Circle or channel that this channel is based on | int | YES | | NULL | |
| access-key | Access key | varchar(1) | 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 | | | 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(255) | 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(255) | 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 | | | media-type | Filtered media types | smallint unsigned | YES | | NULL | |
Indexes Indexes

View File

@ -21,8 +21,6 @@
namespace Friendica\Content\Conversation\Factory; 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\Content\Conversation\Repository\UserDefinedChannel;
use Friendica\Core\Config\Capability\IManageConfigValues; use Friendica\Core\Config\Capability\IManageConfigValues;
use Friendica\Core\L10n; use Friendica\Core\L10n;

View File

@ -139,14 +139,6 @@ class Network extends Timeline
$o = ''; $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'] .= Circle::sidebarWidget($module, $module . '/circle', 'standard', $this->circleId);
$this->page['aside'] .= GroupManager::widget($module . '/group', $this->session->getLocalUserId(), $this->groupContactId); $this->page['aside'] .= GroupManager::widget($module . '/group', $this->session->getLocalUserId(), $this->groupContactId);
$this->page['aside'] .= Widget::postedByYear($module . '/archive', $this->session->getLocalUserId(), false); $this->page['aside'] .= Widget::postedByYear($module . '/archive', $this->session->getLocalUserId(), false);
@ -244,7 +236,19 @@ class Network extends Timeline
$o .= Profile::getEventsReminderHTML(); $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')) { if ($this->pConfig->get($this->session->getLocalUserId(), 'system', 'infinite_scroll')) {
$o .= HTML::scrollLoader(); $o .= HTML::scrollLoader();

View File

@ -346,6 +346,10 @@ class Timeline extends BaseModule
$items = []; $items = [];
$result = $this->database->select('post-engagement', ['uri-id', 'created', 'owner-id', 'comments', 'activities'], $condition, $params); $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)) { while ($item = $this->database->fetch($result)) {
$items[$item['uri-id']] = $item; $items[$item['uri-id']] = $item;
} }

View File

@ -71,7 +71,7 @@ class Channels extends BaseSettings
'circle' => (int)$request['new_circle'], 'circle' => (int)$request['new_circle'],
'include-tags' => $this->cleanTags($request['new_include_tags']), 'include-tags' => $this->cleanTags($request['new_include_tags']),
'exclude-tags' => $this->cleanTags($request['new_exclude_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), 'media-type' => ($request['new_image'] ? 1 : 0) | ($request['new_video'] ? 2 : 0) | ($request['new_audio'] ? 4 : 0),
]); ]);
$saved = $this->channel->save($channel); $saved = $this->channel->save($channel);
@ -95,7 +95,7 @@ class Channels extends BaseSettings
'circle' => (int)$request['circle'][$id], 'circle' => (int)$request['circle'][$id],
'include-tags' => $this->cleanTags($request['include_tags'][$id]), 'include-tags' => $this->cleanTags($request['include_tags'][$id]),
'exclude-tags' => $this->cleanTags($request['exclude_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), 'media-type' => ($request['image'][$id] ? 1 : 0) | ($request['video'][$id] ? 2 : 0) | ($request['audio'][$id] ? 4 : 0),
]); ]);
$saved = $this->channel->save($channel); $saved = $this->channel->save($channel);
@ -131,8 +131,8 @@ class Channels extends BaseSettings
'description' => ["description[$channel->code]", $this->t("Description"), $channel->description], 'description' => ["description[$channel->code]", $this->t("Description"), $channel->description],
'access_key' => ["access_key[$channel->code]", $this->t("Access Key"), $channel->accessKey], 'access_key' => ["access_key[$channel->code]", $this->t("Access Key"), $channel->accessKey],
'circle' => ["circle[$channel->code]", $this->t('Circle/Channel'), $channel->circle, '', $circles], 'circle' => ["circle[$channel->code]", $this->t('Circle/Channel'), $channel->circle, '', $circles],
'include_tags' => ["include_tags[$channel->code]", $this->t("Include Tags"), $channel->includeTags], 'include_tags' => ["include_tags[$channel->code]", $this->t("Include Tags"), str_replace(',', ', ', $channel->includeTags)],
'exclude_tags' => ["exclude_tags[$channel->code]", $this->t("Exclude Tags"), $channel->excludeTags], '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], 'text_search' => ["text_search[$channel->code]", $this->t("Full Text Search"), $channel->fullTextSearch],
'image' => ["image[$channel->code]", $this->t("Images"), $channel->mediaType & 1], 'image' => ["image[$channel->code]", $this->t("Images"), $channel->mediaType & 1],
'video' => ["video[$channel->code]", $this->t("Videos"), $channel->mediaType & 2], 'video' => ["video[$channel->code]", $this->t("Videos"), $channel->mediaType & 2],
@ -180,7 +180,7 @@ class Channels extends BaseSettings
foreach ($tagitems as $tag) { foreach ($tagitems as $tag) {
$tag = trim($tag, '# '); $tag = trim($tag, '# ');
if (!empty($tag)) { if (!empty($tag)) {
$tags[] = $tag; $tags[] = preg_replace('#\s#u', '', $tag);
} }
} }
return implode(',', $tags); return implode(',', $tags);

View File

@ -56,7 +56,7 @@ use Friendica\Database\DBA;
// This file is required several times during the test in DbaDefinition which justifies this condition // This file is required several times during the test in DbaDefinition which justifies this condition
if (!defined('DB_UPDATE_VERSION')) { if (!defined('DB_UPDATE_VERSION')) {
define('DB_UPDATE_VERSION', 1536); define('DB_UPDATE_VERSION', 1537);
} }
return [ return [
@ -560,9 +560,9 @@ return [
"description" => ["type" => "varchar(64)", "comment" => "Channel description"], "description" => ["type" => "varchar(64)", "comment" => "Channel description"],
"circle" => ["type" => "int", "comment" => "Circle or channel that this channel is based on"], "circle" => ["type" => "int", "comment" => "Circle or channel that this channel is based on"],
"access-key" => ["type" => "varchar(1)", "comment" => "Access key"], "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"], "include-tags" => ["type" => "varchar(1023)", "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"], "exclude-tags" => ["type" => "varchar(1023)", "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"], "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"], "media-type" => ["type" => "smallint unsigned", "comment" => "Filtered media types"],
], ],
"indexes" => [ "indexes" => [

View File

@ -8,7 +8,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: 2023.09-rc\n" "Project-Id-Version: 2023.09-rc\n"
"Report-Msgid-Bugs-To: \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" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n" "Language-Team: LANGUAGE <LL@li.org>\n"
@ -2205,11 +2205,11 @@ msgstr ""
msgid "Encrypted content" msgid "Encrypted content"
msgstr "" msgstr ""
#: src/Content/Text/BBCode.php:1957 #: src/Content/Text/BBCode.php:1953
msgid "Invalid source protocol" msgid "Invalid source protocol"
msgstr "" msgstr ""
#: src/Content/Text/BBCode.php:1976 #: src/Content/Text/BBCode.php:1972
msgid "Invalid link protocol" msgid "Invalid link protocol"
msgstr "" msgstr ""
@ -5961,7 +5961,7 @@ msgid "Contact not found."
msgstr "" msgstr ""
#: src/Module/Circle.php:102 src/Module/Contact/Contacts.php:66 #: 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." msgid "Invalid contact."
msgstr "" msgstr ""
@ -6747,16 +6747,21 @@ msgstr ""
msgid "Not available." msgid "Not available."
msgstr "" msgstr ""
#: src/Module/Conversation/Network.php:226 #: src/Module/Conversation/Network.php:218
msgid "No such circle" msgid "No such circle"
msgstr "" msgstr ""
#: src/Module/Conversation/Network.php:230 #: src/Module/Conversation/Network.php:222
#, php-format #, php-format
msgid "Circle: %s" msgid "Circle: %s"
msgstr "" 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." msgid "Network feed not available."
msgstr "" msgstr ""

View File

@ -8,9 +8,9 @@
{{include file="field_input.tpl" field=$description}} {{include file="field_input.tpl" field=$description}}
{{include file="field_input.tpl" field=$access_key}} {{include file="field_input.tpl" field=$access_key}}
{{include file="field_select.tpl" field=$circle}} {{include file="field_select.tpl" field=$circle}}
{{include file="field_input.tpl" field=$include_tags}} {{include file="field_textarea.tpl" field=$include_tags}}
{{include file="field_input.tpl" field=$exclude_tags}} {{include file="field_textarea.tpl" field=$exclude_tags}}
{{include file="field_input.tpl" field=$text_search}} {{include file="field_textarea.tpl" field=$text_search}}
{{include file="field_checkbox.tpl" field=$image}} {{include file="field_checkbox.tpl" field=$image}}
{{include file="field_checkbox.tpl" field=$video}} {{include file="field_checkbox.tpl" field=$video}}
{{include file="field_checkbox.tpl" field=$audio}} {{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.description}}
{{include file="field_input.tpl" field=$e.access_key}} {{include file="field_input.tpl" field=$e.access_key}}
{{include file="field_select.tpl" field=$e.circle}} {{include file="field_select.tpl" field=$e.circle}}
{{include file="field_input.tpl" field=$e.include_tags}} {{include file="field_textarea.tpl" field=$e.include_tags}}
{{include file="field_input.tpl" field=$e.exclude_tags}} {{include file="field_textarea.tpl" field=$e.exclude_tags}}
{{include file="field_input.tpl" field=$e.text_search}} {{include file="field_textarea.tpl" field=$e.text_search}}
{{include file="field_checkbox.tpl" field=$e.image}} {{include file="field_checkbox.tpl" field=$e.image}}
{{include file="field_checkbox.tpl" field=$e.video}} {{include file="field_checkbox.tpl" field=$e.video}}
{{include file="field_checkbox.tpl" field=$e.audio}} {{include file="field_checkbox.tpl" field=$e.audio}}