]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - plugins/OStatus/actions/usersalmon.php
Duplicate URI means we have it already, I assume
[quix0rs-gnu-social.git] / plugins / OStatus / actions / usersalmon.php
index 8b0ab2f83c7c832d2e4e7c4531d84be4858642b6..c62556786001a95f3387c72e925ad40d726da97c 100644 (file)
@@ -95,13 +95,11 @@ class UsersalmonAction extends SalmonAction
             throw new ClientException(_m('Not to anyone in reply to anything.'));
         }
 
-        $existing = Notice::getKV('uri', $this->activity->objects[0]->id);
-        if ($existing instanceof Notice) {
-            common_log(LOG_ERR, "Not saving notice with duplicate URI '".$existing->getUri()."' (seems it already exists).");
+        try {
+            $this->saveNotice();
+        } catch AlreadyFulfilledException($e) {
             return;
         }
-
-        $this->saveNotice();
     }
 
     /**
@@ -130,47 +128,6 @@ class UsersalmonAction extends SalmonAction
         }
     }
 
-    /**
-     * Remote user likes one of our posts.
-     * Confirm the post is ours, and save a local favorite event.
-     */
-
-    function handleFavorite()
-    {
-        $notice = $this->getNotice($this->activity->objects[0]);
-
-        $old = Fave::pkeyGet(array('user_id' => $this->actor->id,
-                                   'notice_id' => $notice->id));
-
-        if ($old instanceof Fave) {
-            // TRANS: Client exception.
-            throw new AlreadyFulfilledException(_m('This is already a favorite.'));
-        }
-
-        if (!Fave::addNew($this->actor, $notice)) {
-           // TRANS: Client exception.
-           throw new ClientException(_m('Could not save new favorite.'));
-        }
-    }
-
-    /**
-     * Remote user doesn't like one of our posts after all!
-     * Confirm the post is ours, and save a local favorite event.
-     */
-    function handleUnfavorite()
-    {
-        $notice = $this->getNotice($this->activity->objects[0]);
-
-        $fave = Fave::pkeyGet(array('user_id' => $this->actor->id,
-                                   'notice_id' => $notice->id));
-        if (!$fave instanceof Fave) {
-            // TRANS: Client exception.
-            throw new AlreadyFulfilledException(_m('Notice was not favorited!'));
-        }
-
-        $fave->delete();
-    }
-
     function handleTag()
     {
         if ($this->activity->target->type == ActivityObject::_LIST) {