Channels are a new way to see different content

This commit is contained in:
Michael 2023-09-01 21:56:59 +00:00
parent 5c26ba5f5d
commit 5c166be3fc
22 changed files with 860 additions and 249 deletions

View File

@ -1,6 +1,6 @@
-- ------------------------------------------
-- Friendica 2023.09-dev (Giant Rhubarb)
-- DB_UPDATE_VERSION 1530
-- DB_UPDATE_VERSION 1531
-- ------------------------------------------
@ -1300,6 +1300,23 @@ CREATE TABLE IF NOT EXISTS `post-delivery-data` (
FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Delivery data for items';
--
-- TABLE post-engagement
--
CREATE TABLE IF NOT EXISTS `post-engagement` (
`uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
`author-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Link to the contact table with uid=0 of the author of this item',
`contact-type` tinyint NOT NULL DEFAULT 0 COMMENT 'Person, organisation, news, community, relay',
`created` datetime COMMENT '',
`comments` mediumint unsigned COMMENT 'Number of comments',
`activities` mediumint unsigned COMMENT 'Number of activities (like, dislike, ...)',
PRIMARY KEY(`uri-id`),
INDEX `author-id` (`author-id`),
INDEX `created` (`created`),
FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE,
FOREIGN KEY (`author-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Engagement data per post';
--
-- TABLE post-history
--

View File

@ -16,6 +16,7 @@ General
-------
* p - Profile
* n - Network
* l - Channel
* c - Community
* s - Search
* a - Admin
@ -28,6 +29,12 @@ General
* l - Local community
* g - Global community
../channel
--------
* h - what's hot
* y - for you
* f - followers
../profile
--------
* m - Status Messages and Posts

View File

@ -61,6 +61,7 @@ Database Tables
| [post-content](help/database/db_post-content) | Content for all posts |
| [post-delivery](help/database/db_post-delivery) | Delivery data for posts for the batch processing |
| [post-delivery-data](help/database/db_post-delivery-data) | Delivery data for items |
| [post-engagement](help/database/db_post-engagement) | Engagement data per post |
| [post-history](help/database/db_post-history) | Post history |
| [post-link](help/database/db_post-link) | Post related external links |
| [post-media](help/database/db_post-media) | Attached media |

View File

@ -0,0 +1,35 @@
Table post-engagement
===========
Engagement data per post
Fields
------
| Field | Description | Type | Null | Key | Default | Extra |
| ------------ | --------------------------------------------------------------- | ------------------ | ---- | --- | ------- | ----- |
| uri-id | Id of the item-uri table entry that contains the item uri | int unsigned | NO | PRI | NULL | |
| author-id | Link to the contact table with uid=0 of the author of this item | int unsigned | NO | | 0 | |
| contact-type | Person, organisation, news, community, relay | tinyint | NO | | 0 | |
| created | | datetime | YES | | NULL | |
| comments | Number of comments | mediumint unsigned | YES | | NULL | |
| activities | Number of activities (like, dislike, ...) | mediumint unsigned | YES | | NULL | |
Indexes
------------
| Name | Fields |
| --------- | --------- |
| PRIMARY | uri-id |
| author-id | author-id |
| created | created |
Foreign Keys
------------
| Field | Target Table | Target Field |
|-------|--------------|--------------|
| uri-id | [item-uri](help/database/db_item-uri) | id |
| author-id | [contact](help/database/db_contact) | id |
Return to [database documentation](help/database)

View File

@ -8,8 +8,8 @@ Fields
| Field | Description | Type | Null | Key | Default | Extra |
| ------- | ---------------------------------------- | ------------------ | ---- | --- | ------- | ----- |
| uid | Owner User id | mediumint unsigned | NO | | 0 | |
| gsid | Gserver id | int unsigned | NO | | 0 | |
| uid | Owner User id | mediumint unsigned | NO | PRI | 0 | |
| gsid | Gserver id | int unsigned | NO | PRI | 0 | |
| ignored | server accounts are ignored for the user | boolean | NO | | 0 | |
Indexes

View File

@ -57,6 +57,7 @@ use Psr\Log\LoggerInterface;
class Conversation
{
const MODE_CHANNEL = 'channel';
const MODE_COMMUNITY = 'community';
const MODE_CONTACTS = 'contacts';
const MODE_CONTACT_POSTS = 'contact-posts';
@ -530,6 +531,17 @@ class Conversation
. "<script> var profile_uid = " . ($this->session->getLocalUserId() ?: 0) . ";"
. "</script>";
}
} elseif ($mode === self::MODE_CHANNEL) {
$items = $this->addChildren($items, true, $order, $uid, $mode, $ignoredGsids);
if (!$update) {
$live_update_div = '<div id="live-channel"></div>' . "\r\n"
. "<script> var profile_uid = -1; var netargs = '" . substr($this->args->getCommand(), 10)
. '?f='
. (!empty($_GET['no_sharer']) ? '&no_sharer=' . rawurlencode($_GET['no_sharer']) : '')
. (!empty($_GET['accounttype']) ? '&accounttype=' . rawurlencode($_GET['accounttype']) : '')
. "'; </script>\r\n";
}
} elseif ($mode === self::MODE_COMMUNITY) {
$items = $this->addChildren($items, true, $order, $uid, $mode, $ignoredGsids);
@ -621,7 +633,7 @@ class Conversation
unset($conv_responses['dislike']);
}
if (in_array($mode, [self::MODE_COMMUNITY, self::MODE_CONTACTS, self::MODE_PROFILE])) {
if (in_array($mode, [self::MODE_CHANNEL, self::MODE_COMMUNITY, self::MODE_CONTACTS, self::MODE_PROFILE])) {
$writable = true;
} else {
$writable = $items[0]['writable'] || ($items[0]['uid'] == 0) && in_array($items[0]['network'], Protocol::FEDERATED);
@ -1009,7 +1021,7 @@ class Conversation
$items[$key]['user-collapsed-owner'] = !$always_display && in_array($row['owner-id'], $collapses);
if (
in_array($mode, [self::MODE_COMMUNITY, self::MODE_NETWORK]) &&
in_array($mode, [self::MODE_CHANNEL, self::MODE_COMMUNITY, self::MODE_NETWORK]) &&
(in_array($row['author-id'], $blocks) || in_array($row['owner-id'], $blocks) || in_array($row['author-id'], $ignores) || in_array($row['owner-id'], $ignores))
) {
unset($items[$key]);

View File

@ -42,6 +42,7 @@ class Nav
private static $selected = [
'global' => null,
'community' => null,
'channel' => null,
'network' => null,
'home' => null,
'profiles' => null,
@ -199,6 +200,7 @@ class Nav
'moderation' => null,
'apps' => null,
'community' => null,
'channel' => null,
'home' => null,
'calendar' => null,
'login' => null,
@ -287,6 +289,8 @@ class Nav
$nav['community'] = ['community', $this->l10n->t('Community'), '', $this->l10n->t('Conversations on this and other servers')];
}
$nav['channel'] = ['channel', $this->l10n->t('Channel'), '', $this->l10n->t('Current posts, filtered by several rules')];
if ($this->session->getLocalUserId()) {
$nav['calendar'] = ['calendar', $this->l10n->t('Calendar'), '', $this->l10n->t('Calendar')];
}

View File

@ -1405,6 +1405,8 @@ class Item
self::updateDisplayCache($posted_item['uri-id']);
}
Post\Engagement::storeFromItem($posted_item);
return $post_user_id;
}

View File

@ -0,0 +1,98 @@
<?php
/**
* @copyright Copyright (C) 2010-2023, the Friendica project
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
namespace Friendica\Model\Post;
use Friendica\Core\Logger;
use Friendica\Core\Protocol;
use Friendica\Database\Database;
use Friendica\Database\DBA;
use Friendica\Model\Contact;
use Friendica\Model\Item;
use Friendica\Model\Post;
use Friendica\Model\Verb;
use Friendica\Protocol\Activity;
use Friendica\Util\DateTimeFormat;
// Channel
class Engagement
{
public static function storeFromItem(array $item)
{
if (!in_array($item['network'], Protocol::FEDERATED)) {
Logger::debug('No federated network', ['uri-id' => $item['uri-id'], 'parent-uri-id' => $item['parent-uri-id'], 'network' => $item['network']]);
return;
}
if ($item['gravity'] == Item::GRAVITY_PARENT) {
Logger::debug('Parent posts are not stored', ['uri-id' => $item['uri-id'], 'parent-uri-id' => $item['parent-uri-id']]);
return;
}
if (($item['uid'] != 0) && ($item['gravity'] == Item::GRAVITY_COMMENT)) {
Logger::debug('Non public comments are not stored', ['uri-id' => $item['uri-id'], 'parent-uri-id' => $item['parent-uri-id'], 'uid' => $item['uid']]);
return;
}
if (in_array($item['verb'], [Activity::FOLLOW, Activity::VIEW, Activity::READ])) {
Logger::debug('Technical activities are not stored', ['uri-id' => $item['uri-id'], 'parent-uri-id' => $item['parent-uri-id'], 'verb' => $item['verb']]);
return;
}
$parent = Post::selectFirst(['created', 'author-id', 'uid', 'private', 'contact-contact-type'], ['uri-id' => $item['parent-uri-id']]);
if ($parent['private'] != Item::PUBLIC) {
Logger::debug('Non public posts are not stored', ['uri-id' => $item['uri-id'], 'parent-uri-id' => $item['parent-uri-id'], 'uid' => $parent['uid'], 'private' => $parent['private']]);
return;
}
if ($parent['contact-contact-type'] == Contact::TYPE_COMMUNITY) {
Logger::debug('Group posts are not stored', ['uri-id' => $item['uri-id'], 'parent-uri-id' => $item['parent-uri-id'], 'author-id' => $parent['author-id']]);
return;
}
if ($parent['created'] < DateTimeFormat::utc('now - 1 day')) {
Logger::debug('Post is too old', ['uri-id' => $item['uri-id'], 'parent-uri-id' => $item['parent-uri-id'], 'created' => $parent['created']]);
return;
}
$engagement = [
'uri-id' => $item['parent-uri-id'],
'author-id' => $parent['author-id'],
'contact-type' => $parent['contact-contact-type'],
'created' => $parent['created'],
'comments' => DBA::count('post', ['parent-uri-id' => $item['parent-uri-id'], 'gravity' => Item::GRAVITY_COMMENT]),
'activities' => DBA::count('post', [
"`parent-uri-id` = ? AND `gravity` = ? AND NOT `vid` IN (?, ?, ?)",
$item['parent-uri-id'], Item::GRAVITY_ACTIVITY,
Verb::getID(Activity::FOLLOW), Verb::getID(Activity::VIEW), Verb::getID(Activity::READ)
])
];
$ret = DBA::insert('post-engagement', $engagement, Database::INSERT_UPDATE);
Logger::debug('Engagement stored', ['fields' => $engagement, 'ret' => $ret]);
}
public static function expire()
{
DBA::delete('post-engagement', ["`created` < ?", DateTimeFormat::utc('now - 1 day')]);
Logger::notice('Cleared expired engagements', ['rows' => DBA::affectedRows()]);
}
}

View File

@ -0,0 +1,305 @@
<?php
/**
* @copyright Copyright (C) 2010-2023, the Friendica project
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
* See update_profile.php for documentation
*/
namespace Friendica\Module\Conversation;
use Friendica\BaseModule;
use Friendica\Content\BoundariesPager;
use Friendica\Content\Conversation;
use Friendica\Content\Feature;
use Friendica\Content\Nav;
use Friendica\Content\Text\HTML;
use Friendica\Content\Widget;
use Friendica\Content\Widget\TrendingTags;
use Friendica\Core\Logger;
use Friendica\Core\Renderer;
use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Model\Contact;
use Friendica\Model\Post;
use Friendica\Model\User;
use Friendica\Module\Security\Login;
use Friendica\Network\HTTPException;
class Channel extends BaseModule
{
const WHATSHOT = 'whatshot';
const FORYOU = 'foryou';
const FOLLOWERS = 'followers';
/**
* @}
*/
protected static $content;
protected static $accountTypeString;
protected static $accountType;
protected static $itemsPerPage;
protected static $min_id;
protected static $max_id;
protected static $item_id;
protected function content(array $request = []): string
{
if (!DI::userSession()->getLocalUserId()) {
return Login::form();
}
$this->parseRequest();
$t = Renderer::getMarkupTemplate("community.tpl");
$o = Renderer::replaceMacros($t, [
'$content' => '',
'$header' => '',
]);
if (DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'system', 'infinite_scroll')) {
$tpl = Renderer::getMarkupTemplate('infinite_scroll_head.tpl');
$o .= Renderer::replaceMacros($tpl, ['$reload_uri' => DI::args()->getQueryString()]);
}
if (empty($_GET['mode']) || ($_GET['mode'] != 'raw')) {
$tabs = [];
$tabs[] = [
'label' => DI::l10n()->t('Whats Hot'),
'url' => 'channel/' . self::WHATSHOT,
'sel' => self::$content == self::WHATSHOT ? 'active' : '',
'title' => DI::l10n()->t('Posts with a lot of interactions'),
'id' => 'channel-whatshot-tab',
'accesskey' => 'h'
];
$tabs[] = [
'label' => DI::l10n()->t('For you'),
'url' => 'channel/' . self::FORYOU,
'sel' => self::$content == self::FORYOU ? 'active' : '',
'title' => DI::l10n()->t('Posts from contacts you interact with and who interact with you'),
'id' => 'channel-foryou-tab',
'accesskey' => 'y'
];
$tabs[] = [
'label' => DI::l10n()->t('Followers'),
'url' => 'channel/' . self::FOLLOWERS,
'sel' => self::$content == self::FOLLOWERS ? 'active' : '',
'title' => DI::l10n()->t('Posts from your followers that you don\'t follow'),
'id' => 'channel-followers-tab',
'accesskey' => 'f'
];
$tab_tpl = Renderer::getMarkupTemplate('common_tabs.tpl');
$o .= Renderer::replaceMacros($tab_tpl, ['$tabs' => $tabs]);
Nav::setSelected('channel');
DI::page()['aside'] .= Widget::accountTypes('channel/' . self::$content, self::$accountTypeString);
if ((self::$content != self::FOLLOWERS) && DI::config()->get('system', 'community_no_sharer')) {
$path = self::$content;
if (!empty($this->parameters['accounttype'])) {
$path .= '/' . $this->parameters['accounttype'];
}
$query_parameters = [];
if (!empty($_GET['min_id'])) {
$query_parameters['min_id'] = $_GET['min_id'];
}
if (!empty($_GET['max_id'])) {
$query_parameters['max_id'] = $_GET['max_id'];
}
if (!empty($_GET['last_created'])) {
$query_parameters['max_id'] = $_GET['last_created'];
}
$path_all = $path . (!empty($query_parameters) ? '?' . http_build_query($query_parameters) : '');
$path_no_sharer = $path . '?' . http_build_query(array_merge($query_parameters, ['no_sharer' => true]));
DI::page()['aside'] .= Renderer::replaceMacros(Renderer::getMarkupTemplate('widget/community_sharer.tpl'), [
'$title' => DI::l10n()->t('Own Contacts'),
'$path_all' => $path_all,
'$path_no_sharer' => $path_no_sharer,
'$no_sharer' => !empty($_REQUEST['no_sharer']),
'$all' => DI::l10n()->t('Include'),
'$no_sharer_label' => DI::l10n()->t('Hide'),
'$base' => 'channel',
]);
}
if (Feature::isEnabled(DI::userSession()->getLocalUserId(), 'trending_tags')) {
DI::page()['aside'] .= TrendingTags::getHTML(self::$content);
}
// We need the editor here to be able to reshare an item.
$o .= DI::conversation()->statusEditor([], 0, true);
}
$items = self::getItems();
if (!DBA::isResult($items)) {
DI::sysmsg()->addNotice(DI::l10n()->t('No results.'));
return $o;
}
$o .= DI::conversation()->render($items, Conversation::MODE_CHANNEL, false, false, 'created', DI::userSession()->getLocalUserId());
$pager = new BoundariesPager(
DI::l10n(),
DI::args()->getQueryString(),
$items[0]['created'],
$items[count($items) - 1]['created'],
self::$itemsPerPage
);
if (DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'system', 'infinite_scroll')) {
$o .= HTML::scrollLoader();
} else {
$o .= $pager->renderMinimal(count($items));
}
return $o;
}
/**
* Computes module parameters from the request and local configuration
*
* @throws HTTPException\BadRequestException
* @throws HTTPException\ForbiddenException
*/
protected function parseRequest()
{
self::$accountTypeString = $_GET['accounttype'] ?? $this->parameters['accounttype'] ?? '';
self::$accountType = User::getAccountTypeByString(self::$accountTypeString);
self::$content = $this->parameters['content'] ?? '';
if (!self::$content) {
self::$content = self::WHATSHOT;
}
if (!in_array(self::$content, [self::WHATSHOT, self::FORYOU, self::FOLLOWERS])) {
throw new HTTPException\BadRequestException(DI::l10n()->t('Channel not available.'));
}
if (DI::mode()->isMobile()) {
self::$itemsPerPage = DI::pConfig()->get(
DI::userSession()->getLocalUserId(),
'system',
'itemspage_mobile_network',
DI::config()->get('system', 'itemspage_network_mobile')
);
} else {
self::$itemsPerPage = DI::pConfig()->get(
DI::userSession()->getLocalUserId(),
'system',
'itemspage_network',
DI::config()->get('system', 'itemspage_network')
);
}
if (!empty($_GET['item'])) {
$item = Post::selectFirst(['parent-uri-id'], ['id' => $_GET['item']]);
self::$item_id = $item['parent-uri-id'] ?? 0;
} else {
self::$item_id = 0;
}
Logger::debug('Blubb', ['get' => $_GET]);
self::$min_id = $_GET['min_id'] ?? null;
self::$max_id = $_GET['max_id'] ?? null;
self::$max_id = $_GET['last_created'] ?? self::$max_id;
}
/**
* Computes the displayed items.
*
* Community pages have a restriction on how many successive posts by the same author can show on any given page,
* so we may have to retrieve more content beyond the first query
*
* @return array
* @throws \Exception
*/
protected static function getItems()
{
$post = DBA::selectToArray('post-engagement', ['comments'], [], ['order' => ['comments' => true], 'limit' => [100, 1]]);
if (self::$content == self::WHATSHOT) {
$comments = $post[0]['comments'] ?? 0;
if (!is_null(self::$accountType)) {
$condition = ["`comments` >= ? AND `contact-type` = ?", $comments, self::$accountType];
} else {
$condition = ["`comments` >= ?", $comments];
}
} elseif (self::$content == self::FORYOU) {
$cid = Contact::getPublicIdByUserId(DI::userSession()->getLocalUserId());
if (!is_null(self::$accountType)) {
$condition = ["`author-id` IN (SELECT `relation-cid` FROM `contact-relation` WHERE `cid` = ? AND `thread-score` > ? AND `relation-thread-score` > ?) AND `contact-type` = ?", $cid, 0, 0, self::$accountType];
} else {
$condition = ["`author-id` IN (SELECT `relation-cid` FROM `contact-relation` WHERE `cid` = ? AND `thread-score` > ? AND `relation-thread-score` > ?)", $cid, 0, 0];
}
} elseif (self::$content == self::FOLLOWERS) {
if (!is_null(self::$accountType)) {
$condition = ["`author-id` IN (SELECT `pid` FROM `account-user-view` WHERE uid` = ? AND `rel` = ?) AND `contact-type` = ?", DI::userSession()->getLocalUserId(), Contact::FOLLOWER, self::$accountType];
} else {
$condition = ["`author-id` IN (SELECT `pid` FROM `account-user-view` WHERE `uid` = ? AND `rel` = ?)", DI::userSession()->getLocalUserId(), Contact::FOLLOWER];
}
}
$params = ['order' => ['created' => true], 'limit' => self::$itemsPerPage];
if (!empty(self::$item_id)) {
// @todo
$condition[0] .= " AND `uri-id` = ?";
$condition[] = self::$item_id;
} else {
if (!empty($_REQUEST['no_sharer'])) {
$condition[0] .= " AND NOT `uri-id` IN (SELECT `uri-id` FROM `post-user` WHERE `post-user`.`uid` = ? AND `post-user`.`uri-id` = `post-engagement`.`uri-id`)";
$condition[] = DI::userSession()->getLocalUserId();
}
if (isset(self::$max_id)) {
$condition[0] .= " AND `created` < ?";
$condition[] = self::$max_id;
}
if (isset(self::$min_id)) {
$condition[0] .= " AND `created` > ?";
$condition[] = self::$min_id;
// Previous page case: we want the items closest to min_id but for that we need to reverse the query order
if (!isset(self::$max_id)) {
$params['order']['created'] = false;
}
}
}
$items = DBA::selectToArray('post-engagement', ['uri-id', 'created'], $condition, $params);
if (empty($items)) {
return [];
}
// Previous page case: once we get the relevant items closest to min_id, we need to restore the expected display order
if (empty(self::$item_id) && isset(self::$min_id) && !isset(self::$max_id)) {
$items = array_reverse($items);
}
return $items;
}
}

