diff --git a/openapi/components/paths.yaml b/openapi/components/paths.yaml index bb4a1e10..264c3ce2 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/playermoderation.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/playermoderation.yaml b/openapi/components/paths/playermoderation.yaml index 838f09d5..28d938ee 100644 --- a/openapi/components/paths/playermoderation.yaml +++ b/openapi/components/paths/playermoderation.yaml @@ -2,7 +2,7 @@ openapi: 3.2.1 info: title: playermoderation description: |- - There are two different moderation API's, "moderation" for Staff actions, and "playermoderation" for players. + There are two kinds of moderation here: player moderations, and moderations created through `createUserModeration`, such as an instance kick. PlayerModerations are user-generated actions towards others, such as muting them, blocking, or toggling interaction. Your global permission settings are stored locally on your computer. @@ -130,6 +130,34 @@ paths: $ref: ../responses/RequestValidationError.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: + - playermoderation + requestBody: + required: true + content: + application/json: + schema: + $ref: ../requests/CreateUserModerationRequest.yaml + security: + - authCookie: [] + responses: + "200": + $ref: ../responses/playermoderation/CreateUserModerationResponse.yaml + "400": + $ref: ../responses/RequestValidationError.yaml + "401": + $ref: ../responses/MissingCredentialsError.yaml + "403": + $ref: ../responses/playermoderation/CreateUserModerationForbiddenError.yaml + "404": + $ref: ../responses/ResourceNotFoundError.yaml components: securitySchemes: $ref: ../securitySchemes.yaml 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/playermoderation/CreateUserModerationForbiddenError.yaml b/openapi/components/responses/playermoderation/CreateUserModerationForbiddenError.yaml new file mode 100644 index 00000000..f43fbec1 --- /dev/null +++ b/openapi/components/responses/playermoderation/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/playermoderation/CreateUserModerationResponse.yaml b/openapi/components/responses/playermoderation/CreateUserModerationResponse.yaml new file mode 100644 index 00000000..73c18521 --- /dev/null +++ b/openapi/components/responses/playermoderation/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..d74a749c 100644 --- a/test/arazzo.yaml +++ b/test/arazzo.yaml @@ -14025,6 +14025,138 @@ 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-not-in-instance + summary: createUserModeration refuses a user who is not in the instance it names + inputs: + type: object + required: + - friendId + properties: + friendId: + type: string + parameters: + - reference: $components.parameters.userAgent + x-security: + - schemeName: authCookie + values: + apiKey: $workflows.session.outputs.sessionToken + steps: + - stepId: create-instance + operationId: $sourceDescriptions.default.createInstance + requestBody: + contentType: application/json + payload: + worldId: wrld_4cf554b4-430c-4f8f-b53e-1f294eed230b + type: private + region: use + ownerId: $workflows.session.outputs.userId + successCriteria: + - condition: $statusCode == 200 + outputs: + instanceId: $response.body#/instanceId + + - stepId: create-user-moderation + operationId: $sourceDescriptions.default.createUserModeration + parameters: + - name: userId + in: path + value: $inputs.friendId + requestBody: + contentType: application/json + payload: + instanceId: $steps.create-instance.outputs.instanceId + reason: x + type: kick + worldId: wrld_4cf554b4-430c-4f8f-b53e-1f294eed230b + successCriteria: + - condition: $statusCode == 403 + - condition: $response.body#/error/message == 'You cannot moderate this user․' + + - workflowId: create-user-moderation-self + summary: createUserModeration refuses the caller as its target + 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․' + + - 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: