summaryrefslogtreecommitdiff
path: root/classes/Notice.php
diff options
context:
space:
mode:
authorBrion Vibber <brion@pobox.com>2010-04-30 13:15:53 -0700
committerBrion Vibber <brion@pobox.com>2010-04-30 13:16:13 -0700
commitcae1329f3bca1f5f1fbfdb1d96b38cbb790fbe00 (patch)
tree21ae74d08b6496c7d7fafbe95a9b147a9ac56cc0 /classes/Notice.php
parent5c05cd2b1a93d360bde7cb7dfc9ba39e5a5a7624 (diff)
parentf8883367184e4fd31dc819d5e1257d0eee11eb10 (diff)
Merge branch '0.9.x' into 1.0.x
Conflicts: lib/util.php
Diffstat (limited to 'classes/Notice.php')
-rw-r--r--classes/Notice.php46
1 files changed, 32 insertions, 14 deletions
diff --git a/classes/Notice.php b/classes/Notice.php
index d65f0da9a..c0828674d 100644
--- a/classes/Notice.php
+++ b/classes/Notice.php
@@ -981,8 +981,7 @@ class Notice extends Memcached_DataObject
* messages, we won't deliver to any remote targets as that's the
* source service's responsibility.
*
- * @fixme Unlike saveReplies() there's no mail notification here.
- * Move that to distrib queue handler?
+ * Mail notifications etc will be handled later.
*
* @param array of unique identifier URIs for recipients
*/
@@ -1008,8 +1007,6 @@ class Notice extends Memcached_DataObject
$reply->profile_id = $user->id;
$id = $reply->insert();
-
- self::blow('reply:stream:%d', $user->id);
}
}
@@ -1021,8 +1018,7 @@ class Notice extends Memcached_DataObject
* and save reply records indicating that this message needs to be
* delivered to those users.
*
- * Side effect: local recipients get e-mail notifications here.
- * @fixme move mail notifications to distrib?
+ * Mail notifications to local profiles will be sent later.
*
* @return array of integer profile IDs
*/
@@ -1076,23 +1072,21 @@ class Notice extends Memcached_DataObject
throw new ServerException("Couldn't save reply for {$this->id}, {$mentioned->id}");
} else {
$replied[$mentioned->id] = 1;
+ self::blow('reply:stream:%d', $mentioned->id);
}
}
}
$recipientIds = array_keys($replied);
- foreach ($recipientIds as $recipientId) {
- $user = User::staticGet('id', $recipientId);
- if (!empty($user)) {
- self::blow('reply:stream:%d', $reply->profile_id);
- mail_notify_attn($user, $this);
- }
- }
-
return $recipientIds;
}
+ /**
+ * Pull the complete list of @-reply targets for this notice.
+ *
+ * @return array of integer profile ids
+ */
function getReplies()
{
// XXX: cache me
@@ -1116,6 +1110,30 @@ class Notice extends Memcached_DataObject
}
/**
+ * Send e-mail notifications to local @-reply targets.
+ *
+ * Replies must already have been saved; this is expected to be run
+ * from the distrib queue handler.
+ */
+ function sendReplyNotifications()
+ {
+ // Don't send reply notifications for repeats
+
+ if (!empty($this->repeat_of)) {
+ return array();
+ }
+
+ $recipientIds = $this->getReplies();
+
+ foreach ($recipientIds as $recipientId) {
+ $user = User::staticGet('id', $recipientId);
+ if (!empty($user)) {
+ mail_notify_attn($user, $this);
+ }
+ }
+ }
+
+ /**
* Pull list of groups this notice needs to be delivered to,
* as previously recorded by saveGroups() or saveKnownGroups().
*