$notice->saveTags();
- $notice->addToInboxes();
+ $groups = $notice->saveGroups();
+
+ $recipients = $notice->saveReplies();
+
+ $notice->addToInboxes($groups, $recipients);
$notice->saveUrls();
return $ids;
}
- function whoGets()
+ function whoGets($groups=null, $recipients=null)
{
$c = self::memcache();
}
}
+ if (is_null($groups)) {
+ $groups = $this->getGroups();
+ }
+
+ if (is_null($recipients)) {
+ $recipients = $this->getReplies();
+ }
+
$users = $this->getSubscribedUsers();
// FIXME: kind of ignoring 'transitional'...
$ni[$id] = NOTICE_INBOX_SOURCE_SUB;
}
- $groups = $this->saveGroups();
$profile = $this->getProfile();
foreach ($groups as $group) {
}
}
- $recipients = $this->saveReplies();
-
foreach ($recipients as $recipient) {
if (!array_key_exists($recipient, $ni)) {
return $ni;
}
- function addToInboxes()
+ function addToInboxes($groups, $recipients)
{
- $ni = $this->whoGets();
+ $ni = $this->whoGets($groups, $recipients);
Inbox::bulkInsert($this->id, array_keys($ni));
return $recipientIds;
}
+ function getReplies()
+ {
+ // XXX: cache me
+
+ $ids = array();
+
+ $reply = new Reply();
+ $reply->selectAdd();
+ $reply->selectAdd('profile_id');
+ $reply->notice_id = $this->id;
+
+ if ($reply->find()) {
+ while($reply->fetch()) {
+ $ids[] = $reply->profile_id;
+ }
+ }
+
+ $reply->free();
+
+ return $ids;
+ }
+
+ function getGroups()
+ {
+ // XXX: cache me
+
+ $ids = array();
+
+ $gi = new Group_inbox();
+
+ $gi->selectAdd();
+ $gi->selectAdd('group_id');
+
+ $gi->notice_id = $this->id;
+
+ if ($gi->find()) {
+ while ($gi->fetch()) {
+ $ids[] = $gi->group_id;
+ }
+ }
+
+ $gi->free();
+
+ return $ids;
+ }
+
function asAtomEntry($namespace=false, $source=false)
{
$profile = $this->getProfile();