summaryrefslogtreecommitdiff
path: root/classes
diff options
context:
space:
mode:
authorBrion Vibber <brion@pobox.com>2010-09-20 15:57:46 -0700
committerBrion Vibber <brion@pobox.com>2010-09-20 16:00:25 -0700
commit521daf5562051d0cc319c35a0dceaae3e0fd49b7 (patch)
tree8bfec99b545a9964d39fa308d64eab93cd4df043 /classes
parent64cdbe6c5578df1dc49d8e3dd72451ab0ac96bd2 (diff)
Ticket #2327: fixing block to remove the blocking user's subscription to the blockee if present; also cleaning up inbox delivery to apply the block checks more consistently, instead of just to group posts.
Diffstat (limited to 'classes')
-rw-r--r--classes/Notice.php33
-rw-r--r--classes/User.php3
2 files changed, 23 insertions, 13 deletions
diff --git a/classes/Notice.php b/classes/Notice.php
index f1b012465..13b322828 100644
--- a/classes/Notice.php
+++ b/classes/Notice.php
@@ -753,8 +753,15 @@ class Notice extends Memcached_DataObject
}
/**
- * @param $groups array of Group *objects*
- * @param $recipients array of profile *ids*
+ * Pull up a full list of local recipients who will be getting
+ * this notice in their inbox. Results will be cached, so don't
+ * change the input data wily-nilly!
+ *
+ * @param array $groups optional list of Group objects;
+ * if left empty, will be loaded from group_inbox records
+ * @param array $recipient optional list of reply profile ids
+ * if left empty, will be loaded from reply records
+ * @return array associating recipient user IDs with an inbox source constant
*/
function whoGets($groups=null, $recipients=null)
{
@@ -787,27 +794,27 @@ class Notice extends Memcached_DataObject
$ni[$id] = NOTICE_INBOX_SOURCE_SUB;
}
- $profile = $this->getProfile();
-
foreach ($groups as $group) {
$users = $group->getUserMembers();
foreach ($users as $id) {
if (!array_key_exists($id, $ni)) {
- $user = User::staticGet('id', $id);
- if (!$user->hasBlocked($profile)) {
- $ni[$id] = NOTICE_INBOX_SOURCE_GROUP;
- }
+ $ni[$id] = NOTICE_INBOX_SOURCE_GROUP;
}
}
}
foreach ($recipients as $recipient) {
-
if (!array_key_exists($recipient, $ni)) {
- $recipientUser = User::staticGet('id', $recipient);
- if (!empty($recipientUser)) {
- $ni[$recipient] = NOTICE_INBOX_SOURCE_REPLY;
- }
+ $ni[$recipient] = NOTICE_INBOX_SOURCE_REPLY;
+ }
+ }
+
+ // Exclude any deleted, non-local, or blocking recipients.
+ $profile = $this->getProfile();
+ foreach ($ni as $id => $source) {
+ $user = User::staticGet('id', $id);
+ if (empty($user) || $user->hasBlocked($profile)) {
+ unset($ni[$id]);
}
}
diff --git a/classes/User.php b/classes/User.php
index 8033229c4..4c25ee3d9 100644
--- a/classes/User.php
+++ b/classes/User.php
@@ -552,6 +552,9 @@ class User extends Memcached_DataObject
if (Subscription::exists($other, $self)) {
Subscription::cancel($other, $self);
}
+ if (Subscription::exists($self, $other)) {
+ Subscription::cancel($self, $other);
+ }
$block->query('COMMIT');