summaryrefslogtreecommitdiff
path: root/lib/jabber.php
diff options
context:
space:
mode:
authorEvan Prodromou <evan@prodromou.name>2008-07-15 15:55:13 -0400
committerEvan Prodromou <evan@prodromou.name>2008-07-15 15:55:13 -0400
commit499afd8c22fa7b14c5d757f52b1e8e6a91bbaf30 (patch)
tree43c07d8135200200c7c53c92693aa6d3305b7c16 /lib/jabber.php
parent3f59000e73f8e80d833963445e7581c3a21f0dc7 (diff)
replies from people you're not subscribed to over Jabber
darcs-hash:20080715195513-84dde-454419c971015be385d9c4c35f7acbee419031f9.gz
Diffstat (limited to 'lib/jabber.php')
-rw-r--r--lib/jabber.php33
1 files changed, 29 insertions, 4 deletions
diff --git a/lib/jabber.php b/lib/jabber.php
index bd04edc63..b0dc24bd0 100644
--- a/lib/jabber.php
+++ b/lib/jabber.php
@@ -194,8 +194,6 @@ function jabber_special_presence($type, $to=NULL, $show=NULL, $status=NULL) {
}
function jabber_broadcast_notice($notice) {
- # First, get users subscribed to this profile
- # XXX: use a join here rather than looping through results
$profile = Profile::staticGet($notice->profile_id);
if (!$profile) {
common_log(LOG_WARNING, 'Refusing to broadcast notice with ' .
@@ -203,23 +201,50 @@ function jabber_broadcast_notice($notice) {
__FILE__);
return false;
}
+ $sent_to = array();
+ # First, get users who this is a direct reply to
+ $reply = new Reply();
+ $reply->notice_id = $notice->id;
+ if ($reply->find()) {
+ while ($reply->fetch()) {
+ $user = User::staticGet($reply->profile_id);
+ if ($user && $user->jabber && $user->jabbernotify && $user->jabberreplies) {
+ common_log(LOG_INFO,
+ 'Sending reply notice ' . $notice->id . ' to ' . $user->jabber,
+ __FILE__);
+ $success = jabber_send_notice($user->jabber, $notice);
+ if ($success) {
+ # Remember so we don't send twice
+ $sent_to[$user->id] = true;
+ } else {
+ # XXX: Not sure, but I think that's the right thing to do
+ return false;
+ }
+ }
+ }
+ }
+ # Now, get users subscribed to this profile
+ # XXX: use a join here rather than looping through results
$sub = new Subscription();
$sub->subscribed = $notice->profile_id;
+
if ($sub->find()) {
while ($sub->fetch()) {
$user = User::staticGet($sub->subscriber);
- if ($user && $user->jabber && $user->jabbernotify) {
+ if ($user && $user->jabber && $user->jabbernotify && !$sent_to[$user->id]) {
common_log(LOG_INFO,
'Sending notice ' . $notice->id . ' to ' . $user->jabber,
__FILE__);
$success = jabber_send_notice($user->jabber, $notice);
- if (!$success) {
+ if ($success) {
+ $sent_to[$user->id] = true;
# XXX: Not sure, but I think that's the right thing to do
return false;
}
}
}
}
+
return true;
}