]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
reuse Subscription::cancel instead of reimplementing it.
authorCraig Andrews <candrews@integralblue.com>
Fri, 12 Mar 2010 01:40:25 +0000 (20:40 -0500)
committerCraig Andrews <candrews@integralblue.com>
Fri, 12 Mar 2010 01:40:25 +0000 (20:40 -0500)
I didn't know this method existed before... pretty neat.

lib/command.php
lib/subs.php

index 0b3b3c95a21a4cd20472a4ef5d08474a8ce08d32..3809c98cca530b3d8eda8a397d749cf9a9667f39 100644 (file)
@@ -729,7 +729,7 @@ class LoseCommand extends Command
             return;
         }
 
-        $result=subs_unsubscribe_from($this->user, $this->other);
+        $result = Subscription::cancel($this->other, $this->user);
 
         if ($result) {
             $channel->output($this->user, sprintf(_('Unsubscribed  %s'), $this->other));
index e2ce0667eb19f78e3c2e9f5aed9fb0fdcc76df47..165bbaa8ff7a4bbdc09429f3b703e55d6407846d 100644 (file)
@@ -43,46 +43,3 @@ function subs_unsubscribe_to($user, $other)
         return $e->getMessage();
     }
 }
-
-function subs_unsubscribe_from($user, $other){
-   $local = User::staticGet("nickname",$other);
-   if($local){
-     return subs_unsubscribe_to($local,$user);
-   } else {
-    try {
-        $remote = Profile::staticGet("nickname",$other);
-        if(is_string($remote)){
-          return $remote;
-        }
-        if (Event::handle('StartUnsubscribe', array($remote,$user))) {
-
-            $sub = DB_DataObject::factory('subscription');
-
-            $sub->subscriber = $remote->id;
-            $sub->subscribed = $user->id;
-
-            $sub->find(true);
-
-            // note we checked for existence above
-
-            if (!$sub->delete())
-              return _('Couldn\'t delete subscription.');
-
-            $cache = common_memcache();
-
-            if ($cache) {
-                $cache->delete(common_cache_key('user:notices_with_friends:' . $remote->id));
-            }
-
-
-            $user->blowSubscribersCount();
-            $remote->blowSubscribersCount();
-
-            Event::handle('EndUnsubscribe', array($remote, $user));
-        }
-    } catch (Exception $e) {
-        return $e->getMessage();
-    }
-   }
-}
-