123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101 |
- <?php
- defined('GNUSOCIAL') || die();
- class RawEventsNoticeStream extends NoticeStream
- {
- public function getNoticeIds($offset, $limit, $since_id, $max_id)
- {
- $notice = new Notice();
- $notice->selectAdd();
- $notice->selectAdd('notice.*');
- $notice->joinAdd(['uri', 'happening:uri']);
- $notice->whereAdd('notice.is_local <> ' . Notice::GATEWAY);
- Notice::addWhereSinceId($notice, $since_id, 'notice.id', 'happening.created');
- Notice::addWhereMaxId($notice, $max_id, 'notice.id', 'happening.created');
-
- $notice->orderBy('happening.created DESC');
- if (!is_null($offset)) {
- $notice->limit($offset, $limit);
- }
- $ids = [];
- if ($notice->find()) {
- while ($notice->fetch()) {
- $ids[] = $notice->id;
- }
- }
- $notice->free();
- unset($notice);
- return $ids;
- }
- }
- class EventsNoticeStream extends ScopingNoticeStream
- {
-
- protected $rsvp = ['Y', 'N', '?'];
- protected $target = null;
- public function __construct(Profile $target, Profile $scoped = null, array $rsvp = [])
- {
- $stream = new RawEventsNoticeStream();
- if ($target->sameAs($scoped)) {
- $key = 'happening:ids_for_user_own:'.$target->getID();
- } else {
- $key = 'happening:ids_for_user:'.$target->getID();
- }
-
-
-
- $this->rsvp = array_intersect($this->rsvp, $rsvp);
- $this->target = $target;
- parent::__construct(new CachingNoticeStream($stream, $key), $scoped);
- }
- protected function filter(Notice $notice)
- {
- if (!parent::filter($notice)) {
-
- return false;
- }
- if (empty($this->rsvp)) {
-
-
- return true;
- }
- $rsvp = new RSVP();
- $rsvp->profile_id = $this->target->getID();
- $rsvp->event_uri = $notice->getUri();
- $rsvp->whereAddIn('response', $this->rsvp, $rsvp->columnType('response'));
-
- return $rsvp->N > 0;
- }
- }
|