]> git.mxchange.org Git - friendica.git/commitdiff
Merge remote-tracking branch 'upstream/develop' into channel-model
authorMichael <heluecht@pirati.ca>
Thu, 7 Sep 2023 17:28:02 +0000 (17:28 +0000)
committerMichael <heluecht@pirati.ca>
Thu, 7 Sep 2023 17:28:02 +0000 (17:28 +0000)
1  2 
src/Module/Conversation/Channel.php

index 41eff2999cb7f0dc2f93cbfd0acb56192d562852,12e0cb467c7e49646050c2d28538aaa833640a2b..f84039059abc2d4817b8a3a04c83de4d17ef2134
@@@ -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.'));
                }
  
                        } 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()))];
                }