summaryrefslogtreecommitdiff
path: root/classes/Notice.php
diff options
context:
space:
mode:
authorBrion Vibber <brion@pobox.com>2010-04-20 12:06:54 +0200
committerBrion Vibber <brion@pobox.com>2010-04-20 13:49:29 +0200
commitc48caa85e12063c2df9913957dbd11af6b5e3ea6 (patch)
treea17c3f1cba59c49de4f1810cf2ce26ccae6b0738 /classes/Notice.php
parent0e1be7e01b00a9ad5201845b96f9f5634ab10236 (diff)
Fix email notifications for @-replies that come via OStatus.
* Moved notification sending from Notice::saveReplies to distrib queue handler, so it'll pull from the reply set we've saved regardless of how we got it. * Set up gettext infrastructure for command-line scripts; gets localization mail notifications etc working from background queues. * Adjusted locale switching: common_switch_locale() works at runtime for bg scripts, forces a message catalog update
Diffstat (limited to 'classes/Notice.php')
-rw-r--r--classes/Notice.php44
1 files changed, 32 insertions, 12 deletions
diff --git a/classes/Notice.php b/classes/Notice.php
index a8147e4c4..4cf12fc6f 100644
--- a/classes/Notice.php
+++ b/classes/Notice.php
@@ -959,8 +959,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
*/
@@ -999,8 +998,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
*/
@@ -1060,17 +1058,14 @@ class Notice extends Memcached_DataObject
$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
@@ -1094,6 +1089,31 @@ 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)) {
+ self::blow('reply:stream:%d', $recipientId);
+ mail_notify_attn($user, $this);
+ }
+ }
+ }
+
+ /**
* Pull list of groups this notice needs to be delivered to,
* as previously recorded by saveGroups() or saveKnownGroups().
*