Revert "[CORE] Another fix for the inboxnoticestream query"

This reverts commit bdd55f611f.
This commit is contained in:
Diogo Peralta Cordeiro 2021-07-16 19:44:14 +01:00
parent bdd55f611f
commit 50c98d53c9

View File

@ -107,26 +107,19 @@ class RawInboxNoticeStream extends FullNoticeStream
$notice->whereAdd(sprintf('notice.created > "%s"', $notice->escape($this->target->created))); $notice->whereAdd(sprintf('notice.created > "%s"', $notice->escape($this->target->created)));
// Reply:: is a table of mentions // Reply:: is a table of mentions
// Subscription:: is a table of subscriptions (every user is subscribed to themselves) // Subscription:: is a table of subscriptions (every user is subscribed to themselves)
$notice->_join .= sprintf( // Sort in descending order as id will give us even really old posts,
"\n" . <<<'END' // which were recently imported. For example, if a remote instance had
LEFT JOIN ( // problems and just managed to post here.
SELECT id FROM notice $notice->whereAdd(
WHERE profile_id sprintf('id IN (SELECT DISTINCT id FROM (' .
IN (SELECT subscribed FROM subscription WHERE subscriber = %1$d) '(SELECT id FROM notice WHERE profile_id IN (SELECT subscribed FROM subscription WHERE subscriber = %1$d)) UNION ' .
UNION ALL '(SELECT notice_id AS id FROM reply WHERE profile_id = %1$d) UNION ' .
SELECT notice_id AS id FROM reply WHERE profile_id = %1$d '(SELECT notice_id AS id FROM attention WHERE profile_id = %1$d) UNION ' .
UNION ALL '(SELECT notice_id AS id FROM group_inbox WHERE group_id IN (SELECT group_id FROM group_member WHERE profile_id = %1$d)) ' .
SELECT notice_id AS id FROM attention WHERE profile_id = %1$d 'ORDER BY id DESC) AS T)',
UNION ALL $this->target->getID())
SELECT notice_id AS id FROM group_inbox INNER JOIN group_member USING (group_id)
WHERE group_member.profile_id = %1$d
) AS t1 USING (id)
END,
$this->target->getID()
); );
$notice->whereAdd('t1.id IS NOT NULL');
if (!empty($since_id)) { if (!empty($since_id)) {
$notice->whereAdd(sprintf('notice.id > %d', $since_id)); $notice->whereAdd(sprintf('notice.id > %d', $since_id));
} }
@ -136,11 +129,6 @@ class RawInboxNoticeStream extends FullNoticeStream
self::filterVerbs($notice, $this->selectVerbs); self::filterVerbs($notice, $this->selectVerbs);
// notice.id will give us even really old posts, which were recently
// imported. For example if a remote instance had problems and just
// managed to post here.
$notice->orderBy('id DESC');
$notice->limit($offset, $limit); $notice->limit($offset, $limit);
if (!$notice->find()) { if (!$notice->find()) {