$notice->limit($offset, $limit);
}
- if (!$this->allVerbs) {
- $notice->whereAdd(sprintf('verb="%s" OR verb="%s"',
- ActivityVerb::POST,
- ActivityUtils::resolveUri(ActivityVerb::POST, true)));
+ if (!empty($this->selectVerbs)) {
+ $notice->whereAddIn('verb', $this->selectVerbs, $notice->columnType('verb'));
}
// ORDER BY
if (!empty($max_id)) {
$notice->whereAdd(sprintf('notice.id <= %d', $max_id));
}
+ if (!empty($this->selectVerbs)) {
+ $notice->whereAddIn('verb', $this->selectVerbs, $notice->columnType('verb'));
+ }
$notice->limit($offset, $limit);
// notice.id will give us even really old posts, which were
// recently imported. For example if a remote instance had
*/
abstract class NoticeStream
{
- protected $allVerbs = false; // Will only get 'post' activityverbs by default.
+ // Will only get notices with the 'post' activityverb by default.
+ protected $selectVerbs = array();
+
+ public function __construct()
+ {
+ $this->selectVerbs = array(ActivityVerb::POST, ActivityUtils::resolveUri(ActivityVerb::POST, true));
+ }
abstract function getNoticeIds($offset, $limit, $since_id, $max_id);
function __construct($profile)
{
+ parent::__construct();
$this->profile = $profile;
}
Notice::addWhereSinceId($notice, $since_id);
Notice::addWhereMaxId($notice, $max_id);
- if (!$this->allVerbs) {
- $notice->whereAdd(sprintf('verb="%s" OR verb="%s"',
- ActivityVerb::POST,
- ActivityUtils::resolveUri(ActivityVerb::POST, true)));
- }
-
$notice->orderBy('created DESC, id DESC');
if (!is_null($offset)) {
Notice::addWhereSinceId($notice, $since_id);
Notice::addWhereMaxId($notice, $max_id);
- if (!$this->allVerbs) {
- $notice->whereAdd(sprintf('verb="%s" OR verb="%s"',
- ActivityVerb::POST,
- ActivityUtils::resolveUri(ActivityVerb::POST, true)));
+ if (!empty($this->selectVerbs)) {
+ $notice->whereAddIn('verb', $this->selectVerbs, $notice->columnType('verb'));
}
$ids = array();
function __construct($user_id, $own)
{
+ parent::__construct();
+
$this->user_id = $user_id;
$this->own = $own;
+
+ $this->selectVerbs = array();
}
/**