Move AlreadyFulfilled check to Fave::addNew

This commit is contained in:
Mikael Nordfeldth
2015-03-10 11:50:16 +01:00
parent fa080328cf
commit 8a273eef20
5 changed files with 11 additions and 34 deletions

View File

@@ -89,20 +89,13 @@ class ApiFavoriteCreateAction extends ApiAuthAction
);
}
// Note: Twitter lets you fave things repeatedly via API.
if (Fave::existsForProfile($this->notice, $this->scoped)) {
$this->clientError(
// TRANS: Client error displayed when trying to mark a notice favourite that already is a favourite.
_('This status is already a favorite.'),
403,
$this->format
);
try {
$stored = Fave::addNew($this->scoped, $this->notice);
} catch (AlreadyFulfilledException $e) {
// Note: Twitter lets you fave things repeatedly via API.
$this->clientError($e->getMessage(), 403);
}
// throws exception on failure
$stored = Fave::addNew($this->scoped, $this->notice);
if ($this->format == 'xml') {
$this->showSingleXmlStatus($this->notice);
} elseif ($this->format == 'json') {