- $notice->selectAdd('notice_id');
- // Reply is a class for mentions
- $notice->joinAdd(array('id', 'reply:notice_id'));
+ $notice->selectAdd('id');
+ $notice->whereAdd(sprintf('notice.created > "%s"', $notice->escape($this->target->created)));
+ // Reply:: is a table of mentions
+ // Subscription:: is a table of subscriptions (every user is subscribed to themselves)
+ $notice->whereAdd(
+ sprintf('notice.id IN (SELECT notice_id FROM reply WHERE profile_id=%1$d) ' .
+ 'OR notice.profile_id IN (SELECT subscribed FROM subscription WHERE subscriber=%1$d) ' .
+ 'OR notice.id IN (SELECT notice_id FROM group_inbox WHERE group_id IN (SELECT group_id FROM group_member WHERE profile_id=%1$d))' .
+ 'OR notice.id IN (SELECT notice_id FROM attention WHERE profile_id=%1$d)',
+ $this->target->id)
+ );
+ if (!empty($since_id)) {
+ $notice->whereAdd(sprintf('notice.id > %d', $since_id));
+ }
+ if (!empty($max_id)) {
+ $notice->whereAdd(sprintf('notice.id <= %d', $max_id));
+ }
+
+ self::filterVerbs($notice, $this->selectVerbs);