summaryrefslogtreecommitdiff
path: root/classes
diff options
context:
space:
mode:
authorEvan Prodromou <evan@status.net>2010-09-22 10:45:34 -0400
committerEvan Prodromou <evan@status.net>2010-09-22 10:45:34 -0400
commitb5cfcba4712809cb17eabba299ce5ff04f4d7d70 (patch)
tree38235bafd6ddf194e484b97321c0c341bea9de38 /classes
parent91a186251047127ad7f1238f47ff761d9127627c (diff)
parentf0105893b0b78ff88d08cc2417773ad8a44dc2fa (diff)
Merge branch '0.9.x' into activityexport
Conflicts: plugins/OStatus/OStatusPlugin.php
Diffstat (limited to 'classes')
-rw-r--r--classes/Notice.php33
-rw-r--r--classes/Status_network.php5
-rw-r--r--classes/User.php16
3 files changed, 38 insertions, 16 deletions
diff --git a/classes/Notice.php b/classes/Notice.php
index 04dcd24cd..4f23e3500 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/Status_network.php b/classes/Status_network.php
index c4f37ce1c..70c7a58eb 100644
--- a/classes/Status_network.php
+++ b/classes/Status_network.php
@@ -167,9 +167,8 @@ class Status_network extends Safe_DataObject
' WHERE nickname = ' . $this->_quote($this->nickname);
$orig->decache();
$result = $this->query($qry);
- if ($result) {
- $this->encache();
- }
+ $this->decache();
+
return $result;
}
diff --git a/classes/User.php b/classes/User.php
index 8033229c4..080e338fe 100644
--- a/classes/User.php
+++ b/classes/User.php
@@ -255,6 +255,19 @@ class User extends Memcached_DataObject
$user->inboxed = 1;
+ // Set default-on options here, otherwise they'll be disabled
+ // initially for sites using caching, since the initial encache
+ // doesn't know about the defaults in the database.
+ $user->emailnotifysub = 1;
+ $user->emailnotifyfav = 1;
+ $user->emailnotifynudge = 1;
+ $user->emailnotifymsg = 1;
+ $user->emailnotifyattn = 1;
+ $user->emailmicroid = 1;
+ $user->emailpost = 1;
+ $user->jabbermicroid = 1;
+ $user->viewdesigns = 1;
+
$user->created = common_sql_now();
if (Event::handle('StartUserRegister', array(&$user, &$profile))) {
@@ -552,6 +565,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');