Commit a715271f847fed7d7c725c5b752ea7a00800520a

reuse Subscription::cancel instead of reimplementing it.

I didn't know this method existed before... pretty neat.
  
729729 return;
730730 }
731731
732 $result=subs_unsubscribe_from($this->user, $this->other);
732 $result = Subscription::cancel($this->other, $this->user);
733733
734734 if ($result) {
735735 $channel->output($this->user, sprintf(_('Unsubscribed %s'), $this->other));
lib/subs.php
(0 / 42)
  
4343 return $e->getMessage();
4444 }
4545}
46
47function subs_unsubscribe_from($user, $other){
48 $local = User::staticGet("nickname",$other);
49 if($local){
50 return subs_unsubscribe_to($local,$user);
51 } else {
52 try {
53 $remote = Profile::staticGet("nickname",$other);
54 if(is_string($remote)){
55 return $remote;
56 }
57 if (Event::handle('StartUnsubscribe', array($remote,$user))) {
58
59 $sub = DB_DataObject::factory('subscription');
60
61 $sub->subscriber = $remote->id;
62 $sub->subscribed = $user->id;
63
64 $sub->find(true);
65
66 // note we checked for existence above
67
68 if (!$sub->delete())
69 return _('Couldn\'t delete subscription.');
70
71 $cache = common_memcache();
72
73 if ($cache) {
74 $cache->delete(common_cache_key('user:notices_with_friends:' . $remote->id));
75 }
76
77
78 $user->blowSubscribersCount();
79 $remote->blowSubscribersCount();
80
81 Event::handle('EndUnsubscribe', array($remote, $user));
82 }
83 } catch (Exception $e) {
84 return $e->getMessage();
85 }
86 }
87}