From: Mikael Nordfeldth Date: Sun, 27 Dec 2015 00:40:00 +0000 (+0100) Subject: Duplicate URI means we have it already, I assume X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=0ac71c2b7b20a2cfbae4164fa21b43782276afb0;p=quix0rs-gnu-social.git Duplicate URI means we have it already, I assume --- diff --git a/classes/Notice.php b/classes/Notice.php index 6fe2e4c76a..c5c07e6d19 100644 --- a/classes/Notice.php +++ b/classes/Notice.php @@ -780,7 +780,9 @@ class Notice extends Managed_DataObject $stored->uri = $uri; if ($stored->find()) { common_debug('cannot create duplicate Notice URI: '.$stored->uri); - throw new Exception('Notice URI already exists'); + // I _assume_ saving a Notice with a colliding URI means we're really trying to + // save the same notice again... + throw new AlreadyFulfilledException('Notice URI already exists'); } } diff --git a/plugins/OStatus/actions/groupsalmon.php b/plugins/OStatus/actions/groupsalmon.php index a255a3d022..ee82e627d4 100644 --- a/plugins/OStatus/actions/groupsalmon.php +++ b/plugins/OStatus/actions/groupsalmon.php @@ -88,7 +88,11 @@ class GroupsalmonAction extends SalmonAction } } - $this->saveNotice(); + try { + $this->saveNotice(); + } catch AlreadyFulfilledException($e) { + return; + } } /** diff --git a/plugins/OStatus/actions/usersalmon.php b/plugins/OStatus/actions/usersalmon.php index 7fce6c808c..c625567860 100644 --- a/plugins/OStatus/actions/usersalmon.php +++ b/plugins/OStatus/actions/usersalmon.php @@ -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(); } /**