- if (common_config('memcached', 'enabled')) {
- $cache = new Memcache();
- if ($cache->connect(common_config('memcached', 'server'), common_config('memcached', 'port'))) {
- $cache->delete(common_cache_key('user:notices_with_friends:' . $user->id));
- }
+function subs_subscribe_to($user, $other)
+{
+ if ($user->isSubscribed($other)) {
+ return _('Already subscribed!.');
+ }
+
+ if ($other->hasBlocked($user)) {
+ return _('User has blocked you.');
+ }
+
+ if (!$user->subscribeTo($other)) {
+ return _('Could not subscribe.');
+ return;
+ }
+
+ subs_notify($other, $user);
+
+ $cache = common_memcache();
+
+ if ($cache) {
+ $cache->delete(common_cache_key('user:notices_with_friends:' . $user->id));