fix(ban): Add missing banId to unban URL

Signed-off-by: Joas Schilling <coding@schilljs.com>
This commit is contained in:
Joas Schilling 2024-07-02 08:55:00 +02:00
parent d6cf2f2ff2
commit 2edddcc2ce
No known key found for this signature in database
GPG key ID: 74434EFE0D2E2205
6 changed files with 67 additions and 41 deletions

View file

@ -17,6 +17,6 @@ return [
/** @see \OCA\Talk\Controller\BanController::listBans() */
['name' => 'Ban#listBans', 'url' => '/api/{apiVersion}/ban/{token}', 'verb' => 'GET', 'requirements' => $requirements],
/** @see \OCA\Talk\Controller\BanController::unbanActor() */
['name' => 'Ban#unbanActor', 'url' => '/api/{apiVersion}/ban/{token}', 'verb' => 'DELETE', 'requirements' => $requirements],
['name' => 'Ban#unbanActor', 'url' => '/api/{apiVersion}/ban/{token}/{banId}', 'verb' => 'DELETE', 'requirements' => $requirements],
],
];

View file

@ -103,16 +103,8 @@ class BanController extends AEnvironmentAwareController {
*/
#[PublicPage]
#[RequireModeratorParticipant]
public function unbanActor(): DataResponse {
$banId = $this->request->getParam('id');
if ($banId === null) {
return new DataResponse([
'error' => 'Missing ban ID',
], Http::STATUS_BAD_REQUEST);
}
echo "Ban ID!!!: $banId\n";
$this->banService->findAndDeleteBanById((int)$banId);
echo "Unbanned successfully\n";
public function unbanActor(int $banId): DataResponse {
$this->banService->findAndDeleteBanById($banId);
return new DataResponse([], Http::STATUS_OK);
}

View file

@ -2196,7 +2196,9 @@
}
}
}
},
}
},
"/ocs/v2.php/apps/spreed/api/{apiVersion}/ban/{token}/{banId}": {
"delete": {
"operationId": "ban-unban-actor",
"summary": "Unban an actor or IP address",
@ -2214,16 +2216,6 @@
}
],
"parameters": [
{
"name": "banId",
"in": "query",
"description": "ID of the ban to be removed",
"required": true,
"schema": {
"type": "integer",
"format": "int64"
}
},
{
"name": "apiVersion",
"in": "path",
@ -2245,6 +2237,16 @@
"pattern": "^[a-z0-9]{4,30}$"
}
},
{
"name": "banId",
"in": "path",
"description": "ID of the ban to be removed",
"required": true,
"schema": {
"type": "integer",
"format": "int64"
}
},
{
"name": "OCS-APIRequest",
"in": "header",

View file

@ -2083,7 +2083,9 @@
}
}
}
},
}
},
"/ocs/v2.php/apps/spreed/api/{apiVersion}/ban/{token}/{banId}": {
"delete": {
"operationId": "ban-unban-actor",
"summary": "Unban an actor or IP address",
@ -2101,16 +2103,6 @@
}
],
"parameters": [
{
"name": "banId",
"in": "query",
"description": "ID of the ban to be removed",
"required": true,
"schema": {
"type": "integer",
"format": "int64"
}
},
{
"name": "apiVersion",
"in": "path",
@ -2132,6 +2124,16 @@
"pattern": "^[a-z0-9]{4,30}$"
}
},
{
"name": "banId",
"in": "path",
"description": "ID of the ban to be removed",
"required": true,
"schema": {
"type": "integer",
"format": "int64"
}
},
{
"name": "OCS-APIRequest",
"in": "header",

View file

@ -75,6 +75,22 @@ export type paths = {
* @description Required capability: `ban-v1`
*/
post: operations["ban-ban-actor"];
delete?: never;
options?: never;
head?: never;
patch?: never;
trace?: never;
};
"/ocs/v2.php/apps/spreed/api/{apiVersion}/ban/{token}/{banId}": {
parameters: {
query?: never;
header?: never;
path?: never;
cookie?: never;
};
get?: never;
put?: never;
post?: never;
/**
* Unban an actor or IP address
* @description Required capability: `ban-v1`
@ -2422,10 +2438,7 @@ export interface operations {
};
"ban-unban-actor": {
parameters: {
query: {
/** @description ID of the ban to be removed */
banId: number;
};
query?: never;
header: {
/** @description Required to be true for the API request to pass */
"OCS-APIRequest": boolean;
@ -2433,6 +2446,8 @@ export interface operations {
path: {
apiVersion: "v1";
token: string;
/** @description ID of the ban to be removed */
banId: number;
};
cookie?: never;
};

View file

@ -75,6 +75,22 @@ export type paths = {
* @description Required capability: `ban-v1`
*/
post: operations["ban-ban-actor"];
delete?: never;
options?: never;
head?: never;
patch?: never;
trace?: never;
};
"/ocs/v2.php/apps/spreed/api/{apiVersion}/ban/{token}/{banId}": {
parameters: {
query?: never;
header?: never;
path?: never;
cookie?: never;
};
get?: never;
put?: never;
post?: never;
/**
* Unban an actor or IP address
* @description Required capability: `ban-v1`
@ -1907,10 +1923,7 @@ export interface operations {
};
"ban-unban-actor": {
parameters: {
query: {
/** @description ID of the ban to be removed */
banId: number;
};
query?: never;
header: {
/** @description Required to be true for the API request to pass */
"OCS-APIRequest": boolean;
@ -1918,6 +1931,8 @@ export interface operations {
path: {
apiVersion: "v1";
token: string;
/** @description ID of the ban to be removed */
banId: number;
};
cookie?: never;
};