From: Michael Date: Thu, 7 Sep 2023 17:28:02 +0000 (+0000) Subject: Merge remote-tracking branch 'upstream/develop' into channel-model X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=067d72ec85fd99c2ddb2029aed00281c7345916d;p=friendica.git Merge remote-tracking branch 'upstream/develop' into channel-model --- 067d72ec85fd99c2ddb2029aed00281c7345916d diff --cc src/Module/Conversation/Channel.php index 41eff2999c,12e0cb467c..f84039059a --- a/src/Module/Conversation/Channel.php +++ b/src/Module/Conversation/Channel.php @@@ -218,10 -287,10 +219,10 @@@ class Channel extends BaseModul 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.')); } @@@ -269,23 -338,34 +270,33 @@@ } 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()))]; }