123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134 |
- <?php
- defined('GNUSOCIAL') || die();
- class InboxNoticeStream extends ScopingNoticeStream
- {
-
- public function __construct(Profile $target, Profile $scoped = null)
- {
- parent::__construct(new CachingNoticeStream(new RawInboxNoticeStream($target), 'profileall:'.$target->getID()), $scoped);
- }
- }
- class RawInboxNoticeStream extends FullNoticeStream
- {
- protected $target = null;
- protected $inbox = null;
-
- public function __construct(Profile $target)
- {
- parent::__construct();
- $this->target = $target;
- }
-
- public function getNoticeIds($offset, $limit, $since_id = null, $max_id = null)
- {
- $notice = new Notice();
- $notice->selectAdd();
- $notice->selectAdd('id');
-
-
- $notice->_join .= sprintf(
- "\n" . 'NATURAL INNER JOIN (' .
- '(SELECT id FROM notice WHERE profile_id IN (SELECT subscribed FROM subscription WHERE subscriber = %1$d)) ' .
- 'UNION (SELECT notice_id AS id FROM reply WHERE profile_id = %1$d) ' .
- 'UNION (SELECT notice_id AS id FROM attention WHERE profile_id = %1$d) ' .
- 'UNION (SELECT notice_id AS id FROM group_inbox WHERE group_id IN (SELECT group_id FROM group_member WHERE profile_id = %1$d))' .
- ') AS t1',
- $this->target->getID()
- );
- $notice->whereAdd(sprintf(
- "notice.created > TIMESTAMP '%s'",
- $notice->escape($this->target->created)
- ));
- if (!empty($since_id)) {
- $notice->whereAdd('id > ' . $since_id);
- }
- if (!empty($max_id)) {
- $notice->whereAdd('id <= ' . $max_id);
- }
- $notice->whereAdd('scope <> ' . Notice::MESSAGE_SCOPE);
- self::filterVerbs($notice, $this->selectVerbs);
-
-
-
- $notice->orderBy('id DESC');
- $notice->limit($offset, $limit);
- if (!$notice->find()) {
- return [];
- }
- return $notice->fetchAll('id');
- }
- }
|