Merge pull request #55793 from nextcloud/backport/fix/55776/stable30

[stable30] fix(TextToImage): Set better attribute for routes
pull/55695/head
Andy Scherzinger 2025-10-16 10:27:10 +07:00 committed by GitHub
commit 655bb38186
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 4 additions and 14 deletions

@ -17,7 +17,6 @@ use OCP\AppFramework\Http\Attribute\AnonRateLimit;
use OCP\AppFramework\Http\Attribute\ApiRoute;
use OCP\AppFramework\Http\Attribute\BruteForceProtection;
use OCP\AppFramework\Http\Attribute\NoAdminRequired;
use OCP\AppFramework\Http\Attribute\PublicPage;
use OCP\AppFramework\Http\Attribute\UserRateLimit;
use OCP\AppFramework\Http\DataResponse;
use OCP\AppFramework\Http\FileDisplayResponse;
@ -53,7 +52,7 @@ class TextToImageApiController extends \OCP\AppFramework\OCSController {
*
* 200: Returns availability status
*/
#[PublicPage]
#[NoAdminRequired]
#[ApiRoute(verb: 'GET', url: '/is_available', root: '/text2image')]
public function isAvailable(): DataResponse {
return new DataResponse([
@ -74,9 +73,8 @@ class TextToImageApiController extends \OCP\AppFramework\OCSController {
* 200: Task scheduled successfully
* 412: Scheduling task is not possible
*/
#[PublicPage]
#[NoAdminRequired]
#[UserRateLimit(limit: 20, period: 120)]
#[AnonRateLimit(limit: 5, period: 120)]
#[ApiRoute(verb: 'POST', url: '/schedule', root: '/text2image')]
public function schedule(string $input, string $appId, string $identifier = '', int $numberOfImages = 8): DataResponse {
$task = new Task($input, $appId, $numberOfImages, $this->userId, $identifier);
@ -110,7 +108,7 @@ class TextToImageApiController extends \OCP\AppFramework\OCSController {
* 200: Task returned
* 404: Task not found
*/
#[PublicPage]
#[NoAdminRequired]
#[BruteForceProtection(action: 'text2image')]
#[ApiRoute(verb: 'GET', url: '/task/{id}', root: '/text2image')]
public function getTask(int $id): DataResponse {
@ -142,7 +140,7 @@ class TextToImageApiController extends \OCP\AppFramework\OCSController {
* 200: Image returned
* 404: Task or image not found
*/
#[PublicPage]
#[NoAdminRequired]
#[BruteForceProtection(action: 'text2image')]
#[ApiRoute(verb: 'GET', url: '/task/{id}/image/{index}', root: '/text2image')]
public function getImage(int $id, int $index): DataResponse|FileDisplayResponse {

@ -5902,7 +5902,6 @@
"text_to_image_api"
],
"security": [
{},
{
"bearer_auth": []
},
@ -5972,7 +5971,6 @@
"text_to_image_api"
],
"security": [
{},
{
"bearer_auth": []
},
@ -6153,7 +6151,6 @@
"text_to_image_api"
],
"security": [
{},
{
"bearer_auth": []
},
@ -6462,7 +6459,6 @@
"text_to_image_api"
],
"security": [
{},
{
"bearer_auth": []
},

@ -5902,7 +5902,6 @@
"text_to_image_api"
],
"security": [
{},
{
"bearer_auth": []
},
@ -5972,7 +5971,6 @@
"text_to_image_api"
],
"security": [
{},
{
"bearer_auth": []
},
@ -6153,7 +6151,6 @@
"text_to_image_api"
],
"security": [
{},
{
"bearer_auth": []
},
@ -6462,7 +6459,6 @@
"text_to_image_api"
],
"security": [
{},
{
"bearer_auth": []
},