View File

@ -137,6 +137,7 @@ class Community extends BaseModule
'$no_sharer' => !empty($_REQUEST['no_sharer']),
'$all' => DI::l10n()->t('Include'),
'$no_sharer_label' => DI::l10n()->t('Hide'),
'$base' => 'community',
]);
}
@ -245,8 +246,8 @@ class Community extends BaseModule
}
self::$min_id = $_GET['min_id'] ?? null;
self::$max_id = $_GET['max_id'] ?? null;
self::$max_id = $_GET['last_commented'] ?? self::$max_id;
self::$max_id = $_GET['max_id'] ?? null;
self::$max_id = $_GET['last_commented'] ?? self::$max_id;
}
/**

View File

@ -0,0 +1,48 @@
<?php
/**
* @copyright Copyright (C) 2010-2023, the Friendica project
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
* See update_profile.php for documentation
*/
namespace Friendica\Module\Update;
use Friendica\Content\Conversation;
use Friendica\Core\System;
use Friendica\DI;
use Friendica\Module\Conversation\Channel as ChannelModule;
/**
* Asynchronous update module for the Channel page
*
* @package Friendica\Module\Update
*/
class Channel extends ChannelModule
{
protected function rawContent(array $request = [])
{
$this->parseRequest();
$o = '';
if (!empty($request['force'])) {
$o = DI::conversation()->render(self::getItems(), Conversation::MODE_CHANNEL, true, false, 'created', DI::userSession()->getLocalUserId());
}
System::htmlUpdateExit($o);
}
}

