Merge pull request #13539 from annando/channel-improvements

Channels: Larger fields, better error handling
pull/13544/head
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)
-- 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`),

View 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

View 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;

View 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();

View 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;
}

View 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);

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
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" => [

View File

@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: 2023.09-rc\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"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
@ -2725,8 +2725,8 @@ msgstr ""
#: src/Core/Installer.php:519
msgid ""
"The web installer needs to be able to create a file called \"local.config."
"php\" in the \"config\" folder of your web server and it is unable to do so."
"The web installer needs to be able to create a file called \"local.config.php"
"\" in the \"config\" folder of your web server and it is unable to do so."
msgstr ""
#: src/Core/Installer.php:520
@ -5357,9 +5357,9 @@ msgstr ""
#: src/Module/Admin/Summary.php:98
msgid ""
"The last update failed. Please run \"php bin/console.php dbstructure "
"update\" from the command line and have a look at the errors that might "
"appear. (Some of the errors are possibly inside the logfile.)"
"The last update failed. Please run \"php bin/console.php dbstructure update"
"\" from the command line and have a look at the errors that might appear. "
"(Some of the errors are possibly inside the logfile.)"
msgstr ""
#: src/Module/Admin/Summary.php:102
@ -5510,8 +5510,8 @@ msgstr ""
#, php-format
msgid ""
"Show some informations regarding the needed information to operate the node "
"according e.g. to <a href=\"%s\" target=\"_blank\" rel=\"noopener "
"noreferrer\">EU-GDPR</a>."
"according e.g. to <a href=\"%s\" target=\"_blank\" rel=\"noopener noreferrer"
"\">EU-GDPR</a>."
msgstr ""
#: src/Module/Admin/Tos.php:81
@ -5967,7 +5967,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 ""
@ -6753,16 +6753,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 ""
@ -8839,8 +8844,8 @@ msgstr ""
#: src/Module/Profile/Profile.php:158
#, php-format
msgid ""
"You're currently viewing your profile as <b>%s</b> <a href=\"%s\" "
"class=\"btn btn-sm pull-right\">Cancel</a>"
"You're currently viewing your profile as <b>%s</b> <a href=\"%s\" class="
"\"btn btn-sm pull-right\">Cancel</a>"
msgstr ""
#: src/Module/Profile/Profile.php:167
@ -9388,8 +9393,8 @@ msgstr ""
#: src/Module/Security/TwoFactor/Verify.php:100
#, php-format
msgid ""
"If you do not have access to your authentication code you can use a <a "
"href=\"%s\">two-factor recovery code</a>."
"If you do not have access to your authentication code you can use a <a href="
"\"%s\">two-factor recovery code</a>."
msgstr ""
#: src/Module/Security/TwoFactor/Verify.php:101
@ -11040,8 +11045,8 @@ msgstr ""
#: src/Module/Settings/TwoFactor/Verify.php:149
#, php-format
msgid ""
"<p>Or you can open the following URL in your mobile device:</p><p><a "
"href=\"%s\">%s</a></p>"
"<p>Or you can open the following URL in your mobile device:</p><p><a href="
"\"%s\">%s</a></p>"
msgstr ""
#: src/Module/Settings/TwoFactor/Verify.php:156
@ -11150,9 +11155,9 @@ msgstr ""
msgid ""
"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 "
"to delete their account they can do so at <a href=\"%1$s/settings/"
"removeme\">%1$s/settings/removeme</a>. The deletion of the account will be "
"permanent. Deletion of the data will also be requested from the nodes of the "
"to delete their account they can do so at <a href=\"%1$s/settings/removeme\">"
"%1$s/settings/removeme</a>. The deletion of the account will be permanent. "
"Deletion of the data will also be requested from the nodes of the "
"communication partners."
msgstr ""

View 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}}