- $stream = new UserActivityStream($this->_user);
-
- $acts = array_reverse($stream->activities);
-
- // Reverse activities to run in correct chron order
-
- foreach ($acts as $act) {
- $this->_moveActivity($act);
- }
- }
-
- private function _moveActivity($act)
- {
- switch ($act->verb) {
- case ActivityVerb::FAVORITE:
- // push it, then delete local
- $this->_sink->postActivity($act);
- $notice = Notice::staticGet('uri', $act->objects[0]->id);
- if (!empty($notice)) {
- $fave = Fave::pkeyGet(array('user_id' => $this->_user->id,
- 'notice_id' => $notice->id));
- $fave->delete();
- }
- break;
- case ActivityVerb::POST:
- // XXX: send a reshare, not a post
- common_log(LOG_INFO, "Pushing notice {$act->objects[0]->id} to {$this->_remote->getURI()}");
- $this->_sink->postActivity($act);
- $notice = Notice::staticGet('uri', $act->objects[0]->id);
- if (!empty($notice)) {
- $notice->delete();
- }
- break;
- case ActivityVerb::JOIN:
- $this->_sink->postActivity($act);
- $group = User_group::staticGet('uri', $act->objects[0]->id);
- if (!empty($group)) {
- Group_member::leave($group->id, $this->_user->id);
- }
- break;
- case ActivityVerb::FOLLOW:
- if ($act->actor->id == $this->_user->uri) {
- $this->_sink->postActivity($act);
- $other = Profile::fromURI($act->objects[0]->id);
- if (!empty($other)) {
- Subscription::cancel($this->_profile, $other);
- }
- } else {
- $otherUser = User::staticGet('uri', $act->actor->id);
- if (!empty($otherUser)) {
- $otherProfile = $otherUser->getProfile();
- Subscription::start($otherProfile, $this->_remote);
- Subscription::cancel($otherProfile, $this->_user->getProfile());
- } else {
- // It's a remote subscription. Do something here!
- }
- }
- break;
- }