fix(ban): Allow empty internal note as it's optional

Signed-off-by: Joas Schilling <coding@schilljs.com>
This commit is contained in:
Joas Schilling 2024-07-12 15:29:53 +02:00
parent 7b7c2895ad
commit 31c5347f17
No known key found for this signature in database
GPG key ID: 74434EFE0D2E2205
7 changed files with 8 additions and 6 deletions

View file

@ -41,7 +41,7 @@ class BanController extends AEnvironmentAwareController {
* @param 'users'|'groups'|'circles'|'emails'|'federated_users'|'phones'|'ip' $actorType Type of actor to ban, or `ip` when banning a clients remote address
* @psalm-param Attendee::ACTOR_*|'ip' $actorType Type of actor to ban, or `ip` when banning a clients remote address
* @param string $actorId Actor ID or the IP address or range in case of type `ip`
* @param string $internalNote Optional internal note
* @param string $internalNote Optional internal note (max. 4000 characters)
* @return DataResponse<Http::STATUS_OK, TalkBan, array{}>|DataResponse<Http::STATUS_BAD_REQUEST, array{error: 'bannedActor'|'internalNote'}, array{}>
*
* 200: Ban successfully

View file

@ -32,6 +32,8 @@ use OCP\AppFramework\Db\Entity;
* @method null|string getInternalNote()
*/
class Ban extends Entity implements \JsonSerializable {
public const NOTE_MAX_LENGTH = 4000;
protected string $actorType = '';
protected string $actorId = '';
protected int $roomId = 0;

View file

@ -33,7 +33,7 @@ class BanService {
throw new \InvalidArgumentException('bannedActor');
}
if (empty($internalNote)) {
if (strlen($internalNote) > Ban::NOTE_MAX_LENGTH) {
throw new \InvalidArgumentException('internalNote');
}

View file

@ -2003,7 +2003,7 @@
{
"name": "internalNote",
"in": "query",
"description": "Optional internal note",
"description": "Optional internal note (max. 4000 characters)",
"schema": {
"type": "string",
"default": ""

View file

@ -1890,7 +1890,7 @@
{
"name": "internalNote",
"in": "query",
"description": "Optional internal note",
"description": "Optional internal note (max. 4000 characters)",
"schema": {
"type": "string",
"default": ""

View file

@ -2389,7 +2389,7 @@ export interface operations {
actorType: "users" | "groups" | "circles" | "emails" | "federated_users" | "phones" | "ip";
/** @description Actor ID or the IP address or range in case of type `ip` */
actorId: string;
/** @description Optional internal note */
/** @description Optional internal note (max. 4000 characters) */
internalNote?: string;
};
header: {

View file

@ -1874,7 +1874,7 @@ export interface operations {
actorType: "users" | "groups" | "circles" | "emails" | "federated_users" | "phones" | "ip";
/** @description Actor ID or the IP address or range in case of type `ip` */
actorId: string;
/** @description Optional internal note */
/** @description Optional internal note (max. 4000 characters) */
internalNote?: string;
};
header: {