2015-11-23 22:40:59 +09:00
|
|
|
<?php
|
|
|
|
|
|
|
|
class RawEventsNoticeStream extends NoticeStream
|
|
|
|
{
|
|
|
|
protected $target;
|
|
|
|
protected $own;
|
|
|
|
|
|
|
|
function __construct(Profile $target)
|
|
|
|
{
|
|
|
|
$this->target = $target;
|
|
|
|
}
|
|
|
|
|
|
|
|
function getNoticeIds($offset, $limit, $since_id, $max_id)
|
|
|
|
{
|
|
|
|
$notice = new Notice();
|
|
|
|
$qry = null;
|
|
|
|
|
|
|
|
$qry = 'SELECT notice.* FROM notice ';
|
|
|
|
$qry .= 'INNER JOIN happening ON happening.uri = notice.uri ';
|
|
|
|
$qry .= 'WHERE happening.profile_id = ' . $this->target->getID() . ' ';
|
|
|
|
$qry .= 'AND notice.is_local != ' . Notice::GATEWAY . ' ';
|
|
|
|
|
|
|
|
if ($since_id != 0) {
|
|
|
|
$qry .= 'AND notice.id > ' . $since_id . ' ';
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($max_id != 0) {
|
|
|
|
$qry .= 'AND notice.id <= ' . $max_id . ' ';
|
|
|
|
}
|
|
|
|
|
2016-01-01 02:04:12 +09:00
|
|
|
// NOTE: we sort by event time, not by notice time!
|
2015-11-23 22:40:59 +09:00
|
|
|
$qry .= 'ORDER BY created DESC ';
|
|
|
|
if (!is_null($offset)) {
|
|
|
|
$qry .= "LIMIT $limit OFFSET $offset";
|
|
|
|
}
|
|
|
|
|
|
|
|
$notice->query($qry);
|
|
|
|
$ids = array();
|
|
|
|
while ($notice->fetch()) {
|
|
|
|
$ids[] = $notice->id;
|
|
|
|
}
|
|
|
|
|
|
|
|
$notice->free();
|
|
|
|
unset($notice);
|
|
|
|
return $ids;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class EventsNoticeStream extends ScopingNoticeStream
|
|
|
|
{
|
|
|
|
function __construct(Profile $target, Profile $scoped=null)
|
|
|
|
{
|
|
|
|
$stream = new RawEventsNoticeStream($target);
|
|
|
|
|
|
|
|
if ($target->sameAs($scoped)) {
|
2016-01-01 02:04:12 +09:00
|
|
|
$key = 'happening:ids_for_user_own:'.$target->getID();
|
2015-11-23 22:40:59 +09:00
|
|
|
} else {
|
2016-01-01 02:04:12 +09:00
|
|
|
$key = 'happening:ids_for_user:'.$target->getID();
|
2015-11-23 22:40:59 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
parent::__construct(new CachingNoticeStream($stream, $key), $scoped);
|
|
|
|
}
|
|
|
|
}
|