Channels in your language
This commit is contained in:
parent
e68f781f9d
commit
508be7a742
4 changed files with 56 additions and 13 deletions
|
@ -1308,6 +1308,7 @@ CREATE TABLE IF NOT EXISTS `post-engagement` (
|
||||||
`owner-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Item owner',
|
`owner-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Item owner',
|
||||||
`contact-type` tinyint NOT NULL DEFAULT 0 COMMENT 'Person, organisation, news, community, relay',
|
`contact-type` tinyint NOT NULL DEFAULT 0 COMMENT 'Person, organisation, news, community, relay',
|
||||||
`media-type` tinyint NOT NULL DEFAULT 0 COMMENT 'Type of media in a bit array (1 = image, 2 = video, 4 = audio',
|
`media-type` tinyint NOT NULL DEFAULT 0 COMMENT 'Type of media in a bit array (1 = image, 2 = video, 4 = audio',
|
||||||
|
`language` varbinary(128) COMMENT 'Language information about this post',
|
||||||
`created` datetime COMMENT '',
|
`created` datetime COMMENT '',
|
||||||
`comments` mediumint unsigned COMMENT 'Number of comments',
|
`comments` mediumint unsigned COMMENT 'Number of comments',
|
||||||
`activities` mediumint unsigned COMMENT 'Number of activities (like, dislike, ...)',
|
`activities` mediumint unsigned COMMENT 'Number of activities (like, dislike, ...)',
|
||||||
|
|
|
@ -37,6 +37,8 @@ General
|
||||||
* i - Images
|
* i - Images
|
||||||
* v - Videos
|
* v - Videos
|
||||||
* d - Audio
|
* d - Audio
|
||||||
|
* g - Posts in your language
|
||||||
|
* o - Hot posts in your language
|
||||||
|
|
||||||
../profile
|
../profile
|
||||||
--------
|
--------
|
||||||
|
|
|
@ -46,6 +46,7 @@ use Friendica\Network\HTTPException;
|
||||||
use Friendica\Core\Session\Model\UserSession;
|
use Friendica\Core\Session\Model\UserSession;
|
||||||
use Friendica\Database\Database;
|
use Friendica\Database\Database;
|
||||||
use Friendica\Module\Response;
|
use Friendica\Module\Response;
|
||||||
|
use Friendica\Navigation\SystemMessages;
|
||||||
use Friendica\Util\Profiler;
|
use Friendica\Util\Profiler;
|
||||||
use Psr\Log\LoggerInterface;
|
use Psr\Log\LoggerInterface;
|
||||||
|
|
||||||
|
@ -57,6 +58,8 @@ class Channel extends BaseModule
|
||||||
const IMAGE = 'image';
|
const IMAGE = 'image';
|
||||||
const VIDEO = 'video';
|
const VIDEO = 'video';
|
||||||
const AUDIO = 'audio';
|
const AUDIO = 'audio';
|
||||||
|
const LANGUAGE = 'language';
|
||||||
|
const HOTLANG = 'hotlang';
|
||||||
|
|
||||||
protected static $content;
|
protected static $content;
|
||||||
protected static $accountTypeString;
|
protected static $accountTypeString;
|
||||||
|
@ -86,18 +89,19 @@ class Channel extends BaseModule
|
||||||
protected $database;
|
protected $database;
|
||||||
|
|
||||||
|
|
||||||
public function __construct(Database $database, IManagePersonalConfigValues $pConfig, Mode $mode, Conversation $conversation, App\Page $page, IManageConfigValues $config, ICanCache $cache, IHandleUserSessions $session, L10n $l10n, App\BaseURL $baseUrl, App\Arguments $args, LoggerInterface $logger, Profiler $profiler, Response $response, array $server, array $parameters = [])
|
public function __construct(SystemMessages $systemMessages, Database $database, IManagePersonalConfigValues $pConfig, Mode $mode, Conversation $conversation, App\Page $page, IManageConfigValues $config, ICanCache $cache, IHandleUserSessions $session, L10n $l10n, App\BaseURL $baseUrl, App\Arguments $args, LoggerInterface $logger, Profiler $profiler, Response $response, array $server, array $parameters = [])
|
||||||
{
|
{
|
||||||
parent::__construct($l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters);
|
parent::__construct($l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters);
|
||||||
|
|
||||||
$this->database = $database;
|
$this->systemMessages = $systemMessages;
|
||||||
$this->pConfig = $pConfig;
|
$this->database = $database;
|
||||||
$this->mode = $mode;
|
$this->pConfig = $pConfig;
|
||||||
$this->conversation = $conversation;
|
$this->mode = $mode;
|
||||||
$this->page = $page;
|
$this->conversation = $conversation;
|
||||||
$this->config = $config;
|
$this->page = $page;
|
||||||
$this->cache = $cache;
|
$this->config = $config;
|
||||||
$this->session = $session;
|
$this->cache = $cache;
|
||||||
|
$this->session = $session;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function content(array $request = []): string
|
protected function content(array $request = []): string
|
||||||
|
@ -176,6 +180,28 @@ class Channel extends BaseModule
|
||||||
'accesskey' => 'd'
|
'accesskey' => 'd'
|
||||||
];
|
];
|
||||||
|
|
||||||
|
$owner = User::getOwnerDataById($this->session->getLocalUserId());
|
||||||
|
$languages = $this->l10n->getAvailableLanguages();
|
||||||
|
if (!empty($owner['language']) && !empty($languages[$owner['language']])) {
|
||||||
|
$tabs[] = [
|
||||||
|
'label' => $languages[$owner['language']],
|
||||||
|
'url' => 'channel/' . self::LANGUAGE,
|
||||||
|
'sel' => self::$content == self::LANGUAGE ? 'active' : '',
|
||||||
|
'title' => $this->l10n->t('Posts in %s', $languages[$owner['language']]),
|
||||||
|
'id' => 'channel-language-tab',
|
||||||
|
'accesskey' => 'g'
|
||||||
|
];
|
||||||
|
|
||||||
|
$tabs[] = [
|
||||||
|
'label' => $this->l10n->t('Whats Hot %s', $languages[$owner['language']]),
|
||||||
|
'url' => 'channel/' . self::HOTLANG,
|
||||||
|
'sel' => self::$content == self::HOTLANG ? 'active' : '',
|
||||||
|
'title' => $this->l10n->t('Posts in %s with a lot of interactions', $languages[$owner['language']]),
|
||||||
|
'id' => 'channel-hotlang-tab',
|
||||||
|
'accesskey' => 'o'
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
$tab_tpl = Renderer::getMarkupTemplate('common_tabs.tpl');
|
$tab_tpl = Renderer::getMarkupTemplate('common_tabs.tpl');
|
||||||
$o .= Renderer::replaceMacros($tab_tpl, ['$tabs' => $tabs]);
|
$o .= Renderer::replaceMacros($tab_tpl, ['$tabs' => $tabs]);
|
||||||
|
|
||||||
|
@ -263,7 +289,7 @@ class Channel extends BaseModule
|
||||||
self::$content = self::FORYOU;
|
self::$content = self::FORYOU;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!in_array(self::$content, [self::WHATSHOT, self::FORYOU, self::FOLLOWERS, self::IMAGE, self::VIDEO, self::AUDIO])) {
|
if (!in_array(self::$content, [self::WHATSHOT, self::FORYOU, self::FOLLOWERS, self::IMAGE, self::VIDEO, self::AUDIO, self::LANGUAGE, self::HOTLANG])) {
|
||||||
throw new HTTPException\BadRequestException($this->l10n->t('Channel not available.'));
|
throw new HTTPException\BadRequestException($this->l10n->t('Channel not available.'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -327,6 +353,16 @@ class Channel extends BaseModule
|
||||||
$condition = ["`media-type` & ?", 2];
|
$condition = ["`media-type` & ?", 2];
|
||||||
} elseif (self::$content == self::AUDIO) {
|
} elseif (self::$content == self::AUDIO) {
|
||||||
$condition = ["`media-type` & ?", 4];
|
$condition = ["`media-type` & ?", 4];
|
||||||
|
} elseif (self::$content == self::LANGUAGE) {
|
||||||
|
$owner = User::getOwnerDataById($this->session->getLocalUserId());
|
||||||
|
$condition = ["JSON_EXTRACT(`language`, ?) > ?", '$.' . $owner['language'], $this->config->get('channel', 'language_threshold')];
|
||||||
|
} elseif (self::$content == self::HOTLANG) {
|
||||||
|
$owner = User::getOwnerDataById($this->session->getLocalUserId());
|
||||||
|
if (!is_null(self::$accountType)) {
|
||||||
|
$condition = ["(`comments` >= ? OR `activities` >= ?) AND `contact-type` = ? AND JSON_EXTRACT(`language`, ?) > ?", $this->getMedianComments(4), $this->getMedianActivities(4), self::$accountType, '$.' . $owner['language'], $this->config->get('channel', 'language_threshold')];
|
||||||
|
} else {
|
||||||
|
$condition = ["(`comments` >= ? OR `activities` >= ?) AND `contact-type` != ? AND JSON_EXTRACT(`language`, ?) > ?", $this->getMedianComments(4), $this->getMedianActivities(4), Contact::TYPE_COMMUNITY, '$.' . $owner['language'], $this->config->get('channel', 'language_threshold')];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$condition[0] .= " AND NOT EXISTS(SELECT `cid` FROM `user-contact` WHERE `uid` = ? AND `cid` = `post-engagement`.`owner-id` AND (`ignored` OR `blocked` OR `collapsed`))";
|
$condition[0] .= " AND NOT EXISTS(SELECT `cid` FROM `user-contact` WHERE `uid` = ? AND `cid` = `post-engagement`.`owner-id` AND (`ignored` OR `blocked` OR `collapsed`))";
|
||||||
|
|
|
@ -797,12 +797,16 @@ return [
|
||||||
'public' => true,
|
'public' => true,
|
||||||
],
|
],
|
||||||
'channel' => [
|
'channel' => [
|
||||||
|
// engagement_hours (Integer)
|
||||||
|
// Number of hours posts are held in the engagement table
|
||||||
|
'engagement_hours' => 24,
|
||||||
|
|
||||||
// interaction_score_days (Integer)
|
// interaction_score_days (Integer)
|
||||||
// Number of days that are used to calculate the interaction score.
|
// Number of days that are used to calculate the interaction score.
|
||||||
'interaction_score_days' => 30,
|
'interaction_score_days' => 30,
|
||||||
|
|
||||||
// engagement_hours (Integer)
|
// language_threshold (Float)
|
||||||
// Number of hours posts are held in the engagement table
|
// Treshold for the language detection.
|
||||||
'engagement_hours' => 24,
|
'language_threshold' => 0.6,
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
|
|
Loading…
Reference in a new issue