aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDavid Siegfried <david.siegfried@uni-vechta.de>2025-09-12 15:00:11 +0200
committerDavid Siegfried <david.siegfried@uni-vechta.de>2025-09-12 15:00:11 +0200
commit1d2c9f99421e6f39c2765e407f23bfd8bdb2bf03 (patch)
tree7e86753ad94604c6dbe0338e67cb28e64617c280 /lib
parent61ca2f2a3fc71afed3550b19141bb9fededa3011 (diff)
rename migration and fixstep-1670
Diffstat (limited to 'lib')
-rw-r--r--lib/bootstrap.php2
-rw-r--r--lib/classes/JsonApi/Routes/ShortUrls/ShortUrlCreate.php9
2 files changed, 7 insertions, 4 deletions
diff --git a/lib/bootstrap.php b/lib/bootstrap.php
index b1b336e..4d83992 100644
--- a/lib/bootstrap.php
+++ b/lib/bootstrap.php
@@ -1,4 +1,4 @@
-<?php
+ <?php
# Lifter010: TODO
/*
* Copyright (c) 2009 Stud.IP CoreGroup
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([