summaryrefslogtreecommitdiff
path: root/classes/Subscription.php
diff options
context:
space:
mode:
authorZach Copley <zach@status.net>2010-03-18 15:28:21 -0700
committerZach Copley <zach@status.net>2010-03-18 15:28:21 -0700
commit109aac3c49041e9323f74d9a9660186de069176d (patch)
tree3e8170235c4072d3a47f93aa665530028019e347 /classes/Subscription.php
parente10d023d037ac9d2a628f8246dfccb4ad525ed59 (diff)
parent69b25ba1be7a9f42a06a8297304dccc6e7ce23ec (diff)
Merge branch 'testing' of gitorious.org:statusnet/mainline into testing
* 'testing' of gitorious.org:statusnet/mainline: Fix for xmpp/sms notification options appearing to be disabled on new subscriptions.
Diffstat (limited to 'classes/Subscription.php')
-rw-r--r--classes/Subscription.php56
1 files changed, 29 insertions, 27 deletions
diff --git a/classes/Subscription.php b/classes/Subscription.php
index 5ac95f922..97c44a2e4 100644
--- a/classes/Subscription.php
+++ b/classes/Subscription.php
@@ -75,20 +75,7 @@ class Subscription extends Memcached_DataObject
}
if (Event::handle('StartSubscribe', array($subscriber, $other))) {
-
- $sub = new Subscription();
-
- $sub->subscriber = $subscriber->id;
- $sub->subscribed = $other->id;
- $sub->created = common_sql_now();
-
- $result = $sub->insert();
-
- if (!$result) {
- common_log_db_error($sub, 'INSERT', __FILE__);
- throw new Exception(_('Could not save subscription.'));
- }
-
+ $sub = self::saveNew($subscriber->id, $other->id);
$sub->notify();
self::blow('user:notices_with_friends:%d', $subscriber->id);
@@ -103,20 +90,11 @@ class Subscription extends Memcached_DataObject
!self::exists($other, $subscriber) &&
!$subscriber->hasBlocked($other)) {
- $auto = new Subscription();
-
- $auto->subscriber = $other->id;
- $auto->subscribed = $subscriber->id;
- $auto->created = common_sql_now();
-
- $result = $auto->insert();
-
- if (!$result) {
- common_log_db_error($auto, 'INSERT', __FILE__);
- throw new Exception(_('Could not save subscription.'));
+ try {
+ self::start($other, $subscriber);
+ } catch (Exception $e) {
+ common_log(LOG_ERR, "Exception during autosubscribe of {$other->nickname} to profile {$subscriber->id}: {$e->getMessage()}");
}
-
- $auto->notify();
}
Event::handle('EndSubscribe', array($subscriber, $other));
@@ -125,6 +103,30 @@ class Subscription extends Memcached_DataObject
return true;
}
+ /**
+ * Low-level subscription save.
+ * Outside callers should use Subscription::start()
+ */
+ protected function saveNew($subscriber_id, $other_id)
+ {
+ $sub = new Subscription();
+
+ $sub->subscriber = $subscriber_id;
+ $sub->subscribed = $other_id;
+ $sub->jabber = 1;
+ $sub->sms = 1;
+ $sub->created = common_sql_now();
+
+ $result = $sub->insert();
+
+ if (!$result) {
+ common_log_db_error($sub, 'INSERT', __FILE__);
+ throw new Exception(_('Could not save subscription.'));
+ }
+
+ return $sub;
+ }
+
function notify()
{
# XXX: add other notifications (Jabber, SMS) here