Merge pull request #13539 from annando/channel-improvements

Channels: Larger fields, better error handling
This commit is contained in:
Hypolite Petovan 2023-10-14 15:57:49 -04:00 committed by GitHub
commit 4a67771bfa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 65 additions and 54 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-14 14:18-0400\n" "POT-Creation-Date: 2023-10-14 19:09+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"
@ -2725,8 +2725,8 @@ msgstr ""
#: src/Core/Installer.php:519 #: src/Core/Installer.php:519
msgid "" msgid ""
"The web installer needs to be able to create a file called \"local.config." "The web installer needs to be able to create a file called \"local.config.php"
"php\" in the \"config\" folder of your web server and it is unable to do so." "\" in the \"config\" folder of your web server and it is unable to do so."
msgstr "" msgstr ""
#: src/Core/Installer.php:520 #: src/Core/Installer.php:520
@ -5357,9 +5357,9 @@ msgstr ""
#: src/Module/Admin/Summary.php:98 #: src/Module/Admin/Summary.php:98
msgid "" msgid ""
"The last update failed. Please run \"php bin/console.php dbstructure " "The last update failed. Please run \"php bin/console.php dbstructure update"
"update\" from the command line and have a look at the errors that might " "\" from the command line and have a look at the errors that might appear. "
"appear. (Some of the errors are possibly inside the logfile.)" "(Some of the errors are possibly inside the logfile.)"
msgstr "" msgstr ""
#: src/Module/Admin/Summary.php:102 #: src/Module/Admin/Summary.php:102
@ -5510,8 +5510,8 @@ msgstr ""
#, php-format #, php-format
msgid "" msgid ""
"Show some informations regarding the needed information to operate the node " "Show some informations regarding the needed information to operate the node "
"according e.g. to <a href=\"%s\" target=\"_blank\" rel=\"noopener " "according e.g. to <a href=\"%s\" target=\"_blank\" rel=\"noopener noreferrer"
"noreferrer\">EU-GDPR</a>." "\">EU-GDPR</a>."
msgstr "" msgstr ""
#: src/Module/Admin/Tos.php:81 #: src/Module/Admin/Tos.php:81
@ -5967,7 +5967,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 ""
@ -6753,16 +6753,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 ""
@ -8839,8 +8844,8 @@ msgstr ""
#: src/Module/Profile/Profile.php:158 #: src/Module/Profile/Profile.php:158
#, php-format #, php-format
msgid "" msgid ""
"You're currently viewing your profile as <b>%s</b> <a href=\"%s\" " "You're currently viewing your profile as <b>%s</b> <a href=\"%s\" class="
"class=\"btn btn-sm pull-right\">Cancel</a>" "\"btn btn-sm pull-right\">Cancel</a>"
msgstr "" msgstr ""
#: src/Module/Profile/Profile.php:167 #: src/Module/Profile/Profile.php:167
@ -9388,8 +9393,8 @@ msgstr ""
#: src/Module/Security/TwoFactor/Verify.php:100 #: src/Module/Security/TwoFactor/Verify.php:100
#, php-format #, php-format
msgid "" msgid ""
"If you do not have access to your authentication code you can use a <a " "If you do not have access to your authentication code you can use a <a href="
"href=\"%s\">two-factor recovery code</a>." "\"%s\">two-factor recovery code</a>."
msgstr "" msgstr ""
#: src/Module/Security/TwoFactor/Verify.php:101 #: src/Module/Security/TwoFactor/Verify.php:101
@ -11040,8 +11045,8 @@ msgstr ""
#: src/Module/Settings/TwoFactor/Verify.php:149 #: src/Module/Settings/TwoFactor/Verify.php:149
#, php-format #, php-format
msgid "" msgid ""
"<p>Or you can open the following URL in your mobile device:</p><p><a " "<p>Or you can open the following URL in your mobile device:</p><p><a href="
"href=\"%s\">%s</a></p>" "\"%s\">%s</a></p>"
msgstr "" msgstr ""
#: src/Module/Settings/TwoFactor/Verify.php:156 #: src/Module/Settings/TwoFactor/Verify.php:156
@ -11150,9 +11155,9 @@ msgstr ""
msgid "" msgid ""
"At any point in time a logged in user can export their account data from the " "At any point in time a logged in user can export their account data from the "
"<a href=\"%1$s/settings/userexport\">account settings</a>. If the user wants " "<a href=\"%1$s/settings/userexport\">account settings</a>. If the user wants "
"to delete their account they can do so at <a href=\"%1$s/settings/" "to delete their account they can do so at <a href=\"%1$s/settings/removeme\">"
"removeme\">%1$s/settings/removeme</a>. The deletion of the account will be " "%1$s/settings/removeme</a>. The deletion of the account will be permanent. "
"permanent. Deletion of the data will also be requested from the nodes of the " "Deletion of the data will also be requested from the nodes of the "
"communication partners." "communication partners."
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}}