]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - lib/activitymover.php
Code cleanup and enabling User object's etc. getUri()
[quix0rs-gnu-social.git] / lib / activitymover.php
index b308ad5624c1188b230cdbece2e2cfb7f3d74c54..0493750d0877e5b8f8108011027e13b16eda9dc9 100644 (file)
@@ -55,7 +55,7 @@ class ActivityMover extends QueueHandler
     {
         list ($act, $sink, $userURI, $remoteURI) = $data;
 
-        $user   = User::staticGet('uri', $userURI);
+        $user   = User::getKV('uri', $userURI);
         $remote = Profile::fromURI($remoteURI);
 
         try {
@@ -81,7 +81,8 @@ class ActivityMover extends QueueHandler
     function moveActivity($act, $sink, $user, $remote)
     {
         if (empty($user)) {
-            throw new Exception(sprintf(_("No such user %s."),$act->actor->id));
+            // TRANS: Exception thrown if a non-existing user is provided. %s is a user ID.
+            throw new Exception(sprintf(_('No such user "%s".'),$act->actor->id));
         }
 
         switch ($act->verb) {
@@ -91,7 +92,7 @@ class ActivityMover extends QueueHandler
                        "{$act->actor->id} to {$remote->nickname}.");
             // push it, then delete local
             $sink->postActivity($act);
-            $notice = Notice::staticGet('uri', $act->objects[0]->id);
+            $notice = Notice::getKV('uri', $act->objects[0]->id);
             if (!empty($notice)) {
                 $fave = Fave::pkeyGet(array('user_id' => $user->id,
                                             'notice_id' => $notice->id));
@@ -104,7 +105,7 @@ class ActivityMover extends QueueHandler
                        "{$act->actor->id} to {$remote->nickname}.");
             // XXX: send a reshare, not a post
             $sink->postActivity($act);
-            $notice = Notice::staticGet('uri', $act->objects[0]->id);
+            $notice = Notice::getKV('uri', $act->objects[0]->id);
             if (!empty($notice)) {
                 $notice->delete();
             }
@@ -114,13 +115,13 @@ class ActivityMover extends QueueHandler
                        "Moving group join of {$act->objects[0]->id} by ".
                        "{$act->actor->id} to {$remote->nickname}.");
             $sink->postActivity($act);
-            $group = User_group::staticGet('uri', $act->objects[0]->id);
+            $group = User_group::getKV('uri', $act->objects[0]->id);
             if (!empty($group)) {
                 $user->leaveGroup($group);
             }
             break;
         case ActivityVerb::FOLLOW:
-            if ($act->actor->id == $user->uri) {
+            if ($act->actor->id === $user->getUri()) {
                 $this->log(LOG_INFO,
                            "Moving subscription to {$act->objects[0]->id} by ".
                            "{$act->actor->id} to {$remote->nickname}.");
@@ -130,7 +131,7 @@ class ActivityMover extends QueueHandler
                     Subscription::cancel($user->getProfile(), $other);
                 }
             } else {
-                $otherUser = User::staticGet('uri', $act->actor->id);
+                $otherUser = User::getKV('uri', $act->actor->id);
                 if (!empty($otherUser)) {
                     $this->log(LOG_INFO,
                                "Changing sub to {$act->objects[0]->id}".