diff --git a/openapi/components/paths.yaml b/openapi/components/paths.yaml index bb4a1e10..756c8d07 100644 --- a/openapi/components/paths.yaml +++ b/openapi/components/paths.yaml @@ -434,6 +434,8 @@ $ref: "./paths/inventory.yaml#/paths/~1user~1{userId}~1inventory~1{inventoryItemId}" "/user/{userId}/listings": $ref: "./paths/economy.yaml#/paths/~1user~1{userId}~1listings" +"/user/{userId}/moderations": + $ref: "./paths/users.yaml#/paths/~1user~1{userId}~1moderations" "/user/{userId}/products": $ref: "./paths/economy.yaml#/paths/~1user~1{userId}~1products" "/user/{userId}/tilia/kyc": diff --git a/openapi/components/paths/users.yaml b/openapi/components/paths/users.yaml index 0853534f..e3967e44 100644 --- a/openapi/components/paths/users.yaml +++ b/openapi/components/paths/users.yaml @@ -81,6 +81,36 @@ paths: $ref: ../responses/users/PrivateProfileResponse.yaml "401": $ref: ../responses/MissingCredentialsError.yaml + "/user/{userId}/moderations": + parameters: + - $ref: ../parameters.yaml#/userId + post: + operationId: createUserModeration + summary: Create User Moderation + description: With `type` `kick`, bans the user in the path from the instance given by `worldId` and `instanceId`. The user is not removed from the instance, but cannot join it again, even by invite. + tags: + - users + requestBody: + required: true + content: + application/json: + schema: + $ref: ../requests/CreateUserModerationRequest.yaml + security: + - authCookie: [] + responses: + "200": + $ref: ../responses/users/CreateUserModerationResponse.yaml + "400": + $ref: ../responses/RequestValidationError.yaml + "401": + $ref: ../responses/MissingCredentialsError.yaml + "403": + $ref: ../responses/users/CreateUserModerationForbiddenError.yaml + "404": + $ref: ../responses/ResourceNotFoundError.yaml + "429": + $ref: ../responses/users/CreateUserModerationRateLimitError.yaml /userNotes: get: operationId: getUserNotes diff --git a/openapi/components/requests/CreateUserModerationRequest.yaml b/openapi/components/requests/CreateUserModerationRequest.yaml new file mode 100644 index 00000000..e967c96e --- /dev/null +++ b/openapi/components/requests/CreateUserModerationRequest.yaml @@ -0,0 +1,19 @@ +title: CreateUserModerationRequest +type: object +properties: + expires: + type: string + format: date-time + instanceId: + $ref: ../schemas/InstanceID.yaml + isPermanent: + type: boolean + reason: + type: string + type: + $ref: ../schemas/CreateUserModerationRequestType.yaml + worldId: + $ref: ../schemas/WorldID.yaml +required: + - reason + - type diff --git a/openapi/components/responses/users/CreateUserModerationForbiddenError.yaml b/openapi/components/responses/users/CreateUserModerationForbiddenError.yaml new file mode 100644 index 00000000..f43fbec1 --- /dev/null +++ b/openapi/components/responses/users/CreateUserModerationForbiddenError.yaml @@ -0,0 +1,11 @@ +description: Error response when the user in the path can't be moderated, such as when they aren't in the instance given by `worldId` and `instanceId`, either of those is missing, or the user is you. +content: + application/json: + examples: + Cannot Moderate User: + value: + error: + message: You cannot moderate this user․ + status_code: 403 + schema: + $ref: ../../schemas/Error.yaml diff --git a/openapi/components/responses/users/CreateUserModerationRateLimitError.yaml b/openapi/components/responses/users/CreateUserModerationRateLimitError.yaml new file mode 100644 index 00000000..f8a695d7 --- /dev/null +++ b/openapi/components/responses/users/CreateUserModerationRateLimitError.yaml @@ -0,0 +1,11 @@ +description: Error response when moderating the same user too often. +content: + application/json: + examples: + Too Many Moderations: + value: + error: + message: Too many moderations being created at one player․ + status_code: 429 + schema: + $ref: ../../schemas/Error.yaml diff --git a/openapi/components/responses/users/CreateUserModerationResponse.yaml b/openapi/components/responses/users/CreateUserModerationResponse.yaml new file mode 100644 index 00000000..73c18521 --- /dev/null +++ b/openapi/components/responses/users/CreateUserModerationResponse.yaml @@ -0,0 +1,5 @@ +description: Returns the ID of the created moderation. +content: + application/json: + schema: + $ref: ../../schemas/CreateUserModerationResponse.yaml diff --git a/openapi/components/schemas/CreateUserModerationRequestType.yaml b/openapi/components/schemas/CreateUserModerationRequestType.yaml new file mode 100644 index 00000000..a1c6f300 --- /dev/null +++ b/openapi/components/schemas/CreateUserModerationRequestType.yaml @@ -0,0 +1,25 @@ +title: CreateUserModerationRequestType +enum: + - avatar + - ban + - banpubliconly + - chat + - emoji + - event + - gallery + - group + - hardban + - icon + - kick + - note + - nuisance + - print + - profile + - publicinstance + - sticker + - voice + - warn + - warning + - world +examples: + - kick diff --git a/openapi/components/schemas/CreateUserModerationResponse.yaml b/openapi/components/schemas/CreateUserModerationResponse.yaml new file mode 100644 index 00000000..a21d45cd --- /dev/null +++ b/openapi/components/schemas/CreateUserModerationResponse.yaml @@ -0,0 +1,7 @@ +title: CreateUserModerationResponse +type: object +properties: + id: + $ref: ./ModerationID.yaml +required: + - id diff --git a/openapi/components/schemas/ModerationID.yaml b/openapi/components/schemas/ModerationID.yaml new file mode 100644 index 00000000..7be84360 --- /dev/null +++ b/openapi/components/schemas/ModerationID.yaml @@ -0,0 +1,4 @@ +title: ModerationID +type: string +examples: + - mod_f862716d-23bf-49e0-a931-a08759450834 diff --git a/test/arazzo.yaml b/test/arazzo.yaml index 6858da25..c03f1d40 100644 --- a/test/arazzo.yaml +++ b/test/arazzo.yaml @@ -14025,6 +14025,106 @@ workflows: successCriteria: - condition: $statusCode == 401 + - workflowId: create-user-moderation-invalid-type + summary: createUserModeration refuses a type it does not know + parameters: + - reference: $components.parameters.userAgent + x-security: + - schemeName: authCookie + values: + apiKey: $workflows.session.outputs.sessionToken + steps: + - stepId: create-user-moderation + operationId: $sourceDescriptions.default.createUserModeration + parameters: + - name: userId + in: path + value: usr_00000000-0000-0000-0000-000000000000 + requestBody: + contentType: application/json + payload: + reason: x + type: x + successCriteria: + - condition: $statusCode == 400 + - condition: $response.body#/error/message == 'type must be one of ["ban"‚"note"‚"warning"‚"nuisance"‚"hardban"‚"kick"‚"warn"‚"banpubliconly"‚"publicinstance"‚"avatar"‚"world"‚"event"‚"group"‚"voice"‚"chat"‚"profile"‚"sticker"‚"emoji"‚"gallery"‚"print"‚"icon"]‚ not "x"' + + - workflowId: create-user-moderation-not-found + summary: createUserModeration refuses a user that does not exist + parameters: + - reference: $components.parameters.userAgent + x-security: + - schemeName: authCookie + values: + apiKey: $workflows.session.outputs.sessionToken + steps: + - stepId: create-user-moderation + operationId: $sourceDescriptions.default.createUserModeration + parameters: + - name: userId + in: path + value: usr_00000000-0000-0000-0000-000000000000 + requestBody: + contentType: application/json + payload: + reason: x + type: kick + successCriteria: + - condition: $statusCode == 404 + + - workflowId: create-user-moderation-self + summary: createUserModeration refuses the caller as its target, and rate limits a second attempt + parameters: + - reference: $components.parameters.userAgent + x-security: + - schemeName: authCookie + values: + apiKey: $workflows.session.outputs.sessionToken + steps: + - stepId: create-user-moderation + operationId: $sourceDescriptions.default.createUserModeration + parameters: + - name: userId + in: path + value: $workflows.session.outputs.userId + requestBody: + contentType: application/json + payload: + reason: x + type: kick + successCriteria: + - condition: $statusCode == 403 + - condition: $response.body#/error/message == 'You cannot moderate this user․' + + - stepId: create-user-moderation-rate-limited + operationId: $sourceDescriptions.default.createUserModeration + parameters: + - name: userId + in: path + value: $workflows.session.outputs.userId + requestBody: + contentType: application/json + payload: + reason: x + type: kick + successCriteria: + - condition: $statusCode == 429 + - condition: $response.body#/error/message == 'Too many moderations being created at one player․' + + - workflowId: create-user-moderation-unauthenticated + summary: createUserModeration refuses an anonymous caller + parameters: + - reference: $components.parameters.userAgent + steps: + - stepId: create-user-moderation + operationId: $sourceDescriptions.default.createUserModeration + parameters: + - name: userId + in: path + value: usr_00000000-0000-0000-0000-000000000000 + successCriteria: + - condition: $statusCode == 401 + - workflowId: delete-all-user-persistence-data-unauthenticated summary: deleteAllUserPersistenceData refuses an anonymous caller parameters: