- if (empty($this->inbox)) {
- $this->inbox = Inbox::fromNoticeInbox($user_id);
- if (empty($this->inbox)) {
- return array();
- } else {
- $this->inbox->encache();
- }
- }
-
- $ids = $this->inbox->unpack();
-
+ $notice = new Notice();
+ $notice->selectAdd();
+ $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)
+ );