self::$content = $this->parameters['content'] ?? '';
if (!self::$content) {
- self::$content = self::FORYOU;
+ self::$content = ChannelEntity::FORYOU;
}
- if (!in_array(self::$content, [ChannelEntity::WHATSHOT, ChannelEntity::FORYOU, ChannelEntity::FOLLOWERS, ChannelEntity::IMAGE, ChannelEntity::VIDEO, ChannelEntity::AUDIO, ChannelEntity::LANGUAGE])) {
- if (!in_array(self::$content, [self::WHATSHOT, self::FORYOU, self::FOLLOWERS, self::SHARERSOFSHARERS, self::IMAGE, self::VIDEO, self::AUDIO, self::LANGUAGE])) {
++ if (!in_array(self::$content, [ChannelEntity::WHATSHOT, ChannelEntity::FORYOU, ChannelEntity::FOLLOWERS, ChannelEntity::SHARERSOFSHARERS, ChannelEntity::IMAGE, ChannelEntity::VIDEO, ChannelEntity::AUDIO, ChannelEntity::LANGUAGE])) {
throw new HTTPException\BadRequestException($this->l10n->t('Channel not available.'));
}
} else {
$condition = ["(`comments` >= ? OR `activities` >= ?) AND `contact-type` != ?", $this->getMedianComments(4), $this->getMedianActivities(4), Contact::TYPE_COMMUNITY];
}
- } elseif (self::$content == self::FORYOU) {
+ } elseif (self::$content == ChannelEntity::FORYOU) {
$cid = Contact::getPublicIdByUserId($this->session->getLocalUserId());
--
- $condition = ["(`owner-id` IN (SELECT `relation-cid` FROM `contact-relation` WHERE `cid` = ? AND `thread-score` > ?) OR
- ((`comments` >= ? OR `activities` >= ?) AND `owner-id` IN (SELECT `pid` FROM `account-user-view` WHERE `uid` = ? AND `rel` IN (?, ?))) OR
- ( `owner-id` IN (SELECT `pid` FROM `account-user-view` WHERE `uid` = ? AND `rel` IN (?, ?) AND `notify_new_posts`)))",
- $cid, $this->getMedianThreadScore($cid, 4), $this->getMedianComments(4), $this->getMedianActivities(4), $this->session->getLocalUserId(), Contact::FRIEND, Contact::SHARING,
- $this->session->getLocalUserId(), Contact::FRIEND, Contact::SHARING];
+ $condition = [
+ "(`owner-id` IN (SELECT `cid` FROM `contact-relation` WHERE `relation-cid` = ? AND `relation-thread-score` > ?) OR
+ ((`comments` >= ? OR `activities` >= ?) AND `owner-id` IN (SELECT `cid` FROM `contact-relation` WHERE `follows` AND `relation-cid` = ?)) OR
+ (`owner-id` IN (SELECT `pid` FROM `account-user-view` WHERE `uid` = ? AND `rel` IN (?, ?) AND `notify_new_posts`)))",
+ $cid, $this->getMedianRelationThreadScore($cid, 4), $this->getMedianComments(4), $this->getMedianActivities(4), $cid,
+ $this->session->getLocalUserId(), Contact::FRIEND, Contact::SHARING
+ ];
- } elseif (self::$content == self::FOLLOWERS) {
+ } elseif (self::$content == ChannelEntity::FOLLOWERS) {
$condition = ["`owner-id` IN (SELECT `pid` FROM `account-user-view` WHERE `uid` = ? AND `rel` = ?)", $this->session->getLocalUserId(), Contact::FOLLOWER];
- } elseif (self::$content == self::SHARERSOFSHARERS) {
++ } elseif (self::$content == ChannelEntity::SHARERSOFSHARERS) {
+ $cid = Contact::getPublicIdByUserId($this->session->getLocalUserId());
+
+ $condition = [
+ "`owner-id` IN (SELECT `cid` FROM `contact-relation` WHERE `follows` AND `last-interaction` > ?
+ AND `relation-cid` IN (SELECT `cid` FROM `contact-relation` WHERE `follows` AND `relation-cid` = ? AND `relation-thread-score` >= ?)
+ AND NOT `cid` IN (SELECT `cid` FROM `contact-relation` WHERE `follows` AND `relation-cid` = ?))",
+ DateTimeFormat::utc('now - 90 day'), $cid, $this->getMedianRelationThreadScore($cid, 4), $cid
+ ];
- } elseif (self::$content == self::IMAGE) {
+ } elseif (self::$content == ChannelEntity::IMAGE) {
$condition = ["`media-type` & ?", 1];
- } elseif (self::$content == self::VIDEO) {
+ } elseif (self::$content == ChannelEntity::VIDEO) {
$condition = ["`media-type` & ?", 2];
- } elseif (self::$content == self::AUDIO) {
+ } elseif (self::$content == ChannelEntity::AUDIO) {
$condition = ["`media-type` & ?", 4];
- } elseif (self::$content == self::LANGUAGE) {
+ } elseif (self::$content == ChannelEntity::LANGUAGE) {
$condition = ["JSON_EXTRACT(JSON_KEYS(language), '$[0]') = ?", $this->l10n->convertCodeForLanguageDetection(User::getLanguageCode($this->session->getLocalUserId()))];
}