Commit a715271f847fed7d7c725c5b752ea7a00800520a
- Diff rendering mode:
- inline
- side by side
lib/command.php
(1 / 1)
|   | |||
| 729 | 729 | return; | |
| 730 | 730 | } | |
| 731 | 731 | ||
| 732 | $result=subs_unsubscribe_from($this->user, $this->other); | ||
| 732 | $result = Subscription::cancel($this->other, $this->user); | ||
| 733 | 733 | ||
| 734 | 734 | if ($result) { | |
| 735 | 735 | $channel->output($this->user, sprintf(_('Unsubscribed %s'), $this->other)); |
lib/subs.php
(0 / 42)
|   | |||
| 43 | 43 | return $e->getMessage(); | |
| 44 | 44 | } | |
| 45 | 45 | } | |
| 46 | |||
| 47 | function 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 | } |

