diff options
| author | David Siegfried <david.siegfried@uni-vechta.de> | 2025-09-12 15:00:11 +0200 |
|---|---|---|
| committer | David Siegfried <david.siegfried@uni-vechta.de> | 2025-09-12 15:00:11 +0200 |
| commit | 1d2c9f99421e6f39c2765e407f23bfd8bdb2bf03 (patch) | |
| tree | 7e86753ad94604c6dbe0338e67cb28e64617c280 /lib/classes/JsonApi | |
| parent | 61ca2f2a3fc71afed3550b19141bb9fededa3011 (diff) | |
rename migration and fixstep-1670
Diffstat (limited to 'lib/classes/JsonApi')
| -rw-r--r-- | lib/classes/JsonApi/Routes/ShortUrls/ShortUrlCreate.php | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/lib/classes/JsonApi/Routes/ShortUrls/ShortUrlCreate.php b/lib/classes/JsonApi/Routes/ShortUrls/ShortUrlCreate.php index db2a856..1b8524a 100644 --- a/lib/classes/JsonApi/Routes/ShortUrls/ShortUrlCreate.php +++ b/lib/classes/JsonApi/Routes/ShortUrls/ShortUrlCreate.php @@ -2,6 +2,7 @@ namespace JsonApi\Routes\ShortUrls; +use ShortUrl; use JsonApi\Errors\AuthorizationFailedException; use JsonApi\Errors\ConflictException; use JsonApi\JsonApiController; @@ -26,12 +27,14 @@ final class ShortUrlCreate extends JsonApiController $json = $this->validate($request, $args); - if (\ShortUrl::countBySql('path = ? AND user_id = ?', [ $json['data']['attributes']['path'], $user->id]) > 0) { - throw new ConflictException(_('Sie haben für diese Seite bereits eine Kurz-URL erstellt!')); + $short_url = ShortUrl::findOneBySQL('`path` = ? AND `user_id` = ?', [$json['data']['attributes']['path'], $user->id]); + + if ($short_url) { + return $this->getContentResponse($short_url); } if (\ShortUrl::countBySql('alias = ?', [ $json['data']['attributes']['alias']])) { - throw new ConflictException(_('Sie haben für diese Seite bereits eine Kurz-URL erstellt!')); + throw new ConflictException(_('Der verwendete Alias existiert bereits.')); } $short_url = \ShortUrl::create([ |