View File

@ -21,6 +21,7 @@
namespace Friendica\Object;
use Friendica\Content\Conversation;
use Friendica\Core\Logger;
use Friendica\Core\Protocol;
use Friendica\DI;
@ -73,24 +74,28 @@ class Thread
$a = DI::app();
switch ($mode) {
case 'network':
case 'notes':
case Conversation::MODE_NETWORK:
case Conversation::MODE_NOTES:
$this->profile_owner = DI::userSession()->getLocalUserId();
$this->writable = true;
break;
case 'profile':
case Conversation::MODE_PROFILE:
$this->profile_owner = $a->getProfileOwner();
$this->writable = Security::canWriteToUserWall($this->profile_owner) || $writable;
break;
case 'display':
case Conversation::MODE_DISPLAY:
$this->profile_owner = $a->getProfileOwner();
$this->writable = Security::canWriteToUserWall($this->profile_owner) || $writable;
break;
case 'community':
case Conversation::MODE_CHANNEL:
$this->profile_owner = 0;
$this->writable = $writable;
break;
case 'contacts':
case Conversation::MODE_COMMUNITY:
$this->profile_owner = 0;
$this->writable = $writable;
break;
case Conversation::MODE_CONTACTS:
$this->profile_owner = 0;
$this->writable = $writable;
break;

View File

@ -45,6 +45,7 @@ class OptimizeTables
DBA::optimizeTable('oembed');
DBA::optimizeTable('parsed_url');
DBA::optimizeTable('session');
DBA::optimizeTable('post-engagement');
if (DI::config()->get('system', 'optimize_all_tables')) {
DBA::optimizeTable('apcontact');

View File

@ -24,6 +24,7 @@ namespace Friendica\Worker;
use Friendica\Core\Logger;
use Friendica\Database\DBA;
use Friendica\Model\Contact\Relation;
use Friendica\Model\Post;
/**
* Update the interaction scores
@ -41,6 +42,9 @@ class UpdateScores
DBA::close($users);
Logger::notice('Score update done');
Post\Engagement::expire();
return;
}
}

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', 1530);
define('DB_UPDATE_VERSION', 1531);
}
return [
@ -162,8 +162,8 @@ return [
"user-gserver" => [
"comment" => "User settings about remote servers",
"fields" => [
"uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "foreign" => ["user" => "uid"], "comment" => "Owner User id"],
"gsid" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "foreign" => ["gserver" => "id"], "comment" => "Gserver id"],
"uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "foreign" => ["user" => "uid"], "primary" => "1", "comment" => "Owner User id"],
"gsid" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "foreign" => ["gserver" => "id"], "primary" => "1", "comment" => "Gserver id"],
"ignored" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "server accounts are ignored for the user"],
],
"indexes" => [
@ -1323,6 +1323,22 @@ return [
"PRIMARY" => ["uri-id"],
]
],
"post-engagement" => [
"comment" => "Engagement data per post",
"fields" => [
"uri-id" => ["type" => "int unsigned", "not null" => "1", "primary" => "1", "foreign" => ["item-uri" => "id"], "comment" => "Id of the item-uri table entry that contains the item uri"],
"author-id" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "foreign" => ["contact" => "id", "on delete" => "restrict"], "comment" => "Link to the contact table with uid=0 of the author of this item"],
"contact-type" => ["type" => "tinyint", "not null" => "1", "default" => "0", "comment" => "Person, organisation, news, community, relay"],
"created" => ["type" => "datetime", "comment" => ""],
"comments" => ["type" => "mediumint unsigned", "comment" => "Number of comments"],
"activities" => ["type" => "mediumint unsigned", "comment" => "Number of activities (like, dislike, ...)"],
],
"indexes" => [
"PRIMARY" => ["uri-id"],
"author-id" => ["author-id"],
"created" => ["created"],
]
],
"post-history" => [
"comment" => "Post history",
"fields" => [

View File

@ -391,6 +391,7 @@ return [
'/event/{mode:edit|copy}/{id:\d+}' => [Module\Calendar\Event\Form::class, [R::GET ]],
],
'/channel[/{content}]' => [Module\Conversation\Channel::class, [R::GET]],
'/community[/{content}]' => [Module\Conversation\Community::class, [R::GET]],
'/compose[/{type}]' => [Module\Item\Compose::class, [R::GET, R::POST]],
@ -686,6 +687,7 @@ return [
'/toggle_mobile' => [Module\ToggleMobile::class, [R::GET]],
'/tos' => [Module\Tos::class, [R::GET]],
'/update_channel[/{content}]' => [Module\Update\Channel::class, [R::GET]],
'/update_community[/{content}]' => [Module\Update\Community::class, [R::GET]],
'/update_display' => [Module\Update\Display::class, [R::GET]],

File diff suppressed because it is too large Load Diff

View File

@ -32,6 +32,9 @@
<a accesskey="p" id="nav-home-link" class="nav-commlink {{$nav.home.2}} {{$sel.home}}" href="{{$nav.home.0}}" title="{{$nav.home.3}}">{{$nav.home.1}}</a>
<span id="home-update" class="nav-ajax-left"></span>
{{/if}}
{{if $nav.channel}}
<a accesskey="l" id="nav-channel-link" class="nav-commlink {{$nav.channel.2}} {{$sel.channel}}" href="{{$nav.channel.0}}" title="{{$nav.channel.3}}">{{$nav.channel.1}}</a>
{{/if}}
{{if $nav.community}}
<a accesskey="c" id="nav-community-link" class="nav-commlink {{$nav.community.2}} {{$sel.community}}" href="{{$nav.community.0}}" title="{{$nav.community.3}}">{{$nav.community.1}}</a>
{{/if}}

View File

@ -6,8 +6,8 @@
<h3>{{$title}}</h3>
</span>
<ul class="sidebar-community-no-sharer-ul">
<li role="menuitem" class="sidebar-community-no-sharer-li{{if !$no_sharer}} selected{{/if}}"><a href="community/{{$path_all}}">{{$all}}</a></li>
<li role="menuitem" class="sidebar-community-no-sharer-li{{if $no_sharer}} selected{{/if}}"><a href="community/{{$path_no_sharer}}">{{$no_sharer_label}}</a></li>
<li role="menuitem" class="sidebar-community-no-sharer-li{{if !$no_sharer}} selected{{/if}}"><a href="{{$base}}/{{$path_all}}">{{$all}}</a></li>
<li role="menuitem" class="sidebar-community-no-sharer-li{{if $no_sharer}} selected{{/if}}"><a href="{{$base}}/{{$path_no_sharer}}">{{$no_sharer_label}}</a></li>
</ul>
</div>
<script>

View File

@ -63,6 +63,14 @@
</li>
{{/if}}
{{if $nav.channel}}
<li class="nav-segment">
<a accesskey="l" class="nav-menu {{$sel.channel}}" href="{{$nav.channel.0}}"
data-toggle="tooltip" aria-label="{{$nav.channel.3}}" title="{{$nav.channel.3}}"><i
class="fa fa-lg fa-th-list fa-fw" aria-hidden="true"></i></a>
</li>
{{/if}}
{{if $nav.community}}
<li class="nav-segment">
<a accesskey="c" class="nav-menu {{$sel.community}}" href="{{$nav.community.0}}"

View File

@ -36,6 +36,12 @@
<a class="{{$nav.events.2}} mobile-view" href="{{$nav.events.0}}" title="{{$nav.events.3}}"><i class="icon s22 icon-calendar"></i></a>
</li>
{{/if}}
{{if $nav.channel}}
<li role="menuitem" id="nav-channel-link" class="nav-menu {{$sel.channel}}">
<a accesskey="l" class="{{$nav.channel.2}} desktop-view" href="{{$nav.channel.0}}" title="{{$nav.channel.3}}">{{$nav.channel.1}}</a>
<a class="{{$nav.channel.2}} mobile-view" href="{{$nav.channel.0}}" title="{{$nav.channel.3}}"><i class="icon s22 icon-bullseye"></i></a>
</li>
{{/if}}
{{if $nav.community}}
<li role="menuitem" id="nav-community-link" class="nav-menu {{$sel.community}}">
<a accesskey="c" class="{{$nav.community.2}} desktop-view" href="{{$nav.community.0}}" title="{{$nav.community.3}}">{{$nav.community.1}}</a>