-
- $friend_user = User::staticGet('id', $friend_flink->user_id);
-
- if (!empty($friend_user)) {
- $result = subs_subscribe_to($user, $friend_user);
-
- if ($result === true) {
- common_log(LOG_INFO,
- $this->name() . ' - Subscribed ' .
- "$friend_user->nickname to $user->nickname.");
- } else {
- common_debug($this->name() .
- ' - Tried subscribing ' .
- "$friend_user->nickname to $user->nickname - " .
- $result);
- }
- }
+ $friend_profile = $friend_flink->getProfile();
+
+ Subscription::start($profile, $friend_profile);
+ common_log(LOG_INFO,
+ $this->name() . ' - Subscribed ' .
+ "{$friend_profile->nickname} to {$profile->nickname}.");
+ } catch (NoResultException $e) {
+ // either no foreign link for this friend's foreign ID or no profile found on local ID.
+ } catch (Exception $e) {
+ common_debug($this->name() .
+ ' - Tried and failed subscribing ' .
+ "{$friend_profile->nickname} to {$profile->nickname} - " .
+ $e->getMessage());