Compare commits
1 Commits
thumbnail-
...
restricted
| Author | SHA1 | Date | |
|---|---|---|---|
|
69438a9d0c
|
726
Cargo.lock
generated
726
Cargo.lock
generated
File diff suppressed because it is too large
Load Diff
@@ -1,5 +1,5 @@
|
|||||||
# Stage 1: Build
|
# Stage 1: Build
|
||||||
FROM registry.itzana.me/docker-proxy/golang:1.24 AS builder
|
FROM docker.io/golang:1.23 AS builder
|
||||||
|
|
||||||
# Set the working directory in the container
|
# Set the working directory in the container
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
@@ -14,7 +14,7 @@ COPY . .
|
|||||||
RUN CGO_ENABLED=0 GOOS=linux go build -o service ./cmd/maps-service/service.go
|
RUN CGO_ENABLED=0 GOOS=linux go build -o service ./cmd/maps-service/service.go
|
||||||
|
|
||||||
# Stage 2: Run
|
# Stage 2: Run
|
||||||
FROM registry.itzana.me/docker-proxy/alpine:3.21
|
FROM alpine
|
||||||
|
|
||||||
# Set up a non-root user for security
|
# Set up a non-root user for security
|
||||||
RUN addgroup -S appgroup && adduser -S appuser -G appgroup
|
RUN addgroup -S appgroup && adduser -S appuser -G appgroup
|
||||||
|
|||||||
@@ -26,11 +26,10 @@ Prerequisite: golang installed
|
|||||||
|
|
||||||
Prerequisite: bun installed
|
Prerequisite: bun installed
|
||||||
|
|
||||||
The environment variables `API_HOST` and `AUTH_HOST` will need to be set for the middleware.
|
The environment variable `API_HOST` will need to be set for the middleware.
|
||||||
Example `.env` in web's root:
|
Example `.env` in web's root:
|
||||||
```
|
```
|
||||||
API_HOST="http://localhost:8082/"
|
API_HOST="http://localhost:8082/v1/"
|
||||||
AUTH_HOST="http://localhost:8083/"
|
|
||||||
```
|
```
|
||||||
|
|
||||||
1. `cd web`
|
1. `cd web`
|
||||||
|
|||||||
@@ -33,8 +33,6 @@ services:
|
|||||||
"--auth-rpc-host","authrpc:8081",
|
"--auth-rpc-host","authrpc:8081",
|
||||||
"--data-rpc-host","dataservice:9000",
|
"--data-rpc-host","dataservice:9000",
|
||||||
]
|
]
|
||||||
env_file:
|
|
||||||
- ../auth-compose/strafesnet_staging.env
|
|
||||||
depends_on:
|
depends_on:
|
||||||
- authrpc
|
- authrpc
|
||||||
- nats
|
- nats
|
||||||
@@ -52,7 +50,6 @@ services:
|
|||||||
- "3000:3000"
|
- "3000:3000"
|
||||||
environment:
|
environment:
|
||||||
- API_HOST=http://submissions:8082/v1
|
- API_HOST=http://submissions:8082/v1
|
||||||
- AUTH_HOST=http://localhost:8080/
|
|
||||||
|
|
||||||
validation:
|
validation:
|
||||||
image:
|
image:
|
||||||
|
|||||||
@@ -48,121 +48,12 @@ paths:
|
|||||||
schema:
|
schema:
|
||||||
type: integer
|
type: integer
|
||||||
format: int64
|
format: int64
|
||||||
minimum: 0
|
|
||||||
- name: ValidatedModelVersion
|
- name: ValidatedModelVersion
|
||||||
in: query
|
in: query
|
||||||
required: true
|
required: true
|
||||||
schema:
|
schema:
|
||||||
type: integer
|
type: integer
|
||||||
format: int64
|
format: int64
|
||||||
minimum: 0
|
|
||||||
responses:
|
|
||||||
"204":
|
|
||||||
description: Successful response
|
|
||||||
default:
|
|
||||||
description: General Error
|
|
||||||
content:
|
|
||||||
application/json:
|
|
||||||
schema:
|
|
||||||
$ref: "#/components/schemas/Error"
|
|
||||||
/mapfixes/{MapfixID}/error:
|
|
||||||
post:
|
|
||||||
summary: Validator posts an error to the audit log
|
|
||||||
operationId: createMapfixAuditError
|
|
||||||
tags:
|
|
||||||
- Mapfixes
|
|
||||||
parameters:
|
|
||||||
- $ref: '#/components/parameters/MapfixID'
|
|
||||||
- name: ErrorMessage
|
|
||||||
in: query
|
|
||||||
required: true
|
|
||||||
schema:
|
|
||||||
type: string
|
|
||||||
minLength: 0
|
|
||||||
maxLength: 4096
|
|
||||||
responses:
|
|
||||||
"204":
|
|
||||||
description: Successful response
|
|
||||||
default:
|
|
||||||
description: General Error
|
|
||||||
content:
|
|
||||||
application/json:
|
|
||||||
schema:
|
|
||||||
$ref: "#/components/schemas/Error"
|
|
||||||
/mapfixes/{MapfixID}/checklist:
|
|
||||||
post:
|
|
||||||
summary: Validator posts a checklist to the audit log
|
|
||||||
operationId: createMapfixAuditCheckList
|
|
||||||
tags:
|
|
||||||
- Mapfixes
|
|
||||||
parameters:
|
|
||||||
- $ref: '#/components/parameters/MapfixID'
|
|
||||||
requestBody:
|
|
||||||
required: true
|
|
||||||
content:
|
|
||||||
application/json:
|
|
||||||
schema:
|
|
||||||
$ref: '#/components/schemas/CheckList'
|
|
||||||
responses:
|
|
||||||
"204":
|
|
||||||
description: Successful response
|
|
||||||
default:
|
|
||||||
description: General Error
|
|
||||||
content:
|
|
||||||
application/json:
|
|
||||||
schema:
|
|
||||||
$ref: "#/components/schemas/Error"
|
|
||||||
/mapfixes/{MapfixID}/status/validator-submitted:
|
|
||||||
post:
|
|
||||||
summary: (Internal endpoint) Role Validator changes status from Submitting -> Submitted
|
|
||||||
operationId: actionMapfixSubmitted
|
|
||||||
tags:
|
|
||||||
- Mapfixes
|
|
||||||
parameters:
|
|
||||||
- $ref: '#/components/parameters/MapfixID'
|
|
||||||
- name: ModelVersion
|
|
||||||
in: query
|
|
||||||
required: true
|
|
||||||
schema:
|
|
||||||
type: integer
|
|
||||||
format: int64
|
|
||||||
minimum: 0
|
|
||||||
- name: DisplayName
|
|
||||||
in: query
|
|
||||||
required: true
|
|
||||||
schema:
|
|
||||||
type: string
|
|
||||||
maxLength: 128
|
|
||||||
- name: Creator
|
|
||||||
in: query
|
|
||||||
required: true
|
|
||||||
schema:
|
|
||||||
type: string
|
|
||||||
maxLength: 128
|
|
||||||
- name: GameID
|
|
||||||
in: query
|
|
||||||
required: true
|
|
||||||
schema:
|
|
||||||
type: integer
|
|
||||||
format: int32
|
|
||||||
minimum: 0
|
|
||||||
responses:
|
|
||||||
"204":
|
|
||||||
description: Successful response
|
|
||||||
default:
|
|
||||||
description: General Error
|
|
||||||
content:
|
|
||||||
application/json:
|
|
||||||
schema:
|
|
||||||
$ref: "#/components/schemas/Error"
|
|
||||||
/mapfixes/{MapfixID}/status/validator-request-changes:
|
|
||||||
post:
|
|
||||||
summary: (Internal endpoint) Role Validator changes status from Submitting -> ChangesRequested
|
|
||||||
operationId: actionMapfixRequestChanges
|
|
||||||
tags:
|
|
||||||
- Mapfixes
|
|
||||||
parameters:
|
|
||||||
- $ref: '#/components/parameters/MapfixID'
|
|
||||||
responses:
|
responses:
|
||||||
"204":
|
"204":
|
||||||
description: Successful response
|
description: Successful response
|
||||||
@@ -197,6 +88,13 @@ paths:
|
|||||||
- Mapfixes
|
- Mapfixes
|
||||||
parameters:
|
parameters:
|
||||||
- $ref: '#/components/parameters/MapfixID'
|
- $ref: '#/components/parameters/MapfixID'
|
||||||
|
- name: StatusMessage
|
||||||
|
in: query
|
||||||
|
required: true
|
||||||
|
schema:
|
||||||
|
type: string
|
||||||
|
minLength: 0
|
||||||
|
maxLength: 4096
|
||||||
responses:
|
responses:
|
||||||
"204":
|
"204":
|
||||||
description: Successful response
|
description: Successful response
|
||||||
@@ -286,121 +184,12 @@ paths:
|
|||||||
schema:
|
schema:
|
||||||
type: integer
|
type: integer
|
||||||
format: int64
|
format: int64
|
||||||
minimum: 0
|
|
||||||
- name: ValidatedModelVersion
|
- name: ValidatedModelVersion
|
||||||
in: query
|
in: query
|
||||||
required: true
|
required: true
|
||||||
schema:
|
schema:
|
||||||
type: integer
|
type: integer
|
||||||
format: int64
|
format: int64
|
||||||
minimum: 0
|
|
||||||
responses:
|
|
||||||
"204":
|
|
||||||
description: Successful response
|
|
||||||
default:
|
|
||||||
description: General Error
|
|
||||||
content:
|
|
||||||
application/json:
|
|
||||||
schema:
|
|
||||||
$ref: "#/components/schemas/Error"
|
|
||||||
/submissions/{SubmissionID}/error:
|
|
||||||
post:
|
|
||||||
summary: Validator posts an error to the audit log
|
|
||||||
operationId: createSubmissionAuditError
|
|
||||||
tags:
|
|
||||||
- Submissions
|
|
||||||
parameters:
|
|
||||||
- $ref: '#/components/parameters/SubmissionID'
|
|
||||||
- name: ErrorMessage
|
|
||||||
in: query
|
|
||||||
required: true
|
|
||||||
schema:
|
|
||||||
type: string
|
|
||||||
minLength: 0
|
|
||||||
maxLength: 4096
|
|
||||||
responses:
|
|
||||||
"204":
|
|
||||||
description: Successful response
|
|
||||||
default:
|
|
||||||
description: General Error
|
|
||||||
content:
|
|
||||||
application/json:
|
|
||||||
schema:
|
|
||||||
$ref: "#/components/schemas/Error"
|
|
||||||
/submissions/{SubmissionID}/checklist:
|
|
||||||
post:
|
|
||||||
summary: Validator posts a checklist to the audit log
|
|
||||||
operationId: createSubmissionAuditCheckList
|
|
||||||
tags:
|
|
||||||
- Submissions
|
|
||||||
parameters:
|
|
||||||
- $ref: '#/components/parameters/SubmissionID'
|
|
||||||
requestBody:
|
|
||||||
required: true
|
|
||||||
content:
|
|
||||||
application/json:
|
|
||||||
schema:
|
|
||||||
$ref: '#/components/schemas/CheckList'
|
|
||||||
responses:
|
|
||||||
"204":
|
|
||||||
description: Successful response
|
|
||||||
default:
|
|
||||||
description: General Error
|
|
||||||
content:
|
|
||||||
application/json:
|
|
||||||
schema:
|
|
||||||
$ref: "#/components/schemas/Error"
|
|
||||||
/submissions/{SubmissionID}/status/validator-submitted:
|
|
||||||
post:
|
|
||||||
summary: (Internal endpoint) Role Validator changes status from Submitting -> Submitted
|
|
||||||
operationId: actionSubmissionSubmitted
|
|
||||||
tags:
|
|
||||||
- Submissions
|
|
||||||
parameters:
|
|
||||||
- $ref: '#/components/parameters/SubmissionID'
|
|
||||||
- name: ModelVersion
|
|
||||||
in: query
|
|
||||||
required: true
|
|
||||||
schema:
|
|
||||||
type: integer
|
|
||||||
format: int64
|
|
||||||
minimum: 0
|
|
||||||
- name: DisplayName
|
|
||||||
in: query
|
|
||||||
required: true
|
|
||||||
schema:
|
|
||||||
type: string
|
|
||||||
maxLength: 128
|
|
||||||
- name: Creator
|
|
||||||
in: query
|
|
||||||
required: true
|
|
||||||
schema:
|
|
||||||
type: string
|
|
||||||
maxLength: 128
|
|
||||||
- name: GameID
|
|
||||||
in: query
|
|
||||||
required: true
|
|
||||||
schema:
|
|
||||||
type: integer
|
|
||||||
format: int32
|
|
||||||
minimum: 0
|
|
||||||
responses:
|
|
||||||
"204":
|
|
||||||
description: Successful response
|
|
||||||
default:
|
|
||||||
description: General Error
|
|
||||||
content:
|
|
||||||
application/json:
|
|
||||||
schema:
|
|
||||||
$ref: "#/components/schemas/Error"
|
|
||||||
/submissions/{SubmissionID}/status/validator-request-changes:
|
|
||||||
post:
|
|
||||||
summary: (Internal endpoint) Role Validator changes status from Submitting -> ChangesRequested
|
|
||||||
operationId: actionSubmissionRequestChanges
|
|
||||||
tags:
|
|
||||||
- Submissions
|
|
||||||
parameters:
|
|
||||||
- $ref: '#/components/parameters/SubmissionID'
|
|
||||||
responses:
|
responses:
|
||||||
"204":
|
"204":
|
||||||
description: Successful response
|
description: Successful response
|
||||||
@@ -435,6 +224,13 @@ paths:
|
|||||||
- Submissions
|
- Submissions
|
||||||
parameters:
|
parameters:
|
||||||
- $ref: '#/components/parameters/SubmissionID'
|
- $ref: '#/components/parameters/SubmissionID'
|
||||||
|
- name: StatusMessage
|
||||||
|
in: query
|
||||||
|
required: true
|
||||||
|
schema:
|
||||||
|
type: string
|
||||||
|
minLength: 0
|
||||||
|
maxLength: 4096
|
||||||
responses:
|
responses:
|
||||||
"204":
|
"204":
|
||||||
description: Successful response
|
description: Successful response
|
||||||
@@ -458,7 +254,6 @@ paths:
|
|||||||
schema:
|
schema:
|
||||||
type: integer
|
type: integer
|
||||||
format: int64
|
format: int64
|
||||||
minimum: 0
|
|
||||||
responses:
|
responses:
|
||||||
"204":
|
"204":
|
||||||
description: Successful response
|
description: Successful response
|
||||||
@@ -488,13 +283,11 @@ paths:
|
|||||||
schema:
|
schema:
|
||||||
type: integer
|
type: integer
|
||||||
format: int64
|
format: int64
|
||||||
minimum: 0
|
|
||||||
- name: Policy
|
- name: Policy
|
||||||
in: query
|
in: query
|
||||||
schema:
|
schema:
|
||||||
type: integer
|
type: integer
|
||||||
format: int32
|
format: int32
|
||||||
minimum: 0
|
|
||||||
responses:
|
responses:
|
||||||
"200":
|
"200":
|
||||||
description: Successful response
|
description: Successful response
|
||||||
@@ -564,13 +357,11 @@ paths:
|
|||||||
schema:
|
schema:
|
||||||
type: integer
|
type: integer
|
||||||
format: int32
|
format: int32
|
||||||
minimum: 0
|
|
||||||
- name: ResourceID
|
- name: ResourceID
|
||||||
in: query
|
in: query
|
||||||
schema:
|
schema:
|
||||||
type: integer
|
type: integer
|
||||||
format: int64
|
format: int64
|
||||||
minimum: 0
|
|
||||||
responses:
|
responses:
|
||||||
"200":
|
"200":
|
||||||
description: Successful response
|
description: Successful response
|
||||||
@@ -641,7 +432,6 @@ components:
|
|||||||
schema:
|
schema:
|
||||||
type: integer
|
type: integer
|
||||||
format: int64
|
format: int64
|
||||||
minimum: 0
|
|
||||||
OperationID:
|
OperationID:
|
||||||
name: OperationID
|
name: OperationID
|
||||||
in: path
|
in: path
|
||||||
@@ -650,7 +440,6 @@ components:
|
|||||||
schema:
|
schema:
|
||||||
type: integer
|
type: integer
|
||||||
format: int32
|
format: int32
|
||||||
minimum: 0
|
|
||||||
SubmissionID:
|
SubmissionID:
|
||||||
name: SubmissionID
|
name: SubmissionID
|
||||||
in: path
|
in: path
|
||||||
@@ -659,7 +448,6 @@ components:
|
|||||||
schema:
|
schema:
|
||||||
type: integer
|
type: integer
|
||||||
format: int64
|
format: int64
|
||||||
minimum: 0
|
|
||||||
ScriptID:
|
ScriptID:
|
||||||
name: ScriptID
|
name: ScriptID
|
||||||
in: path
|
in: path
|
||||||
@@ -668,7 +456,6 @@ components:
|
|||||||
schema:
|
schema:
|
||||||
type: integer
|
type: integer
|
||||||
format: int64
|
format: int64
|
||||||
minimum: 0
|
|
||||||
Page:
|
Page:
|
||||||
name: Page
|
name: Page
|
||||||
in: query
|
in: query
|
||||||
@@ -695,7 +482,6 @@ components:
|
|||||||
MapfixID:
|
MapfixID:
|
||||||
type: integer
|
type: integer
|
||||||
format: int64
|
format: int64
|
||||||
minimum: 0
|
|
||||||
SubmissionID:
|
SubmissionID:
|
||||||
required:
|
required:
|
||||||
- SubmissionID
|
- SubmissionID
|
||||||
@@ -704,7 +490,6 @@ components:
|
|||||||
SubmissionID:
|
SubmissionID:
|
||||||
type: integer
|
type: integer
|
||||||
format: int64
|
format: int64
|
||||||
minimum: 0
|
|
||||||
ScriptID:
|
ScriptID:
|
||||||
required:
|
required:
|
||||||
- ScriptID
|
- ScriptID
|
||||||
@@ -713,7 +498,6 @@ components:
|
|||||||
ScriptID:
|
ScriptID:
|
||||||
type: integer
|
type: integer
|
||||||
format: int64
|
format: int64
|
||||||
minimum: 0
|
|
||||||
ScriptPolicyID:
|
ScriptPolicyID:
|
||||||
required:
|
required:
|
||||||
- ScriptPolicyID
|
- ScriptPolicyID
|
||||||
@@ -722,7 +506,6 @@ components:
|
|||||||
ScriptPolicyID:
|
ScriptPolicyID:
|
||||||
type: integer
|
type: integer
|
||||||
format: int64
|
format: int64
|
||||||
minimum: 0
|
|
||||||
MapfixCreate:
|
MapfixCreate:
|
||||||
required:
|
required:
|
||||||
- OperationID
|
- OperationID
|
||||||
@@ -733,17 +516,14 @@ components:
|
|||||||
- AssetID
|
- AssetID
|
||||||
- AssetVersion
|
- AssetVersion
|
||||||
- TargetAssetID
|
- TargetAssetID
|
||||||
- Description
|
|
||||||
type: object
|
type: object
|
||||||
properties:
|
properties:
|
||||||
OperationID:
|
OperationID:
|
||||||
type: integer
|
type: integer
|
||||||
format: int32
|
format: int32
|
||||||
minimum: 0
|
|
||||||
AssetOwner:
|
AssetOwner:
|
||||||
type: integer
|
type: integer
|
||||||
format: int64
|
format: int64
|
||||||
minimum: 0
|
|
||||||
DisplayName:
|
DisplayName:
|
||||||
type: string
|
type: string
|
||||||
maxLength: 128
|
maxLength: 128
|
||||||
@@ -753,22 +533,15 @@ components:
|
|||||||
GameID:
|
GameID:
|
||||||
type: integer
|
type: integer
|
||||||
format: int32
|
format: int32
|
||||||
minimum: 0
|
|
||||||
AssetID:
|
AssetID:
|
||||||
type: integer
|
type: integer
|
||||||
format: int64
|
format: int64
|
||||||
minimum: 0
|
|
||||||
AssetVersion:
|
AssetVersion:
|
||||||
type: integer
|
type: integer
|
||||||
format: int64
|
format: int64
|
||||||
minimum: 0
|
|
||||||
TargetAssetID:
|
TargetAssetID:
|
||||||
type: integer
|
type: integer
|
||||||
format: int64
|
format: int64
|
||||||
minimum: 0
|
|
||||||
Description:
|
|
||||||
type: string
|
|
||||||
maxLength: 256
|
|
||||||
SubmissionCreate:
|
SubmissionCreate:
|
||||||
required:
|
required:
|
||||||
- OperationID
|
- OperationID
|
||||||
@@ -778,18 +551,14 @@ components:
|
|||||||
- GameID
|
- GameID
|
||||||
- AssetID
|
- AssetID
|
||||||
- AssetVersion
|
- AssetVersion
|
||||||
- Status
|
|
||||||
- Roles
|
|
||||||
type: object
|
type: object
|
||||||
properties:
|
properties:
|
||||||
OperationID:
|
OperationID:
|
||||||
type: integer
|
type: integer
|
||||||
format: int32
|
format: int32
|
||||||
minimum: 0
|
|
||||||
AssetOwner:
|
AssetOwner:
|
||||||
type: integer
|
type: integer
|
||||||
format: int64
|
format: int64
|
||||||
minimum: 0
|
|
||||||
DisplayName:
|
DisplayName:
|
||||||
type: string
|
type: string
|
||||||
maxLength: 128
|
maxLength: 128
|
||||||
@@ -799,23 +568,12 @@ components:
|
|||||||
GameID:
|
GameID:
|
||||||
type: integer
|
type: integer
|
||||||
format: int32
|
format: int32
|
||||||
minimum: 0
|
|
||||||
AssetID:
|
AssetID:
|
||||||
type: integer
|
type: integer
|
||||||
format: int64
|
format: int64
|
||||||
minimum: 0
|
|
||||||
AssetVersion:
|
AssetVersion:
|
||||||
type: integer
|
type: integer
|
||||||
format: int64
|
format: int64
|
||||||
minimum: 0
|
|
||||||
Status:
|
|
||||||
type: integer
|
|
||||||
format: uint32
|
|
||||||
minimum: 0
|
|
||||||
maximum: 9
|
|
||||||
Roles:
|
|
||||||
type: integer
|
|
||||||
format: uint32
|
|
||||||
Script:
|
Script:
|
||||||
required:
|
required:
|
||||||
- ID
|
- ID
|
||||||
@@ -829,7 +587,6 @@ components:
|
|||||||
ID:
|
ID:
|
||||||
type: integer
|
type: integer
|
||||||
format: int64
|
format: int64
|
||||||
minimum: 0
|
|
||||||
Name:
|
Name:
|
||||||
type: string
|
type: string
|
||||||
maxLength: 128
|
maxLength: 128
|
||||||
@@ -843,11 +600,9 @@ components:
|
|||||||
ResourceType:
|
ResourceType:
|
||||||
type: integer
|
type: integer
|
||||||
format: int32
|
format: int32
|
||||||
minimum: 0
|
|
||||||
ResourceID:
|
ResourceID:
|
||||||
type: integer
|
type: integer
|
||||||
format: int64
|
format: int64
|
||||||
minimum: 0
|
|
||||||
ScriptCreate:
|
ScriptCreate:
|
||||||
required:
|
required:
|
||||||
- Name
|
- Name
|
||||||
@@ -865,11 +620,9 @@ components:
|
|||||||
ResourceType:
|
ResourceType:
|
||||||
type: integer
|
type: integer
|
||||||
format: int32
|
format: int32
|
||||||
minimum: 0
|
|
||||||
ResourceID:
|
ResourceID:
|
||||||
type: integer
|
type: integer
|
||||||
format: int64
|
format: int64
|
||||||
minimum: 0
|
|
||||||
ScriptPolicy:
|
ScriptPolicy:
|
||||||
required:
|
required:
|
||||||
- ID
|
- ID
|
||||||
@@ -881,7 +634,6 @@ components:
|
|||||||
ID:
|
ID:
|
||||||
type: integer
|
type: integer
|
||||||
format: int64
|
format: int64
|
||||||
minimum: 0
|
|
||||||
FromScriptHash:
|
FromScriptHash:
|
||||||
type: string
|
type: string
|
||||||
minLength: 16
|
minLength: 16
|
||||||
@@ -889,11 +641,9 @@ components:
|
|||||||
ToScriptID:
|
ToScriptID:
|
||||||
type: integer
|
type: integer
|
||||||
format: int64
|
format: int64
|
||||||
minimum: 0
|
|
||||||
Policy:
|
Policy:
|
||||||
type: integer
|
type: integer
|
||||||
format: int32
|
format: int32
|
||||||
minimum: 0
|
|
||||||
ScriptPolicyCreate:
|
ScriptPolicyCreate:
|
||||||
required:
|
required:
|
||||||
- FromScriptID
|
- FromScriptID
|
||||||
@@ -904,34 +654,12 @@ components:
|
|||||||
FromScriptID:
|
FromScriptID:
|
||||||
type: integer
|
type: integer
|
||||||
format: int64
|
format: int64
|
||||||
minimum: 0
|
|
||||||
ToScriptID:
|
ToScriptID:
|
||||||
type: integer
|
type: integer
|
||||||
format: int64
|
format: int64
|
||||||
minimum: 0
|
|
||||||
Policy:
|
Policy:
|
||||||
type: integer
|
type: integer
|
||||||
format: int32
|
format: int32
|
||||||
minimum: 0
|
|
||||||
Check:
|
|
||||||
required:
|
|
||||||
- Name
|
|
||||||
- Summary
|
|
||||||
- Passed
|
|
||||||
type: object
|
|
||||||
properties:
|
|
||||||
Name:
|
|
||||||
type: string
|
|
||||||
maxLength: 128
|
|
||||||
Summary:
|
|
||||||
type: string
|
|
||||||
maxLength: 4096
|
|
||||||
Passed:
|
|
||||||
type: boolean
|
|
||||||
CheckList:
|
|
||||||
type: array
|
|
||||||
items:
|
|
||||||
$ref: "#/components/schemas/Check"
|
|
||||||
Error:
|
Error:
|
||||||
description: Represents error object
|
description: Represents error object
|
||||||
type: object
|
type: object
|
||||||
@@ -939,7 +667,6 @@ components:
|
|||||||
code:
|
code:
|
||||||
type: integer
|
type: integer
|
||||||
format: int64
|
format: int64
|
||||||
minimum: 0
|
|
||||||
message:
|
message:
|
||||||
type: string
|
type: string
|
||||||
required:
|
required:
|
||||||
|
|||||||
537
openapi.yaml
537
openapi.yaml
@@ -105,22 +105,11 @@ paths:
|
|||||||
schema:
|
schema:
|
||||||
type: integer
|
type: integer
|
||||||
format: int32
|
format: int32
|
||||||
minimum: 1
|
|
||||||
maximum: 5
|
|
||||||
- name: Sort
|
- name: Sort
|
||||||
in: query
|
in: query
|
||||||
schema:
|
schema:
|
||||||
type: integer
|
type: integer
|
||||||
format: int32
|
format: int32
|
||||||
minimum: 0
|
|
||||||
maximum: 4
|
|
||||||
description: >
|
|
||||||
Sort order:
|
|
||||||
* `0` - Disabled
|
|
||||||
* `1` - DisplayNameAscending
|
|
||||||
* `2` - DisplayNameDescending
|
|
||||||
* `3` - DateAscending
|
|
||||||
* `4` - DateDescending
|
|
||||||
responses:
|
responses:
|
||||||
"200":
|
"200":
|
||||||
description: Successful response
|
description: Successful response
|
||||||
@@ -158,34 +147,6 @@ paths:
|
|||||||
application/json:
|
application/json:
|
||||||
schema:
|
schema:
|
||||||
$ref: "#/components/schemas/Error"
|
$ref: "#/components/schemas/Error"
|
||||||
/maps/{MapID}/location:
|
|
||||||
get:
|
|
||||||
summary: Get location of asset
|
|
||||||
operationId: getMapAssetLocation
|
|
||||||
tags:
|
|
||||||
- Maps
|
|
||||||
parameters:
|
|
||||||
- name: MapID
|
|
||||||
in: path
|
|
||||||
required: true
|
|
||||||
schema:
|
|
||||||
type: integer
|
|
||||||
format: int64
|
|
||||||
minimum: 0
|
|
||||||
responses:
|
|
||||||
"200":
|
|
||||||
description: Successful response
|
|
||||||
content:
|
|
||||||
text/plain:
|
|
||||||
schema:
|
|
||||||
type: string
|
|
||||||
maxLength: 1024
|
|
||||||
default:
|
|
||||||
description: General Error
|
|
||||||
content:
|
|
||||||
application/json:
|
|
||||||
schema:
|
|
||||||
$ref: "#/components/schemas/Error"
|
|
||||||
/mapfixes:
|
/mapfixes:
|
||||||
get:
|
get:
|
||||||
summary: Get list of mapfixes
|
summary: Get list of mapfixes
|
||||||
@@ -211,77 +172,20 @@ paths:
|
|||||||
schema:
|
schema:
|
||||||
type: integer
|
type: integer
|
||||||
format: int32
|
format: int32
|
||||||
minimum: 1
|
|
||||||
maximum: 5
|
|
||||||
description: >
|
|
||||||
Game ID:
|
|
||||||
* `1` - Bhop
|
|
||||||
* `2` - Surf
|
|
||||||
* `5` - FlyTrials
|
|
||||||
- name: Sort
|
- name: Sort
|
||||||
in: query
|
in: query
|
||||||
schema:
|
schema:
|
||||||
type: integer
|
type: integer
|
||||||
format: int32
|
format: int32
|
||||||
minimum: 0
|
|
||||||
maximum: 4
|
|
||||||
description: >
|
|
||||||
Sort order:
|
|
||||||
* `0` - Disabled
|
|
||||||
* `1` - DisplayNameAscending
|
|
||||||
* `2` - DisplayNameDescending
|
|
||||||
* `3` - DateAscending
|
|
||||||
* `4` - DateDescending
|
|
||||||
- name: Submitter
|
|
||||||
in: query
|
|
||||||
schema:
|
|
||||||
type: integer
|
|
||||||
format: int64
|
|
||||||
minimum: 0
|
|
||||||
- name: AssetID
|
|
||||||
in: query
|
|
||||||
schema:
|
|
||||||
type: integer
|
|
||||||
format: int64
|
|
||||||
minimum: 0
|
|
||||||
- name: TargetAssetID
|
|
||||||
in: query
|
|
||||||
schema:
|
|
||||||
type: integer
|
|
||||||
format: int64
|
|
||||||
minimum: 0
|
|
||||||
- name: StatusID
|
|
||||||
in: query
|
|
||||||
schema:
|
|
||||||
type: integer
|
|
||||||
format: int32
|
|
||||||
minimum: 0
|
|
||||||
maximum: 9
|
|
||||||
description: >
|
|
||||||
// Phase: Creation
|
|
||||||
* `0` - UnderConstruction
|
|
||||||
* `1` - ChangesRequested
|
|
||||||
|
|
||||||
// Phase: Review
|
|
||||||
* `2` - Submitting
|
|
||||||
* `3` - Submitted
|
|
||||||
|
|
||||||
// Phase: Testing
|
|
||||||
* `4` - AcceptedUnvalidated // pending script review, can re-trigger validation
|
|
||||||
* `5` - Validating
|
|
||||||
* `6` - Validated
|
|
||||||
* `7` - Uploading
|
|
||||||
|
|
||||||
// Phase: Final MapfixStatus
|
|
||||||
* `8` - Uploaded // uploaded to the group, but pending release
|
|
||||||
* `9` - Rejected
|
|
||||||
responses:
|
responses:
|
||||||
"200":
|
"200":
|
||||||
description: Successful response
|
description: Successful response
|
||||||
content:
|
content:
|
||||||
application/json:
|
application/json:
|
||||||
schema:
|
schema:
|
||||||
$ref: "#/components/schemas/Mapfixes"
|
type: array
|
||||||
|
items:
|
||||||
|
$ref: "#/components/schemas/Mapfix"
|
||||||
default:
|
default:
|
||||||
description: General Error
|
description: General Error
|
||||||
content:
|
content:
|
||||||
@@ -334,56 +238,6 @@ paths:
|
|||||||
application/json:
|
application/json:
|
||||||
schema:
|
schema:
|
||||||
$ref: "#/components/schemas/Error"
|
$ref: "#/components/schemas/Error"
|
||||||
/mapfixes/{MapfixID}/audit-events:
|
|
||||||
get:
|
|
||||||
summary: Retrieve a list of audit events
|
|
||||||
operationId: listMapfixAuditEvents
|
|
||||||
tags:
|
|
||||||
- Mapfixes
|
|
||||||
security: []
|
|
||||||
parameters:
|
|
||||||
- $ref: '#/components/parameters/MapfixID'
|
|
||||||
- $ref: "#/components/parameters/Page"
|
|
||||||
- $ref: "#/components/parameters/Limit"
|
|
||||||
responses:
|
|
||||||
"200":
|
|
||||||
description: Successful response
|
|
||||||
content:
|
|
||||||
application/json:
|
|
||||||
schema:
|
|
||||||
type: array
|
|
||||||
items:
|
|
||||||
$ref: "#/components/schemas/AuditEvent"
|
|
||||||
default:
|
|
||||||
description: General Error
|
|
||||||
content:
|
|
||||||
application/json:
|
|
||||||
schema:
|
|
||||||
$ref: "#/components/schemas/Error"
|
|
||||||
/mapfixes/{MapfixID}/comment:
|
|
||||||
post:
|
|
||||||
summary: Post a comment to the audit log
|
|
||||||
operationId: createMapfixAuditComment
|
|
||||||
tags:
|
|
||||||
- Mapfixes
|
|
||||||
parameters:
|
|
||||||
- $ref: '#/components/parameters/MapfixID'
|
|
||||||
requestBody:
|
|
||||||
required: true
|
|
||||||
content:
|
|
||||||
text/plain:
|
|
||||||
schema:
|
|
||||||
type: string
|
|
||||||
maxLength: 1024
|
|
||||||
responses:
|
|
||||||
"204":
|
|
||||||
description: Successful response
|
|
||||||
default:
|
|
||||||
description: General Error
|
|
||||||
content:
|
|
||||||
application/json:
|
|
||||||
schema:
|
|
||||||
$ref: "#/components/schemas/Error"
|
|
||||||
/mapfixes/{MapfixID}/model:
|
/mapfixes/{MapfixID}/model:
|
||||||
post:
|
post:
|
||||||
summary: Update model following role restrictions
|
summary: Update model following role restrictions
|
||||||
@@ -398,14 +252,12 @@ paths:
|
|||||||
schema:
|
schema:
|
||||||
type: integer
|
type: integer
|
||||||
format: int64
|
format: int64
|
||||||
minimum: 0
|
- name: VersionID
|
||||||
- name: ModelVersion
|
|
||||||
in: query
|
in: query
|
||||||
required: true
|
required: true
|
||||||
schema:
|
schema:
|
||||||
type: integer
|
type: integer
|
||||||
format: int64
|
format: int64
|
||||||
minimum: 0
|
|
||||||
responses:
|
responses:
|
||||||
"204":
|
"204":
|
||||||
description: Successful response
|
description: Successful response
|
||||||
@@ -432,44 +284,10 @@ paths:
|
|||||||
application/json:
|
application/json:
|
||||||
schema:
|
schema:
|
||||||
$ref: "#/components/schemas/Error"
|
$ref: "#/components/schemas/Error"
|
||||||
/mapfixes/{MapfixID}/status/trigger-submit:
|
/mapfixes/{MapfixID}/status/submit:
|
||||||
post:
|
post:
|
||||||
summary: Role Submitter changes status from UnderConstruction|ChangesRequested -> Submitting
|
summary: Role Submitter changes status from UnderConstruction|ChangesRequested -> Submitted
|
||||||
operationId: actionMapfixTriggerSubmit
|
operationId: actionMapfixSubmit
|
||||||
tags:
|
|
||||||
- Mapfixes
|
|
||||||
parameters:
|
|
||||||
- $ref: '#/components/parameters/MapfixID'
|
|
||||||
responses:
|
|
||||||
"204":
|
|
||||||
description: Successful response
|
|
||||||
default:
|
|
||||||
description: General Error
|
|
||||||
content:
|
|
||||||
application/json:
|
|
||||||
schema:
|
|
||||||
$ref: "#/components/schemas/Error"
|
|
||||||
/mapfixes/{MapfixID}/status/trigger-submit-unchecked:
|
|
||||||
post:
|
|
||||||
summary: Role Reviewer changes status from ChangesRequested -> Submitting
|
|
||||||
operationId: actionMapfixTriggerSubmitUnchecked
|
|
||||||
tags:
|
|
||||||
- Mapfixes
|
|
||||||
parameters:
|
|
||||||
- $ref: '#/components/parameters/MapfixID'
|
|
||||||
responses:
|
|
||||||
"204":
|
|
||||||
description: Successful response
|
|
||||||
default:
|
|
||||||
description: General Error
|
|
||||||
content:
|
|
||||||
application/json:
|
|
||||||
schema:
|
|
||||||
$ref: "#/components/schemas/Error"
|
|
||||||
/mapfixes/{MapfixID}/status/reset-submitting:
|
|
||||||
post:
|
|
||||||
summary: Role Submitter manually resets submitting softlock and changes status from Submitting -> UnderConstruction
|
|
||||||
operationId: actionMapfixResetSubmitting
|
|
||||||
tags:
|
tags:
|
||||||
- Mapfixes
|
- Mapfixes
|
||||||
parameters:
|
parameters:
|
||||||
@@ -665,78 +483,20 @@ paths:
|
|||||||
schema:
|
schema:
|
||||||
type: integer
|
type: integer
|
||||||
format: int32
|
format: int32
|
||||||
minimum: 1
|
|
||||||
maximum: 5
|
|
||||||
description: >
|
|
||||||
Game ID:
|
|
||||||
* `1` - Bhop
|
|
||||||
* `2` - Surf
|
|
||||||
* `5` - FlyTrials
|
|
||||||
- name: Sort
|
- name: Sort
|
||||||
in: query
|
in: query
|
||||||
schema:
|
schema:
|
||||||
type: integer
|
type: integer
|
||||||
format: int32
|
format: int32
|
||||||
minimum: 0
|
|
||||||
maximum: 4
|
|
||||||
description: >
|
|
||||||
Sort order:
|
|
||||||
* `0` - Disabled
|
|
||||||
* `1` - DisplayNameAscending
|
|
||||||
* `2` - DisplayNameDescending
|
|
||||||
* `3` - DateAscending
|
|
||||||
* `4` - DateDescending
|
|
||||||
- name: Submitter
|
|
||||||
in: query
|
|
||||||
schema:
|
|
||||||
type: integer
|
|
||||||
format: int64
|
|
||||||
minimum: 0
|
|
||||||
- name: AssetID
|
|
||||||
in: query
|
|
||||||
schema:
|
|
||||||
type: integer
|
|
||||||
format: int64
|
|
||||||
minimum: 0
|
|
||||||
- name: UploadedAssetID
|
|
||||||
in: query
|
|
||||||
schema:
|
|
||||||
type: integer
|
|
||||||
format: int64
|
|
||||||
minimum: 0
|
|
||||||
- name: StatusID
|
|
||||||
in: query
|
|
||||||
schema:
|
|
||||||
type: integer
|
|
||||||
format: int32
|
|
||||||
minimum: 0
|
|
||||||
maximum: 10
|
|
||||||
description: >
|
|
||||||
// Phase: Creation
|
|
||||||
* `0` - UnderConstruction
|
|
||||||
* `1` - ChangesRequested
|
|
||||||
|
|
||||||
// Phase: Review
|
|
||||||
* `2` - Submitting
|
|
||||||
* `3` - Submitted
|
|
||||||
|
|
||||||
// Phase: Testing
|
|
||||||
* `4` - AcceptedUnvalidated // pending script review, can re-trigger validation
|
|
||||||
* `5` - Validating
|
|
||||||
* `6` - Validated
|
|
||||||
* `7` - Uploading
|
|
||||||
* `8` - Uploaded // uploaded to the group, but pending release
|
|
||||||
|
|
||||||
// Phase: Final SubmissionStatus
|
|
||||||
* `9` - Rejected
|
|
||||||
* `10` - Released
|
|
||||||
responses:
|
responses:
|
||||||
"200":
|
"200":
|
||||||
description: Successful response
|
description: Successful response
|
||||||
content:
|
content:
|
||||||
application/json:
|
application/json:
|
||||||
schema:
|
schema:
|
||||||
$ref: "#/components/schemas/Submissions"
|
type: array
|
||||||
|
items:
|
||||||
|
$ref: "#/components/schemas/Submission"
|
||||||
default:
|
default:
|
||||||
description: General Error
|
description: General Error
|
||||||
content:
|
content:
|
||||||
@@ -767,31 +527,6 @@ paths:
|
|||||||
application/json:
|
application/json:
|
||||||
schema:
|
schema:
|
||||||
$ref: "#/components/schemas/Error"
|
$ref: "#/components/schemas/Error"
|
||||||
/submissions-admin:
|
|
||||||
post:
|
|
||||||
summary: Trigger the validator to create a new submission
|
|
||||||
operationId: createSubmissionAdmin
|
|
||||||
tags:
|
|
||||||
- Submissions
|
|
||||||
requestBody:
|
|
||||||
required: true
|
|
||||||
content:
|
|
||||||
application/json:
|
|
||||||
schema:
|
|
||||||
$ref: '#/components/schemas/SubmissionTriggerCreate'
|
|
||||||
responses:
|
|
||||||
"201":
|
|
||||||
description: Successful response
|
|
||||||
content:
|
|
||||||
application/json:
|
|
||||||
schema:
|
|
||||||
$ref: "#/components/schemas/OperationID"
|
|
||||||
default:
|
|
||||||
description: General Error
|
|
||||||
content:
|
|
||||||
application/json:
|
|
||||||
schema:
|
|
||||||
$ref: "#/components/schemas/Error"
|
|
||||||
/submissions/{SubmissionID}:
|
/submissions/{SubmissionID}:
|
||||||
get:
|
get:
|
||||||
summary: Retrieve map with ID
|
summary: Retrieve map with ID
|
||||||
@@ -814,56 +549,6 @@ paths:
|
|||||||
application/json:
|
application/json:
|
||||||
schema:
|
schema:
|
||||||
$ref: "#/components/schemas/Error"
|
$ref: "#/components/schemas/Error"
|
||||||
/submissions/{SubmissionID}/audit-events:
|
|
||||||
get:
|
|
||||||
summary: Retrieve a list of audit events
|
|
||||||
operationId: listSubmissionAuditEvents
|
|
||||||
tags:
|
|
||||||
- Submissions
|
|
||||||
security: []
|
|
||||||
parameters:
|
|
||||||
- $ref: '#/components/parameters/SubmissionID'
|
|
||||||
- $ref: "#/components/parameters/Page"
|
|
||||||
- $ref: "#/components/parameters/Limit"
|
|
||||||
responses:
|
|
||||||
"200":
|
|
||||||
description: Successful response
|
|
||||||
content:
|
|
||||||
application/json:
|
|
||||||
schema:
|
|
||||||
type: array
|
|
||||||
items:
|
|
||||||
$ref: "#/components/schemas/AuditEvent"
|
|
||||||
default:
|
|
||||||
description: General Error
|
|
||||||
content:
|
|
||||||
application/json:
|
|
||||||
schema:
|
|
||||||
$ref: "#/components/schemas/Error"
|
|
||||||
/submissions/{SubmissionID}/comment:
|
|
||||||
post:
|
|
||||||
summary: Post a comment to the audit log
|
|
||||||
operationId: createSubmissionAuditComment
|
|
||||||
tags:
|
|
||||||
- Submissions
|
|
||||||
parameters:
|
|
||||||
- $ref: '#/components/parameters/SubmissionID'
|
|
||||||
requestBody:
|
|
||||||
required: true
|
|
||||||
content:
|
|
||||||
text/plain:
|
|
||||||
schema:
|
|
||||||
type: string
|
|
||||||
maxLength: 1024
|
|
||||||
responses:
|
|
||||||
"204":
|
|
||||||
description: Successful response
|
|
||||||
default:
|
|
||||||
description: General Error
|
|
||||||
content:
|
|
||||||
application/json:
|
|
||||||
schema:
|
|
||||||
$ref: "#/components/schemas/Error"
|
|
||||||
/submissions/{SubmissionID}/model:
|
/submissions/{SubmissionID}/model:
|
||||||
post:
|
post:
|
||||||
summary: Update model following role restrictions
|
summary: Update model following role restrictions
|
||||||
@@ -878,14 +563,12 @@ paths:
|
|||||||
schema:
|
schema:
|
||||||
type: integer
|
type: integer
|
||||||
format: int64
|
format: int64
|
||||||
minimum: 0
|
- name: VersionID
|
||||||
- name: ModelVersion
|
|
||||||
in: query
|
in: query
|
||||||
required: true
|
required: true
|
||||||
schema:
|
schema:
|
||||||
type: integer
|
type: integer
|
||||||
format: int64
|
format: int64
|
||||||
minimum: 0
|
|
||||||
responses:
|
responses:
|
||||||
"204":
|
"204":
|
||||||
description: Successful response
|
description: Successful response
|
||||||
@@ -912,44 +595,10 @@ paths:
|
|||||||
application/json:
|
application/json:
|
||||||
schema:
|
schema:
|
||||||
$ref: "#/components/schemas/Error"
|
$ref: "#/components/schemas/Error"
|
||||||
/submissions/{SubmissionID}/status/trigger-submit:
|
/submissions/{SubmissionID}/status/submit:
|
||||||
post:
|
post:
|
||||||
summary: Role Submitter changes status from UnderConstruction|ChangesRequested -> Submitting
|
summary: Role Submitter changes status from UnderConstruction|ChangesRequested -> Submitted
|
||||||
operationId: actionSubmissionTriggerSubmit
|
operationId: actionSubmissionSubmit
|
||||||
tags:
|
|
||||||
- Submissions
|
|
||||||
parameters:
|
|
||||||
- $ref: '#/components/parameters/SubmissionID'
|
|
||||||
responses:
|
|
||||||
"204":
|
|
||||||
description: Successful response
|
|
||||||
default:
|
|
||||||
description: General Error
|
|
||||||
content:
|
|
||||||
application/json:
|
|
||||||
schema:
|
|
||||||
$ref: "#/components/schemas/Error"
|
|
||||||
/submissions/{SubmissionID}/status/trigger-submit-unchecked:
|
|
||||||
post:
|
|
||||||
summary: Role Reviewer changes status from ChangesRequested -> Submitting
|
|
||||||
operationId: actionSubmissionTriggerSubmitUnchecked
|
|
||||||
tags:
|
|
||||||
- Submissions
|
|
||||||
parameters:
|
|
||||||
- $ref: '#/components/parameters/SubmissionID'
|
|
||||||
responses:
|
|
||||||
"204":
|
|
||||||
description: Successful response
|
|
||||||
default:
|
|
||||||
description: General Error
|
|
||||||
content:
|
|
||||||
application/json:
|
|
||||||
schema:
|
|
||||||
$ref: "#/components/schemas/Error"
|
|
||||||
/submissions/{SubmissionID}/status/reset-submitting:
|
|
||||||
post:
|
|
||||||
summary: Role Submitter manually resets submitting softlock and changes status from Submitting -> UnderConstruction
|
|
||||||
operationId: actionSubmissionResetSubmitting
|
|
||||||
tags:
|
tags:
|
||||||
- Submissions
|
- Submissions
|
||||||
parameters:
|
parameters:
|
||||||
@@ -1145,13 +794,11 @@ paths:
|
|||||||
schema:
|
schema:
|
||||||
type: integer
|
type: integer
|
||||||
format: int64
|
format: int64
|
||||||
minimum: 0
|
|
||||||
- name: Policy
|
- name: Policy
|
||||||
in: query
|
in: query
|
||||||
schema:
|
schema:
|
||||||
type: integer
|
type: integer
|
||||||
format: int32
|
format: int32
|
||||||
minimum: 0
|
|
||||||
responses:
|
responses:
|
||||||
"200":
|
"200":
|
||||||
description: Successful response
|
description: Successful response
|
||||||
@@ -1282,13 +929,11 @@ paths:
|
|||||||
schema:
|
schema:
|
||||||
type: integer
|
type: integer
|
||||||
format: int32
|
format: int32
|
||||||
minimum: 0
|
|
||||||
- name: ResourceID
|
- name: ResourceID
|
||||||
in: query
|
in: query
|
||||||
schema:
|
schema:
|
||||||
type: integer
|
type: integer
|
||||||
format: int64
|
format: int64
|
||||||
minimum: 0
|
|
||||||
responses:
|
responses:
|
||||||
"200":
|
"200":
|
||||||
description: Successful response
|
description: Successful response
|
||||||
@@ -1403,7 +1048,6 @@ components:
|
|||||||
schema:
|
schema:
|
||||||
type: integer
|
type: integer
|
||||||
format: int64
|
format: int64
|
||||||
minimum: 0
|
|
||||||
MapfixID:
|
MapfixID:
|
||||||
name: MapfixID
|
name: MapfixID
|
||||||
in: path
|
in: path
|
||||||
@@ -1412,7 +1056,6 @@ components:
|
|||||||
schema:
|
schema:
|
||||||
type: integer
|
type: integer
|
||||||
format: int64
|
format: int64
|
||||||
minimum: 0
|
|
||||||
OperationID:
|
OperationID:
|
||||||
name: OperationID
|
name: OperationID
|
||||||
in: path
|
in: path
|
||||||
@@ -1421,7 +1064,6 @@ components:
|
|||||||
schema:
|
schema:
|
||||||
type: integer
|
type: integer
|
||||||
format: int32
|
format: int32
|
||||||
minimum: 0
|
|
||||||
SubmissionID:
|
SubmissionID:
|
||||||
name: SubmissionID
|
name: SubmissionID
|
||||||
in: path
|
in: path
|
||||||
@@ -1430,7 +1072,6 @@ components:
|
|||||||
schema:
|
schema:
|
||||||
type: integer
|
type: integer
|
||||||
format: int64
|
format: int64
|
||||||
minimum: 0
|
|
||||||
ScriptID:
|
ScriptID:
|
||||||
name: ScriptID
|
name: ScriptID
|
||||||
in: path
|
in: path
|
||||||
@@ -1439,7 +1080,6 @@ components:
|
|||||||
schema:
|
schema:
|
||||||
type: integer
|
type: integer
|
||||||
format: int64
|
format: int64
|
||||||
minimum: 0
|
|
||||||
ScriptPolicyID:
|
ScriptPolicyID:
|
||||||
name: ScriptPolicyID
|
name: ScriptPolicyID
|
||||||
in: path
|
in: path
|
||||||
@@ -1448,7 +1088,6 @@ components:
|
|||||||
schema:
|
schema:
|
||||||
type: integer
|
type: integer
|
||||||
format: int64
|
format: int64
|
||||||
minimum: 0
|
|
||||||
Page:
|
Page:
|
||||||
name: Page
|
name: Page
|
||||||
in: query
|
in: query
|
||||||
@@ -1464,47 +1103,9 @@ components:
|
|||||||
schema:
|
schema:
|
||||||
type: integer
|
type: integer
|
||||||
format: int32
|
format: int32
|
||||||
minimum: 0
|
minimum: 1
|
||||||
maximum: 100
|
maximum: 100
|
||||||
schemas:
|
schemas:
|
||||||
AuditEvent:
|
|
||||||
type: object
|
|
||||||
required:
|
|
||||||
- ID
|
|
||||||
- Date
|
|
||||||
- User
|
|
||||||
- Username
|
|
||||||
- ResourceType
|
|
||||||
- ResourceID
|
|
||||||
- EventType
|
|
||||||
- EventData
|
|
||||||
properties:
|
|
||||||
ID:
|
|
||||||
type: integer
|
|
||||||
format: int64
|
|
||||||
Date:
|
|
||||||
type: integer
|
|
||||||
format: int64
|
|
||||||
User:
|
|
||||||
type: integer
|
|
||||||
format: int64
|
|
||||||
Username:
|
|
||||||
type: string
|
|
||||||
maxLength: 64
|
|
||||||
ResourceType:
|
|
||||||
type: integer
|
|
||||||
format: int32
|
|
||||||
description: Is this a submission or is it a mapfix
|
|
||||||
ResourceID:
|
|
||||||
type: integer
|
|
||||||
format: int64
|
|
||||||
EventType:
|
|
||||||
type: integer
|
|
||||||
format: int32
|
|
||||||
EventData:
|
|
||||||
type: object
|
|
||||||
description: Arbitrary event data
|
|
||||||
additionalProperties: true
|
|
||||||
OperationID:
|
OperationID:
|
||||||
required:
|
required:
|
||||||
- OperationID
|
- OperationID
|
||||||
@@ -1513,7 +1114,6 @@ components:
|
|||||||
OperationID:
|
OperationID:
|
||||||
type: integer
|
type: integer
|
||||||
format: int32
|
format: int32
|
||||||
minimum: 0
|
|
||||||
ScriptID:
|
ScriptID:
|
||||||
required:
|
required:
|
||||||
- ScriptID
|
- ScriptID
|
||||||
@@ -1522,7 +1122,6 @@ components:
|
|||||||
ScriptID:
|
ScriptID:
|
||||||
type: integer
|
type: integer
|
||||||
format: int64
|
format: int64
|
||||||
minimum: 0
|
|
||||||
ScriptPolicyID:
|
ScriptPolicyID:
|
||||||
required:
|
required:
|
||||||
- ScriptPolicyID
|
- ScriptPolicyID
|
||||||
@@ -1531,7 +1130,6 @@ components:
|
|||||||
ScriptPolicyID:
|
ScriptPolicyID:
|
||||||
type: integer
|
type: integer
|
||||||
format: int64
|
format: int64
|
||||||
minimum: 0
|
|
||||||
Roles:
|
Roles:
|
||||||
required:
|
required:
|
||||||
- Roles
|
- Roles
|
||||||
@@ -1540,7 +1138,6 @@ components:
|
|||||||
Roles:
|
Roles:
|
||||||
type: integer
|
type: integer
|
||||||
format: int32
|
format: int32
|
||||||
minimum: 0
|
|
||||||
User:
|
User:
|
||||||
required:
|
required:
|
||||||
- UserID
|
- UserID
|
||||||
@@ -1551,7 +1148,6 @@ components:
|
|||||||
UserID:
|
UserID:
|
||||||
type: integer
|
type: integer
|
||||||
format: int64
|
format: int64
|
||||||
minimum: 0
|
|
||||||
Username:
|
Username:
|
||||||
type: string
|
type: string
|
||||||
maxLength: 128
|
maxLength: 128
|
||||||
@@ -1570,7 +1166,6 @@ components:
|
|||||||
ID:
|
ID:
|
||||||
type: integer
|
type: integer
|
||||||
format: int64
|
format: int64
|
||||||
minimum: 0
|
|
||||||
DisplayName:
|
DisplayName:
|
||||||
type: string
|
type: string
|
||||||
maxLength: 128
|
maxLength: 128
|
||||||
@@ -1580,11 +1175,9 @@ components:
|
|||||||
GameID:
|
GameID:
|
||||||
type: integer
|
type: integer
|
||||||
format: int32
|
format: int32
|
||||||
minimum: 0
|
|
||||||
Date:
|
Date:
|
||||||
type: integer
|
type: integer
|
||||||
format: int64
|
format: int64
|
||||||
minimum: 0
|
|
||||||
Mapfix:
|
Mapfix:
|
||||||
required:
|
required:
|
||||||
- ID
|
- ID
|
||||||
@@ -1599,13 +1192,12 @@ components:
|
|||||||
- Completed
|
- Completed
|
||||||
- TargetAssetID
|
- TargetAssetID
|
||||||
- StatusID
|
- StatusID
|
||||||
- Description
|
- StatusMessage
|
||||||
type: object
|
type: object
|
||||||
properties:
|
properties:
|
||||||
ID:
|
ID:
|
||||||
type: integer
|
type: integer
|
||||||
format: int64
|
format: int64
|
||||||
minimum: 0
|
|
||||||
DisplayName:
|
DisplayName:
|
||||||
type: string
|
type: string
|
||||||
maxLength: 128
|
maxLength: 128
|
||||||
@@ -1615,72 +1207,44 @@ components:
|
|||||||
GameID:
|
GameID:
|
||||||
type: integer
|
type: integer
|
||||||
format: int32
|
format: int32
|
||||||
minimum: 0
|
|
||||||
CreatedAt:
|
CreatedAt:
|
||||||
type: integer
|
type: integer
|
||||||
format: int64
|
format: int64
|
||||||
minimum: 0
|
|
||||||
UpdatedAt:
|
UpdatedAt:
|
||||||
type: integer
|
type: integer
|
||||||
format: int64
|
format: int64
|
||||||
minimum: 0
|
|
||||||
Submitter:
|
Submitter:
|
||||||
type: integer
|
type: integer
|
||||||
format: int64
|
format: int64
|
||||||
minimum: 0
|
|
||||||
AssetID:
|
AssetID:
|
||||||
type: integer
|
type: integer
|
||||||
format: int64
|
format: int64
|
||||||
minimum: 0
|
|
||||||
AssetVersion:
|
AssetVersion:
|
||||||
type: integer
|
type: integer
|
||||||
format: int64
|
format: int64
|
||||||
minimum: 0
|
|
||||||
Completed:
|
Completed:
|
||||||
type: boolean
|
type: boolean
|
||||||
TargetAssetID:
|
TargetAssetID:
|
||||||
type: integer
|
type: integer
|
||||||
format: int64
|
format: int64
|
||||||
minimum: 0
|
|
||||||
StatusID:
|
StatusID:
|
||||||
type: integer
|
type: integer
|
||||||
format: int32
|
format: int32
|
||||||
minimum: 0
|
StatusMessage:
|
||||||
Description:
|
|
||||||
type: string
|
type: string
|
||||||
maxLength: 256
|
maxLength: 256
|
||||||
Mapfixes:
|
|
||||||
type: object
|
|
||||||
required:
|
|
||||||
- Total
|
|
||||||
- Mapfixes
|
|
||||||
properties:
|
|
||||||
Total:
|
|
||||||
type: integer
|
|
||||||
format: int64
|
|
||||||
minimum: 0
|
|
||||||
Mapfixes:
|
|
||||||
type: array
|
|
||||||
items:
|
|
||||||
$ref: "#/components/schemas/Mapfix"
|
|
||||||
MapfixTriggerCreate:
|
MapfixTriggerCreate:
|
||||||
required:
|
required:
|
||||||
- AssetID
|
- AssetID
|
||||||
- TargetAssetID
|
- TargetAssetID
|
||||||
- Description
|
|
||||||
type: object
|
type: object
|
||||||
properties:
|
properties:
|
||||||
AssetID:
|
AssetID:
|
||||||
type: integer
|
type: integer
|
||||||
format: int64
|
format: int64
|
||||||
minimum: 0
|
|
||||||
TargetAssetID:
|
TargetAssetID:
|
||||||
type: integer
|
type: integer
|
||||||
format: int64
|
format: int64
|
||||||
minimum: 0
|
|
||||||
Description:
|
|
||||||
type: string
|
|
||||||
maxLength: 256
|
|
||||||
Operation:
|
Operation:
|
||||||
required:
|
required:
|
||||||
- OperationID
|
- OperationID
|
||||||
@@ -1694,19 +1258,15 @@ components:
|
|||||||
OperationID:
|
OperationID:
|
||||||
type: integer
|
type: integer
|
||||||
format: int32
|
format: int32
|
||||||
minimum: 0
|
|
||||||
Date:
|
Date:
|
||||||
type: integer
|
type: integer
|
||||||
format: int64
|
format: int64
|
||||||
minimum: 0
|
|
||||||
Owner:
|
Owner:
|
||||||
type: integer
|
type: integer
|
||||||
format: int64
|
format: int64
|
||||||
minimum: 0
|
|
||||||
Status:
|
Status:
|
||||||
type: integer
|
type: integer
|
||||||
format: int32
|
format: int32
|
||||||
minimum: 0
|
|
||||||
StatusMessage:
|
StatusMessage:
|
||||||
type: string
|
type: string
|
||||||
maxLength: 256
|
maxLength: 256
|
||||||
@@ -1729,12 +1289,12 @@ components:
|
|||||||
- Completed
|
- Completed
|
||||||
# - UploadedAssetID
|
# - UploadedAssetID
|
||||||
- StatusID
|
- StatusID
|
||||||
|
- StatusMessage
|
||||||
type: object
|
type: object
|
||||||
properties:
|
properties:
|
||||||
ID:
|
ID:
|
||||||
type: integer
|
type: integer
|
||||||
format: int64
|
format: int64
|
||||||
minimum: 0
|
|
||||||
DisplayName:
|
DisplayName:
|
||||||
type: string
|
type: string
|
||||||
maxLength: 128
|
maxLength: 128
|
||||||
@@ -1744,81 +1304,46 @@ components:
|
|||||||
GameID:
|
GameID:
|
||||||
type: integer
|
type: integer
|
||||||
format: int32
|
format: int32
|
||||||
minimum: 0
|
|
||||||
CreatedAt:
|
CreatedAt:
|
||||||
type: integer
|
type: integer
|
||||||
format: int64
|
format: int64
|
||||||
minimum: 0
|
|
||||||
UpdatedAt:
|
UpdatedAt:
|
||||||
type: integer
|
type: integer
|
||||||
format: int64
|
format: int64
|
||||||
minimum: 0
|
|
||||||
Submitter:
|
Submitter:
|
||||||
type: integer
|
type: integer
|
||||||
format: int64
|
format: int64
|
||||||
minimum: 0
|
|
||||||
AssetID:
|
AssetID:
|
||||||
type: integer
|
type: integer
|
||||||
format: int64
|
format: int64
|
||||||
minimum: 0
|
|
||||||
AssetVersion:
|
AssetVersion:
|
||||||
type: integer
|
type: integer
|
||||||
format: int64
|
format: int64
|
||||||
minimum: 0
|
|
||||||
ValidatedAssetID:
|
ValidatedAssetID:
|
||||||
type: integer
|
type: integer
|
||||||
format: int64
|
format: int64
|
||||||
minimum: 0
|
|
||||||
ValidatedAssetVersion:
|
ValidatedAssetVersion:
|
||||||
type: integer
|
type: integer
|
||||||
format: int64
|
format: int64
|
||||||
minimum: 0
|
|
||||||
Completed:
|
Completed:
|
||||||
type: boolean
|
type: boolean
|
||||||
UploadedAssetID:
|
UploadedAssetID:
|
||||||
type: integer
|
type: integer
|
||||||
format: int64
|
format: int64
|
||||||
minimum: 0
|
|
||||||
StatusID:
|
StatusID:
|
||||||
type: integer
|
type: integer
|
||||||
format: int32
|
format: int32
|
||||||
minimum: 0
|
StatusMessage:
|
||||||
Submissions:
|
type: string
|
||||||
required:
|
maxLength: 256
|
||||||
- Total
|
|
||||||
- Submissions
|
|
||||||
type: object
|
|
||||||
properties:
|
|
||||||
Total:
|
|
||||||
type: integer
|
|
||||||
format: int64
|
|
||||||
minimum: 0
|
|
||||||
Submissions:
|
|
||||||
type: array
|
|
||||||
items:
|
|
||||||
$ref: "#/components/schemas/Submission"
|
|
||||||
SubmissionTriggerCreate:
|
SubmissionTriggerCreate:
|
||||||
required:
|
required:
|
||||||
- AssetID
|
- AssetID
|
||||||
- DisplayName
|
|
||||||
- Creator
|
|
||||||
- GameID
|
|
||||||
type: object
|
type: object
|
||||||
properties:
|
properties:
|
||||||
AssetID:
|
AssetID:
|
||||||
type: integer
|
type: integer
|
||||||
format: int64
|
format: int64
|
||||||
minimum: 0
|
|
||||||
DisplayName:
|
|
||||||
type: string
|
|
||||||
maxLength: 128
|
|
||||||
Creator:
|
|
||||||
type: string
|
|
||||||
maxLength: 128
|
|
||||||
GameID:
|
|
||||||
type: integer
|
|
||||||
format: int32
|
|
||||||
minimum: 0
|
|
||||||
ReleaseInfo:
|
ReleaseInfo:
|
||||||
required:
|
required:
|
||||||
- SubmissionID
|
- SubmissionID
|
||||||
@@ -1828,7 +1353,6 @@ components:
|
|||||||
SubmissionID:
|
SubmissionID:
|
||||||
type: integer
|
type: integer
|
||||||
format: int64
|
format: int64
|
||||||
minimum: 0
|
|
||||||
Date:
|
Date:
|
||||||
type: string
|
type: string
|
||||||
format: date-time
|
format: date-time
|
||||||
@@ -1845,7 +1369,6 @@ components:
|
|||||||
ID:
|
ID:
|
||||||
type: integer
|
type: integer
|
||||||
format: int64
|
format: int64
|
||||||
minimum: 0
|
|
||||||
Name:
|
Name:
|
||||||
type: string
|
type: string
|
||||||
maxLength: 128
|
maxLength: 128
|
||||||
@@ -1859,11 +1382,9 @@ components:
|
|||||||
ResourceType:
|
ResourceType:
|
||||||
type: integer
|
type: integer
|
||||||
format: int32
|
format: int32
|
||||||
minimum: 0
|
|
||||||
ResourceID:
|
ResourceID:
|
||||||
type: integer
|
type: integer
|
||||||
format: int64
|
format: int64
|
||||||
minimum: 0
|
|
||||||
ScriptCreate:
|
ScriptCreate:
|
||||||
required:
|
required:
|
||||||
- Name
|
- Name
|
||||||
@@ -1881,11 +1402,9 @@ components:
|
|||||||
ResourceType:
|
ResourceType:
|
||||||
type: integer
|
type: integer
|
||||||
format: int32
|
format: int32
|
||||||
minimum: 0
|
|
||||||
ResourceID:
|
ResourceID:
|
||||||
type: integer
|
type: integer
|
||||||
format: int64
|
format: int64
|
||||||
minimum: 0
|
|
||||||
ScriptUpdate:
|
ScriptUpdate:
|
||||||
required:
|
required:
|
||||||
- ID
|
- ID
|
||||||
@@ -1894,7 +1413,6 @@ components:
|
|||||||
ID:
|
ID:
|
||||||
type: integer
|
type: integer
|
||||||
format: int64
|
format: int64
|
||||||
minimum: 0
|
|
||||||
Name:
|
Name:
|
||||||
type: string
|
type: string
|
||||||
maxLength: 128
|
maxLength: 128
|
||||||
@@ -1904,11 +1422,9 @@ components:
|
|||||||
ResourceType:
|
ResourceType:
|
||||||
type: integer
|
type: integer
|
||||||
format: int32
|
format: int32
|
||||||
minimum: 0
|
|
||||||
ResourceID:
|
ResourceID:
|
||||||
type: integer
|
type: integer
|
||||||
format: int64
|
format: int64
|
||||||
minimum: 0
|
|
||||||
ScriptPolicy:
|
ScriptPolicy:
|
||||||
required:
|
required:
|
||||||
- ID
|
- ID
|
||||||
@@ -1920,7 +1436,6 @@ components:
|
|||||||
ID:
|
ID:
|
||||||
type: integer
|
type: integer
|
||||||
format: int64
|
format: int64
|
||||||
minimum: 0
|
|
||||||
FromScriptHash:
|
FromScriptHash:
|
||||||
type: string
|
type: string
|
||||||
minLength: 16
|
minLength: 16
|
||||||
@@ -1928,11 +1443,9 @@ components:
|
|||||||
ToScriptID:
|
ToScriptID:
|
||||||
type: integer
|
type: integer
|
||||||
format: int64
|
format: int64
|
||||||
minimum: 0
|
|
||||||
Policy:
|
Policy:
|
||||||
type: integer
|
type: integer
|
||||||
format: int32
|
format: int32
|
||||||
minimum: 0
|
|
||||||
ScriptPolicyCreate:
|
ScriptPolicyCreate:
|
||||||
required:
|
required:
|
||||||
- FromScriptID
|
- FromScriptID
|
||||||
@@ -1943,15 +1456,12 @@ components:
|
|||||||
FromScriptID:
|
FromScriptID:
|
||||||
type: integer
|
type: integer
|
||||||
format: int64
|
format: int64
|
||||||
minimum: 0
|
|
||||||
ToScriptID:
|
ToScriptID:
|
||||||
type: integer
|
type: integer
|
||||||
format: int64
|
format: int64
|
||||||
minimum: 0
|
|
||||||
Policy:
|
Policy:
|
||||||
type: integer
|
type: integer
|
||||||
format: int32
|
format: int32
|
||||||
minimum: 0
|
|
||||||
ScriptPolicyUpdate:
|
ScriptPolicyUpdate:
|
||||||
required:
|
required:
|
||||||
- ID
|
- ID
|
||||||
@@ -1960,19 +1470,15 @@ components:
|
|||||||
ID:
|
ID:
|
||||||
type: integer
|
type: integer
|
||||||
format: int64
|
format: int64
|
||||||
minimum: 0
|
|
||||||
FromScriptID:
|
FromScriptID:
|
||||||
type: integer
|
type: integer
|
||||||
format: int64
|
format: int64
|
||||||
minimum: 0
|
|
||||||
ToScriptID:
|
ToScriptID:
|
||||||
type: integer
|
type: integer
|
||||||
format: int64
|
format: int64
|
||||||
minimum: 0
|
|
||||||
Policy:
|
Policy:
|
||||||
type: integer
|
type: integer
|
||||||
format: int32
|
format: int32
|
||||||
minimum: 0
|
|
||||||
Error:
|
Error:
|
||||||
description: Represents error object
|
description: Represents error object
|
||||||
type: object
|
type: object
|
||||||
@@ -1980,7 +1486,6 @@ components:
|
|||||||
code:
|
code:
|
||||||
type: integer
|
type: integer
|
||||||
format: int64
|
format: int64
|
||||||
minimum: 0
|
|
||||||
message:
|
message:
|
||||||
type: string
|
type: string
|
||||||
required:
|
required:
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -13,277 +13,6 @@ import (
|
|||||||
"github.com/ogen-go/ogen/validate"
|
"github.com/ogen-go/ogen/validate"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Encode implements json.Marshaler.
|
|
||||||
func (s *AuditEvent) Encode(e *jx.Encoder) {
|
|
||||||
e.ObjStart()
|
|
||||||
s.encodeFields(e)
|
|
||||||
e.ObjEnd()
|
|
||||||
}
|
|
||||||
|
|
||||||
// encodeFields encodes fields.
|
|
||||||
func (s *AuditEvent) encodeFields(e *jx.Encoder) {
|
|
||||||
{
|
|
||||||
e.FieldStart("ID")
|
|
||||||
e.Int64(s.ID)
|
|
||||||
}
|
|
||||||
{
|
|
||||||
e.FieldStart("Date")
|
|
||||||
e.Int64(s.Date)
|
|
||||||
}
|
|
||||||
{
|
|
||||||
e.FieldStart("User")
|
|
||||||
e.Int64(s.User)
|
|
||||||
}
|
|
||||||
{
|
|
||||||
e.FieldStart("Username")
|
|
||||||
e.Str(s.Username)
|
|
||||||
}
|
|
||||||
{
|
|
||||||
e.FieldStart("ResourceType")
|
|
||||||
e.Int32(s.ResourceType)
|
|
||||||
}
|
|
||||||
{
|
|
||||||
e.FieldStart("ResourceID")
|
|
||||||
e.Int64(s.ResourceID)
|
|
||||||
}
|
|
||||||
{
|
|
||||||
e.FieldStart("EventType")
|
|
||||||
e.Int32(s.EventType)
|
|
||||||
}
|
|
||||||
{
|
|
||||||
e.FieldStart("EventData")
|
|
||||||
s.EventData.Encode(e)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
var jsonFieldsNameOfAuditEvent = [8]string{
|
|
||||||
0: "ID",
|
|
||||||
1: "Date",
|
|
||||||
2: "User",
|
|
||||||
3: "Username",
|
|
||||||
4: "ResourceType",
|
|
||||||
5: "ResourceID",
|
|
||||||
6: "EventType",
|
|
||||||
7: "EventData",
|
|
||||||
}
|
|
||||||
|
|
||||||
// Decode decodes AuditEvent from json.
|
|
||||||
func (s *AuditEvent) Decode(d *jx.Decoder) error {
|
|
||||||
if s == nil {
|
|
||||||
return errors.New("invalid: unable to decode AuditEvent to nil")
|
|
||||||
}
|
|
||||||
var requiredBitSet [1]uint8
|
|
||||||
|
|
||||||
if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error {
|
|
||||||
switch string(k) {
|
|
||||||
case "ID":
|
|
||||||
requiredBitSet[0] |= 1 << 0
|
|
||||||
if err := func() error {
|
|
||||||
v, err := d.Int64()
|
|
||||||
s.ID = int64(v)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}(); err != nil {
|
|
||||||
return errors.Wrap(err, "decode field \"ID\"")
|
|
||||||
}
|
|
||||||
case "Date":
|
|
||||||
requiredBitSet[0] |= 1 << 1
|
|
||||||
if err := func() error {
|
|
||||||
v, err := d.Int64()
|
|
||||||
s.Date = int64(v)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}(); err != nil {
|
|
||||||
return errors.Wrap(err, "decode field \"Date\"")
|
|
||||||
}
|
|
||||||
case "User":
|
|
||||||
requiredBitSet[0] |= 1 << 2
|
|
||||||
if err := func() error {
|
|
||||||
v, err := d.Int64()
|
|
||||||
s.User = int64(v)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}(); err != nil {
|
|
||||||
return errors.Wrap(err, "decode field \"User\"")
|
|
||||||
}
|
|
||||||
case "Username":
|
|
||||||
requiredBitSet[0] |= 1 << 3
|
|
||||||
if err := func() error {
|
|
||||||
v, err := d.Str()
|
|
||||||
s.Username = string(v)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}(); err != nil {
|
|
||||||
return errors.Wrap(err, "decode field \"Username\"")
|
|
||||||
}
|
|
||||||
case "ResourceType":
|
|
||||||
requiredBitSet[0] |= 1 << 4
|
|
||||||
if err := func() error {
|
|
||||||
v, err := d.Int32()
|
|
||||||
s.ResourceType = int32(v)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}(); err != nil {
|
|
||||||
return errors.Wrap(err, "decode field \"ResourceType\"")
|
|
||||||
}
|
|
||||||
case "ResourceID":
|
|
||||||
requiredBitSet[0] |= 1 << 5
|
|
||||||
if err := func() error {
|
|
||||||
v, err := d.Int64()
|
|
||||||
s.ResourceID = int64(v)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}(); err != nil {
|
|
||||||
return errors.Wrap(err, "decode field \"ResourceID\"")
|
|
||||||
}
|
|
||||||
case "EventType":
|
|
||||||
requiredBitSet[0] |= 1 << 6
|
|
||||||
if err := func() error {
|
|
||||||
v, err := d.Int32()
|
|
||||||
s.EventType = int32(v)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}(); err != nil {
|
|
||||||
return errors.Wrap(err, "decode field \"EventType\"")
|
|
||||||
}
|
|
||||||
case "EventData":
|
|
||||||
requiredBitSet[0] |= 1 << 7
|
|
||||||
if err := func() error {
|
|
||||||
if err := s.EventData.Decode(d); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}(); err != nil {
|
|
||||||
return errors.Wrap(err, "decode field \"EventData\"")
|
|
||||||
}
|
|
||||||
default:
|
|
||||||
return d.Skip()
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}); err != nil {
|
|
||||||
return errors.Wrap(err, "decode AuditEvent")
|
|
||||||
}
|
|
||||||
// Validate required fields.
|
|
||||||
var failures []validate.FieldError
|
|
||||||
for i, mask := range [1]uint8{
|
|
||||||
0b11111111,
|
|
||||||
} {
|
|
||||||
if result := (requiredBitSet[i] & mask) ^ mask; result != 0 {
|
|
||||||
// Mask only required fields and check equality to mask using XOR.
|
|
||||||
//
|
|
||||||
// If XOR result is not zero, result is not equal to expected, so some fields are missed.
|
|
||||||
// Bits of fields which would be set are actually bits of missed fields.
|
|
||||||
missed := bits.OnesCount8(result)
|
|
||||||
for bitN := 0; bitN < missed; bitN++ {
|
|
||||||
bitIdx := bits.TrailingZeros8(result)
|
|
||||||
fieldIdx := i*8 + bitIdx
|
|
||||||
var name string
|
|
||||||
if fieldIdx < len(jsonFieldsNameOfAuditEvent) {
|
|
||||||
name = jsonFieldsNameOfAuditEvent[fieldIdx]
|
|
||||||
} else {
|
|
||||||
name = strconv.Itoa(fieldIdx)
|
|
||||||
}
|
|
||||||
failures = append(failures, validate.FieldError{
|
|
||||||
Name: name,
|
|
||||||
Error: validate.ErrFieldRequired,
|
|
||||||
})
|
|
||||||
// Reset bit.
|
|
||||||
result &^= 1 << bitIdx
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if len(failures) > 0 {
|
|
||||||
return &validate.Error{Fields: failures}
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// MarshalJSON implements stdjson.Marshaler.
|
|
||||||
func (s *AuditEvent) MarshalJSON() ([]byte, error) {
|
|
||||||
e := jx.Encoder{}
|
|
||||||
s.Encode(&e)
|
|
||||||
return e.Bytes(), nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// UnmarshalJSON implements stdjson.Unmarshaler.
|
|
||||||
func (s *AuditEvent) UnmarshalJSON(data []byte) error {
|
|
||||||
d := jx.DecodeBytes(data)
|
|
||||||
return s.Decode(d)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Encode implements json.Marshaler.
|
|
||||||
func (s AuditEventEventData) Encode(e *jx.Encoder) {
|
|
||||||
e.ObjStart()
|
|
||||||
s.encodeFields(e)
|
|
||||||
e.ObjEnd()
|
|
||||||
}
|
|
||||||
|
|
||||||
// encodeFields implements json.Marshaler.
|
|
||||||
func (s AuditEventEventData) encodeFields(e *jx.Encoder) {
|
|
||||||
for k, elem := range s {
|
|
||||||
e.FieldStart(k)
|
|
||||||
|
|
||||||
if len(elem) != 0 {
|
|
||||||
e.Raw(elem)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Decode decodes AuditEventEventData from json.
|
|
||||||
func (s *AuditEventEventData) Decode(d *jx.Decoder) error {
|
|
||||||
if s == nil {
|
|
||||||
return errors.New("invalid: unable to decode AuditEventEventData to nil")
|
|
||||||
}
|
|
||||||
m := s.init()
|
|
||||||
if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error {
|
|
||||||
var elem jx.Raw
|
|
||||||
if err := func() error {
|
|
||||||
v, err := d.RawAppend(nil)
|
|
||||||
elem = jx.Raw(v)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}(); err != nil {
|
|
||||||
return errors.Wrapf(err, "decode field %q", k)
|
|
||||||
}
|
|
||||||
m[string(k)] = elem
|
|
||||||
return nil
|
|
||||||
}); err != nil {
|
|
||||||
return errors.Wrap(err, "decode AuditEventEventData")
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// MarshalJSON implements stdjson.Marshaler.
|
|
||||||
func (s AuditEventEventData) MarshalJSON() ([]byte, error) {
|
|
||||||
e := jx.Encoder{}
|
|
||||||
s.Encode(&e)
|
|
||||||
return e.Bytes(), nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// UnmarshalJSON implements stdjson.Unmarshaler.
|
|
||||||
func (s *AuditEventEventData) UnmarshalJSON(data []byte) error {
|
|
||||||
d := jx.DecodeBytes(data)
|
|
||||||
return s.Decode(d)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Encode implements json.Marshaler.
|
// Encode implements json.Marshaler.
|
||||||
func (s *Error) Encode(e *jx.Encoder) {
|
func (s *Error) Encode(e *jx.Encoder) {
|
||||||
e.ObjStart()
|
e.ObjStart()
|
||||||
@@ -619,8 +348,8 @@ func (s *Mapfix) encodeFields(e *jx.Encoder) {
|
|||||||
e.Int32(s.StatusID)
|
e.Int32(s.StatusID)
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
e.FieldStart("Description")
|
e.FieldStart("StatusMessage")
|
||||||
e.Str(s.Description)
|
e.Str(s.StatusMessage)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -637,7 +366,7 @@ var jsonFieldsNameOfMapfix = [13]string{
|
|||||||
9: "Completed",
|
9: "Completed",
|
||||||
10: "TargetAssetID",
|
10: "TargetAssetID",
|
||||||
11: "StatusID",
|
11: "StatusID",
|
||||||
12: "Description",
|
12: "StatusMessage",
|
||||||
}
|
}
|
||||||
|
|
||||||
// Decode decodes Mapfix from json.
|
// Decode decodes Mapfix from json.
|
||||||
@@ -793,17 +522,17 @@ func (s *Mapfix) Decode(d *jx.Decoder) error {
|
|||||||
}(); err != nil {
|
}(); err != nil {
|
||||||
return errors.Wrap(err, "decode field \"StatusID\"")
|
return errors.Wrap(err, "decode field \"StatusID\"")
|
||||||
}
|
}
|
||||||
case "Description":
|
case "StatusMessage":
|
||||||
requiredBitSet[1] |= 1 << 4
|
requiredBitSet[1] |= 1 << 4
|
||||||
if err := func() error {
|
if err := func() error {
|
||||||
v, err := d.Str()
|
v, err := d.Str()
|
||||||
s.Description = string(v)
|
s.StatusMessage = string(v)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}(); err != nil {
|
}(); err != nil {
|
||||||
return errors.Wrap(err, "decode field \"Description\"")
|
return errors.Wrap(err, "decode field \"StatusMessage\"")
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
return d.Skip()
|
return d.Skip()
|
||||||
@@ -879,16 +608,11 @@ func (s *MapfixTriggerCreate) encodeFields(e *jx.Encoder) {
|
|||||||
e.FieldStart("TargetAssetID")
|
e.FieldStart("TargetAssetID")
|
||||||
e.Int64(s.TargetAssetID)
|
e.Int64(s.TargetAssetID)
|
||||||
}
|
}
|
||||||
{
|
|
||||||
e.FieldStart("Description")
|
|
||||||
e.Str(s.Description)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var jsonFieldsNameOfMapfixTriggerCreate = [3]string{
|
var jsonFieldsNameOfMapfixTriggerCreate = [2]string{
|
||||||
0: "AssetID",
|
0: "AssetID",
|
||||||
1: "TargetAssetID",
|
1: "TargetAssetID",
|
||||||
2: "Description",
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Decode decodes MapfixTriggerCreate from json.
|
// Decode decodes MapfixTriggerCreate from json.
|
||||||
@@ -924,18 +648,6 @@ func (s *MapfixTriggerCreate) Decode(d *jx.Decoder) error {
|
|||||||
}(); err != nil {
|
}(); err != nil {
|
||||||
return errors.Wrap(err, "decode field \"TargetAssetID\"")
|
return errors.Wrap(err, "decode field \"TargetAssetID\"")
|
||||||
}
|
}
|
||||||
case "Description":
|
|
||||||
requiredBitSet[0] |= 1 << 2
|
|
||||||
if err := func() error {
|
|
||||||
v, err := d.Str()
|
|
||||||
s.Description = string(v)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}(); err != nil {
|
|
||||||
return errors.Wrap(err, "decode field \"Description\"")
|
|
||||||
}
|
|
||||||
default:
|
default:
|
||||||
return d.Skip()
|
return d.Skip()
|
||||||
}
|
}
|
||||||
@@ -946,7 +658,7 @@ func (s *MapfixTriggerCreate) Decode(d *jx.Decoder) error {
|
|||||||
// Validate required fields.
|
// Validate required fields.
|
||||||
var failures []validate.FieldError
|
var failures []validate.FieldError
|
||||||
for i, mask := range [1]uint8{
|
for i, mask := range [1]uint8{
|
||||||
0b00000111,
|
0b00000011,
|
||||||
} {
|
} {
|
||||||
if result := (requiredBitSet[i] & mask) ^ mask; result != 0 {
|
if result := (requiredBitSet[i] & mask) ^ mask; result != 0 {
|
||||||
// Mask only required fields and check equality to mask using XOR.
|
// Mask only required fields and check equality to mask using XOR.
|
||||||
@@ -992,129 +704,6 @@ func (s *MapfixTriggerCreate) UnmarshalJSON(data []byte) error {
|
|||||||
return s.Decode(d)
|
return s.Decode(d)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Encode implements json.Marshaler.
|
|
||||||
func (s *Mapfixes) Encode(e *jx.Encoder) {
|
|
||||||
e.ObjStart()
|
|
||||||
s.encodeFields(e)
|
|
||||||
e.ObjEnd()
|
|
||||||
}
|
|
||||||
|
|
||||||
// encodeFields encodes fields.
|
|
||||||
func (s *Mapfixes) encodeFields(e *jx.Encoder) {
|
|
||||||
{
|
|
||||||
e.FieldStart("Total")
|
|
||||||
e.Int64(s.Total)
|
|
||||||
}
|
|
||||||
{
|
|
||||||
e.FieldStart("Mapfixes")
|
|
||||||
e.ArrStart()
|
|
||||||
for _, elem := range s.Mapfixes {
|
|
||||||
elem.Encode(e)
|
|
||||||
}
|
|
||||||
e.ArrEnd()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
var jsonFieldsNameOfMapfixes = [2]string{
|
|
||||||
0: "Total",
|
|
||||||
1: "Mapfixes",
|
|
||||||
}
|
|
||||||
|
|
||||||
// Decode decodes Mapfixes from json.
|
|
||||||
func (s *Mapfixes) Decode(d *jx.Decoder) error {
|
|
||||||
if s == nil {
|
|
||||||
return errors.New("invalid: unable to decode Mapfixes to nil")
|
|
||||||
}
|
|
||||||
var requiredBitSet [1]uint8
|
|
||||||
|
|
||||||
if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error {
|
|
||||||
switch string(k) {
|
|
||||||
case "Total":
|
|
||||||
requiredBitSet[0] |= 1 << 0
|
|
||||||
if err := func() error {
|
|
||||||
v, err := d.Int64()
|
|
||||||
s.Total = int64(v)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}(); err != nil {
|
|
||||||
return errors.Wrap(err, "decode field \"Total\"")
|
|
||||||
}
|
|
||||||
case "Mapfixes":
|
|
||||||
requiredBitSet[0] |= 1 << 1
|
|
||||||
if err := func() error {
|
|
||||||
s.Mapfixes = make([]Mapfix, 0)
|
|
||||||
if err := d.Arr(func(d *jx.Decoder) error {
|
|
||||||
var elem Mapfix
|
|
||||||
if err := elem.Decode(d); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
s.Mapfixes = append(s.Mapfixes, elem)
|
|
||||||
return nil
|
|
||||||
}); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}(); err != nil {
|
|
||||||
return errors.Wrap(err, "decode field \"Mapfixes\"")
|
|
||||||
}
|
|
||||||
default:
|
|
||||||
return d.Skip()
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}); err != nil {
|
|
||||||
return errors.Wrap(err, "decode Mapfixes")
|
|
||||||
}
|
|
||||||
// Validate required fields.
|
|
||||||
var failures []validate.FieldError
|
|
||||||
for i, mask := range [1]uint8{
|
|
||||||
0b00000011,
|
|
||||||
} {
|
|
||||||
if result := (requiredBitSet[i] & mask) ^ mask; result != 0 {
|
|
||||||
// Mask only required fields and check equality to mask using XOR.
|
|
||||||
//
|
|
||||||
// If XOR result is not zero, result is not equal to expected, so some fields are missed.
|
|
||||||
// Bits of fields which would be set are actually bits of missed fields.
|
|
||||||
missed := bits.OnesCount8(result)
|
|
||||||
for bitN := 0; bitN < missed; bitN++ {
|
|
||||||
bitIdx := bits.TrailingZeros8(result)
|
|
||||||
fieldIdx := i*8 + bitIdx
|
|
||||||
var name string
|
|
||||||
if fieldIdx < len(jsonFieldsNameOfMapfixes) {
|
|
||||||
name = jsonFieldsNameOfMapfixes[fieldIdx]
|
|
||||||
} else {
|
|
||||||
name = strconv.Itoa(fieldIdx)
|
|
||||||
}
|
|
||||||
failures = append(failures, validate.FieldError{
|
|
||||||
Name: name,
|
|
||||||
Error: validate.ErrFieldRequired,
|
|
||||||
})
|
|
||||||
// Reset bit.
|
|
||||||
result &^= 1 << bitIdx
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if len(failures) > 0 {
|
|
||||||
return &validate.Error{Fields: failures}
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// MarshalJSON implements stdjson.Marshaler.
|
|
||||||
func (s *Mapfixes) MarshalJSON() ([]byte, error) {
|
|
||||||
e := jx.Encoder{}
|
|
||||||
s.Encode(&e)
|
|
||||||
return e.Bytes(), nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// UnmarshalJSON implements stdjson.Unmarshaler.
|
|
||||||
func (s *Mapfixes) UnmarshalJSON(data []byte) error {
|
|
||||||
d := jx.DecodeBytes(data)
|
|
||||||
return s.Decode(d)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Encode implements json.Marshaler.
|
// Encode implements json.Marshaler.
|
||||||
func (s *Operation) Encode(e *jx.Encoder) {
|
func (s *Operation) Encode(e *jx.Encoder) {
|
||||||
e.ObjStart()
|
e.ObjStart()
|
||||||
@@ -2885,9 +2474,13 @@ func (s *Submission) encodeFields(e *jx.Encoder) {
|
|||||||
e.FieldStart("StatusID")
|
e.FieldStart("StatusID")
|
||||||
e.Int32(s.StatusID)
|
e.Int32(s.StatusID)
|
||||||
}
|
}
|
||||||
|
{
|
||||||
|
e.FieldStart("StatusMessage")
|
||||||
|
e.Str(s.StatusMessage)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var jsonFieldsNameOfSubmission = [14]string{
|
var jsonFieldsNameOfSubmission = [15]string{
|
||||||
0: "ID",
|
0: "ID",
|
||||||
1: "DisplayName",
|
1: "DisplayName",
|
||||||
2: "Creator",
|
2: "Creator",
|
||||||
@@ -2902,6 +2495,7 @@ var jsonFieldsNameOfSubmission = [14]string{
|
|||||||
11: "Completed",
|
11: "Completed",
|
||||||
12: "UploadedAssetID",
|
12: "UploadedAssetID",
|
||||||
13: "StatusID",
|
13: "StatusID",
|
||||||
|
14: "StatusMessage",
|
||||||
}
|
}
|
||||||
|
|
||||||
// Decode decodes Submission from json.
|
// Decode decodes Submission from json.
|
||||||
@@ -3075,6 +2669,18 @@ func (s *Submission) Decode(d *jx.Decoder) error {
|
|||||||
}(); err != nil {
|
}(); err != nil {
|
||||||
return errors.Wrap(err, "decode field \"StatusID\"")
|
return errors.Wrap(err, "decode field \"StatusID\"")
|
||||||
}
|
}
|
||||||
|
case "StatusMessage":
|
||||||
|
requiredBitSet[1] |= 1 << 6
|
||||||
|
if err := func() error {
|
||||||
|
v, err := d.Str()
|
||||||
|
s.StatusMessage = string(v)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}(); err != nil {
|
||||||
|
return errors.Wrap(err, "decode field \"StatusMessage\"")
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
return d.Skip()
|
return d.Skip()
|
||||||
}
|
}
|
||||||
@@ -3086,7 +2692,7 @@ func (s *Submission) Decode(d *jx.Decoder) error {
|
|||||||
var failures []validate.FieldError
|
var failures []validate.FieldError
|
||||||
for i, mask := range [2]uint8{
|
for i, mask := range [2]uint8{
|
||||||
0b11111111,
|
0b11111111,
|
||||||
0b00101001,
|
0b01101001,
|
||||||
} {
|
} {
|
||||||
if result := (requiredBitSet[i] & mask) ^ mask; result != 0 {
|
if result := (requiredBitSet[i] & mask) ^ mask; result != 0 {
|
||||||
// Mask only required fields and check equality to mask using XOR.
|
// Mask only required fields and check equality to mask using XOR.
|
||||||
@@ -3145,25 +2751,10 @@ func (s *SubmissionTriggerCreate) encodeFields(e *jx.Encoder) {
|
|||||||
e.FieldStart("AssetID")
|
e.FieldStart("AssetID")
|
||||||
e.Int64(s.AssetID)
|
e.Int64(s.AssetID)
|
||||||
}
|
}
|
||||||
{
|
|
||||||
e.FieldStart("DisplayName")
|
|
||||||
e.Str(s.DisplayName)
|
|
||||||
}
|
|
||||||
{
|
|
||||||
e.FieldStart("Creator")
|
|
||||||
e.Str(s.Creator)
|
|
||||||
}
|
|
||||||
{
|
|
||||||
e.FieldStart("GameID")
|
|
||||||
e.Int32(s.GameID)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var jsonFieldsNameOfSubmissionTriggerCreate = [4]string{
|
var jsonFieldsNameOfSubmissionTriggerCreate = [1]string{
|
||||||
0: "AssetID",
|
0: "AssetID",
|
||||||
1: "DisplayName",
|
|
||||||
2: "Creator",
|
|
||||||
3: "GameID",
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Decode decodes SubmissionTriggerCreate from json.
|
// Decode decodes SubmissionTriggerCreate from json.
|
||||||
@@ -3187,42 +2778,6 @@ func (s *SubmissionTriggerCreate) Decode(d *jx.Decoder) error {
|
|||||||
}(); err != nil {
|
}(); err != nil {
|
||||||
return errors.Wrap(err, "decode field \"AssetID\"")
|
return errors.Wrap(err, "decode field \"AssetID\"")
|
||||||
}
|
}
|
||||||
case "DisplayName":
|
|
||||||
requiredBitSet[0] |= 1 << 1
|
|
||||||
if err := func() error {
|
|
||||||
v, err := d.Str()
|
|
||||||
s.DisplayName = string(v)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}(); err != nil {
|
|
||||||
return errors.Wrap(err, "decode field \"DisplayName\"")
|
|
||||||
}
|
|
||||||
case "Creator":
|
|
||||||
requiredBitSet[0] |= 1 << 2
|
|
||||||
if err := func() error {
|
|
||||||
v, err := d.Str()
|
|
||||||
s.Creator = string(v)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}(); err != nil {
|
|
||||||
return errors.Wrap(err, "decode field \"Creator\"")
|
|
||||||
}
|
|
||||||
case "GameID":
|
|
||||||
requiredBitSet[0] |= 1 << 3
|
|
||||||
if err := func() error {
|
|
||||||
v, err := d.Int32()
|
|
||||||
s.GameID = int32(v)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}(); err != nil {
|
|
||||||
return errors.Wrap(err, "decode field \"GameID\"")
|
|
||||||
}
|
|
||||||
default:
|
default:
|
||||||
return d.Skip()
|
return d.Skip()
|
||||||
}
|
}
|
||||||
@@ -3233,7 +2788,7 @@ func (s *SubmissionTriggerCreate) Decode(d *jx.Decoder) error {
|
|||||||
// Validate required fields.
|
// Validate required fields.
|
||||||
var failures []validate.FieldError
|
var failures []validate.FieldError
|
||||||
for i, mask := range [1]uint8{
|
for i, mask := range [1]uint8{
|
||||||
0b00001111,
|
0b00000001,
|
||||||
} {
|
} {
|
||||||
if result := (requiredBitSet[i] & mask) ^ mask; result != 0 {
|
if result := (requiredBitSet[i] & mask) ^ mask; result != 0 {
|
||||||
// Mask only required fields and check equality to mask using XOR.
|
// Mask only required fields and check equality to mask using XOR.
|
||||||
@@ -3279,129 +2834,6 @@ func (s *SubmissionTriggerCreate) UnmarshalJSON(data []byte) error {
|
|||||||
return s.Decode(d)
|
return s.Decode(d)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Encode implements json.Marshaler.
|
|
||||||
func (s *Submissions) Encode(e *jx.Encoder) {
|
|
||||||
e.ObjStart()
|
|
||||||
s.encodeFields(e)
|
|
||||||
e.ObjEnd()
|
|
||||||
}
|
|
||||||
|
|
||||||
// encodeFields encodes fields.
|
|
||||||
func (s *Submissions) encodeFields(e *jx.Encoder) {
|
|
||||||
{
|
|
||||||
e.FieldStart("Total")
|
|
||||||
e.Int64(s.Total)
|
|
||||||
}
|
|
||||||
{
|
|
||||||
e.FieldStart("Submissions")
|
|
||||||
e.ArrStart()
|
|
||||||
for _, elem := range s.Submissions {
|
|
||||||
elem.Encode(e)
|
|
||||||
}
|
|
||||||
e.ArrEnd()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
var jsonFieldsNameOfSubmissions = [2]string{
|
|
||||||
0: "Total",
|
|
||||||
1: "Submissions",
|
|
||||||
}
|
|
||||||
|
|
||||||
// Decode decodes Submissions from json.
|
|
||||||
func (s *Submissions) Decode(d *jx.Decoder) error {
|
|
||||||
if s == nil {
|
|
||||||
return errors.New("invalid: unable to decode Submissions to nil")
|
|
||||||
}
|
|
||||||
var requiredBitSet [1]uint8
|
|
||||||
|
|
||||||
if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error {
|
|
||||||
switch string(k) {
|
|
||||||
case "Total":
|
|
||||||
requiredBitSet[0] |= 1 << 0
|
|
||||||
if err := func() error {
|
|
||||||
v, err := d.Int64()
|
|
||||||
s.Total = int64(v)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}(); err != nil {
|
|
||||||
return errors.Wrap(err, "decode field \"Total\"")
|
|
||||||
}
|
|
||||||
case "Submissions":
|
|
||||||
requiredBitSet[0] |= 1 << 1
|
|
||||||
if err := func() error {
|
|
||||||
s.Submissions = make([]Submission, 0)
|
|
||||||
if err := d.Arr(func(d *jx.Decoder) error {
|
|
||||||
var elem Submission
|
|
||||||
if err := elem.Decode(d); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
s.Submissions = append(s.Submissions, elem)
|
|
||||||
return nil
|
|
||||||
}); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}(); err != nil {
|
|
||||||
return errors.Wrap(err, "decode field \"Submissions\"")
|
|
||||||
}
|
|
||||||
default:
|
|
||||||
return d.Skip()
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}); err != nil {
|
|
||||||
return errors.Wrap(err, "decode Submissions")
|
|
||||||
}
|
|
||||||
// Validate required fields.
|
|
||||||
var failures []validate.FieldError
|
|
||||||
for i, mask := range [1]uint8{
|
|
||||||
0b00000011,
|
|
||||||
} {
|
|
||||||
if result := (requiredBitSet[i] & mask) ^ mask; result != 0 {
|
|
||||||
// Mask only required fields and check equality to mask using XOR.
|
|
||||||
//
|
|
||||||
// If XOR result is not zero, result is not equal to expected, so some fields are missed.
|
|
||||||
// Bits of fields which would be set are actually bits of missed fields.
|
|
||||||
missed := bits.OnesCount8(result)
|
|
||||||
for bitN := 0; bitN < missed; bitN++ {
|
|
||||||
bitIdx := bits.TrailingZeros8(result)
|
|
||||||
fieldIdx := i*8 + bitIdx
|
|
||||||
var name string
|
|
||||||
if fieldIdx < len(jsonFieldsNameOfSubmissions) {
|
|
||||||
name = jsonFieldsNameOfSubmissions[fieldIdx]
|
|
||||||
} else {
|
|
||||||
name = strconv.Itoa(fieldIdx)
|
|
||||||
}
|
|
||||||
failures = append(failures, validate.FieldError{
|
|
||||||
Name: name,
|
|
||||||
Error: validate.ErrFieldRequired,
|
|
||||||
})
|
|
||||||
// Reset bit.
|
|
||||||
result &^= 1 << bitIdx
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if len(failures) > 0 {
|
|
||||||
return &validate.Error{Fields: failures}
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// MarshalJSON implements stdjson.Marshaler.
|
|
||||||
func (s *Submissions) MarshalJSON() ([]byte, error) {
|
|
||||||
e := jx.Encoder{}
|
|
||||||
s.Encode(&e)
|
|
||||||
return e.Bytes(), nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// UnmarshalJSON implements stdjson.Unmarshaler.
|
|
||||||
func (s *Submissions) UnmarshalJSON(data []byte) error {
|
|
||||||
d := jx.DecodeBytes(data)
|
|
||||||
return s.Decode(d)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Encode implements json.Marshaler.
|
// Encode implements json.Marshaler.
|
||||||
func (s *User) Encode(e *jx.Encoder) {
|
func (s *User) Encode(e *jx.Encoder) {
|
||||||
e.ObjStart()
|
e.ObjStart()
|
||||||
|
|||||||
@@ -6,59 +6,49 @@ package api
|
|||||||
type OperationName = string
|
type OperationName = string
|
||||||
|
|
||||||
const (
|
const (
|
||||||
ActionMapfixAcceptedOperation OperationName = "ActionMapfixAccepted"
|
ActionMapfixAcceptedOperation OperationName = "ActionMapfixAccepted"
|
||||||
ActionMapfixRejectOperation OperationName = "ActionMapfixReject"
|
ActionMapfixRejectOperation OperationName = "ActionMapfixReject"
|
||||||
ActionMapfixRequestChangesOperation OperationName = "ActionMapfixRequestChanges"
|
ActionMapfixRequestChangesOperation OperationName = "ActionMapfixRequestChanges"
|
||||||
ActionMapfixResetSubmittingOperation OperationName = "ActionMapfixResetSubmitting"
|
ActionMapfixRetryValidateOperation OperationName = "ActionMapfixRetryValidate"
|
||||||
ActionMapfixRetryValidateOperation OperationName = "ActionMapfixRetryValidate"
|
ActionMapfixRevokeOperation OperationName = "ActionMapfixRevoke"
|
||||||
ActionMapfixRevokeOperation OperationName = "ActionMapfixRevoke"
|
ActionMapfixSubmitOperation OperationName = "ActionMapfixSubmit"
|
||||||
ActionMapfixTriggerSubmitOperation OperationName = "ActionMapfixTriggerSubmit"
|
ActionMapfixTriggerUploadOperation OperationName = "ActionMapfixTriggerUpload"
|
||||||
ActionMapfixTriggerSubmitUncheckedOperation OperationName = "ActionMapfixTriggerSubmitUnchecked"
|
ActionMapfixTriggerValidateOperation OperationName = "ActionMapfixTriggerValidate"
|
||||||
ActionMapfixTriggerUploadOperation OperationName = "ActionMapfixTriggerUpload"
|
ActionMapfixValidatedOperation OperationName = "ActionMapfixValidated"
|
||||||
ActionMapfixTriggerValidateOperation OperationName = "ActionMapfixTriggerValidate"
|
ActionSubmissionAcceptedOperation OperationName = "ActionSubmissionAccepted"
|
||||||
ActionMapfixValidatedOperation OperationName = "ActionMapfixValidated"
|
ActionSubmissionRejectOperation OperationName = "ActionSubmissionReject"
|
||||||
ActionSubmissionAcceptedOperation OperationName = "ActionSubmissionAccepted"
|
ActionSubmissionRequestChangesOperation OperationName = "ActionSubmissionRequestChanges"
|
||||||
ActionSubmissionRejectOperation OperationName = "ActionSubmissionReject"
|
ActionSubmissionRetryValidateOperation OperationName = "ActionSubmissionRetryValidate"
|
||||||
ActionSubmissionRequestChangesOperation OperationName = "ActionSubmissionRequestChanges"
|
ActionSubmissionRevokeOperation OperationName = "ActionSubmissionRevoke"
|
||||||
ActionSubmissionResetSubmittingOperation OperationName = "ActionSubmissionResetSubmitting"
|
ActionSubmissionSubmitOperation OperationName = "ActionSubmissionSubmit"
|
||||||
ActionSubmissionRetryValidateOperation OperationName = "ActionSubmissionRetryValidate"
|
ActionSubmissionTriggerUploadOperation OperationName = "ActionSubmissionTriggerUpload"
|
||||||
ActionSubmissionRevokeOperation OperationName = "ActionSubmissionRevoke"
|
ActionSubmissionTriggerValidateOperation OperationName = "ActionSubmissionTriggerValidate"
|
||||||
ActionSubmissionTriggerSubmitOperation OperationName = "ActionSubmissionTriggerSubmit"
|
ActionSubmissionValidatedOperation OperationName = "ActionSubmissionValidated"
|
||||||
ActionSubmissionTriggerSubmitUncheckedOperation OperationName = "ActionSubmissionTriggerSubmitUnchecked"
|
CreateMapfixOperation OperationName = "CreateMapfix"
|
||||||
ActionSubmissionTriggerUploadOperation OperationName = "ActionSubmissionTriggerUpload"
|
CreateScriptOperation OperationName = "CreateScript"
|
||||||
ActionSubmissionTriggerValidateOperation OperationName = "ActionSubmissionTriggerValidate"
|
CreateScriptPolicyOperation OperationName = "CreateScriptPolicy"
|
||||||
ActionSubmissionValidatedOperation OperationName = "ActionSubmissionValidated"
|
CreateSubmissionOperation OperationName = "CreateSubmission"
|
||||||
CreateMapfixOperation OperationName = "CreateMapfix"
|
DeleteScriptOperation OperationName = "DeleteScript"
|
||||||
CreateMapfixAuditCommentOperation OperationName = "CreateMapfixAuditComment"
|
DeleteScriptPolicyOperation OperationName = "DeleteScriptPolicy"
|
||||||
CreateScriptOperation OperationName = "CreateScript"
|
GetMapOperation OperationName = "GetMap"
|
||||||
CreateScriptPolicyOperation OperationName = "CreateScriptPolicy"
|
GetMapfixOperation OperationName = "GetMapfix"
|
||||||
CreateSubmissionOperation OperationName = "CreateSubmission"
|
GetOperationOperation OperationName = "GetOperation"
|
||||||
CreateSubmissionAdminOperation OperationName = "CreateSubmissionAdmin"
|
GetScriptOperation OperationName = "GetScript"
|
||||||
CreateSubmissionAuditCommentOperation OperationName = "CreateSubmissionAuditComment"
|
GetScriptPolicyOperation OperationName = "GetScriptPolicy"
|
||||||
DeleteScriptOperation OperationName = "DeleteScript"
|
GetSubmissionOperation OperationName = "GetSubmission"
|
||||||
DeleteScriptPolicyOperation OperationName = "DeleteScriptPolicy"
|
ListMapfixesOperation OperationName = "ListMapfixes"
|
||||||
GetMapOperation OperationName = "GetMap"
|
ListMapsOperation OperationName = "ListMaps"
|
||||||
GetMapAssetLocationOperation OperationName = "GetMapAssetLocation"
|
ListScriptPolicyOperation OperationName = "ListScriptPolicy"
|
||||||
GetMapfixOperation OperationName = "GetMapfix"
|
ListScriptsOperation OperationName = "ListScripts"
|
||||||
GetOperationOperation OperationName = "GetOperation"
|
ListSubmissionsOperation OperationName = "ListSubmissions"
|
||||||
GetScriptOperation OperationName = "GetScript"
|
ReleaseSubmissionsOperation OperationName = "ReleaseSubmissions"
|
||||||
GetScriptPolicyOperation OperationName = "GetScriptPolicy"
|
SessionRolesOperation OperationName = "SessionRoles"
|
||||||
GetSubmissionOperation OperationName = "GetSubmission"
|
SessionUserOperation OperationName = "SessionUser"
|
||||||
ListMapfixAuditEventsOperation OperationName = "ListMapfixAuditEvents"
|
SessionValidateOperation OperationName = "SessionValidate"
|
||||||
ListMapfixesOperation OperationName = "ListMapfixes"
|
SetMapfixCompletedOperation OperationName = "SetMapfixCompleted"
|
||||||
ListMapsOperation OperationName = "ListMaps"
|
SetSubmissionCompletedOperation OperationName = "SetSubmissionCompleted"
|
||||||
ListScriptPolicyOperation OperationName = "ListScriptPolicy"
|
UpdateMapfixModelOperation OperationName = "UpdateMapfixModel"
|
||||||
ListScriptsOperation OperationName = "ListScripts"
|
UpdateScriptOperation OperationName = "UpdateScript"
|
||||||
ListSubmissionAuditEventsOperation OperationName = "ListSubmissionAuditEvents"
|
UpdateScriptPolicyOperation OperationName = "UpdateScriptPolicy"
|
||||||
ListSubmissionsOperation OperationName = "ListSubmissions"
|
UpdateSubmissionModelOperation OperationName = "UpdateSubmissionModel"
|
||||||
ReleaseSubmissionsOperation OperationName = "ReleaseSubmissions"
|
|
||||||
SessionRolesOperation OperationName = "SessionRoles"
|
|
||||||
SessionUserOperation OperationName = "SessionUser"
|
|
||||||
SessionValidateOperation OperationName = "SessionValidate"
|
|
||||||
SetMapfixCompletedOperation OperationName = "SetMapfixCompleted"
|
|
||||||
SetSubmissionCompletedOperation OperationName = "SetSubmissionCompleted"
|
|
||||||
UpdateMapfixModelOperation OperationName = "UpdateMapfixModel"
|
|
||||||
UpdateScriptOperation OperationName = "UpdateScript"
|
|
||||||
UpdateScriptPolicyOperation OperationName = "UpdateScriptPolicy"
|
|
||||||
UpdateSubmissionModelOperation OperationName = "UpdateSubmissionModel"
|
|
||||||
)
|
)
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -3,13 +3,13 @@
|
|||||||
package api
|
package api
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
|
||||||
"io"
|
"io"
|
||||||
"mime"
|
"mime"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
"github.com/go-faster/errors"
|
"github.com/go-faster/errors"
|
||||||
"github.com/go-faster/jx"
|
"github.com/go-faster/jx"
|
||||||
|
"go.uber.org/multierr"
|
||||||
|
|
||||||
"github.com/ogen-go/ogen/ogenerrors"
|
"github.com/ogen-go/ogen/ogenerrors"
|
||||||
"github.com/ogen-go/ogen/validate"
|
"github.com/ogen-go/ogen/validate"
|
||||||
@@ -26,13 +26,13 @@ func (s *Server) decodeCreateMapfixRequest(r *http.Request) (
|
|||||||
// Close in reverse order, to match defer behavior.
|
// Close in reverse order, to match defer behavior.
|
||||||
for i := len(closers) - 1; i >= 0; i-- {
|
for i := len(closers) - 1; i >= 0; i-- {
|
||||||
c := closers[i]
|
c := closers[i]
|
||||||
merr = errors.Join(merr, c())
|
merr = multierr.Append(merr, c())
|
||||||
}
|
}
|
||||||
return merr
|
return merr
|
||||||
}
|
}
|
||||||
defer func() {
|
defer func() {
|
||||||
if rerr != nil {
|
if rerr != nil {
|
||||||
rerr = errors.Join(rerr, close())
|
rerr = multierr.Append(rerr, close())
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
ct, _, err := mime.ParseMediaType(r.Header.Get("Content-Type"))
|
ct, _, err := mime.ParseMediaType(r.Header.Get("Content-Type"))
|
||||||
@@ -72,54 +72,12 @@ func (s *Server) decodeCreateMapfixRequest(r *http.Request) (
|
|||||||
}
|
}
|
||||||
return req, close, err
|
return req, close, err
|
||||||
}
|
}
|
||||||
if err := func() error {
|
|
||||||
if err := request.Validate(); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}(); err != nil {
|
|
||||||
return req, close, errors.Wrap(err, "validate")
|
|
||||||
}
|
|
||||||
return &request, close, nil
|
return &request, close, nil
|
||||||
default:
|
default:
|
||||||
return req, close, validate.InvalidContentType(ct)
|
return req, close, validate.InvalidContentType(ct)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Server) decodeCreateMapfixAuditCommentRequest(r *http.Request) (
|
|
||||||
req CreateMapfixAuditCommentReq,
|
|
||||||
close func() error,
|
|
||||||
rerr error,
|
|
||||||
) {
|
|
||||||
var closers []func() error
|
|
||||||
close = func() error {
|
|
||||||
var merr error
|
|
||||||
// Close in reverse order, to match defer behavior.
|
|
||||||
for i := len(closers) - 1; i >= 0; i-- {
|
|
||||||
c := closers[i]
|
|
||||||
merr = errors.Join(merr, c())
|
|
||||||
}
|
|
||||||
return merr
|
|
||||||
}
|
|
||||||
defer func() {
|
|
||||||
if rerr != nil {
|
|
||||||
rerr = errors.Join(rerr, close())
|
|
||||||
}
|
|
||||||
}()
|
|
||||||
ct, _, err := mime.ParseMediaType(r.Header.Get("Content-Type"))
|
|
||||||
if err != nil {
|
|
||||||
return req, close, errors.Wrap(err, "parse media type")
|
|
||||||
}
|
|
||||||
switch {
|
|
||||||
case ct == "text/plain":
|
|
||||||
reader := r.Body
|
|
||||||
request := CreateMapfixAuditCommentReq{Data: reader}
|
|
||||||
return request, close, nil
|
|
||||||
default:
|
|
||||||
return req, close, validate.InvalidContentType(ct)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *Server) decodeCreateScriptRequest(r *http.Request) (
|
func (s *Server) decodeCreateScriptRequest(r *http.Request) (
|
||||||
req *ScriptCreate,
|
req *ScriptCreate,
|
||||||
close func() error,
|
close func() error,
|
||||||
@@ -131,13 +89,13 @@ func (s *Server) decodeCreateScriptRequest(r *http.Request) (
|
|||||||
// Close in reverse order, to match defer behavior.
|
// Close in reverse order, to match defer behavior.
|
||||||
for i := len(closers) - 1; i >= 0; i-- {
|
for i := len(closers) - 1; i >= 0; i-- {
|
||||||
c := closers[i]
|
c := closers[i]
|
||||||
merr = errors.Join(merr, c())
|
merr = multierr.Append(merr, c())
|
||||||
}
|
}
|
||||||
return merr
|
return merr
|
||||||
}
|
}
|
||||||
defer func() {
|
defer func() {
|
||||||
if rerr != nil {
|
if rerr != nil {
|
||||||
rerr = errors.Join(rerr, close())
|
rerr = multierr.Append(rerr, close())
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
ct, _, err := mime.ParseMediaType(r.Header.Get("Content-Type"))
|
ct, _, err := mime.ParseMediaType(r.Header.Get("Content-Type"))
|
||||||
@@ -202,13 +160,13 @@ func (s *Server) decodeCreateScriptPolicyRequest(r *http.Request) (
|
|||||||
// Close in reverse order, to match defer behavior.
|
// Close in reverse order, to match defer behavior.
|
||||||
for i := len(closers) - 1; i >= 0; i-- {
|
for i := len(closers) - 1; i >= 0; i-- {
|
||||||
c := closers[i]
|
c := closers[i]
|
||||||
merr = errors.Join(merr, c())
|
merr = multierr.Append(merr, c())
|
||||||
}
|
}
|
||||||
return merr
|
return merr
|
||||||
}
|
}
|
||||||
defer func() {
|
defer func() {
|
||||||
if rerr != nil {
|
if rerr != nil {
|
||||||
rerr = errors.Join(rerr, close())
|
rerr = multierr.Append(rerr, close())
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
ct, _, err := mime.ParseMediaType(r.Header.Get("Content-Type"))
|
ct, _, err := mime.ParseMediaType(r.Header.Get("Content-Type"))
|
||||||
@@ -248,14 +206,6 @@ func (s *Server) decodeCreateScriptPolicyRequest(r *http.Request) (
|
|||||||
}
|
}
|
||||||
return req, close, err
|
return req, close, err
|
||||||
}
|
}
|
||||||
if err := func() error {
|
|
||||||
if err := request.Validate(); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}(); err != nil {
|
|
||||||
return req, close, errors.Wrap(err, "validate")
|
|
||||||
}
|
|
||||||
return &request, close, nil
|
return &request, close, nil
|
||||||
default:
|
default:
|
||||||
return req, close, validate.InvalidContentType(ct)
|
return req, close, validate.InvalidContentType(ct)
|
||||||
@@ -273,13 +223,13 @@ func (s *Server) decodeCreateSubmissionRequest(r *http.Request) (
|
|||||||
// Close in reverse order, to match defer behavior.
|
// Close in reverse order, to match defer behavior.
|
||||||
for i := len(closers) - 1; i >= 0; i-- {
|
for i := len(closers) - 1; i >= 0; i-- {
|
||||||
c := closers[i]
|
c := closers[i]
|
||||||
merr = errors.Join(merr, c())
|
merr = multierr.Append(merr, c())
|
||||||
}
|
}
|
||||||
return merr
|
return merr
|
||||||
}
|
}
|
||||||
defer func() {
|
defer func() {
|
||||||
if rerr != nil {
|
if rerr != nil {
|
||||||
rerr = errors.Join(rerr, close())
|
rerr = multierr.Append(rerr, close())
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
ct, _, err := mime.ParseMediaType(r.Header.Get("Content-Type"))
|
ct, _, err := mime.ParseMediaType(r.Header.Get("Content-Type"))
|
||||||
@@ -319,125 +269,12 @@ func (s *Server) decodeCreateSubmissionRequest(r *http.Request) (
|
|||||||
}
|
}
|
||||||
return req, close, err
|
return req, close, err
|
||||||
}
|
}
|
||||||
if err := func() error {
|
|
||||||
if err := request.Validate(); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}(); err != nil {
|
|
||||||
return req, close, errors.Wrap(err, "validate")
|
|
||||||
}
|
|
||||||
return &request, close, nil
|
return &request, close, nil
|
||||||
default:
|
default:
|
||||||
return req, close, validate.InvalidContentType(ct)
|
return req, close, validate.InvalidContentType(ct)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Server) decodeCreateSubmissionAdminRequest(r *http.Request) (
|
|
||||||
req *SubmissionTriggerCreate,
|
|
||||||
close func() error,
|
|
||||||
rerr error,
|
|
||||||
) {
|
|
||||||
var closers []func() error
|
|
||||||
close = func() error {
|
|
||||||
var merr error
|
|
||||||
// Close in reverse order, to match defer behavior.
|
|
||||||
for i := len(closers) - 1; i >= 0; i-- {
|
|
||||||
c := closers[i]
|
|
||||||
merr = errors.Join(merr, c())
|
|
||||||
}
|
|
||||||
return merr
|
|
||||||
}
|
|
||||||
defer func() {
|
|
||||||
if rerr != nil {
|
|
||||||
rerr = errors.Join(rerr, close())
|
|
||||||
}
|
|
||||||
}()
|
|
||||||
ct, _, err := mime.ParseMediaType(r.Header.Get("Content-Type"))
|
|
||||||
if err != nil {
|
|
||||||
return req, close, errors.Wrap(err, "parse media type")
|
|
||||||
}
|
|
||||||
switch {
|
|
||||||
case ct == "application/json":
|
|
||||||
if r.ContentLength == 0 {
|
|
||||||
return req, close, validate.ErrBodyRequired
|
|
||||||
}
|
|
||||||
buf, err := io.ReadAll(r.Body)
|
|
||||||
if err != nil {
|
|
||||||
return req, close, err
|
|
||||||
}
|
|
||||||
|
|
||||||
if len(buf) == 0 {
|
|
||||||
return req, close, validate.ErrBodyRequired
|
|
||||||
}
|
|
||||||
|
|
||||||
d := jx.DecodeBytes(buf)
|
|
||||||
|
|
||||||
var request SubmissionTriggerCreate
|
|
||||||
if err := func() error {
|
|
||||||
if err := request.Decode(d); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
if err := d.Skip(); err != io.EOF {
|
|
||||||
return errors.New("unexpected trailing data")
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}(); err != nil {
|
|
||||||
err = &ogenerrors.DecodeBodyError{
|
|
||||||
ContentType: ct,
|
|
||||||
Body: buf,
|
|
||||||
Err: err,
|
|
||||||
}
|
|
||||||
return req, close, err
|
|
||||||
}
|
|
||||||
if err := func() error {
|
|
||||||
if err := request.Validate(); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}(); err != nil {
|
|
||||||
return req, close, errors.Wrap(err, "validate")
|
|
||||||
}
|
|
||||||
return &request, close, nil
|
|
||||||
default:
|
|
||||||
return req, close, validate.InvalidContentType(ct)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *Server) decodeCreateSubmissionAuditCommentRequest(r *http.Request) (
|
|
||||||
req CreateSubmissionAuditCommentReq,
|
|
||||||
close func() error,
|
|
||||||
rerr error,
|
|
||||||
) {
|
|
||||||
var closers []func() error
|
|
||||||
close = func() error {
|
|
||||||
var merr error
|
|
||||||
// Close in reverse order, to match defer behavior.
|
|
||||||
for i := len(closers) - 1; i >= 0; i-- {
|
|
||||||
c := closers[i]
|
|
||||||
merr = errors.Join(merr, c())
|
|
||||||
}
|
|
||||||
return merr
|
|
||||||
}
|
|
||||||
defer func() {
|
|
||||||
if rerr != nil {
|
|
||||||
rerr = errors.Join(rerr, close())
|
|
||||||
}
|
|
||||||
}()
|
|
||||||
ct, _, err := mime.ParseMediaType(r.Header.Get("Content-Type"))
|
|
||||||
if err != nil {
|
|
||||||
return req, close, errors.Wrap(err, "parse media type")
|
|
||||||
}
|
|
||||||
switch {
|
|
||||||
case ct == "text/plain":
|
|
||||||
reader := r.Body
|
|
||||||
request := CreateSubmissionAuditCommentReq{Data: reader}
|
|
||||||
return request, close, nil
|
|
||||||
default:
|
|
||||||
return req, close, validate.InvalidContentType(ct)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *Server) decodeReleaseSubmissionsRequest(r *http.Request) (
|
func (s *Server) decodeReleaseSubmissionsRequest(r *http.Request) (
|
||||||
req []ReleaseInfo,
|
req []ReleaseInfo,
|
||||||
close func() error,
|
close func() error,
|
||||||
@@ -449,13 +286,13 @@ func (s *Server) decodeReleaseSubmissionsRequest(r *http.Request) (
|
|||||||
// Close in reverse order, to match defer behavior.
|
// Close in reverse order, to match defer behavior.
|
||||||
for i := len(closers) - 1; i >= 0; i-- {
|
for i := len(closers) - 1; i >= 0; i-- {
|
||||||
c := closers[i]
|
c := closers[i]
|
||||||
merr = errors.Join(merr, c())
|
merr = multierr.Append(merr, c())
|
||||||
}
|
}
|
||||||
return merr
|
return merr
|
||||||
}
|
}
|
||||||
defer func() {
|
defer func() {
|
||||||
if rerr != nil {
|
if rerr != nil {
|
||||||
rerr = errors.Join(rerr, close())
|
rerr = multierr.Append(rerr, close())
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
ct, _, err := mime.ParseMediaType(r.Header.Get("Content-Type"))
|
ct, _, err := mime.ParseMediaType(r.Header.Get("Content-Type"))
|
||||||
@@ -515,23 +352,6 @@ func (s *Server) decodeReleaseSubmissionsRequest(r *http.Request) (
|
|||||||
}).ValidateLength(len(request)); err != nil {
|
}).ValidateLength(len(request)); err != nil {
|
||||||
return errors.Wrap(err, "array")
|
return errors.Wrap(err, "array")
|
||||||
}
|
}
|
||||||
var failures []validate.FieldError
|
|
||||||
for i, elem := range request {
|
|
||||||
if err := func() error {
|
|
||||||
if err := elem.Validate(); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}(); err != nil {
|
|
||||||
failures = append(failures, validate.FieldError{
|
|
||||||
Name: fmt.Sprintf("[%d]", i),
|
|
||||||
Error: err,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if len(failures) > 0 {
|
|
||||||
return &validate.Error{Fields: failures}
|
|
||||||
}
|
|
||||||
return nil
|
return nil
|
||||||
}(); err != nil {
|
}(); err != nil {
|
||||||
return req, close, errors.Wrap(err, "validate")
|
return req, close, errors.Wrap(err, "validate")
|
||||||
@@ -553,13 +373,13 @@ func (s *Server) decodeUpdateScriptRequest(r *http.Request) (
|
|||||||
// Close in reverse order, to match defer behavior.
|
// Close in reverse order, to match defer behavior.
|
||||||
for i := len(closers) - 1; i >= 0; i-- {
|
for i := len(closers) - 1; i >= 0; i-- {
|
||||||
c := closers[i]
|
c := closers[i]
|
||||||
merr = errors.Join(merr, c())
|
merr = multierr.Append(merr, c())
|
||||||
}
|
}
|
||||||
return merr
|
return merr
|
||||||
}
|
}
|
||||||
defer func() {
|
defer func() {
|
||||||
if rerr != nil {
|
if rerr != nil {
|
||||||
rerr = errors.Join(rerr, close())
|
rerr = multierr.Append(rerr, close())
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
ct, _, err := mime.ParseMediaType(r.Header.Get("Content-Type"))
|
ct, _, err := mime.ParseMediaType(r.Header.Get("Content-Type"))
|
||||||
@@ -624,13 +444,13 @@ func (s *Server) decodeUpdateScriptPolicyRequest(r *http.Request) (
|
|||||||
// Close in reverse order, to match defer behavior.
|
// Close in reverse order, to match defer behavior.
|
||||||
for i := len(closers) - 1; i >= 0; i-- {
|
for i := len(closers) - 1; i >= 0; i-- {
|
||||||
c := closers[i]
|
c := closers[i]
|
||||||
merr = errors.Join(merr, c())
|
merr = multierr.Append(merr, c())
|
||||||
}
|
}
|
||||||
return merr
|
return merr
|
||||||
}
|
}
|
||||||
defer func() {
|
defer func() {
|
||||||
if rerr != nil {
|
if rerr != nil {
|
||||||
rerr = errors.Join(rerr, close())
|
rerr = multierr.Append(rerr, close())
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
ct, _, err := mime.ParseMediaType(r.Header.Get("Content-Type"))
|
ct, _, err := mime.ParseMediaType(r.Header.Get("Content-Type"))
|
||||||
@@ -670,14 +490,6 @@ func (s *Server) decodeUpdateScriptPolicyRequest(r *http.Request) (
|
|||||||
}
|
}
|
||||||
return req, close, err
|
return req, close, err
|
||||||
}
|
}
|
||||||
if err := func() error {
|
|
||||||
if err := request.Validate(); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}(); err != nil {
|
|
||||||
return req, close, errors.Wrap(err, "validate")
|
|
||||||
}
|
|
||||||
return &request, close, nil
|
return &request, close, nil
|
||||||
default:
|
default:
|
||||||
return req, close, validate.InvalidContentType(ct)
|
return req, close, validate.InvalidContentType(ct)
|
||||||
|
|||||||
@@ -25,16 +25,6 @@ func encodeCreateMapfixRequest(
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func encodeCreateMapfixAuditCommentRequest(
|
|
||||||
req CreateMapfixAuditCommentReq,
|
|
||||||
r *http.Request,
|
|
||||||
) error {
|
|
||||||
const contentType = "text/plain"
|
|
||||||
body := req
|
|
||||||
ht.SetBody(r, body, contentType)
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func encodeCreateScriptRequest(
|
func encodeCreateScriptRequest(
|
||||||
req *ScriptCreate,
|
req *ScriptCreate,
|
||||||
r *http.Request,
|
r *http.Request,
|
||||||
@@ -77,30 +67,6 @@ func encodeCreateSubmissionRequest(
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func encodeCreateSubmissionAdminRequest(
|
|
||||||
req *SubmissionTriggerCreate,
|
|
||||||
r *http.Request,
|
|
||||||
) error {
|
|
||||||
const contentType = "application/json"
|
|
||||||
e := new(jx.Encoder)
|
|
||||||
{
|
|
||||||
req.Encode(e)
|
|
||||||
}
|
|
||||||
encoded := e.Bytes()
|
|
||||||
ht.SetBody(r, bytes.NewReader(encoded), contentType)
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func encodeCreateSubmissionAuditCommentRequest(
|
|
||||||
req CreateSubmissionAuditCommentReq,
|
|
||||||
r *http.Request,
|
|
||||||
) error {
|
|
||||||
const contentType = "text/plain"
|
|
||||||
body := req
|
|
||||||
ht.SetBody(r, body, contentType)
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func encodeReleaseSubmissionsRequest(
|
func encodeReleaseSubmissionsRequest(
|
||||||
req []ReleaseInfo,
|
req []ReleaseInfo,
|
||||||
r *http.Request,
|
r *http.Request,
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -3,7 +3,6 @@
|
|||||||
package api
|
package api
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"io"
|
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
"github.com/go-faster/errors"
|
"github.com/go-faster/errors"
|
||||||
@@ -35,13 +34,6 @@ func encodeActionMapfixRequestChangesResponse(response *ActionMapfixRequestChang
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func encodeActionMapfixResetSubmittingResponse(response *ActionMapfixResetSubmittingNoContent, w http.ResponseWriter, span trace.Span) error {
|
|
||||||
w.WriteHeader(204)
|
|
||||||
span.SetStatus(codes.Ok, http.StatusText(204))
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func encodeActionMapfixRetryValidateResponse(response *ActionMapfixRetryValidateNoContent, w http.ResponseWriter, span trace.Span) error {
|
func encodeActionMapfixRetryValidateResponse(response *ActionMapfixRetryValidateNoContent, w http.ResponseWriter, span trace.Span) error {
|
||||||
w.WriteHeader(204)
|
w.WriteHeader(204)
|
||||||
span.SetStatus(codes.Ok, http.StatusText(204))
|
span.SetStatus(codes.Ok, http.StatusText(204))
|
||||||
@@ -56,14 +48,7 @@ func encodeActionMapfixRevokeResponse(response *ActionMapfixRevokeNoContent, w h
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func encodeActionMapfixTriggerSubmitResponse(response *ActionMapfixTriggerSubmitNoContent, w http.ResponseWriter, span trace.Span) error {
|
func encodeActionMapfixSubmitResponse(response *ActionMapfixSubmitNoContent, w http.ResponseWriter, span trace.Span) error {
|
||||||
w.WriteHeader(204)
|
|
||||||
span.SetStatus(codes.Ok, http.StatusText(204))
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func encodeActionMapfixTriggerSubmitUncheckedResponse(response *ActionMapfixTriggerSubmitUncheckedNoContent, w http.ResponseWriter, span trace.Span) error {
|
|
||||||
w.WriteHeader(204)
|
w.WriteHeader(204)
|
||||||
span.SetStatus(codes.Ok, http.StatusText(204))
|
span.SetStatus(codes.Ok, http.StatusText(204))
|
||||||
|
|
||||||
@@ -112,13 +97,6 @@ func encodeActionSubmissionRequestChangesResponse(response *ActionSubmissionRequ
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func encodeActionSubmissionResetSubmittingResponse(response *ActionSubmissionResetSubmittingNoContent, w http.ResponseWriter, span trace.Span) error {
|
|
||||||
w.WriteHeader(204)
|
|
||||||
span.SetStatus(codes.Ok, http.StatusText(204))
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func encodeActionSubmissionRetryValidateResponse(response *ActionSubmissionRetryValidateNoContent, w http.ResponseWriter, span trace.Span) error {
|
func encodeActionSubmissionRetryValidateResponse(response *ActionSubmissionRetryValidateNoContent, w http.ResponseWriter, span trace.Span) error {
|
||||||
w.WriteHeader(204)
|
w.WriteHeader(204)
|
||||||
span.SetStatus(codes.Ok, http.StatusText(204))
|
span.SetStatus(codes.Ok, http.StatusText(204))
|
||||||
@@ -133,14 +111,7 @@ func encodeActionSubmissionRevokeResponse(response *ActionSubmissionRevokeNoCont
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func encodeActionSubmissionTriggerSubmitResponse(response *ActionSubmissionTriggerSubmitNoContent, w http.ResponseWriter, span trace.Span) error {
|
func encodeActionSubmissionSubmitResponse(response *ActionSubmissionSubmitNoContent, w http.ResponseWriter, span trace.Span) error {
|
||||||
w.WriteHeader(204)
|
|
||||||
span.SetStatus(codes.Ok, http.StatusText(204))
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func encodeActionSubmissionTriggerSubmitUncheckedResponse(response *ActionSubmissionTriggerSubmitUncheckedNoContent, w http.ResponseWriter, span trace.Span) error {
|
|
||||||
w.WriteHeader(204)
|
w.WriteHeader(204)
|
||||||
span.SetStatus(codes.Ok, http.StatusText(204))
|
span.SetStatus(codes.Ok, http.StatusText(204))
|
||||||
|
|
||||||
@@ -182,13 +153,6 @@ func encodeCreateMapfixResponse(response *OperationID, w http.ResponseWriter, sp
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func encodeCreateMapfixAuditCommentResponse(response *CreateMapfixAuditCommentNoContent, w http.ResponseWriter, span trace.Span) error {
|
|
||||||
w.WriteHeader(204)
|
|
||||||
span.SetStatus(codes.Ok, http.StatusText(204))
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func encodeCreateScriptResponse(response *ScriptID, w http.ResponseWriter, span trace.Span) error {
|
func encodeCreateScriptResponse(response *ScriptID, w http.ResponseWriter, span trace.Span) error {
|
||||||
w.Header().Set("Content-Type", "application/json; charset=utf-8")
|
w.Header().Set("Content-Type", "application/json; charset=utf-8")
|
||||||
w.WriteHeader(201)
|
w.WriteHeader(201)
|
||||||
@@ -231,27 +195,6 @@ func encodeCreateSubmissionResponse(response *OperationID, w http.ResponseWriter
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func encodeCreateSubmissionAdminResponse(response *OperationID, w http.ResponseWriter, span trace.Span) error {
|
|
||||||
w.Header().Set("Content-Type", "application/json; charset=utf-8")
|
|
||||||
w.WriteHeader(201)
|
|
||||||
span.SetStatus(codes.Ok, http.StatusText(201))
|
|
||||||
|
|
||||||
e := new(jx.Encoder)
|
|
||||||
response.Encode(e)
|
|
||||||
if _, err := e.WriteTo(w); err != nil {
|
|
||||||
return errors.Wrap(err, "write")
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func encodeCreateSubmissionAuditCommentResponse(response *CreateSubmissionAuditCommentNoContent, w http.ResponseWriter, span trace.Span) error {
|
|
||||||
w.WriteHeader(204)
|
|
||||||
span.SetStatus(codes.Ok, http.StatusText(204))
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func encodeDeleteScriptResponse(response *DeleteScriptNoContent, w http.ResponseWriter, span trace.Span) error {
|
func encodeDeleteScriptResponse(response *DeleteScriptNoContent, w http.ResponseWriter, span trace.Span) error {
|
||||||
w.WriteHeader(204)
|
w.WriteHeader(204)
|
||||||
span.SetStatus(codes.Ok, http.StatusText(204))
|
span.SetStatus(codes.Ok, http.StatusText(204))
|
||||||
@@ -280,22 +223,6 @@ func encodeGetMapResponse(response *Map, w http.ResponseWriter, span trace.Span)
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func encodeGetMapAssetLocationResponse(response GetMapAssetLocationOK, w http.ResponseWriter, span trace.Span) error {
|
|
||||||
w.Header().Set("Content-Type", "text/plain; charset=utf-8")
|
|
||||||
w.WriteHeader(200)
|
|
||||||
span.SetStatus(codes.Ok, http.StatusText(200))
|
|
||||||
|
|
||||||
writer := w
|
|
||||||
if closer, ok := response.Data.(io.Closer); ok {
|
|
||||||
defer closer.Close()
|
|
||||||
}
|
|
||||||
if _, err := io.Copy(writer, response); err != nil {
|
|
||||||
return errors.Wrap(err, "write")
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func encodeGetMapfixResponse(response *Mapfix, w http.ResponseWriter, span trace.Span) error {
|
func encodeGetMapfixResponse(response *Mapfix, w http.ResponseWriter, span trace.Span) error {
|
||||||
w.Header().Set("Content-Type", "application/json; charset=utf-8")
|
w.Header().Set("Content-Type", "application/json; charset=utf-8")
|
||||||
w.WriteHeader(200)
|
w.WriteHeader(200)
|
||||||
@@ -366,7 +293,7 @@ func encodeGetSubmissionResponse(response *Submission, w http.ResponseWriter, sp
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func encodeListMapfixAuditEventsResponse(response []AuditEvent, w http.ResponseWriter, span trace.Span) error {
|
func encodeListMapfixesResponse(response []Mapfix, w http.ResponseWriter, span trace.Span) error {
|
||||||
w.Header().Set("Content-Type", "application/json; charset=utf-8")
|
w.Header().Set("Content-Type", "application/json; charset=utf-8")
|
||||||
w.WriteHeader(200)
|
w.WriteHeader(200)
|
||||||
span.SetStatus(codes.Ok, http.StatusText(200))
|
span.SetStatus(codes.Ok, http.StatusText(200))
|
||||||
@@ -384,20 +311,6 @@ func encodeListMapfixAuditEventsResponse(response []AuditEvent, w http.ResponseW
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func encodeListMapfixesResponse(response *Mapfixes, w http.ResponseWriter, span trace.Span) error {
|
|
||||||
w.Header().Set("Content-Type", "application/json; charset=utf-8")
|
|
||||||
w.WriteHeader(200)
|
|
||||||
span.SetStatus(codes.Ok, http.StatusText(200))
|
|
||||||
|
|
||||||
e := new(jx.Encoder)
|
|
||||||
response.Encode(e)
|
|
||||||
if _, err := e.WriteTo(w); err != nil {
|
|
||||||
return errors.Wrap(err, "write")
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func encodeListMapsResponse(response []Map, w http.ResponseWriter, span trace.Span) error {
|
func encodeListMapsResponse(response []Map, w http.ResponseWriter, span trace.Span) error {
|
||||||
w.Header().Set("Content-Type", "application/json; charset=utf-8")
|
w.Header().Set("Content-Type", "application/json; charset=utf-8")
|
||||||
w.WriteHeader(200)
|
w.WriteHeader(200)
|
||||||
@@ -452,7 +365,7 @@ func encodeListScriptsResponse(response []Script, w http.ResponseWriter, span tr
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func encodeListSubmissionAuditEventsResponse(response []AuditEvent, w http.ResponseWriter, span trace.Span) error {
|
func encodeListSubmissionsResponse(response []Submission, w http.ResponseWriter, span trace.Span) error {
|
||||||
w.Header().Set("Content-Type", "application/json; charset=utf-8")
|
w.Header().Set("Content-Type", "application/json; charset=utf-8")
|
||||||
w.WriteHeader(200)
|
w.WriteHeader(200)
|
||||||
span.SetStatus(codes.Ok, http.StatusText(200))
|
span.SetStatus(codes.Ok, http.StatusText(200))
|
||||||
@@ -470,20 +383,6 @@ func encodeListSubmissionAuditEventsResponse(response []AuditEvent, w http.Respo
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func encodeListSubmissionsResponse(response *Submissions, w http.ResponseWriter, span trace.Span) error {
|
|
||||||
w.Header().Set("Content-Type", "application/json; charset=utf-8")
|
|
||||||
w.WriteHeader(200)
|
|
||||||
span.SetStatus(codes.Ok, http.StatusText(200))
|
|
||||||
|
|
||||||
e := new(jx.Encoder)
|
|
||||||
response.Encode(e)
|
|
||||||
if _, err := e.WriteTo(w); err != nil {
|
|
||||||
return errors.Wrap(err, "write")
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func encodeReleaseSubmissionsResponse(response *ReleaseSubmissionsCreated, w http.ResponseWriter, span trace.Span) error {
|
func encodeReleaseSubmissionsResponse(response *ReleaseSubmissionsCreated, w http.ResponseWriter, span trace.Span) error {
|
||||||
w.WriteHeader(201)
|
w.WriteHeader(201)
|
||||||
span.SetStatus(codes.Ok, http.StatusText(201))
|
span.SetStatus(codes.Ok, http.StatusText(201))
|
||||||
|
|||||||
@@ -136,9 +136,9 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
|||||||
break
|
break
|
||||||
}
|
}
|
||||||
switch elem[0] {
|
switch elem[0] {
|
||||||
case 'a': // Prefix: "audit-events"
|
case 'c': // Prefix: "completed"
|
||||||
|
|
||||||
if l := len("audit-events"); len(elem) >= l && elem[0:l] == "audit-events" {
|
if l := len("completed"); len(elem) >= l && elem[0:l] == "completed" {
|
||||||
elem = elem[l:]
|
elem = elem[l:]
|
||||||
} else {
|
} else {
|
||||||
break
|
break
|
||||||
@@ -147,75 +147,17 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
|||||||
if len(elem) == 0 {
|
if len(elem) == 0 {
|
||||||
// Leaf node.
|
// Leaf node.
|
||||||
switch r.Method {
|
switch r.Method {
|
||||||
case "GET":
|
case "POST":
|
||||||
s.handleListMapfixAuditEventsRequest([1]string{
|
s.handleSetMapfixCompletedRequest([1]string{
|
||||||
args[0],
|
args[0],
|
||||||
}, elemIsEscaped, w, r)
|
}, elemIsEscaped, w, r)
|
||||||
default:
|
default:
|
||||||
s.notAllowed(w, r, "GET")
|
s.notAllowed(w, r, "POST")
|
||||||
}
|
}
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
case 'c': // Prefix: "com"
|
|
||||||
|
|
||||||
if l := len("com"); len(elem) >= l && elem[0:l] == "com" {
|
|
||||||
elem = elem[l:]
|
|
||||||
} else {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
|
|
||||||
if len(elem) == 0 {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
switch elem[0] {
|
|
||||||
case 'm': // Prefix: "ment"
|
|
||||||
|
|
||||||
if l := len("ment"); len(elem) >= l && elem[0:l] == "ment" {
|
|
||||||
elem = elem[l:]
|
|
||||||
} else {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
|
|
||||||
if len(elem) == 0 {
|
|
||||||
// Leaf node.
|
|
||||||
switch r.Method {
|
|
||||||
case "POST":
|
|
||||||
s.handleCreateMapfixAuditCommentRequest([1]string{
|
|
||||||
args[0],
|
|
||||||
}, elemIsEscaped, w, r)
|
|
||||||
default:
|
|
||||||
s.notAllowed(w, r, "POST")
|
|
||||||
}
|
|
||||||
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
case 'p': // Prefix: "pleted"
|
|
||||||
|
|
||||||
if l := len("pleted"); len(elem) >= l && elem[0:l] == "pleted" {
|
|
||||||
elem = elem[l:]
|
|
||||||
} else {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
|
|
||||||
if len(elem) == 0 {
|
|
||||||
// Leaf node.
|
|
||||||
switch r.Method {
|
|
||||||
case "POST":
|
|
||||||
s.handleSetMapfixCompletedRequest([1]string{
|
|
||||||
args[0],
|
|
||||||
}, elemIsEscaped, w, r)
|
|
||||||
default:
|
|
||||||
s.notAllowed(w, r, "POST")
|
|
||||||
}
|
|
||||||
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
case 'm': // Prefix: "model"
|
case 'm': // Prefix: "model"
|
||||||
|
|
||||||
if l := len("model"); len(elem) >= l && elem[0:l] == "model" {
|
if l := len("model"); len(elem) >= l && elem[0:l] == "model" {
|
||||||
@@ -318,28 +260,6 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
|||||||
break
|
break
|
||||||
}
|
}
|
||||||
switch elem[0] {
|
switch elem[0] {
|
||||||
case 's': // Prefix: "submitting"
|
|
||||||
|
|
||||||
if l := len("submitting"); len(elem) >= l && elem[0:l] == "submitting" {
|
|
||||||
elem = elem[l:]
|
|
||||||
} else {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
|
|
||||||
if len(elem) == 0 {
|
|
||||||
// Leaf node.
|
|
||||||
switch r.Method {
|
|
||||||
case "POST":
|
|
||||||
s.handleActionMapfixResetSubmittingRequest([1]string{
|
|
||||||
args[0],
|
|
||||||
}, elemIsEscaped, w, r)
|
|
||||||
default:
|
|
||||||
s.notAllowed(w, r, "POST")
|
|
||||||
}
|
|
||||||
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
case 'u': // Prefix: "uploading"
|
case 'u': // Prefix: "uploading"
|
||||||
|
|
||||||
if l := len("uploading"); len(elem) >= l && elem[0:l] == "uploading" {
|
if l := len("uploading"); len(elem) >= l && elem[0:l] == "uploading" {
|
||||||
@@ -432,6 +352,28 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case 's': // Prefix: "submit"
|
||||||
|
|
||||||
|
if l := len("submit"); len(elem) >= l && elem[0:l] == "submit" {
|
||||||
|
elem = elem[l:]
|
||||||
|
} else {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(elem) == 0 {
|
||||||
|
// Leaf node.
|
||||||
|
switch r.Method {
|
||||||
|
case "POST":
|
||||||
|
s.handleActionMapfixSubmitRequest([1]string{
|
||||||
|
args[0],
|
||||||
|
}, elemIsEscaped, w, r)
|
||||||
|
default:
|
||||||
|
s.notAllowed(w, r, "POST")
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
case 't': // Prefix: "trigger-"
|
case 't': // Prefix: "trigger-"
|
||||||
|
|
||||||
if l := len("trigger-"); len(elem) >= l && elem[0:l] == "trigger-" {
|
if l := len("trigger-"); len(elem) >= l && elem[0:l] == "trigger-" {
|
||||||
@@ -444,51 +386,6 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
|||||||
break
|
break
|
||||||
}
|
}
|
||||||
switch elem[0] {
|
switch elem[0] {
|
||||||
case 's': // Prefix: "submit"
|
|
||||||
|
|
||||||
if l := len("submit"); len(elem) >= l && elem[0:l] == "submit" {
|
|
||||||
elem = elem[l:]
|
|
||||||
} else {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
|
|
||||||
if len(elem) == 0 {
|
|
||||||
switch r.Method {
|
|
||||||
case "POST":
|
|
||||||
s.handleActionMapfixTriggerSubmitRequest([1]string{
|
|
||||||
args[0],
|
|
||||||
}, elemIsEscaped, w, r)
|
|
||||||
default:
|
|
||||||
s.notAllowed(w, r, "POST")
|
|
||||||
}
|
|
||||||
|
|
||||||
return
|
|
||||||
}
|
|
||||||
switch elem[0] {
|
|
||||||
case '-': // Prefix: "-unchecked"
|
|
||||||
|
|
||||||
if l := len("-unchecked"); len(elem) >= l && elem[0:l] == "-unchecked" {
|
|
||||||
elem = elem[l:]
|
|
||||||
} else {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
|
|
||||||
if len(elem) == 0 {
|
|
||||||
// Leaf node.
|
|
||||||
switch r.Method {
|
|
||||||
case "POST":
|
|
||||||
s.handleActionMapfixTriggerSubmitUncheckedRequest([1]string{
|
|
||||||
args[0],
|
|
||||||
}, elemIsEscaped, w, r)
|
|
||||||
default:
|
|
||||||
s.notAllowed(w, r, "POST")
|
|
||||||
}
|
|
||||||
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
case 'u': // Prefix: "upload"
|
case 'u': // Prefix: "upload"
|
||||||
|
|
||||||
if l := len("upload"); len(elem) >= l && elem[0:l] == "upload" {
|
if l := len("upload"); len(elem) >= l && elem[0:l] == "upload" {
|
||||||
@@ -571,15 +468,16 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Param: "MapID"
|
// Param: "MapID"
|
||||||
// Match until "/"
|
// Leaf parameter, slashes are prohibited
|
||||||
idx := strings.IndexByte(elem, '/')
|
idx := strings.IndexByte(elem, '/')
|
||||||
if idx < 0 {
|
if idx >= 0 {
|
||||||
idx = len(elem)
|
break
|
||||||
}
|
}
|
||||||
args[0] = elem[:idx]
|
args[0] = elem
|
||||||
elem = elem[idx:]
|
elem = ""
|
||||||
|
|
||||||
if len(elem) == 0 {
|
if len(elem) == 0 {
|
||||||
|
// Leaf node.
|
||||||
switch r.Method {
|
switch r.Method {
|
||||||
case "GET":
|
case "GET":
|
||||||
s.handleGetMapRequest([1]string{
|
s.handleGetMapRequest([1]string{
|
||||||
@@ -591,30 +489,6 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
|||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
switch elem[0] {
|
|
||||||
case '/': // Prefix: "/location"
|
|
||||||
|
|
||||||
if l := len("/location"); len(elem) >= l && elem[0:l] == "/location" {
|
|
||||||
elem = elem[l:]
|
|
||||||
} else {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
|
|
||||||
if len(elem) == 0 {
|
|
||||||
// Leaf node.
|
|
||||||
switch r.Method {
|
|
||||||
case "GET":
|
|
||||||
s.handleGetMapAssetLocationRequest([1]string{
|
|
||||||
args[0],
|
|
||||||
}, elemIsEscaped, w, r)
|
|
||||||
default:
|
|
||||||
s.notAllowed(w, r, "GET")
|
|
||||||
}
|
|
||||||
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -916,26 +790,6 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
switch elem[0] {
|
switch elem[0] {
|
||||||
case '-': // Prefix: "-admin"
|
|
||||||
|
|
||||||
if l := len("-admin"); len(elem) >= l && elem[0:l] == "-admin" {
|
|
||||||
elem = elem[l:]
|
|
||||||
} else {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
|
|
||||||
if len(elem) == 0 {
|
|
||||||
// Leaf node.
|
|
||||||
switch r.Method {
|
|
||||||
case "POST":
|
|
||||||
s.handleCreateSubmissionAdminRequest([0]string{}, elemIsEscaped, w, r)
|
|
||||||
default:
|
|
||||||
s.notAllowed(w, r, "POST")
|
|
||||||
}
|
|
||||||
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
case '/': // Prefix: "/"
|
case '/': // Prefix: "/"
|
||||||
|
|
||||||
if l := len("/"); len(elem) >= l && elem[0:l] == "/" {
|
if l := len("/"); len(elem) >= l && elem[0:l] == "/" {
|
||||||
@@ -978,9 +832,9 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
|||||||
break
|
break
|
||||||
}
|
}
|
||||||
switch elem[0] {
|
switch elem[0] {
|
||||||
case 'a': // Prefix: "audit-events"
|
case 'c': // Prefix: "completed"
|
||||||
|
|
||||||
if l := len("audit-events"); len(elem) >= l && elem[0:l] == "audit-events" {
|
if l := len("completed"); len(elem) >= l && elem[0:l] == "completed" {
|
||||||
elem = elem[l:]
|
elem = elem[l:]
|
||||||
} else {
|
} else {
|
||||||
break
|
break
|
||||||
@@ -989,75 +843,17 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
|||||||
if len(elem) == 0 {
|
if len(elem) == 0 {
|
||||||
// Leaf node.
|
// Leaf node.
|
||||||
switch r.Method {
|
switch r.Method {
|
||||||
case "GET":
|
case "POST":
|
||||||
s.handleListSubmissionAuditEventsRequest([1]string{
|
s.handleSetSubmissionCompletedRequest([1]string{
|
||||||
args[0],
|
args[0],
|
||||||
}, elemIsEscaped, w, r)
|
}, elemIsEscaped, w, r)
|
||||||
default:
|
default:
|
||||||
s.notAllowed(w, r, "GET")
|
s.notAllowed(w, r, "POST")
|
||||||
}
|
}
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
case 'c': // Prefix: "com"
|
|
||||||
|
|
||||||
if l := len("com"); len(elem) >= l && elem[0:l] == "com" {
|
|
||||||
elem = elem[l:]
|
|
||||||
} else {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
|
|
||||||
if len(elem) == 0 {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
switch elem[0] {
|
|
||||||
case 'm': // Prefix: "ment"
|
|
||||||
|
|
||||||
if l := len("ment"); len(elem) >= l && elem[0:l] == "ment" {
|
|
||||||
elem = elem[l:]
|
|
||||||
} else {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
|
|
||||||
if len(elem) == 0 {
|
|
||||||
// Leaf node.
|
|
||||||
switch r.Method {
|
|
||||||
case "POST":
|
|
||||||
s.handleCreateSubmissionAuditCommentRequest([1]string{
|
|
||||||
args[0],
|
|
||||||
}, elemIsEscaped, w, r)
|
|
||||||
default:
|
|
||||||
s.notAllowed(w, r, "POST")
|
|
||||||
}
|
|
||||||
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
case 'p': // Prefix: "pleted"
|
|
||||||
|
|
||||||
if l := len("pleted"); len(elem) >= l && elem[0:l] == "pleted" {
|
|
||||||
elem = elem[l:]
|
|
||||||
} else {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
|
|
||||||
if len(elem) == 0 {
|
|
||||||
// Leaf node.
|
|
||||||
switch r.Method {
|
|
||||||
case "POST":
|
|
||||||
s.handleSetSubmissionCompletedRequest([1]string{
|
|
||||||
args[0],
|
|
||||||
}, elemIsEscaped, w, r)
|
|
||||||
default:
|
|
||||||
s.notAllowed(w, r, "POST")
|
|
||||||
}
|
|
||||||
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
case 'm': // Prefix: "model"
|
case 'm': // Prefix: "model"
|
||||||
|
|
||||||
if l := len("model"); len(elem) >= l && elem[0:l] == "model" {
|
if l := len("model"); len(elem) >= l && elem[0:l] == "model" {
|
||||||
@@ -1160,28 +956,6 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
|||||||
break
|
break
|
||||||
}
|
}
|
||||||
switch elem[0] {
|
switch elem[0] {
|
||||||
case 's': // Prefix: "submitting"
|
|
||||||
|
|
||||||
if l := len("submitting"); len(elem) >= l && elem[0:l] == "submitting" {
|
|
||||||
elem = elem[l:]
|
|
||||||
} else {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
|
|
||||||
if len(elem) == 0 {
|
|
||||||
// Leaf node.
|
|
||||||
switch r.Method {
|
|
||||||
case "POST":
|
|
||||||
s.handleActionSubmissionResetSubmittingRequest([1]string{
|
|
||||||
args[0],
|
|
||||||
}, elemIsEscaped, w, r)
|
|
||||||
default:
|
|
||||||
s.notAllowed(w, r, "POST")
|
|
||||||
}
|
|
||||||
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
case 'u': // Prefix: "uploading"
|
case 'u': // Prefix: "uploading"
|
||||||
|
|
||||||
if l := len("uploading"); len(elem) >= l && elem[0:l] == "uploading" {
|
if l := len("uploading"); len(elem) >= l && elem[0:l] == "uploading" {
|
||||||
@@ -1274,6 +1048,28 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case 's': // Prefix: "submit"
|
||||||
|
|
||||||
|
if l := len("submit"); len(elem) >= l && elem[0:l] == "submit" {
|
||||||
|
elem = elem[l:]
|
||||||
|
} else {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(elem) == 0 {
|
||||||
|
// Leaf node.
|
||||||
|
switch r.Method {
|
||||||
|
case "POST":
|
||||||
|
s.handleActionSubmissionSubmitRequest([1]string{
|
||||||
|
args[0],
|
||||||
|
}, elemIsEscaped, w, r)
|
||||||
|
default:
|
||||||
|
s.notAllowed(w, r, "POST")
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
case 't': // Prefix: "trigger-"
|
case 't': // Prefix: "trigger-"
|
||||||
|
|
||||||
if l := len("trigger-"); len(elem) >= l && elem[0:l] == "trigger-" {
|
if l := len("trigger-"); len(elem) >= l && elem[0:l] == "trigger-" {
|
||||||
@@ -1286,51 +1082,6 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
|||||||
break
|
break
|
||||||
}
|
}
|
||||||
switch elem[0] {
|
switch elem[0] {
|
||||||
case 's': // Prefix: "submit"
|
|
||||||
|
|
||||||
if l := len("submit"); len(elem) >= l && elem[0:l] == "submit" {
|
|
||||||
elem = elem[l:]
|
|
||||||
} else {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
|
|
||||||
if len(elem) == 0 {
|
|
||||||
switch r.Method {
|
|
||||||
case "POST":
|
|
||||||
s.handleActionSubmissionTriggerSubmitRequest([1]string{
|
|
||||||
args[0],
|
|
||||||
}, elemIsEscaped, w, r)
|
|
||||||
default:
|
|
||||||
s.notAllowed(w, r, "POST")
|
|
||||||
}
|
|
||||||
|
|
||||||
return
|
|
||||||
}
|
|
||||||
switch elem[0] {
|
|
||||||
case '-': // Prefix: "-unchecked"
|
|
||||||
|
|
||||||
if l := len("-unchecked"); len(elem) >= l && elem[0:l] == "-unchecked" {
|
|
||||||
elem = elem[l:]
|
|
||||||
} else {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
|
|
||||||
if len(elem) == 0 {
|
|
||||||
// Leaf node.
|
|
||||||
switch r.Method {
|
|
||||||
case "POST":
|
|
||||||
s.handleActionSubmissionTriggerSubmitUncheckedRequest([1]string{
|
|
||||||
args[0],
|
|
||||||
}, elemIsEscaped, w, r)
|
|
||||||
default:
|
|
||||||
s.notAllowed(w, r, "POST")
|
|
||||||
}
|
|
||||||
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
case 'u': // Prefix: "upload"
|
case 'u': // Prefix: "upload"
|
||||||
|
|
||||||
if l := len("upload"); len(elem) >= l && elem[0:l] == "upload" {
|
if l := len("upload"); len(elem) >= l && elem[0:l] == "upload" {
|
||||||
@@ -1568,9 +1319,9 @@ func (s *Server) FindPath(method string, u *url.URL) (r Route, _ bool) {
|
|||||||
break
|
break
|
||||||
}
|
}
|
||||||
switch elem[0] {
|
switch elem[0] {
|
||||||
case 'a': // Prefix: "audit-events"
|
case 'c': // Prefix: "completed"
|
||||||
|
|
||||||
if l := len("audit-events"); len(elem) >= l && elem[0:l] == "audit-events" {
|
if l := len("completed"); len(elem) >= l && elem[0:l] == "completed" {
|
||||||
elem = elem[l:]
|
elem = elem[l:]
|
||||||
} else {
|
} else {
|
||||||
break
|
break
|
||||||
@@ -1579,11 +1330,11 @@ func (s *Server) FindPath(method string, u *url.URL) (r Route, _ bool) {
|
|||||||
if len(elem) == 0 {
|
if len(elem) == 0 {
|
||||||
// Leaf node.
|
// Leaf node.
|
||||||
switch method {
|
switch method {
|
||||||
case "GET":
|
case "POST":
|
||||||
r.name = ListMapfixAuditEventsOperation
|
r.name = SetMapfixCompletedOperation
|
||||||
r.summary = "Retrieve a list of audit events"
|
r.summary = "Called by maptest when a player completes the map"
|
||||||
r.operationID = "listMapfixAuditEvents"
|
r.operationID = "setMapfixCompleted"
|
||||||
r.pathPattern = "/mapfixes/{MapfixID}/audit-events"
|
r.pathPattern = "/mapfixes/{MapfixID}/completed"
|
||||||
r.args = args
|
r.args = args
|
||||||
r.count = 1
|
r.count = 1
|
||||||
return r, true
|
return r, true
|
||||||
@@ -1592,68 +1343,6 @@ func (s *Server) FindPath(method string, u *url.URL) (r Route, _ bool) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
case 'c': // Prefix: "com"
|
|
||||||
|
|
||||||
if l := len("com"); len(elem) >= l && elem[0:l] == "com" {
|
|
||||||
elem = elem[l:]
|
|
||||||
} else {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
|
|
||||||
if len(elem) == 0 {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
switch elem[0] {
|
|
||||||
case 'm': // Prefix: "ment"
|
|
||||||
|
|
||||||
if l := len("ment"); len(elem) >= l && elem[0:l] == "ment" {
|
|
||||||
elem = elem[l:]
|
|
||||||
} else {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
|
|
||||||
if len(elem) == 0 {
|
|
||||||
// Leaf node.
|
|
||||||
switch method {
|
|
||||||
case "POST":
|
|
||||||
r.name = CreateMapfixAuditCommentOperation
|
|
||||||
r.summary = "Post a comment to the audit log"
|
|
||||||
r.operationID = "createMapfixAuditComment"
|
|
||||||
r.pathPattern = "/mapfixes/{MapfixID}/comment"
|
|
||||||
r.args = args
|
|
||||||
r.count = 1
|
|
||||||
return r, true
|
|
||||||
default:
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
case 'p': // Prefix: "pleted"
|
|
||||||
|
|
||||||
if l := len("pleted"); len(elem) >= l && elem[0:l] == "pleted" {
|
|
||||||
elem = elem[l:]
|
|
||||||
} else {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
|
|
||||||
if len(elem) == 0 {
|
|
||||||
// Leaf node.
|
|
||||||
switch method {
|
|
||||||
case "POST":
|
|
||||||
r.name = SetMapfixCompletedOperation
|
|
||||||
r.summary = "Called by maptest when a player completes the map"
|
|
||||||
r.operationID = "setMapfixCompleted"
|
|
||||||
r.pathPattern = "/mapfixes/{MapfixID}/completed"
|
|
||||||
r.args = args
|
|
||||||
r.count = 1
|
|
||||||
return r, true
|
|
||||||
default:
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
case 'm': // Prefix: "model"
|
case 'm': // Prefix: "model"
|
||||||
|
|
||||||
if l := len("model"); len(elem) >= l && elem[0:l] == "model" {
|
if l := len("model"); len(elem) >= l && elem[0:l] == "model" {
|
||||||
@@ -1762,30 +1451,6 @@ func (s *Server) FindPath(method string, u *url.URL) (r Route, _ bool) {
|
|||||||
break
|
break
|
||||||
}
|
}
|
||||||
switch elem[0] {
|
switch elem[0] {
|
||||||
case 's': // Prefix: "submitting"
|
|
||||||
|
|
||||||
if l := len("submitting"); len(elem) >= l && elem[0:l] == "submitting" {
|
|
||||||
elem = elem[l:]
|
|
||||||
} else {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
|
|
||||||
if len(elem) == 0 {
|
|
||||||
// Leaf node.
|
|
||||||
switch method {
|
|
||||||
case "POST":
|
|
||||||
r.name = ActionMapfixResetSubmittingOperation
|
|
||||||
r.summary = "Role Submitter manually resets submitting softlock and changes status from Submitting -> UnderConstruction"
|
|
||||||
r.operationID = "actionMapfixResetSubmitting"
|
|
||||||
r.pathPattern = "/mapfixes/{MapfixID}/status/reset-submitting"
|
|
||||||
r.args = args
|
|
||||||
r.count = 1
|
|
||||||
return r, true
|
|
||||||
default:
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
case 'u': // Prefix: "uploading"
|
case 'u': // Prefix: "uploading"
|
||||||
|
|
||||||
if l := len("uploading"); len(elem) >= l && elem[0:l] == "uploading" {
|
if l := len("uploading"); len(elem) >= l && elem[0:l] == "uploading" {
|
||||||
@@ -1886,6 +1551,30 @@ func (s *Server) FindPath(method string, u *url.URL) (r Route, _ bool) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case 's': // Prefix: "submit"
|
||||||
|
|
||||||
|
if l := len("submit"); len(elem) >= l && elem[0:l] == "submit" {
|
||||||
|
elem = elem[l:]
|
||||||
|
} else {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(elem) == 0 {
|
||||||
|
// Leaf node.
|
||||||
|
switch method {
|
||||||
|
case "POST":
|
||||||
|
r.name = ActionMapfixSubmitOperation
|
||||||
|
r.summary = "Role Submitter changes status from UnderConstruction|ChangesRequested -> Submitted"
|
||||||
|
r.operationID = "actionMapfixSubmit"
|
||||||
|
r.pathPattern = "/mapfixes/{MapfixID}/status/submit"
|
||||||
|
r.args = args
|
||||||
|
r.count = 1
|
||||||
|
return r, true
|
||||||
|
default:
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
case 't': // Prefix: "trigger-"
|
case 't': // Prefix: "trigger-"
|
||||||
|
|
||||||
if l := len("trigger-"); len(elem) >= l && elem[0:l] == "trigger-" {
|
if l := len("trigger-"); len(elem) >= l && elem[0:l] == "trigger-" {
|
||||||
@@ -1898,55 +1587,6 @@ func (s *Server) FindPath(method string, u *url.URL) (r Route, _ bool) {
|
|||||||
break
|
break
|
||||||
}
|
}
|
||||||
switch elem[0] {
|
switch elem[0] {
|
||||||
case 's': // Prefix: "submit"
|
|
||||||
|
|
||||||
if l := len("submit"); len(elem) >= l && elem[0:l] == "submit" {
|
|
||||||
elem = elem[l:]
|
|
||||||
} else {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
|
|
||||||
if len(elem) == 0 {
|
|
||||||
switch method {
|
|
||||||
case "POST":
|
|
||||||
r.name = ActionMapfixTriggerSubmitOperation
|
|
||||||
r.summary = "Role Submitter changes status from UnderConstruction|ChangesRequested -> Submitting"
|
|
||||||
r.operationID = "actionMapfixTriggerSubmit"
|
|
||||||
r.pathPattern = "/mapfixes/{MapfixID}/status/trigger-submit"
|
|
||||||
r.args = args
|
|
||||||
r.count = 1
|
|
||||||
return r, true
|
|
||||||
default:
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
|
||||||
switch elem[0] {
|
|
||||||
case '-': // Prefix: "-unchecked"
|
|
||||||
|
|
||||||
if l := len("-unchecked"); len(elem) >= l && elem[0:l] == "-unchecked" {
|
|
||||||
elem = elem[l:]
|
|
||||||
} else {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
|
|
||||||
if len(elem) == 0 {
|
|
||||||
// Leaf node.
|
|
||||||
switch method {
|
|
||||||
case "POST":
|
|
||||||
r.name = ActionMapfixTriggerSubmitUncheckedOperation
|
|
||||||
r.summary = "Role Reviewer changes status from ChangesRequested -> Submitting"
|
|
||||||
r.operationID = "actionMapfixTriggerSubmitUnchecked"
|
|
||||||
r.pathPattern = "/mapfixes/{MapfixID}/status/trigger-submit-unchecked"
|
|
||||||
r.args = args
|
|
||||||
r.count = 1
|
|
||||||
return r, true
|
|
||||||
default:
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
case 'u': // Prefix: "upload"
|
case 'u': // Prefix: "upload"
|
||||||
|
|
||||||
if l := len("upload"); len(elem) >= l && elem[0:l] == "upload" {
|
if l := len("upload"); len(elem) >= l && elem[0:l] == "upload" {
|
||||||
@@ -2037,15 +1677,16 @@ func (s *Server) FindPath(method string, u *url.URL) (r Route, _ bool) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Param: "MapID"
|
// Param: "MapID"
|
||||||
// Match until "/"
|
// Leaf parameter, slashes are prohibited
|
||||||
idx := strings.IndexByte(elem, '/')
|
idx := strings.IndexByte(elem, '/')
|
||||||
if idx < 0 {
|
if idx >= 0 {
|
||||||
idx = len(elem)
|
break
|
||||||
}
|
}
|
||||||
args[0] = elem[:idx]
|
args[0] = elem
|
||||||
elem = elem[idx:]
|
elem = ""
|
||||||
|
|
||||||
if len(elem) == 0 {
|
if len(elem) == 0 {
|
||||||
|
// Leaf node.
|
||||||
switch method {
|
switch method {
|
||||||
case "GET":
|
case "GET":
|
||||||
r.name = GetMapOperation
|
r.name = GetMapOperation
|
||||||
@@ -2059,32 +1700,6 @@ func (s *Server) FindPath(method string, u *url.URL) (r Route, _ bool) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
switch elem[0] {
|
|
||||||
case '/': // Prefix: "/location"
|
|
||||||
|
|
||||||
if l := len("/location"); len(elem) >= l && elem[0:l] == "/location" {
|
|
||||||
elem = elem[l:]
|
|
||||||
} else {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
|
|
||||||
if len(elem) == 0 {
|
|
||||||
// Leaf node.
|
|
||||||
switch method {
|
|
||||||
case "GET":
|
|
||||||
r.name = GetMapAssetLocationOperation
|
|
||||||
r.summary = "Get location of asset"
|
|
||||||
r.operationID = "getMapAssetLocation"
|
|
||||||
r.pathPattern = "/maps/{MapID}/location"
|
|
||||||
r.args = args
|
|
||||||
r.count = 1
|
|
||||||
return r, true
|
|
||||||
default:
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2454,30 +2069,6 @@ func (s *Server) FindPath(method string, u *url.URL) (r Route, _ bool) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
switch elem[0] {
|
switch elem[0] {
|
||||||
case '-': // Prefix: "-admin"
|
|
||||||
|
|
||||||
if l := len("-admin"); len(elem) >= l && elem[0:l] == "-admin" {
|
|
||||||
elem = elem[l:]
|
|
||||||
} else {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
|
|
||||||
if len(elem) == 0 {
|
|
||||||
// Leaf node.
|
|
||||||
switch method {
|
|
||||||
case "POST":
|
|
||||||
r.name = CreateSubmissionAdminOperation
|
|
||||||
r.summary = "Trigger the validator to create a new submission"
|
|
||||||
r.operationID = "createSubmissionAdmin"
|
|
||||||
r.pathPattern = "/submissions-admin"
|
|
||||||
r.args = args
|
|
||||||
r.count = 0
|
|
||||||
return r, true
|
|
||||||
default:
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
case '/': // Prefix: "/"
|
case '/': // Prefix: "/"
|
||||||
|
|
||||||
if l := len("/"); len(elem) >= l && elem[0:l] == "/" {
|
if l := len("/"); len(elem) >= l && elem[0:l] == "/" {
|
||||||
@@ -2522,9 +2113,9 @@ func (s *Server) FindPath(method string, u *url.URL) (r Route, _ bool) {
|
|||||||
break
|
break
|
||||||
}
|
}
|
||||||
switch elem[0] {
|
switch elem[0] {
|
||||||
case 'a': // Prefix: "audit-events"
|
case 'c': // Prefix: "completed"
|
||||||
|
|
||||||
if l := len("audit-events"); len(elem) >= l && elem[0:l] == "audit-events" {
|
if l := len("completed"); len(elem) >= l && elem[0:l] == "completed" {
|
||||||
elem = elem[l:]
|
elem = elem[l:]
|
||||||
} else {
|
} else {
|
||||||
break
|
break
|
||||||
@@ -2533,11 +2124,11 @@ func (s *Server) FindPath(method string, u *url.URL) (r Route, _ bool) {
|
|||||||
if len(elem) == 0 {
|
if len(elem) == 0 {
|
||||||
// Leaf node.
|
// Leaf node.
|
||||||
switch method {
|
switch method {
|
||||||
case "GET":
|
case "POST":
|
||||||
r.name = ListSubmissionAuditEventsOperation
|
r.name = SetSubmissionCompletedOperation
|
||||||
r.summary = "Retrieve a list of audit events"
|
r.summary = "Called by maptest when a player completes the map"
|
||||||
r.operationID = "listSubmissionAuditEvents"
|
r.operationID = "setSubmissionCompleted"
|
||||||
r.pathPattern = "/submissions/{SubmissionID}/audit-events"
|
r.pathPattern = "/submissions/{SubmissionID}/completed"
|
||||||
r.args = args
|
r.args = args
|
||||||
r.count = 1
|
r.count = 1
|
||||||
return r, true
|
return r, true
|
||||||
@@ -2546,68 +2137,6 @@ func (s *Server) FindPath(method string, u *url.URL) (r Route, _ bool) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
case 'c': // Prefix: "com"
|
|
||||||
|
|
||||||
if l := len("com"); len(elem) >= l && elem[0:l] == "com" {
|
|
||||||
elem = elem[l:]
|
|
||||||
} else {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
|
|
||||||
if len(elem) == 0 {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
switch elem[0] {
|
|
||||||
case 'm': // Prefix: "ment"
|
|
||||||
|
|
||||||
if l := len("ment"); len(elem) >= l && elem[0:l] == "ment" {
|
|
||||||
elem = elem[l:]
|
|
||||||
} else {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
|
|
||||||
if len(elem) == 0 {
|
|
||||||
// Leaf node.
|
|
||||||
switch method {
|
|
||||||
case "POST":
|
|
||||||
r.name = CreateSubmissionAuditCommentOperation
|
|
||||||
r.summary = "Post a comment to the audit log"
|
|
||||||
r.operationID = "createSubmissionAuditComment"
|
|
||||||
r.pathPattern = "/submissions/{SubmissionID}/comment"
|
|
||||||
r.args = args
|
|
||||||
r.count = 1
|
|
||||||
return r, true
|
|
||||||
default:
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
case 'p': // Prefix: "pleted"
|
|
||||||
|
|
||||||
if l := len("pleted"); len(elem) >= l && elem[0:l] == "pleted" {
|
|
||||||
elem = elem[l:]
|
|
||||||
} else {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
|
|
||||||
if len(elem) == 0 {
|
|
||||||
// Leaf node.
|
|
||||||
switch method {
|
|
||||||
case "POST":
|
|
||||||
r.name = SetSubmissionCompletedOperation
|
|
||||||
r.summary = "Called by maptest when a player completes the map"
|
|
||||||
r.operationID = "setSubmissionCompleted"
|
|
||||||
r.pathPattern = "/submissions/{SubmissionID}/completed"
|
|
||||||
r.args = args
|
|
||||||
r.count = 1
|
|
||||||
return r, true
|
|
||||||
default:
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
case 'm': // Prefix: "model"
|
case 'm': // Prefix: "model"
|
||||||
|
|
||||||
if l := len("model"); len(elem) >= l && elem[0:l] == "model" {
|
if l := len("model"); len(elem) >= l && elem[0:l] == "model" {
|
||||||
@@ -2716,30 +2245,6 @@ func (s *Server) FindPath(method string, u *url.URL) (r Route, _ bool) {
|
|||||||
break
|
break
|
||||||
}
|
}
|
||||||
switch elem[0] {
|
switch elem[0] {
|
||||||
case 's': // Prefix: "submitting"
|
|
||||||
|
|
||||||
if l := len("submitting"); len(elem) >= l && elem[0:l] == "submitting" {
|
|
||||||
elem = elem[l:]
|
|
||||||
} else {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
|
|
||||||
if len(elem) == 0 {
|
|
||||||
// Leaf node.
|
|
||||||
switch method {
|
|
||||||
case "POST":
|
|
||||||
r.name = ActionSubmissionResetSubmittingOperation
|
|
||||||
r.summary = "Role Submitter manually resets submitting softlock and changes status from Submitting -> UnderConstruction"
|
|
||||||
r.operationID = "actionSubmissionResetSubmitting"
|
|
||||||
r.pathPattern = "/submissions/{SubmissionID}/status/reset-submitting"
|
|
||||||
r.args = args
|
|
||||||
r.count = 1
|
|
||||||
return r, true
|
|
||||||
default:
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
case 'u': // Prefix: "uploading"
|
case 'u': // Prefix: "uploading"
|
||||||
|
|
||||||
if l := len("uploading"); len(elem) >= l && elem[0:l] == "uploading" {
|
if l := len("uploading"); len(elem) >= l && elem[0:l] == "uploading" {
|
||||||
@@ -2840,6 +2345,30 @@ func (s *Server) FindPath(method string, u *url.URL) (r Route, _ bool) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case 's': // Prefix: "submit"
|
||||||
|
|
||||||
|
if l := len("submit"); len(elem) >= l && elem[0:l] == "submit" {
|
||||||
|
elem = elem[l:]
|
||||||
|
} else {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(elem) == 0 {
|
||||||
|
// Leaf node.
|
||||||
|
switch method {
|
||||||
|
case "POST":
|
||||||
|
r.name = ActionSubmissionSubmitOperation
|
||||||
|
r.summary = "Role Submitter changes status from UnderConstruction|ChangesRequested -> Submitted"
|
||||||
|
r.operationID = "actionSubmissionSubmit"
|
||||||
|
r.pathPattern = "/submissions/{SubmissionID}/status/submit"
|
||||||
|
r.args = args
|
||||||
|
r.count = 1
|
||||||
|
return r, true
|
||||||
|
default:
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
case 't': // Prefix: "trigger-"
|
case 't': // Prefix: "trigger-"
|
||||||
|
|
||||||
if l := len("trigger-"); len(elem) >= l && elem[0:l] == "trigger-" {
|
if l := len("trigger-"); len(elem) >= l && elem[0:l] == "trigger-" {
|
||||||
@@ -2852,55 +2381,6 @@ func (s *Server) FindPath(method string, u *url.URL) (r Route, _ bool) {
|
|||||||
break
|
break
|
||||||
}
|
}
|
||||||
switch elem[0] {
|
switch elem[0] {
|
||||||
case 's': // Prefix: "submit"
|
|
||||||
|
|
||||||
if l := len("submit"); len(elem) >= l && elem[0:l] == "submit" {
|
|
||||||
elem = elem[l:]
|
|
||||||
} else {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
|
|
||||||
if len(elem) == 0 {
|
|
||||||
switch method {
|
|
||||||
case "POST":
|
|
||||||
r.name = ActionSubmissionTriggerSubmitOperation
|
|
||||||
r.summary = "Role Submitter changes status from UnderConstruction|ChangesRequested -> Submitting"
|
|
||||||
r.operationID = "actionSubmissionTriggerSubmit"
|
|
||||||
r.pathPattern = "/submissions/{SubmissionID}/status/trigger-submit"
|
|
||||||
r.args = args
|
|
||||||
r.count = 1
|
|
||||||
return r, true
|
|
||||||
default:
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
|
||||||
switch elem[0] {
|
|
||||||
case '-': // Prefix: "-unchecked"
|
|
||||||
|
|
||||||
if l := len("-unchecked"); len(elem) >= l && elem[0:l] == "-unchecked" {
|
|
||||||
elem = elem[l:]
|
|
||||||
} else {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
|
|
||||||
if len(elem) == 0 {
|
|
||||||
// Leaf node.
|
|
||||||
switch method {
|
|
||||||
case "POST":
|
|
||||||
r.name = ActionSubmissionTriggerSubmitUncheckedOperation
|
|
||||||
r.summary = "Role Reviewer changes status from ChangesRequested -> Submitting"
|
|
||||||
r.operationID = "actionSubmissionTriggerSubmitUnchecked"
|
|
||||||
r.pathPattern = "/submissions/{SubmissionID}/status/trigger-submit-unchecked"
|
|
||||||
r.args = args
|
|
||||||
r.count = 1
|
|
||||||
return r, true
|
|
||||||
default:
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
case 'u': // Prefix: "upload"
|
case 'u': // Prefix: "upload"
|
||||||
|
|
||||||
if l := len("upload"); len(elem) >= l && elem[0:l] == "upload" {
|
if l := len("upload"); len(elem) >= l && elem[0:l] == "upload" {
|
||||||
|
|||||||
@@ -4,10 +4,7 @@ package api
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/go-faster/jx"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func (s *ErrorStatusCode) Error() string {
|
func (s *ErrorStatusCode) Error() string {
|
||||||
@@ -23,20 +20,14 @@ type ActionMapfixRejectNoContent struct{}
|
|||||||
// ActionMapfixRequestChangesNoContent is response for ActionMapfixRequestChanges operation.
|
// ActionMapfixRequestChangesNoContent is response for ActionMapfixRequestChanges operation.
|
||||||
type ActionMapfixRequestChangesNoContent struct{}
|
type ActionMapfixRequestChangesNoContent struct{}
|
||||||
|
|
||||||
// ActionMapfixResetSubmittingNoContent is response for ActionMapfixResetSubmitting operation.
|
|
||||||
type ActionMapfixResetSubmittingNoContent struct{}
|
|
||||||
|
|
||||||
// ActionMapfixRetryValidateNoContent is response for ActionMapfixRetryValidate operation.
|
// ActionMapfixRetryValidateNoContent is response for ActionMapfixRetryValidate operation.
|
||||||
type ActionMapfixRetryValidateNoContent struct{}
|
type ActionMapfixRetryValidateNoContent struct{}
|
||||||
|
|
||||||
// ActionMapfixRevokeNoContent is response for ActionMapfixRevoke operation.
|
// ActionMapfixRevokeNoContent is response for ActionMapfixRevoke operation.
|
||||||
type ActionMapfixRevokeNoContent struct{}
|
type ActionMapfixRevokeNoContent struct{}
|
||||||
|
|
||||||
// ActionMapfixTriggerSubmitNoContent is response for ActionMapfixTriggerSubmit operation.
|
// ActionMapfixSubmitNoContent is response for ActionMapfixSubmit operation.
|
||||||
type ActionMapfixTriggerSubmitNoContent struct{}
|
type ActionMapfixSubmitNoContent struct{}
|
||||||
|
|
||||||
// ActionMapfixTriggerSubmitUncheckedNoContent is response for ActionMapfixTriggerSubmitUnchecked operation.
|
|
||||||
type ActionMapfixTriggerSubmitUncheckedNoContent struct{}
|
|
||||||
|
|
||||||
// ActionMapfixTriggerUploadNoContent is response for ActionMapfixTriggerUpload operation.
|
// ActionMapfixTriggerUploadNoContent is response for ActionMapfixTriggerUpload operation.
|
||||||
type ActionMapfixTriggerUploadNoContent struct{}
|
type ActionMapfixTriggerUploadNoContent struct{}
|
||||||
@@ -56,20 +47,14 @@ type ActionSubmissionRejectNoContent struct{}
|
|||||||
// ActionSubmissionRequestChangesNoContent is response for ActionSubmissionRequestChanges operation.
|
// ActionSubmissionRequestChangesNoContent is response for ActionSubmissionRequestChanges operation.
|
||||||
type ActionSubmissionRequestChangesNoContent struct{}
|
type ActionSubmissionRequestChangesNoContent struct{}
|
||||||
|
|
||||||
// ActionSubmissionResetSubmittingNoContent is response for ActionSubmissionResetSubmitting operation.
|
|
||||||
type ActionSubmissionResetSubmittingNoContent struct{}
|
|
||||||
|
|
||||||
// ActionSubmissionRetryValidateNoContent is response for ActionSubmissionRetryValidate operation.
|
// ActionSubmissionRetryValidateNoContent is response for ActionSubmissionRetryValidate operation.
|
||||||
type ActionSubmissionRetryValidateNoContent struct{}
|
type ActionSubmissionRetryValidateNoContent struct{}
|
||||||
|
|
||||||
// ActionSubmissionRevokeNoContent is response for ActionSubmissionRevoke operation.
|
// ActionSubmissionRevokeNoContent is response for ActionSubmissionRevoke operation.
|
||||||
type ActionSubmissionRevokeNoContent struct{}
|
type ActionSubmissionRevokeNoContent struct{}
|
||||||
|
|
||||||
// ActionSubmissionTriggerSubmitNoContent is response for ActionSubmissionTriggerSubmit operation.
|
// ActionSubmissionSubmitNoContent is response for ActionSubmissionSubmit operation.
|
||||||
type ActionSubmissionTriggerSubmitNoContent struct{}
|
type ActionSubmissionSubmitNoContent struct{}
|
||||||
|
|
||||||
// ActionSubmissionTriggerSubmitUncheckedNoContent is response for ActionSubmissionTriggerSubmitUnchecked operation.
|
|
||||||
type ActionSubmissionTriggerSubmitUncheckedNoContent struct{}
|
|
||||||
|
|
||||||
// ActionSubmissionTriggerUploadNoContent is response for ActionSubmissionTriggerUpload operation.
|
// ActionSubmissionTriggerUploadNoContent is response for ActionSubmissionTriggerUpload operation.
|
||||||
type ActionSubmissionTriggerUploadNoContent struct{}
|
type ActionSubmissionTriggerUploadNoContent struct{}
|
||||||
@@ -80,115 +65,8 @@ type ActionSubmissionTriggerValidateNoContent struct{}
|
|||||||
// ActionSubmissionValidatedNoContent is response for ActionSubmissionValidated operation.
|
// ActionSubmissionValidatedNoContent is response for ActionSubmissionValidated operation.
|
||||||
type ActionSubmissionValidatedNoContent struct{}
|
type ActionSubmissionValidatedNoContent struct{}
|
||||||
|
|
||||||
// Ref: #/components/schemas/AuditEvent
|
|
||||||
type AuditEvent struct {
|
|
||||||
ID int64 `json:"ID"`
|
|
||||||
Date int64 `json:"Date"`
|
|
||||||
User int64 `json:"User"`
|
|
||||||
Username string `json:"Username"`
|
|
||||||
// Is this a submission or is it a mapfix.
|
|
||||||
ResourceType int32 `json:"ResourceType"`
|
|
||||||
ResourceID int64 `json:"ResourceID"`
|
|
||||||
EventType int32 `json:"EventType"`
|
|
||||||
// Arbitrary event data.
|
|
||||||
EventData AuditEventEventData `json:"EventData"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetID returns the value of ID.
|
|
||||||
func (s *AuditEvent) GetID() int64 {
|
|
||||||
return s.ID
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetDate returns the value of Date.
|
|
||||||
func (s *AuditEvent) GetDate() int64 {
|
|
||||||
return s.Date
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetUser returns the value of User.
|
|
||||||
func (s *AuditEvent) GetUser() int64 {
|
|
||||||
return s.User
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetUsername returns the value of Username.
|
|
||||||
func (s *AuditEvent) GetUsername() string {
|
|
||||||
return s.Username
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetResourceType returns the value of ResourceType.
|
|
||||||
func (s *AuditEvent) GetResourceType() int32 {
|
|
||||||
return s.ResourceType
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetResourceID returns the value of ResourceID.
|
|
||||||
func (s *AuditEvent) GetResourceID() int64 {
|
|
||||||
return s.ResourceID
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetEventType returns the value of EventType.
|
|
||||||
func (s *AuditEvent) GetEventType() int32 {
|
|
||||||
return s.EventType
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetEventData returns the value of EventData.
|
|
||||||
func (s *AuditEvent) GetEventData() AuditEventEventData {
|
|
||||||
return s.EventData
|
|
||||||
}
|
|
||||||
|
|
||||||
// SetID sets the value of ID.
|
|
||||||
func (s *AuditEvent) SetID(val int64) {
|
|
||||||
s.ID = val
|
|
||||||
}
|
|
||||||
|
|
||||||
// SetDate sets the value of Date.
|
|
||||||
func (s *AuditEvent) SetDate(val int64) {
|
|
||||||
s.Date = val
|
|
||||||
}
|
|
||||||
|
|
||||||
// SetUser sets the value of User.
|
|
||||||
func (s *AuditEvent) SetUser(val int64) {
|
|
||||||
s.User = val
|
|
||||||
}
|
|
||||||
|
|
||||||
// SetUsername sets the value of Username.
|
|
||||||
func (s *AuditEvent) SetUsername(val string) {
|
|
||||||
s.Username = val
|
|
||||||
}
|
|
||||||
|
|
||||||
// SetResourceType sets the value of ResourceType.
|
|
||||||
func (s *AuditEvent) SetResourceType(val int32) {
|
|
||||||
s.ResourceType = val
|
|
||||||
}
|
|
||||||
|
|
||||||
// SetResourceID sets the value of ResourceID.
|
|
||||||
func (s *AuditEvent) SetResourceID(val int64) {
|
|
||||||
s.ResourceID = val
|
|
||||||
}
|
|
||||||
|
|
||||||
// SetEventType sets the value of EventType.
|
|
||||||
func (s *AuditEvent) SetEventType(val int32) {
|
|
||||||
s.EventType = val
|
|
||||||
}
|
|
||||||
|
|
||||||
// SetEventData sets the value of EventData.
|
|
||||||
func (s *AuditEvent) SetEventData(val AuditEventEventData) {
|
|
||||||
s.EventData = val
|
|
||||||
}
|
|
||||||
|
|
||||||
// Arbitrary event data.
|
|
||||||
type AuditEventEventData map[string]jx.Raw
|
|
||||||
|
|
||||||
func (s *AuditEventEventData) init() AuditEventEventData {
|
|
||||||
m := *s
|
|
||||||
if m == nil {
|
|
||||||
m = map[string]jx.Raw{}
|
|
||||||
*s = m
|
|
||||||
}
|
|
||||||
return m
|
|
||||||
}
|
|
||||||
|
|
||||||
type CookieAuth struct {
|
type CookieAuth struct {
|
||||||
APIKey string
|
APIKey string
|
||||||
Roles []string
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetAPIKey returns the value of APIKey.
|
// GetAPIKey returns the value of APIKey.
|
||||||
@@ -196,55 +74,11 @@ func (s *CookieAuth) GetAPIKey() string {
|
|||||||
return s.APIKey
|
return s.APIKey
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetRoles returns the value of Roles.
|
|
||||||
func (s *CookieAuth) GetRoles() []string {
|
|
||||||
return s.Roles
|
|
||||||
}
|
|
||||||
|
|
||||||
// SetAPIKey sets the value of APIKey.
|
// SetAPIKey sets the value of APIKey.
|
||||||
func (s *CookieAuth) SetAPIKey(val string) {
|
func (s *CookieAuth) SetAPIKey(val string) {
|
||||||
s.APIKey = val
|
s.APIKey = val
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetRoles sets the value of Roles.
|
|
||||||
func (s *CookieAuth) SetRoles(val []string) {
|
|
||||||
s.Roles = val
|
|
||||||
}
|
|
||||||
|
|
||||||
// CreateMapfixAuditCommentNoContent is response for CreateMapfixAuditComment operation.
|
|
||||||
type CreateMapfixAuditCommentNoContent struct{}
|
|
||||||
|
|
||||||
type CreateMapfixAuditCommentReq struct {
|
|
||||||
Data io.Reader
|
|
||||||
}
|
|
||||||
|
|
||||||
// Read reads data from the Data reader.
|
|
||||||
//
|
|
||||||
// Kept to satisfy the io.Reader interface.
|
|
||||||
func (s CreateMapfixAuditCommentReq) Read(p []byte) (n int, err error) {
|
|
||||||
if s.Data == nil {
|
|
||||||
return 0, io.EOF
|
|
||||||
}
|
|
||||||
return s.Data.Read(p)
|
|
||||||
}
|
|
||||||
|
|
||||||
// CreateSubmissionAuditCommentNoContent is response for CreateSubmissionAuditComment operation.
|
|
||||||
type CreateSubmissionAuditCommentNoContent struct{}
|
|
||||||
|
|
||||||
type CreateSubmissionAuditCommentReq struct {
|
|
||||||
Data io.Reader
|
|
||||||
}
|
|
||||||
|
|
||||||
// Read reads data from the Data reader.
|
|
||||||
//
|
|
||||||
// Kept to satisfy the io.Reader interface.
|
|
||||||
func (s CreateSubmissionAuditCommentReq) Read(p []byte) (n int, err error) {
|
|
||||||
if s.Data == nil {
|
|
||||||
return 0, io.EOF
|
|
||||||
}
|
|
||||||
return s.Data.Read(p)
|
|
||||||
}
|
|
||||||
|
|
||||||
// DeleteScriptNoContent is response for DeleteScript operation.
|
// DeleteScriptNoContent is response for DeleteScript operation.
|
||||||
type DeleteScriptNoContent struct{}
|
type DeleteScriptNoContent struct{}
|
||||||
|
|
||||||
@@ -304,20 +138,6 @@ func (s *ErrorStatusCode) SetResponse(val Error) {
|
|||||||
s.Response = val
|
s.Response = val
|
||||||
}
|
}
|
||||||
|
|
||||||
type GetMapAssetLocationOK struct {
|
|
||||||
Data io.Reader
|
|
||||||
}
|
|
||||||
|
|
||||||
// Read reads data from the Data reader.
|
|
||||||
//
|
|
||||||
// Kept to satisfy the io.Reader interface.
|
|
||||||
func (s GetMapAssetLocationOK) Read(p []byte) (n int, err error) {
|
|
||||||
if s.Data == nil {
|
|
||||||
return 0, io.EOF
|
|
||||||
}
|
|
||||||
return s.Data.Read(p)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Ref: #/components/schemas/Map
|
// Ref: #/components/schemas/Map
|
||||||
type Map struct {
|
type Map struct {
|
||||||
ID int64 `json:"ID"`
|
ID int64 `json:"ID"`
|
||||||
@@ -391,7 +211,7 @@ type Mapfix struct {
|
|||||||
Completed bool `json:"Completed"`
|
Completed bool `json:"Completed"`
|
||||||
TargetAssetID int64 `json:"TargetAssetID"`
|
TargetAssetID int64 `json:"TargetAssetID"`
|
||||||
StatusID int32 `json:"StatusID"`
|
StatusID int32 `json:"StatusID"`
|
||||||
Description string `json:"Description"`
|
StatusMessage string `json:"StatusMessage"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetID returns the value of ID.
|
// GetID returns the value of ID.
|
||||||
@@ -454,9 +274,9 @@ func (s *Mapfix) GetStatusID() int32 {
|
|||||||
return s.StatusID
|
return s.StatusID
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetDescription returns the value of Description.
|
// GetStatusMessage returns the value of StatusMessage.
|
||||||
func (s *Mapfix) GetDescription() string {
|
func (s *Mapfix) GetStatusMessage() string {
|
||||||
return s.Description
|
return s.StatusMessage
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetID sets the value of ID.
|
// SetID sets the value of ID.
|
||||||
@@ -519,16 +339,15 @@ func (s *Mapfix) SetStatusID(val int32) {
|
|||||||
s.StatusID = val
|
s.StatusID = val
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetDescription sets the value of Description.
|
// SetStatusMessage sets the value of StatusMessage.
|
||||||
func (s *Mapfix) SetDescription(val string) {
|
func (s *Mapfix) SetStatusMessage(val string) {
|
||||||
s.Description = val
|
s.StatusMessage = val
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ref: #/components/schemas/MapfixTriggerCreate
|
// Ref: #/components/schemas/MapfixTriggerCreate
|
||||||
type MapfixTriggerCreate struct {
|
type MapfixTriggerCreate struct {
|
||||||
AssetID int64 `json:"AssetID"`
|
AssetID int64 `json:"AssetID"`
|
||||||
TargetAssetID int64 `json:"TargetAssetID"`
|
TargetAssetID int64 `json:"TargetAssetID"`
|
||||||
Description string `json:"Description"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetAssetID returns the value of AssetID.
|
// GetAssetID returns the value of AssetID.
|
||||||
@@ -541,11 +360,6 @@ func (s *MapfixTriggerCreate) GetTargetAssetID() int64 {
|
|||||||
return s.TargetAssetID
|
return s.TargetAssetID
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetDescription returns the value of Description.
|
|
||||||
func (s *MapfixTriggerCreate) GetDescription() string {
|
|
||||||
return s.Description
|
|
||||||
}
|
|
||||||
|
|
||||||
// SetAssetID sets the value of AssetID.
|
// SetAssetID sets the value of AssetID.
|
||||||
func (s *MapfixTriggerCreate) SetAssetID(val int64) {
|
func (s *MapfixTriggerCreate) SetAssetID(val int64) {
|
||||||
s.AssetID = val
|
s.AssetID = val
|
||||||
@@ -556,37 +370,6 @@ func (s *MapfixTriggerCreate) SetTargetAssetID(val int64) {
|
|||||||
s.TargetAssetID = val
|
s.TargetAssetID = val
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetDescription sets the value of Description.
|
|
||||||
func (s *MapfixTriggerCreate) SetDescription(val string) {
|
|
||||||
s.Description = val
|
|
||||||
}
|
|
||||||
|
|
||||||
// Ref: #/components/schemas/Mapfixes
|
|
||||||
type Mapfixes struct {
|
|
||||||
Total int64 `json:"Total"`
|
|
||||||
Mapfixes []Mapfix `json:"Mapfixes"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetTotal returns the value of Total.
|
|
||||||
func (s *Mapfixes) GetTotal() int64 {
|
|
||||||
return s.Total
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetMapfixes returns the value of Mapfixes.
|
|
||||||
func (s *Mapfixes) GetMapfixes() []Mapfix {
|
|
||||||
return s.Mapfixes
|
|
||||||
}
|
|
||||||
|
|
||||||
// SetTotal sets the value of Total.
|
|
||||||
func (s *Mapfixes) SetTotal(val int64) {
|
|
||||||
s.Total = val
|
|
||||||
}
|
|
||||||
|
|
||||||
// SetMapfixes sets the value of Mapfixes.
|
|
||||||
func (s *Mapfixes) SetMapfixes(val []Mapfix) {
|
|
||||||
s.Mapfixes = val
|
|
||||||
}
|
|
||||||
|
|
||||||
// Ref: #/components/schemas/Operation
|
// Ref: #/components/schemas/Operation
|
||||||
type Operation struct {
|
type Operation struct {
|
||||||
OperationID int32 `json:"OperationID"`
|
OperationID int32 `json:"OperationID"`
|
||||||
@@ -1216,6 +999,7 @@ type Submission struct {
|
|||||||
Completed bool `json:"Completed"`
|
Completed bool `json:"Completed"`
|
||||||
UploadedAssetID OptInt64 `json:"UploadedAssetID"`
|
UploadedAssetID OptInt64 `json:"UploadedAssetID"`
|
||||||
StatusID int32 `json:"StatusID"`
|
StatusID int32 `json:"StatusID"`
|
||||||
|
StatusMessage string `json:"StatusMessage"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetID returns the value of ID.
|
// GetID returns the value of ID.
|
||||||
@@ -1288,6 +1072,11 @@ func (s *Submission) GetStatusID() int32 {
|
|||||||
return s.StatusID
|
return s.StatusID
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetStatusMessage returns the value of StatusMessage.
|
||||||
|
func (s *Submission) GetStatusMessage() string {
|
||||||
|
return s.StatusMessage
|
||||||
|
}
|
||||||
|
|
||||||
// SetID sets the value of ID.
|
// SetID sets the value of ID.
|
||||||
func (s *Submission) SetID(val int64) {
|
func (s *Submission) SetID(val int64) {
|
||||||
s.ID = val
|
s.ID = val
|
||||||
@@ -1358,12 +1147,14 @@ func (s *Submission) SetStatusID(val int32) {
|
|||||||
s.StatusID = val
|
s.StatusID = val
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// SetStatusMessage sets the value of StatusMessage.
|
||||||
|
func (s *Submission) SetStatusMessage(val string) {
|
||||||
|
s.StatusMessage = val
|
||||||
|
}
|
||||||
|
|
||||||
// Ref: #/components/schemas/SubmissionTriggerCreate
|
// Ref: #/components/schemas/SubmissionTriggerCreate
|
||||||
type SubmissionTriggerCreate struct {
|
type SubmissionTriggerCreate struct {
|
||||||
AssetID int64 `json:"AssetID"`
|
AssetID int64 `json:"AssetID"`
|
||||||
DisplayName string `json:"DisplayName"`
|
|
||||||
Creator string `json:"Creator"`
|
|
||||||
GameID int32 `json:"GameID"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetAssetID returns the value of AssetID.
|
// GetAssetID returns the value of AssetID.
|
||||||
@@ -1371,67 +1162,11 @@ func (s *SubmissionTriggerCreate) GetAssetID() int64 {
|
|||||||
return s.AssetID
|
return s.AssetID
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetDisplayName returns the value of DisplayName.
|
|
||||||
func (s *SubmissionTriggerCreate) GetDisplayName() string {
|
|
||||||
return s.DisplayName
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetCreator returns the value of Creator.
|
|
||||||
func (s *SubmissionTriggerCreate) GetCreator() string {
|
|
||||||
return s.Creator
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetGameID returns the value of GameID.
|
|
||||||
func (s *SubmissionTriggerCreate) GetGameID() int32 {
|
|
||||||
return s.GameID
|
|
||||||
}
|
|
||||||
|
|
||||||
// SetAssetID sets the value of AssetID.
|
// SetAssetID sets the value of AssetID.
|
||||||
func (s *SubmissionTriggerCreate) SetAssetID(val int64) {
|
func (s *SubmissionTriggerCreate) SetAssetID(val int64) {
|
||||||
s.AssetID = val
|
s.AssetID = val
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetDisplayName sets the value of DisplayName.
|
|
||||||
func (s *SubmissionTriggerCreate) SetDisplayName(val string) {
|
|
||||||
s.DisplayName = val
|
|
||||||
}
|
|
||||||
|
|
||||||
// SetCreator sets the value of Creator.
|
|
||||||
func (s *SubmissionTriggerCreate) SetCreator(val string) {
|
|
||||||
s.Creator = val
|
|
||||||
}
|
|
||||||
|
|
||||||
// SetGameID sets the value of GameID.
|
|
||||||
func (s *SubmissionTriggerCreate) SetGameID(val int32) {
|
|
||||||
s.GameID = val
|
|
||||||
}
|
|
||||||
|
|
||||||
// Ref: #/components/schemas/Submissions
|
|
||||||
type Submissions struct {
|
|
||||||
Total int64 `json:"Total"`
|
|
||||||
Submissions []Submission `json:"Submissions"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetTotal returns the value of Total.
|
|
||||||
func (s *Submissions) GetTotal() int64 {
|
|
||||||
return s.Total
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetSubmissions returns the value of Submissions.
|
|
||||||
func (s *Submissions) GetSubmissions() []Submission {
|
|
||||||
return s.Submissions
|
|
||||||
}
|
|
||||||
|
|
||||||
// SetTotal sets the value of Total.
|
|
||||||
func (s *Submissions) SetTotal(val int64) {
|
|
||||||
s.Total = val
|
|
||||||
}
|
|
||||||
|
|
||||||
// SetSubmissions sets the value of Submissions.
|
|
||||||
func (s *Submissions) SetSubmissions(val []Submission) {
|
|
||||||
s.Submissions = val
|
|
||||||
}
|
|
||||||
|
|
||||||
// UpdateMapfixModelNoContent is response for UpdateMapfixModel operation.
|
// UpdateMapfixModelNoContent is response for UpdateMapfixModel operation.
|
||||||
type UpdateMapfixModelNoContent struct{}
|
type UpdateMapfixModelNoContent struct{}
|
||||||
|
|
||||||
|
|||||||
@@ -33,52 +33,6 @@ func findAuthorization(h http.Header, prefix string) (string, bool) {
|
|||||||
return "", false
|
return "", false
|
||||||
}
|
}
|
||||||
|
|
||||||
var operationRolesCookieAuth = map[string][]string{
|
|
||||||
ActionMapfixAcceptedOperation: []string{},
|
|
||||||
ActionMapfixRejectOperation: []string{},
|
|
||||||
ActionMapfixRequestChangesOperation: []string{},
|
|
||||||
ActionMapfixResetSubmittingOperation: []string{},
|
|
||||||
ActionMapfixRetryValidateOperation: []string{},
|
|
||||||
ActionMapfixRevokeOperation: []string{},
|
|
||||||
ActionMapfixTriggerSubmitOperation: []string{},
|
|
||||||
ActionMapfixTriggerSubmitUncheckedOperation: []string{},
|
|
||||||
ActionMapfixTriggerUploadOperation: []string{},
|
|
||||||
ActionMapfixTriggerValidateOperation: []string{},
|
|
||||||
ActionMapfixValidatedOperation: []string{},
|
|
||||||
ActionSubmissionAcceptedOperation: []string{},
|
|
||||||
ActionSubmissionRejectOperation: []string{},
|
|
||||||
ActionSubmissionRequestChangesOperation: []string{},
|
|
||||||
ActionSubmissionResetSubmittingOperation: []string{},
|
|
||||||
ActionSubmissionRetryValidateOperation: []string{},
|
|
||||||
ActionSubmissionRevokeOperation: []string{},
|
|
||||||
ActionSubmissionTriggerSubmitOperation: []string{},
|
|
||||||
ActionSubmissionTriggerSubmitUncheckedOperation: []string{},
|
|
||||||
ActionSubmissionTriggerUploadOperation: []string{},
|
|
||||||
ActionSubmissionTriggerValidateOperation: []string{},
|
|
||||||
ActionSubmissionValidatedOperation: []string{},
|
|
||||||
CreateMapfixOperation: []string{},
|
|
||||||
CreateMapfixAuditCommentOperation: []string{},
|
|
||||||
CreateScriptOperation: []string{},
|
|
||||||
CreateScriptPolicyOperation: []string{},
|
|
||||||
CreateSubmissionOperation: []string{},
|
|
||||||
CreateSubmissionAdminOperation: []string{},
|
|
||||||
CreateSubmissionAuditCommentOperation: []string{},
|
|
||||||
DeleteScriptOperation: []string{},
|
|
||||||
DeleteScriptPolicyOperation: []string{},
|
|
||||||
GetMapAssetLocationOperation: []string{},
|
|
||||||
GetOperationOperation: []string{},
|
|
||||||
ReleaseSubmissionsOperation: []string{},
|
|
||||||
SessionRolesOperation: []string{},
|
|
||||||
SessionUserOperation: []string{},
|
|
||||||
SessionValidateOperation: []string{},
|
|
||||||
SetMapfixCompletedOperation: []string{},
|
|
||||||
SetSubmissionCompletedOperation: []string{},
|
|
||||||
UpdateMapfixModelOperation: []string{},
|
|
||||||
UpdateScriptOperation: []string{},
|
|
||||||
UpdateScriptPolicyOperation: []string{},
|
|
||||||
UpdateSubmissionModelOperation: []string{},
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *Server) securityCookieAuth(ctx context.Context, operationName OperationName, req *http.Request) (context.Context, bool, error) {
|
func (s *Server) securityCookieAuth(ctx context.Context, operationName OperationName, req *http.Request) (context.Context, bool, error) {
|
||||||
var t CookieAuth
|
var t CookieAuth
|
||||||
const parameterName = "session_id"
|
const parameterName = "session_id"
|
||||||
@@ -92,7 +46,6 @@ func (s *Server) securityCookieAuth(ctx context.Context, operationName Operation
|
|||||||
return nil, false, errors.Wrap(err, "get cookie value")
|
return nil, false, errors.Wrap(err, "get cookie value")
|
||||||
}
|
}
|
||||||
t.APIKey = value
|
t.APIKey = value
|
||||||
t.Roles = operationRolesCookieAuth[operationName]
|
|
||||||
rctx, err := s.sec.HandleCookieAuth(ctx, operationName, t)
|
rctx, err := s.sec.HandleCookieAuth(ctx, operationName, t)
|
||||||
if errors.Is(err, ogenerrors.ErrSkipServerSecurity) {
|
if errors.Is(err, ogenerrors.ErrSkipServerSecurity) {
|
||||||
return nil, false, nil
|
return nil, false, nil
|
||||||
|
|||||||
@@ -26,13 +26,6 @@ type Handler interface {
|
|||||||
//
|
//
|
||||||
// POST /mapfixes/{MapfixID}/status/request-changes
|
// POST /mapfixes/{MapfixID}/status/request-changes
|
||||||
ActionMapfixRequestChanges(ctx context.Context, params ActionMapfixRequestChangesParams) error
|
ActionMapfixRequestChanges(ctx context.Context, params ActionMapfixRequestChangesParams) error
|
||||||
// ActionMapfixResetSubmitting implements actionMapfixResetSubmitting operation.
|
|
||||||
//
|
|
||||||
// Role Submitter manually resets submitting softlock and changes status from Submitting ->
|
|
||||||
// UnderConstruction.
|
|
||||||
//
|
|
||||||
// POST /mapfixes/{MapfixID}/status/reset-submitting
|
|
||||||
ActionMapfixResetSubmitting(ctx context.Context, params ActionMapfixResetSubmittingParams) error
|
|
||||||
// ActionMapfixRetryValidate implements actionMapfixRetryValidate operation.
|
// ActionMapfixRetryValidate implements actionMapfixRetryValidate operation.
|
||||||
//
|
//
|
||||||
// Role Reviewer re-runs validation and changes status from Accepted -> Validating.
|
// Role Reviewer re-runs validation and changes status from Accepted -> Validating.
|
||||||
@@ -45,18 +38,12 @@ type Handler interface {
|
|||||||
//
|
//
|
||||||
// POST /mapfixes/{MapfixID}/status/revoke
|
// POST /mapfixes/{MapfixID}/status/revoke
|
||||||
ActionMapfixRevoke(ctx context.Context, params ActionMapfixRevokeParams) error
|
ActionMapfixRevoke(ctx context.Context, params ActionMapfixRevokeParams) error
|
||||||
// ActionMapfixTriggerSubmit implements actionMapfixTriggerSubmit operation.
|
// ActionMapfixSubmit implements actionMapfixSubmit operation.
|
||||||
//
|
//
|
||||||
// Role Submitter changes status from UnderConstruction|ChangesRequested -> Submitting.
|
// Role Submitter changes status from UnderConstruction|ChangesRequested -> Submitted.
|
||||||
//
|
//
|
||||||
// POST /mapfixes/{MapfixID}/status/trigger-submit
|
// POST /mapfixes/{MapfixID}/status/submit
|
||||||
ActionMapfixTriggerSubmit(ctx context.Context, params ActionMapfixTriggerSubmitParams) error
|
ActionMapfixSubmit(ctx context.Context, params ActionMapfixSubmitParams) error
|
||||||
// ActionMapfixTriggerSubmitUnchecked implements actionMapfixTriggerSubmitUnchecked operation.
|
|
||||||
//
|
|
||||||
// Role Reviewer changes status from ChangesRequested -> Submitting.
|
|
||||||
//
|
|
||||||
// POST /mapfixes/{MapfixID}/status/trigger-submit-unchecked
|
|
||||||
ActionMapfixTriggerSubmitUnchecked(ctx context.Context, params ActionMapfixTriggerSubmitUncheckedParams) error
|
|
||||||
// ActionMapfixTriggerUpload implements actionMapfixTriggerUpload operation.
|
// ActionMapfixTriggerUpload implements actionMapfixTriggerUpload operation.
|
||||||
//
|
//
|
||||||
// Role Admin changes status from Validated -> Uploading.
|
// Role Admin changes status from Validated -> Uploading.
|
||||||
@@ -93,13 +80,6 @@ type Handler interface {
|
|||||||
//
|
//
|
||||||
// POST /submissions/{SubmissionID}/status/request-changes
|
// POST /submissions/{SubmissionID}/status/request-changes
|
||||||
ActionSubmissionRequestChanges(ctx context.Context, params ActionSubmissionRequestChangesParams) error
|
ActionSubmissionRequestChanges(ctx context.Context, params ActionSubmissionRequestChangesParams) error
|
||||||
// ActionSubmissionResetSubmitting implements actionSubmissionResetSubmitting operation.
|
|
||||||
//
|
|
||||||
// Role Submitter manually resets submitting softlock and changes status from Submitting ->
|
|
||||||
// UnderConstruction.
|
|
||||||
//
|
|
||||||
// POST /submissions/{SubmissionID}/status/reset-submitting
|
|
||||||
ActionSubmissionResetSubmitting(ctx context.Context, params ActionSubmissionResetSubmittingParams) error
|
|
||||||
// ActionSubmissionRetryValidate implements actionSubmissionRetryValidate operation.
|
// ActionSubmissionRetryValidate implements actionSubmissionRetryValidate operation.
|
||||||
//
|
//
|
||||||
// Role Reviewer re-runs validation and changes status from Accepted -> Validating.
|
// Role Reviewer re-runs validation and changes status from Accepted -> Validating.
|
||||||
@@ -112,18 +92,12 @@ type Handler interface {
|
|||||||
//
|
//
|
||||||
// POST /submissions/{SubmissionID}/status/revoke
|
// POST /submissions/{SubmissionID}/status/revoke
|
||||||
ActionSubmissionRevoke(ctx context.Context, params ActionSubmissionRevokeParams) error
|
ActionSubmissionRevoke(ctx context.Context, params ActionSubmissionRevokeParams) error
|
||||||
// ActionSubmissionTriggerSubmit implements actionSubmissionTriggerSubmit operation.
|
// ActionSubmissionSubmit implements actionSubmissionSubmit operation.
|
||||||
//
|
//
|
||||||
// Role Submitter changes status from UnderConstruction|ChangesRequested -> Submitting.
|
// Role Submitter changes status from UnderConstruction|ChangesRequested -> Submitted.
|
||||||
//
|
//
|
||||||
// POST /submissions/{SubmissionID}/status/trigger-submit
|
// POST /submissions/{SubmissionID}/status/submit
|
||||||
ActionSubmissionTriggerSubmit(ctx context.Context, params ActionSubmissionTriggerSubmitParams) error
|
ActionSubmissionSubmit(ctx context.Context, params ActionSubmissionSubmitParams) error
|
||||||
// ActionSubmissionTriggerSubmitUnchecked implements actionSubmissionTriggerSubmitUnchecked operation.
|
|
||||||
//
|
|
||||||
// Role Reviewer changes status from ChangesRequested -> Submitting.
|
|
||||||
//
|
|
||||||
// POST /submissions/{SubmissionID}/status/trigger-submit-unchecked
|
|
||||||
ActionSubmissionTriggerSubmitUnchecked(ctx context.Context, params ActionSubmissionTriggerSubmitUncheckedParams) error
|
|
||||||
// ActionSubmissionTriggerUpload implements actionSubmissionTriggerUpload operation.
|
// ActionSubmissionTriggerUpload implements actionSubmissionTriggerUpload operation.
|
||||||
//
|
//
|
||||||
// Role Admin changes status from Validated -> Uploading.
|
// Role Admin changes status from Validated -> Uploading.
|
||||||
@@ -148,12 +122,6 @@ type Handler interface {
|
|||||||
//
|
//
|
||||||
// POST /mapfixes
|
// POST /mapfixes
|
||||||
CreateMapfix(ctx context.Context, req *MapfixTriggerCreate) (*OperationID, error)
|
CreateMapfix(ctx context.Context, req *MapfixTriggerCreate) (*OperationID, error)
|
||||||
// CreateMapfixAuditComment implements createMapfixAuditComment operation.
|
|
||||||
//
|
|
||||||
// Post a comment to the audit log.
|
|
||||||
//
|
|
||||||
// POST /mapfixes/{MapfixID}/comment
|
|
||||||
CreateMapfixAuditComment(ctx context.Context, req CreateMapfixAuditCommentReq, params CreateMapfixAuditCommentParams) error
|
|
||||||
// CreateScript implements createScript operation.
|
// CreateScript implements createScript operation.
|
||||||
//
|
//
|
||||||
// Create a new script.
|
// Create a new script.
|
||||||
@@ -172,18 +140,6 @@ type Handler interface {
|
|||||||
//
|
//
|
||||||
// POST /submissions
|
// POST /submissions
|
||||||
CreateSubmission(ctx context.Context, req *SubmissionTriggerCreate) (*OperationID, error)
|
CreateSubmission(ctx context.Context, req *SubmissionTriggerCreate) (*OperationID, error)
|
||||||
// CreateSubmissionAdmin implements createSubmissionAdmin operation.
|
|
||||||
//
|
|
||||||
// Trigger the validator to create a new submission.
|
|
||||||
//
|
|
||||||
// POST /submissions-admin
|
|
||||||
CreateSubmissionAdmin(ctx context.Context, req *SubmissionTriggerCreate) (*OperationID, error)
|
|
||||||
// CreateSubmissionAuditComment implements createSubmissionAuditComment operation.
|
|
||||||
//
|
|
||||||
// Post a comment to the audit log.
|
|
||||||
//
|
|
||||||
// POST /submissions/{SubmissionID}/comment
|
|
||||||
CreateSubmissionAuditComment(ctx context.Context, req CreateSubmissionAuditCommentReq, params CreateSubmissionAuditCommentParams) error
|
|
||||||
// DeleteScript implements deleteScript operation.
|
// DeleteScript implements deleteScript operation.
|
||||||
//
|
//
|
||||||
// Delete the specified script by ID.
|
// Delete the specified script by ID.
|
||||||
@@ -202,12 +158,6 @@ type Handler interface {
|
|||||||
//
|
//
|
||||||
// GET /maps/{MapID}
|
// GET /maps/{MapID}
|
||||||
GetMap(ctx context.Context, params GetMapParams) (*Map, error)
|
GetMap(ctx context.Context, params GetMapParams) (*Map, error)
|
||||||
// GetMapAssetLocation implements getMapAssetLocation operation.
|
|
||||||
//
|
|
||||||
// Get location of asset.
|
|
||||||
//
|
|
||||||
// GET /maps/{MapID}/location
|
|
||||||
GetMapAssetLocation(ctx context.Context, params GetMapAssetLocationParams) (GetMapAssetLocationOK, error)
|
|
||||||
// GetMapfix implements getMapfix operation.
|
// GetMapfix implements getMapfix operation.
|
||||||
//
|
//
|
||||||
// Retrieve map with ID.
|
// Retrieve map with ID.
|
||||||
@@ -238,18 +188,12 @@ type Handler interface {
|
|||||||
//
|
//
|
||||||
// GET /submissions/{SubmissionID}
|
// GET /submissions/{SubmissionID}
|
||||||
GetSubmission(ctx context.Context, params GetSubmissionParams) (*Submission, error)
|
GetSubmission(ctx context.Context, params GetSubmissionParams) (*Submission, error)
|
||||||
// ListMapfixAuditEvents implements listMapfixAuditEvents operation.
|
|
||||||
//
|
|
||||||
// Retrieve a list of audit events.
|
|
||||||
//
|
|
||||||
// GET /mapfixes/{MapfixID}/audit-events
|
|
||||||
ListMapfixAuditEvents(ctx context.Context, params ListMapfixAuditEventsParams) ([]AuditEvent, error)
|
|
||||||
// ListMapfixes implements listMapfixes operation.
|
// ListMapfixes implements listMapfixes operation.
|
||||||
//
|
//
|
||||||
// Get list of mapfixes.
|
// Get list of mapfixes.
|
||||||
//
|
//
|
||||||
// GET /mapfixes
|
// GET /mapfixes
|
||||||
ListMapfixes(ctx context.Context, params ListMapfixesParams) (*Mapfixes, error)
|
ListMapfixes(ctx context.Context, params ListMapfixesParams) ([]Mapfix, error)
|
||||||
// ListMaps implements listMaps operation.
|
// ListMaps implements listMaps operation.
|
||||||
//
|
//
|
||||||
// Get list of maps.
|
// Get list of maps.
|
||||||
@@ -268,18 +212,12 @@ type Handler interface {
|
|||||||
//
|
//
|
||||||
// GET /scripts
|
// GET /scripts
|
||||||
ListScripts(ctx context.Context, params ListScriptsParams) ([]Script, error)
|
ListScripts(ctx context.Context, params ListScriptsParams) ([]Script, error)
|
||||||
// ListSubmissionAuditEvents implements listSubmissionAuditEvents operation.
|
|
||||||
//
|
|
||||||
// Retrieve a list of audit events.
|
|
||||||
//
|
|
||||||
// GET /submissions/{SubmissionID}/audit-events
|
|
||||||
ListSubmissionAuditEvents(ctx context.Context, params ListSubmissionAuditEventsParams) ([]AuditEvent, error)
|
|
||||||
// ListSubmissions implements listSubmissions operation.
|
// ListSubmissions implements listSubmissions operation.
|
||||||
//
|
//
|
||||||
// Get list of submissions.
|
// Get list of submissions.
|
||||||
//
|
//
|
||||||
// GET /submissions
|
// GET /submissions
|
||||||
ListSubmissions(ctx context.Context, params ListSubmissionsParams) (*Submissions, error)
|
ListSubmissions(ctx context.Context, params ListSubmissionsParams) ([]Submission, error)
|
||||||
// ReleaseSubmissions implements releaseSubmissions operation.
|
// ReleaseSubmissions implements releaseSubmissions operation.
|
||||||
//
|
//
|
||||||
// Release a set of uploaded maps.
|
// Release a set of uploaded maps.
|
||||||
|
|||||||
@@ -40,16 +40,6 @@ func (UnimplementedHandler) ActionMapfixRequestChanges(ctx context.Context, para
|
|||||||
return ht.ErrNotImplemented
|
return ht.ErrNotImplemented
|
||||||
}
|
}
|
||||||
|
|
||||||
// ActionMapfixResetSubmitting implements actionMapfixResetSubmitting operation.
|
|
||||||
//
|
|
||||||
// Role Submitter manually resets submitting softlock and changes status from Submitting ->
|
|
||||||
// UnderConstruction.
|
|
||||||
//
|
|
||||||
// POST /mapfixes/{MapfixID}/status/reset-submitting
|
|
||||||
func (UnimplementedHandler) ActionMapfixResetSubmitting(ctx context.Context, params ActionMapfixResetSubmittingParams) error {
|
|
||||||
return ht.ErrNotImplemented
|
|
||||||
}
|
|
||||||
|
|
||||||
// ActionMapfixRetryValidate implements actionMapfixRetryValidate operation.
|
// ActionMapfixRetryValidate implements actionMapfixRetryValidate operation.
|
||||||
//
|
//
|
||||||
// Role Reviewer re-runs validation and changes status from Accepted -> Validating.
|
// Role Reviewer re-runs validation and changes status from Accepted -> Validating.
|
||||||
@@ -68,21 +58,12 @@ func (UnimplementedHandler) ActionMapfixRevoke(ctx context.Context, params Actio
|
|||||||
return ht.ErrNotImplemented
|
return ht.ErrNotImplemented
|
||||||
}
|
}
|
||||||
|
|
||||||
// ActionMapfixTriggerSubmit implements actionMapfixTriggerSubmit operation.
|
// ActionMapfixSubmit implements actionMapfixSubmit operation.
|
||||||
//
|
//
|
||||||
// Role Submitter changes status from UnderConstruction|ChangesRequested -> Submitting.
|
// Role Submitter changes status from UnderConstruction|ChangesRequested -> Submitted.
|
||||||
//
|
//
|
||||||
// POST /mapfixes/{MapfixID}/status/trigger-submit
|
// POST /mapfixes/{MapfixID}/status/submit
|
||||||
func (UnimplementedHandler) ActionMapfixTriggerSubmit(ctx context.Context, params ActionMapfixTriggerSubmitParams) error {
|
func (UnimplementedHandler) ActionMapfixSubmit(ctx context.Context, params ActionMapfixSubmitParams) error {
|
||||||
return ht.ErrNotImplemented
|
|
||||||
}
|
|
||||||
|
|
||||||
// ActionMapfixTriggerSubmitUnchecked implements actionMapfixTriggerSubmitUnchecked operation.
|
|
||||||
//
|
|
||||||
// Role Reviewer changes status from ChangesRequested -> Submitting.
|
|
||||||
//
|
|
||||||
// POST /mapfixes/{MapfixID}/status/trigger-submit-unchecked
|
|
||||||
func (UnimplementedHandler) ActionMapfixTriggerSubmitUnchecked(ctx context.Context, params ActionMapfixTriggerSubmitUncheckedParams) error {
|
|
||||||
return ht.ErrNotImplemented
|
return ht.ErrNotImplemented
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -140,16 +121,6 @@ func (UnimplementedHandler) ActionSubmissionRequestChanges(ctx context.Context,
|
|||||||
return ht.ErrNotImplemented
|
return ht.ErrNotImplemented
|
||||||
}
|
}
|
||||||
|
|
||||||
// ActionSubmissionResetSubmitting implements actionSubmissionResetSubmitting operation.
|
|
||||||
//
|
|
||||||
// Role Submitter manually resets submitting softlock and changes status from Submitting ->
|
|
||||||
// UnderConstruction.
|
|
||||||
//
|
|
||||||
// POST /submissions/{SubmissionID}/status/reset-submitting
|
|
||||||
func (UnimplementedHandler) ActionSubmissionResetSubmitting(ctx context.Context, params ActionSubmissionResetSubmittingParams) error {
|
|
||||||
return ht.ErrNotImplemented
|
|
||||||
}
|
|
||||||
|
|
||||||
// ActionSubmissionRetryValidate implements actionSubmissionRetryValidate operation.
|
// ActionSubmissionRetryValidate implements actionSubmissionRetryValidate operation.
|
||||||
//
|
//
|
||||||
// Role Reviewer re-runs validation and changes status from Accepted -> Validating.
|
// Role Reviewer re-runs validation and changes status from Accepted -> Validating.
|
||||||
@@ -168,21 +139,12 @@ func (UnimplementedHandler) ActionSubmissionRevoke(ctx context.Context, params A
|
|||||||
return ht.ErrNotImplemented
|
return ht.ErrNotImplemented
|
||||||
}
|
}
|
||||||
|
|
||||||
// ActionSubmissionTriggerSubmit implements actionSubmissionTriggerSubmit operation.
|
// ActionSubmissionSubmit implements actionSubmissionSubmit operation.
|
||||||
//
|
//
|
||||||
// Role Submitter changes status from UnderConstruction|ChangesRequested -> Submitting.
|
// Role Submitter changes status from UnderConstruction|ChangesRequested -> Submitted.
|
||||||
//
|
//
|
||||||
// POST /submissions/{SubmissionID}/status/trigger-submit
|
// POST /submissions/{SubmissionID}/status/submit
|
||||||
func (UnimplementedHandler) ActionSubmissionTriggerSubmit(ctx context.Context, params ActionSubmissionTriggerSubmitParams) error {
|
func (UnimplementedHandler) ActionSubmissionSubmit(ctx context.Context, params ActionSubmissionSubmitParams) error {
|
||||||
return ht.ErrNotImplemented
|
|
||||||
}
|
|
||||||
|
|
||||||
// ActionSubmissionTriggerSubmitUnchecked implements actionSubmissionTriggerSubmitUnchecked operation.
|
|
||||||
//
|
|
||||||
// Role Reviewer changes status from ChangesRequested -> Submitting.
|
|
||||||
//
|
|
||||||
// POST /submissions/{SubmissionID}/status/trigger-submit-unchecked
|
|
||||||
func (UnimplementedHandler) ActionSubmissionTriggerSubmitUnchecked(ctx context.Context, params ActionSubmissionTriggerSubmitUncheckedParams) error {
|
|
||||||
return ht.ErrNotImplemented
|
return ht.ErrNotImplemented
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -222,15 +184,6 @@ func (UnimplementedHandler) CreateMapfix(ctx context.Context, req *MapfixTrigger
|
|||||||
return r, ht.ErrNotImplemented
|
return r, ht.ErrNotImplemented
|
||||||
}
|
}
|
||||||
|
|
||||||
// CreateMapfixAuditComment implements createMapfixAuditComment operation.
|
|
||||||
//
|
|
||||||
// Post a comment to the audit log.
|
|
||||||
//
|
|
||||||
// POST /mapfixes/{MapfixID}/comment
|
|
||||||
func (UnimplementedHandler) CreateMapfixAuditComment(ctx context.Context, req CreateMapfixAuditCommentReq, params CreateMapfixAuditCommentParams) error {
|
|
||||||
return ht.ErrNotImplemented
|
|
||||||
}
|
|
||||||
|
|
||||||
// CreateScript implements createScript operation.
|
// CreateScript implements createScript operation.
|
||||||
//
|
//
|
||||||
// Create a new script.
|
// Create a new script.
|
||||||
@@ -258,24 +211,6 @@ func (UnimplementedHandler) CreateSubmission(ctx context.Context, req *Submissio
|
|||||||
return r, ht.ErrNotImplemented
|
return r, ht.ErrNotImplemented
|
||||||
}
|
}
|
||||||
|
|
||||||
// CreateSubmissionAdmin implements createSubmissionAdmin operation.
|
|
||||||
//
|
|
||||||
// Trigger the validator to create a new submission.
|
|
||||||
//
|
|
||||||
// POST /submissions-admin
|
|
||||||
func (UnimplementedHandler) CreateSubmissionAdmin(ctx context.Context, req *SubmissionTriggerCreate) (r *OperationID, _ error) {
|
|
||||||
return r, ht.ErrNotImplemented
|
|
||||||
}
|
|
||||||
|
|
||||||
// CreateSubmissionAuditComment implements createSubmissionAuditComment operation.
|
|
||||||
//
|
|
||||||
// Post a comment to the audit log.
|
|
||||||
//
|
|
||||||
// POST /submissions/{SubmissionID}/comment
|
|
||||||
func (UnimplementedHandler) CreateSubmissionAuditComment(ctx context.Context, req CreateSubmissionAuditCommentReq, params CreateSubmissionAuditCommentParams) error {
|
|
||||||
return ht.ErrNotImplemented
|
|
||||||
}
|
|
||||||
|
|
||||||
// DeleteScript implements deleteScript operation.
|
// DeleteScript implements deleteScript operation.
|
||||||
//
|
//
|
||||||
// Delete the specified script by ID.
|
// Delete the specified script by ID.
|
||||||
@@ -303,15 +238,6 @@ func (UnimplementedHandler) GetMap(ctx context.Context, params GetMapParams) (r
|
|||||||
return r, ht.ErrNotImplemented
|
return r, ht.ErrNotImplemented
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetMapAssetLocation implements getMapAssetLocation operation.
|
|
||||||
//
|
|
||||||
// Get location of asset.
|
|
||||||
//
|
|
||||||
// GET /maps/{MapID}/location
|
|
||||||
func (UnimplementedHandler) GetMapAssetLocation(ctx context.Context, params GetMapAssetLocationParams) (r GetMapAssetLocationOK, _ error) {
|
|
||||||
return r, ht.ErrNotImplemented
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetMapfix implements getMapfix operation.
|
// GetMapfix implements getMapfix operation.
|
||||||
//
|
//
|
||||||
// Retrieve map with ID.
|
// Retrieve map with ID.
|
||||||
@@ -357,21 +283,12 @@ func (UnimplementedHandler) GetSubmission(ctx context.Context, params GetSubmiss
|
|||||||
return r, ht.ErrNotImplemented
|
return r, ht.ErrNotImplemented
|
||||||
}
|
}
|
||||||
|
|
||||||
// ListMapfixAuditEvents implements listMapfixAuditEvents operation.
|
|
||||||
//
|
|
||||||
// Retrieve a list of audit events.
|
|
||||||
//
|
|
||||||
// GET /mapfixes/{MapfixID}/audit-events
|
|
||||||
func (UnimplementedHandler) ListMapfixAuditEvents(ctx context.Context, params ListMapfixAuditEventsParams) (r []AuditEvent, _ error) {
|
|
||||||
return r, ht.ErrNotImplemented
|
|
||||||
}
|
|
||||||
|
|
||||||
// ListMapfixes implements listMapfixes operation.
|
// ListMapfixes implements listMapfixes operation.
|
||||||
//
|
//
|
||||||
// Get list of mapfixes.
|
// Get list of mapfixes.
|
||||||
//
|
//
|
||||||
// GET /mapfixes
|
// GET /mapfixes
|
||||||
func (UnimplementedHandler) ListMapfixes(ctx context.Context, params ListMapfixesParams) (r *Mapfixes, _ error) {
|
func (UnimplementedHandler) ListMapfixes(ctx context.Context, params ListMapfixesParams) (r []Mapfix, _ error) {
|
||||||
return r, ht.ErrNotImplemented
|
return r, ht.ErrNotImplemented
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -402,21 +319,12 @@ func (UnimplementedHandler) ListScripts(ctx context.Context, params ListScriptsP
|
|||||||
return r, ht.ErrNotImplemented
|
return r, ht.ErrNotImplemented
|
||||||
}
|
}
|
||||||
|
|
||||||
// ListSubmissionAuditEvents implements listSubmissionAuditEvents operation.
|
|
||||||
//
|
|
||||||
// Retrieve a list of audit events.
|
|
||||||
//
|
|
||||||
// GET /submissions/{SubmissionID}/audit-events
|
|
||||||
func (UnimplementedHandler) ListSubmissionAuditEvents(ctx context.Context, params ListSubmissionAuditEventsParams) (r []AuditEvent, _ error) {
|
|
||||||
return r, ht.ErrNotImplemented
|
|
||||||
}
|
|
||||||
|
|
||||||
// ListSubmissions implements listSubmissions operation.
|
// ListSubmissions implements listSubmissions operation.
|
||||||
//
|
//
|
||||||
// Get list of submissions.
|
// Get list of submissions.
|
||||||
//
|
//
|
||||||
// GET /submissions
|
// GET /submissions
|
||||||
func (UnimplementedHandler) ListSubmissions(ctx context.Context, params ListSubmissionsParams) (r *Submissions, _ error) {
|
func (UnimplementedHandler) ListSubmissions(ctx context.Context, params ListSubmissionsParams) (r []Submission, _ error) {
|
||||||
return r, ht.ErrNotImplemented
|
return r, ht.ErrNotImplemented
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -6,11 +6,9 @@ import (
|
|||||||
|
|
||||||
"git.itzana.me/strafesnet/go-grpc/auth"
|
"git.itzana.me/strafesnet/go-grpc/auth"
|
||||||
"git.itzana.me/strafesnet/go-grpc/maps"
|
"git.itzana.me/strafesnet/go-grpc/maps"
|
||||||
"git.itzana.me/strafesnet/go-grpc/users"
|
|
||||||
"git.itzana.me/strafesnet/maps-service/pkg/api"
|
"git.itzana.me/strafesnet/maps-service/pkg/api"
|
||||||
"git.itzana.me/strafesnet/maps-service/pkg/datastore/gormstore"
|
"git.itzana.me/strafesnet/maps-service/pkg/datastore/gormstore"
|
||||||
internal "git.itzana.me/strafesnet/maps-service/pkg/internal"
|
internal "git.itzana.me/strafesnet/maps-service/pkg/internal"
|
||||||
"git.itzana.me/strafesnet/maps-service/pkg/roblox"
|
|
||||||
"git.itzana.me/strafesnet/maps-service/pkg/service"
|
"git.itzana.me/strafesnet/maps-service/pkg/service"
|
||||||
"git.itzana.me/strafesnet/maps-service/pkg/service_internal"
|
"git.itzana.me/strafesnet/maps-service/pkg/service_internal"
|
||||||
"github.com/nats-io/nats.go"
|
"github.com/nats-io/nats.go"
|
||||||
@@ -92,12 +90,6 @@ func NewServeCommand() *cli.Command {
|
|||||||
EnvVars: []string{"NATS_HOST"},
|
EnvVars: []string{"NATS_HOST"},
|
||||||
Value: "nats:4222",
|
Value: "nats:4222",
|
||||||
},
|
},
|
||||||
&cli.StringFlag{
|
|
||||||
Name: "rbx-api-key",
|
|
||||||
Usage: "API Key for downloading asset locations",
|
|
||||||
EnvVars: []string{"RBX_API_KEY"},
|
|
||||||
Required: true,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -133,12 +125,7 @@ func serve(ctx *cli.Context) error {
|
|||||||
svc := &service.Service{
|
svc := &service.Service{
|
||||||
DB: db,
|
DB: db,
|
||||||
Nats: js,
|
Nats: js,
|
||||||
Maps: maps.NewMapsServiceClient(conn),
|
Client: maps.NewMapsServiceClient(conn),
|
||||||
Users: users.NewUsersServiceClient(conn),
|
|
||||||
Roblox: roblox.Client{
|
|
||||||
HttpClient: http.DefaultClient,
|
|
||||||
ApiKey: ctx.String("rbx-api-key"),
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
|
|
||||||
conn, err = grpc.Dial(ctx.String("auth-rpc-host"), grpc.WithTransportCredentials(insecure.NewCredentials()))
|
conn, err = grpc.Dial(ctx.String("auth-rpc-host"), grpc.WithTransportCredentials(insecure.NewCredentials()))
|
||||||
|
|||||||
@@ -3,8 +3,6 @@ package datastore
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
"time"
|
|
||||||
|
|
||||||
"git.itzana.me/strafesnet/maps-service/pkg/model"
|
"git.itzana.me/strafesnet/maps-service/pkg/model"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -24,7 +22,6 @@ const (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type Datastore interface {
|
type Datastore interface {
|
||||||
AuditEvents() AuditEvents
|
|
||||||
Mapfixes() Mapfixes
|
Mapfixes() Mapfixes
|
||||||
Operations() Operations
|
Operations() Operations
|
||||||
Submissions() Submissions
|
Submissions() Submissions
|
||||||
@@ -32,14 +29,6 @@ type Datastore interface {
|
|||||||
ScriptPolicy() ScriptPolicy
|
ScriptPolicy() ScriptPolicy
|
||||||
}
|
}
|
||||||
|
|
||||||
type AuditEvents interface {
|
|
||||||
Get(ctx context.Context, id int64) (model.AuditEvent, error)
|
|
||||||
Create(ctx context.Context, smap model.AuditEvent) (model.AuditEvent, error)
|
|
||||||
Update(ctx context.Context, id int64, values OptionalMap) error
|
|
||||||
Delete(ctx context.Context, id int64) error
|
|
||||||
List(ctx context.Context, filters OptionalMap, page model.Page) ([]model.AuditEvent, error)
|
|
||||||
}
|
|
||||||
|
|
||||||
type Mapfixes interface {
|
type Mapfixes interface {
|
||||||
Get(ctx context.Context, id int64) (model.Mapfix, error)
|
Get(ctx context.Context, id int64) (model.Mapfix, error)
|
||||||
GetList(ctx context.Context, id []int64) ([]model.Mapfix, error)
|
GetList(ctx context.Context, id []int64) ([]model.Mapfix, error)
|
||||||
@@ -49,7 +38,7 @@ type Mapfixes interface {
|
|||||||
IfStatusThenUpdateAndGet(ctx context.Context, id int64, statuses []model.MapfixStatus, values OptionalMap) (model.Mapfix, error)
|
IfStatusThenUpdateAndGet(ctx context.Context, id int64, statuses []model.MapfixStatus, values OptionalMap) (model.Mapfix, error)
|
||||||
Delete(ctx context.Context, id int64) error
|
Delete(ctx context.Context, id int64) error
|
||||||
List(ctx context.Context, filters OptionalMap, page model.Page, sort ListSort) ([]model.Mapfix, error)
|
List(ctx context.Context, filters OptionalMap, page model.Page, sort ListSort) ([]model.Mapfix, error)
|
||||||
ListWithTotal(ctx context.Context, filters OptionalMap, page model.Page, sort ListSort) (int64, []model.Mapfix, error)
|
ListRestricted(ctx context.Context, filters OptionalMap, page model.Page, sort ListSort, submitter int64) ([]model.Mapfix, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
type Operations interface {
|
type Operations interface {
|
||||||
@@ -57,7 +46,6 @@ type Operations interface {
|
|||||||
Create(ctx context.Context, smap model.Operation) (model.Operation, error)
|
Create(ctx context.Context, smap model.Operation) (model.Operation, error)
|
||||||
Update(ctx context.Context, id int32, values OptionalMap) error
|
Update(ctx context.Context, id int32, values OptionalMap) error
|
||||||
Delete(ctx context.Context, id int32) error
|
Delete(ctx context.Context, id int32) error
|
||||||
CountSince(ctx context.Context, owner int64, since time.Time) (int64, error)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type Submissions interface {
|
type Submissions interface {
|
||||||
@@ -69,7 +57,7 @@ type Submissions interface {
|
|||||||
IfStatusThenUpdateAndGet(ctx context.Context, id int64, statuses []model.SubmissionStatus, values OptionalMap) (model.Submission, error)
|
IfStatusThenUpdateAndGet(ctx context.Context, id int64, statuses []model.SubmissionStatus, values OptionalMap) (model.Submission, error)
|
||||||
Delete(ctx context.Context, id int64) error
|
Delete(ctx context.Context, id int64) error
|
||||||
List(ctx context.Context, filters OptionalMap, page model.Page, sort ListSort) ([]model.Submission, error)
|
List(ctx context.Context, filters OptionalMap, page model.Page, sort ListSort) ([]model.Submission, error)
|
||||||
ListWithTotal(ctx context.Context, filters OptionalMap, page model.Page, sort ListSort) (int64, []model.Submission, error)
|
ListRestricted(ctx context.Context, filters OptionalMap, page model.Page, sort ListSort, submitter int64) ([]model.Submission, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
type Scripts interface {
|
type Scripts interface {
|
||||||
|
|||||||
@@ -1,64 +0,0 @@
|
|||||||
package gormstore
|
|
||||||
|
|
||||||
import (
|
|
||||||
"context"
|
|
||||||
"errors"
|
|
||||||
|
|
||||||
"git.itzana.me/strafesnet/maps-service/pkg/datastore"
|
|
||||||
"git.itzana.me/strafesnet/maps-service/pkg/model"
|
|
||||||
"gorm.io/gorm"
|
|
||||||
)
|
|
||||||
|
|
||||||
type AuditEvents struct {
|
|
||||||
db *gorm.DB
|
|
||||||
}
|
|
||||||
|
|
||||||
func (env *AuditEvents) Get(ctx context.Context, id int64) (model.AuditEvent, error) {
|
|
||||||
var mdl model.AuditEvent
|
|
||||||
if err := env.db.First(&mdl, id).Error; err != nil {
|
|
||||||
if errors.Is(err, gorm.ErrRecordNotFound) {
|
|
||||||
return mdl, datastore.ErrNotExist
|
|
||||||
}
|
|
||||||
return mdl, err
|
|
||||||
}
|
|
||||||
return mdl, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (env *AuditEvents) Create(ctx context.Context, smap model.AuditEvent) (model.AuditEvent, error) {
|
|
||||||
if err := env.db.Create(&smap).Error; err != nil {
|
|
||||||
return smap, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return smap, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (env *AuditEvents) Update(ctx context.Context, id int64, values datastore.OptionalMap) error {
|
|
||||||
if err := env.db.Model(&model.AuditEvent{}).Where("id = ?", id).Updates(values.Map()).Error; err != nil {
|
|
||||||
if err == gorm.ErrRecordNotFound {
|
|
||||||
return datastore.ErrNotExist
|
|
||||||
}
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (env *AuditEvents) Delete(ctx context.Context, id int64) error {
|
|
||||||
if err := env.db.Delete(&model.AuditEvent{}, id).Error; err != nil {
|
|
||||||
if err == gorm.ErrRecordNotFound {
|
|
||||||
return datastore.ErrNotExist
|
|
||||||
}
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (env *AuditEvents) List(ctx context.Context, filters datastore.OptionalMap, page model.Page) ([]model.AuditEvent, error) {
|
|
||||||
var events []model.AuditEvent
|
|
||||||
if err := env.db.Where(filters.Map()).Offset(int((page.Number - 1) * page.Size)).Limit(int(page.Size)).Find(&events).Error; err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return events, nil
|
|
||||||
}
|
|
||||||
@@ -31,7 +31,6 @@ func New(ctx *cli.Context) (datastore.Datastore, error) {
|
|||||||
|
|
||||||
if ctx.Bool("migrate") {
|
if ctx.Bool("migrate") {
|
||||||
if err := db.AutoMigrate(
|
if err := db.AutoMigrate(
|
||||||
&model.AuditEvent{},
|
|
||||||
&model.Mapfix{},
|
&model.Mapfix{},
|
||||||
&model.Operation{},
|
&model.Operation{},
|
||||||
&model.Submission{},
|
&model.Submission{},
|
||||||
|
|||||||
@@ -9,10 +9,6 @@ type Gormstore struct {
|
|||||||
db *gorm.DB
|
db *gorm.DB
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g Gormstore) AuditEvents() datastore.AuditEvents {
|
|
||||||
return &AuditEvents{db: g.db}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (g Gormstore) Mapfixes() datastore.Mapfixes {
|
func (g Gormstore) Mapfixes() datastore.Mapfixes {
|
||||||
return &Mapfixes{db: g.db}
|
return &Mapfixes{db: g.db}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -55,16 +55,11 @@ func (env *Mapfixes) Update(ctx context.Context, id int64, values datastore.Opti
|
|||||||
|
|
||||||
// the update can only occur if the status matches one of the provided values.
|
// the update can only occur if the status matches one of the provided values.
|
||||||
func (env *Mapfixes) IfStatusThenUpdate(ctx context.Context, id int64, statuses []model.MapfixStatus, values datastore.OptionalMap) error {
|
func (env *Mapfixes) IfStatusThenUpdate(ctx context.Context, id int64, statuses []model.MapfixStatus, values datastore.OptionalMap) error {
|
||||||
result := env.db.Model(&model.Mapfix{}).Where("id = ?", id).Where("status_id IN ?", statuses).Updates(values.Map())
|
if err := env.db.Model(&model.Mapfix{}).Where("id = ?", id).Where("status_id IN ?", statuses).Updates(values.Map()).Error; err != nil {
|
||||||
if result.Error != nil {
|
if err == gorm.ErrRecordNotFound {
|
||||||
if result.Error == gorm.ErrRecordNotFound {
|
|
||||||
return datastore.ErrNotExist
|
return datastore.ErrNotExist
|
||||||
}
|
}
|
||||||
return result.Error
|
return err
|
||||||
}
|
|
||||||
|
|
||||||
if result.RowsAffected == 0 {
|
|
||||||
return datastore.ErroNoRowsAffected
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
@@ -136,18 +131,39 @@ func (env *Mapfixes) List(ctx context.Context, filters datastore.OptionalMap, pa
|
|||||||
return maps, nil
|
return maps, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (env *Mapfixes) ListWithTotal(ctx context.Context, filters datastore.OptionalMap, page model.Page, sort datastore.ListSort) (int64, []model.Mapfix, error) {
|
func (env *Mapfixes) ListRestricted(ctx context.Context, filters datastore.OptionalMap, page model.Page, sort datastore.ListSort, submitter int64) ([]model.Mapfix, error) {
|
||||||
// grab page items
|
var maps []model.Mapfix
|
||||||
maps, err := env.List(ctx, filters, page, sort)
|
|
||||||
if err != nil{
|
db := env.db
|
||||||
return 0, nil, err
|
|
||||||
|
switch sort {
|
||||||
|
case datastore.ListSortDisabled:
|
||||||
|
// No sort
|
||||||
|
break
|
||||||
|
case datastore.ListSortDisplayNameAscending:
|
||||||
|
db=db.Order("display_name ASC")
|
||||||
|
break
|
||||||
|
case datastore.ListSortDisplayNameDescending:
|
||||||
|
db=db.Order("display_name DESC")
|
||||||
|
break
|
||||||
|
case datastore.ListSortDateAscending:
|
||||||
|
db=db.Order("created_at ASC")
|
||||||
|
break
|
||||||
|
case datastore.ListSortDateDescending:
|
||||||
|
db=db.Order("created_at DESC")
|
||||||
|
break
|
||||||
|
default:
|
||||||
|
return nil, datastore.ErrInvalidListSort
|
||||||
}
|
}
|
||||||
|
|
||||||
// count total with filters
|
if err := db.
|
||||||
var total int64
|
Where(filters.Map()).
|
||||||
if err := env.db.Model(&model.Mapfix{}).Where(filters.Map()).Count(&total).Error; err != nil {
|
Where("status_id NOT IN ? OR submitter = ? AND status_id IN ?",PrivateSubmissions,submitter,PrivateSubmissions).
|
||||||
return 0, nil, err
|
Offset(int((page.Number - 1) * page.Size)).
|
||||||
|
Limit(int(page.Size)).
|
||||||
|
Find(&maps).Error; err != nil {
|
||||||
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return total, maps, nil
|
return maps, nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ package gormstore
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
"time"
|
|
||||||
|
|
||||||
"git.itzana.me/strafesnet/maps-service/pkg/datastore"
|
"git.itzana.me/strafesnet/maps-service/pkg/datastore"
|
||||||
"git.itzana.me/strafesnet/maps-service/pkg/model"
|
"git.itzana.me/strafesnet/maps-service/pkg/model"
|
||||||
@@ -54,12 +53,3 @@ func (env *Operations) Delete(ctx context.Context, id int32) error {
|
|||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (env *Operations) CountSince(ctx context.Context, owner int64, since time.Time) (int64, error) {
|
|
||||||
var count int64
|
|
||||||
if err := env.db.Model(&model.Operation{}).Where("owner = ? AND created_at > ?",owner,since).Count(&count).Error; err != nil {
|
|
||||||
return count, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return count, nil
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -10,6 +10,13 @@ import (
|
|||||||
"gorm.io/gorm/clause"
|
"gorm.io/gorm/clause"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var(
|
||||||
|
PrivateSubmissions = []model.SubmissionStatus{
|
||||||
|
model.SubmissionStatusUnderConstruction,
|
||||||
|
model.SubmissionStatusChangesRequested,
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
type Submissions struct {
|
type Submissions struct {
|
||||||
db *gorm.DB
|
db *gorm.DB
|
||||||
}
|
}
|
||||||
@@ -55,16 +62,11 @@ func (env *Submissions) Update(ctx context.Context, id int64, values datastore.O
|
|||||||
|
|
||||||
// the update can only occur if the status matches one of the provided values.
|
// the update can only occur if the status matches one of the provided values.
|
||||||
func (env *Submissions) IfStatusThenUpdate(ctx context.Context, id int64, statuses []model.SubmissionStatus, values datastore.OptionalMap) error {
|
func (env *Submissions) IfStatusThenUpdate(ctx context.Context, id int64, statuses []model.SubmissionStatus, values datastore.OptionalMap) error {
|
||||||
result := env.db.Model(&model.Submission{}).Where("id = ?", id).Where("status_id IN ?", statuses).Updates(values.Map())
|
if err := env.db.Model(&model.Submission{}).Where("id = ?", id).Where("status_id IN ?", statuses).Updates(values.Map()).Error; err != nil {
|
||||||
if result.Error != nil {
|
if err == gorm.ErrRecordNotFound {
|
||||||
if result.Error == gorm.ErrRecordNotFound {
|
|
||||||
return datastore.ErrNotExist
|
return datastore.ErrNotExist
|
||||||
}
|
}
|
||||||
return result.Error
|
return err
|
||||||
}
|
|
||||||
|
|
||||||
if result.RowsAffected == 0 {
|
|
||||||
return datastore.ErroNoRowsAffected
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
@@ -136,18 +138,43 @@ func (env *Submissions) List(ctx context.Context, filters datastore.OptionalMap,
|
|||||||
return maps, nil
|
return maps, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (env *Submissions) ListWithTotal(ctx context.Context, filters datastore.OptionalMap, page model.Page, sort datastore.ListSort) (int64, []model.Submission, error) {
|
func (env *Submissions) ListRestricted(ctx context.Context, filters datastore.OptionalMap, page model.Page, sort datastore.ListSort, submitter int64) ([]model.Submission, error) {
|
||||||
// grab page items
|
var maps []model.Submission
|
||||||
maps, err := env.List(ctx, filters, page, sort)
|
|
||||||
if err != nil{
|
db := env.db
|
||||||
return 0, nil, err
|
|
||||||
|
switch sort {
|
||||||
|
case datastore.ListSortDisabled:
|
||||||
|
// No sort
|
||||||
|
break
|
||||||
|
case datastore.ListSortDisplayNameAscending:
|
||||||
|
db=db.Order("display_name ASC")
|
||||||
|
break
|
||||||
|
case datastore.ListSortDisplayNameDescending:
|
||||||
|
db=db.Order("display_name DESC")
|
||||||
|
break
|
||||||
|
case datastore.ListSortDateAscending:
|
||||||
|
db=db.Order("created_at ASC")
|
||||||
|
break
|
||||||
|
case datastore.ListSortDateDescending:
|
||||||
|
db=db.Order("created_at DESC")
|
||||||
|
break
|
||||||
|
default:
|
||||||
|
return nil, datastore.ErrInvalidListSort
|
||||||
}
|
}
|
||||||
|
|
||||||
// count total with filters
|
if err := db.
|
||||||
var total int64
|
Where(filters.Map()).
|
||||||
if err := env.db.Model(&model.Submission{}).Where(filters.Map()).Count(&total).Error; err != nil {
|
// In order to see submissions,
|
||||||
return 0, nil, err
|
// at least one of two criteria must be met:
|
||||||
|
// - You are the submitter
|
||||||
|
// - The submission is not under construction / changes requested
|
||||||
|
Where("status_id NOT IN ? OR submitter = ? AND status_id IN ?",PrivateSubmissions,submitter,PrivateSubmissions).
|
||||||
|
Offset(int((page.Number - 1) * page.Size)).
|
||||||
|
Limit(int(page.Size)).
|
||||||
|
Find(&maps).Error; err != nil {
|
||||||
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return total, maps, nil
|
return maps, nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,18 +34,6 @@ type Invoker interface {
|
|||||||
//
|
//
|
||||||
// POST /mapfixes/{MapfixID}/status/validator-failed
|
// POST /mapfixes/{MapfixID}/status/validator-failed
|
||||||
ActionMapfixAccepted(ctx context.Context, params ActionMapfixAcceptedParams) error
|
ActionMapfixAccepted(ctx context.Context, params ActionMapfixAcceptedParams) error
|
||||||
// ActionMapfixRequestChanges invokes actionMapfixRequestChanges operation.
|
|
||||||
//
|
|
||||||
// (Internal endpoint) Role Validator changes status from Submitting -> ChangesRequested.
|
|
||||||
//
|
|
||||||
// POST /mapfixes/{MapfixID}/status/validator-request-changes
|
|
||||||
ActionMapfixRequestChanges(ctx context.Context, params ActionMapfixRequestChangesParams) error
|
|
||||||
// ActionMapfixSubmitted invokes actionMapfixSubmitted operation.
|
|
||||||
//
|
|
||||||
// (Internal endpoint) Role Validator changes status from Submitting -> Submitted.
|
|
||||||
//
|
|
||||||
// POST /mapfixes/{MapfixID}/status/validator-submitted
|
|
||||||
ActionMapfixSubmitted(ctx context.Context, params ActionMapfixSubmittedParams) error
|
|
||||||
// ActionMapfixUploaded invokes actionMapfixUploaded operation.
|
// ActionMapfixUploaded invokes actionMapfixUploaded operation.
|
||||||
//
|
//
|
||||||
// (Internal endpoint) Role Validator changes status from Uploading -> Uploaded.
|
// (Internal endpoint) Role Validator changes status from Uploading -> Uploaded.
|
||||||
@@ -70,18 +58,6 @@ type Invoker interface {
|
|||||||
//
|
//
|
||||||
// POST /submissions/{SubmissionID}/status/validator-failed
|
// POST /submissions/{SubmissionID}/status/validator-failed
|
||||||
ActionSubmissionAccepted(ctx context.Context, params ActionSubmissionAcceptedParams) error
|
ActionSubmissionAccepted(ctx context.Context, params ActionSubmissionAcceptedParams) error
|
||||||
// ActionSubmissionRequestChanges invokes actionSubmissionRequestChanges operation.
|
|
||||||
//
|
|
||||||
// (Internal endpoint) Role Validator changes status from Submitting -> ChangesRequested.
|
|
||||||
//
|
|
||||||
// POST /submissions/{SubmissionID}/status/validator-request-changes
|
|
||||||
ActionSubmissionRequestChanges(ctx context.Context, params ActionSubmissionRequestChangesParams) error
|
|
||||||
// ActionSubmissionSubmitted invokes actionSubmissionSubmitted operation.
|
|
||||||
//
|
|
||||||
// (Internal endpoint) Role Validator changes status from Submitting -> Submitted.
|
|
||||||
//
|
|
||||||
// POST /submissions/{SubmissionID}/status/validator-submitted
|
|
||||||
ActionSubmissionSubmitted(ctx context.Context, params ActionSubmissionSubmittedParams) error
|
|
||||||
// ActionSubmissionUploaded invokes actionSubmissionUploaded operation.
|
// ActionSubmissionUploaded invokes actionSubmissionUploaded operation.
|
||||||
//
|
//
|
||||||
// (Internal endpoint) Role Validator changes status from Uploading -> Uploaded.
|
// (Internal endpoint) Role Validator changes status from Uploading -> Uploaded.
|
||||||
@@ -100,18 +76,6 @@ type Invoker interface {
|
|||||||
//
|
//
|
||||||
// POST /mapfixes
|
// POST /mapfixes
|
||||||
CreateMapfix(ctx context.Context, request *MapfixCreate) (*MapfixID, error)
|
CreateMapfix(ctx context.Context, request *MapfixCreate) (*MapfixID, error)
|
||||||
// CreateMapfixAuditCheckList invokes createMapfixAuditCheckList operation.
|
|
||||||
//
|
|
||||||
// Validator posts a checklist to the audit log.
|
|
||||||
//
|
|
||||||
// POST /mapfixes/{MapfixID}/checklist
|
|
||||||
CreateMapfixAuditCheckList(ctx context.Context, request CheckList, params CreateMapfixAuditCheckListParams) error
|
|
||||||
// CreateMapfixAuditError invokes createMapfixAuditError operation.
|
|
||||||
//
|
|
||||||
// Validator posts an error to the audit log.
|
|
||||||
//
|
|
||||||
// POST /mapfixes/{MapfixID}/error
|
|
||||||
CreateMapfixAuditError(ctx context.Context, params CreateMapfixAuditErrorParams) error
|
|
||||||
// CreateScript invokes createScript operation.
|
// CreateScript invokes createScript operation.
|
||||||
//
|
//
|
||||||
// Create a new script.
|
// Create a new script.
|
||||||
@@ -130,18 +94,6 @@ type Invoker interface {
|
|||||||
//
|
//
|
||||||
// POST /submissions
|
// POST /submissions
|
||||||
CreateSubmission(ctx context.Context, request *SubmissionCreate) (*SubmissionID, error)
|
CreateSubmission(ctx context.Context, request *SubmissionCreate) (*SubmissionID, error)
|
||||||
// CreateSubmissionAuditCheckList invokes createSubmissionAuditCheckList operation.
|
|
||||||
//
|
|
||||||
// Validator posts a checklist to the audit log.
|
|
||||||
//
|
|
||||||
// POST /submissions/{SubmissionID}/checklist
|
|
||||||
CreateSubmissionAuditCheckList(ctx context.Context, request CheckList, params CreateSubmissionAuditCheckListParams) error
|
|
||||||
// CreateSubmissionAuditError invokes createSubmissionAuditError operation.
|
|
||||||
//
|
|
||||||
// Validator posts an error to the audit log.
|
|
||||||
//
|
|
||||||
// POST /submissions/{SubmissionID}/error
|
|
||||||
CreateSubmissionAuditError(ctx context.Context, params CreateSubmissionAuditErrorParams) error
|
|
||||||
// GetScript invokes getScript operation.
|
// GetScript invokes getScript operation.
|
||||||
//
|
//
|
||||||
// Get the specified script by ID.
|
// Get the specified script by ID.
|
||||||
@@ -290,242 +242,18 @@ func (c *Client) sendActionMapfixAccepted(ctx context.Context, params ActionMapf
|
|||||||
pathParts[2] = "/status/validator-failed"
|
pathParts[2] = "/status/validator-failed"
|
||||||
uri.AddPathParts(u, pathParts[:]...)
|
uri.AddPathParts(u, pathParts[:]...)
|
||||||
|
|
||||||
stage = "EncodeRequest"
|
|
||||||
r, err := ht.NewRequest(ctx, "POST", u)
|
|
||||||
if err != nil {
|
|
||||||
return res, errors.Wrap(err, "create request")
|
|
||||||
}
|
|
||||||
|
|
||||||
stage = "SendRequest"
|
|
||||||
resp, err := c.cfg.Client.Do(r)
|
|
||||||
if err != nil {
|
|
||||||
return res, errors.Wrap(err, "do request")
|
|
||||||
}
|
|
||||||
defer resp.Body.Close()
|
|
||||||
|
|
||||||
stage = "DecodeResponse"
|
|
||||||
result, err := decodeActionMapfixAcceptedResponse(resp)
|
|
||||||
if err != nil {
|
|
||||||
return res, errors.Wrap(err, "decode response")
|
|
||||||
}
|
|
||||||
|
|
||||||
return result, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// ActionMapfixRequestChanges invokes actionMapfixRequestChanges operation.
|
|
||||||
//
|
|
||||||
// (Internal endpoint) Role Validator changes status from Submitting -> ChangesRequested.
|
|
||||||
//
|
|
||||||
// POST /mapfixes/{MapfixID}/status/validator-request-changes
|
|
||||||
func (c *Client) ActionMapfixRequestChanges(ctx context.Context, params ActionMapfixRequestChangesParams) error {
|
|
||||||
_, err := c.sendActionMapfixRequestChanges(ctx, params)
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *Client) sendActionMapfixRequestChanges(ctx context.Context, params ActionMapfixRequestChangesParams) (res *ActionMapfixRequestChangesNoContent, err error) {
|
|
||||||
otelAttrs := []attribute.KeyValue{
|
|
||||||
otelogen.OperationID("actionMapfixRequestChanges"),
|
|
||||||
semconv.HTTPRequestMethodKey.String("POST"),
|
|
||||||
semconv.HTTPRouteKey.String("/mapfixes/{MapfixID}/status/validator-request-changes"),
|
|
||||||
}
|
|
||||||
|
|
||||||
// Run stopwatch.
|
|
||||||
startTime := time.Now()
|
|
||||||
defer func() {
|
|
||||||
// Use floating point division here for higher precision (instead of Millisecond method).
|
|
||||||
elapsedDuration := time.Since(startTime)
|
|
||||||
c.duration.Record(ctx, float64(elapsedDuration)/float64(time.Millisecond), metric.WithAttributes(otelAttrs...))
|
|
||||||
}()
|
|
||||||
|
|
||||||
// Increment request counter.
|
|
||||||
c.requests.Add(ctx, 1, metric.WithAttributes(otelAttrs...))
|
|
||||||
|
|
||||||
// Start a span for this request.
|
|
||||||
ctx, span := c.cfg.Tracer.Start(ctx, ActionMapfixRequestChangesOperation,
|
|
||||||
trace.WithAttributes(otelAttrs...),
|
|
||||||
clientSpanKind,
|
|
||||||
)
|
|
||||||
// Track stage for error reporting.
|
|
||||||
var stage string
|
|
||||||
defer func() {
|
|
||||||
if err != nil {
|
|
||||||
span.RecordError(err)
|
|
||||||
span.SetStatus(codes.Error, stage)
|
|
||||||
c.errors.Add(ctx, 1, metric.WithAttributes(otelAttrs...))
|
|
||||||
}
|
|
||||||
span.End()
|
|
||||||
}()
|
|
||||||
|
|
||||||
stage = "BuildURL"
|
|
||||||
u := uri.Clone(c.requestURL(ctx))
|
|
||||||
var pathParts [3]string
|
|
||||||
pathParts[0] = "/mapfixes/"
|
|
||||||
{
|
|
||||||
// Encode "MapfixID" parameter.
|
|
||||||
e := uri.NewPathEncoder(uri.PathEncoderConfig{
|
|
||||||
Param: "MapfixID",
|
|
||||||
Style: uri.PathStyleSimple,
|
|
||||||
Explode: false,
|
|
||||||
})
|
|
||||||
if err := func() error {
|
|
||||||
return e.EncodeValue(conv.Int64ToString(params.MapfixID))
|
|
||||||
}(); err != nil {
|
|
||||||
return res, errors.Wrap(err, "encode path")
|
|
||||||
}
|
|
||||||
encoded, err := e.Result()
|
|
||||||
if err != nil {
|
|
||||||
return res, errors.Wrap(err, "encode path")
|
|
||||||
}
|
|
||||||
pathParts[1] = encoded
|
|
||||||
}
|
|
||||||
pathParts[2] = "/status/validator-request-changes"
|
|
||||||
uri.AddPathParts(u, pathParts[:]...)
|
|
||||||
|
|
||||||
stage = "EncodeRequest"
|
|
||||||
r, err := ht.NewRequest(ctx, "POST", u)
|
|
||||||
if err != nil {
|
|
||||||
return res, errors.Wrap(err, "create request")
|
|
||||||
}
|
|
||||||
|
|
||||||
stage = "SendRequest"
|
|
||||||
resp, err := c.cfg.Client.Do(r)
|
|
||||||
if err != nil {
|
|
||||||
return res, errors.Wrap(err, "do request")
|
|
||||||
}
|
|
||||||
defer resp.Body.Close()
|
|
||||||
|
|
||||||
stage = "DecodeResponse"
|
|
||||||
result, err := decodeActionMapfixRequestChangesResponse(resp)
|
|
||||||
if err != nil {
|
|
||||||
return res, errors.Wrap(err, "decode response")
|
|
||||||
}
|
|
||||||
|
|
||||||
return result, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// ActionMapfixSubmitted invokes actionMapfixSubmitted operation.
|
|
||||||
//
|
|
||||||
// (Internal endpoint) Role Validator changes status from Submitting -> Submitted.
|
|
||||||
//
|
|
||||||
// POST /mapfixes/{MapfixID}/status/validator-submitted
|
|
||||||
func (c *Client) ActionMapfixSubmitted(ctx context.Context, params ActionMapfixSubmittedParams) error {
|
|
||||||
_, err := c.sendActionMapfixSubmitted(ctx, params)
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *Client) sendActionMapfixSubmitted(ctx context.Context, params ActionMapfixSubmittedParams) (res *ActionMapfixSubmittedNoContent, err error) {
|
|
||||||
otelAttrs := []attribute.KeyValue{
|
|
||||||
otelogen.OperationID("actionMapfixSubmitted"),
|
|
||||||
semconv.HTTPRequestMethodKey.String("POST"),
|
|
||||||
semconv.HTTPRouteKey.String("/mapfixes/{MapfixID}/status/validator-submitted"),
|
|
||||||
}
|
|
||||||
|
|
||||||
// Run stopwatch.
|
|
||||||
startTime := time.Now()
|
|
||||||
defer func() {
|
|
||||||
// Use floating point division here for higher precision (instead of Millisecond method).
|
|
||||||
elapsedDuration := time.Since(startTime)
|
|
||||||
c.duration.Record(ctx, float64(elapsedDuration)/float64(time.Millisecond), metric.WithAttributes(otelAttrs...))
|
|
||||||
}()
|
|
||||||
|
|
||||||
// Increment request counter.
|
|
||||||
c.requests.Add(ctx, 1, metric.WithAttributes(otelAttrs...))
|
|
||||||
|
|
||||||
// Start a span for this request.
|
|
||||||
ctx, span := c.cfg.Tracer.Start(ctx, ActionMapfixSubmittedOperation,
|
|
||||||
trace.WithAttributes(otelAttrs...),
|
|
||||||
clientSpanKind,
|
|
||||||
)
|
|
||||||
// Track stage for error reporting.
|
|
||||||
var stage string
|
|
||||||
defer func() {
|
|
||||||
if err != nil {
|
|
||||||
span.RecordError(err)
|
|
||||||
span.SetStatus(codes.Error, stage)
|
|
||||||
c.errors.Add(ctx, 1, metric.WithAttributes(otelAttrs...))
|
|
||||||
}
|
|
||||||
span.End()
|
|
||||||
}()
|
|
||||||
|
|
||||||
stage = "BuildURL"
|
|
||||||
u := uri.Clone(c.requestURL(ctx))
|
|
||||||
var pathParts [3]string
|
|
||||||
pathParts[0] = "/mapfixes/"
|
|
||||||
{
|
|
||||||
// Encode "MapfixID" parameter.
|
|
||||||
e := uri.NewPathEncoder(uri.PathEncoderConfig{
|
|
||||||
Param: "MapfixID",
|
|
||||||
Style: uri.PathStyleSimple,
|
|
||||||
Explode: false,
|
|
||||||
})
|
|
||||||
if err := func() error {
|
|
||||||
return e.EncodeValue(conv.Int64ToString(params.MapfixID))
|
|
||||||
}(); err != nil {
|
|
||||||
return res, errors.Wrap(err, "encode path")
|
|
||||||
}
|
|
||||||
encoded, err := e.Result()
|
|
||||||
if err != nil {
|
|
||||||
return res, errors.Wrap(err, "encode path")
|
|
||||||
}
|
|
||||||
pathParts[1] = encoded
|
|
||||||
}
|
|
||||||
pathParts[2] = "/status/validator-submitted"
|
|
||||||
uri.AddPathParts(u, pathParts[:]...)
|
|
||||||
|
|
||||||
stage = "EncodeQueryParams"
|
stage = "EncodeQueryParams"
|
||||||
q := uri.NewQueryEncoder()
|
q := uri.NewQueryEncoder()
|
||||||
{
|
{
|
||||||
// Encode "ModelVersion" parameter.
|
// Encode "StatusMessage" parameter.
|
||||||
cfg := uri.QueryParameterEncodingConfig{
|
cfg := uri.QueryParameterEncodingConfig{
|
||||||
Name: "ModelVersion",
|
Name: "StatusMessage",
|
||||||
Style: uri.QueryStyleForm,
|
Style: uri.QueryStyleForm,
|
||||||
Explode: true,
|
Explode: true,
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := q.EncodeParam(cfg, func(e uri.Encoder) error {
|
if err := q.EncodeParam(cfg, func(e uri.Encoder) error {
|
||||||
return e.EncodeValue(conv.Int64ToString(params.ModelVersion))
|
return e.EncodeValue(conv.StringToString(params.StatusMessage))
|
||||||
}); err != nil {
|
|
||||||
return res, errors.Wrap(err, "encode query")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
{
|
|
||||||
// Encode "DisplayName" parameter.
|
|
||||||
cfg := uri.QueryParameterEncodingConfig{
|
|
||||||
Name: "DisplayName",
|
|
||||||
Style: uri.QueryStyleForm,
|
|
||||||
Explode: true,
|
|
||||||
}
|
|
||||||
|
|
||||||
if err := q.EncodeParam(cfg, func(e uri.Encoder) error {
|
|
||||||
return e.EncodeValue(conv.StringToString(params.DisplayName))
|
|
||||||
}); err != nil {
|
|
||||||
return res, errors.Wrap(err, "encode query")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
{
|
|
||||||
// Encode "Creator" parameter.
|
|
||||||
cfg := uri.QueryParameterEncodingConfig{
|
|
||||||
Name: "Creator",
|
|
||||||
Style: uri.QueryStyleForm,
|
|
||||||
Explode: true,
|
|
||||||
}
|
|
||||||
|
|
||||||
if err := q.EncodeParam(cfg, func(e uri.Encoder) error {
|
|
||||||
return e.EncodeValue(conv.StringToString(params.Creator))
|
|
||||||
}); err != nil {
|
|
||||||
return res, errors.Wrap(err, "encode query")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
{
|
|
||||||
// Encode "GameID" parameter.
|
|
||||||
cfg := uri.QueryParameterEncodingConfig{
|
|
||||||
Name: "GameID",
|
|
||||||
Style: uri.QueryStyleForm,
|
|
||||||
Explode: true,
|
|
||||||
}
|
|
||||||
|
|
||||||
if err := q.EncodeParam(cfg, func(e uri.Encoder) error {
|
|
||||||
return e.EncodeValue(conv.Int32ToString(params.GameID))
|
|
||||||
}); err != nil {
|
}); err != nil {
|
||||||
return res, errors.Wrap(err, "encode query")
|
return res, errors.Wrap(err, "encode query")
|
||||||
}
|
}
|
||||||
@@ -546,7 +274,7 @@ func (c *Client) sendActionMapfixSubmitted(ctx context.Context, params ActionMap
|
|||||||
defer resp.Body.Close()
|
defer resp.Body.Close()
|
||||||
|
|
||||||
stage = "DecodeResponse"
|
stage = "DecodeResponse"
|
||||||
result, err := decodeActionMapfixSubmittedResponse(resp)
|
result, err := decodeActionMapfixAcceptedResponse(resp)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return res, errors.Wrap(err, "decode response")
|
return res, errors.Wrap(err, "decode response")
|
||||||
}
|
}
|
||||||
@@ -914,242 +642,18 @@ func (c *Client) sendActionSubmissionAccepted(ctx context.Context, params Action
|
|||||||
pathParts[2] = "/status/validator-failed"
|
pathParts[2] = "/status/validator-failed"
|
||||||
uri.AddPathParts(u, pathParts[:]...)
|
uri.AddPathParts(u, pathParts[:]...)
|
||||||
|
|
||||||
stage = "EncodeRequest"
|
|
||||||
r, err := ht.NewRequest(ctx, "POST", u)
|
|
||||||
if err != nil {
|
|
||||||
return res, errors.Wrap(err, "create request")
|
|
||||||
}
|
|
||||||
|
|
||||||
stage = "SendRequest"
|
|
||||||
resp, err := c.cfg.Client.Do(r)
|
|
||||||
if err != nil {
|
|
||||||
return res, errors.Wrap(err, "do request")
|
|
||||||
}
|
|
||||||
defer resp.Body.Close()
|
|
||||||
|
|
||||||
stage = "DecodeResponse"
|
|
||||||
result, err := decodeActionSubmissionAcceptedResponse(resp)
|
|
||||||
if err != nil {
|
|
||||||
return res, errors.Wrap(err, "decode response")
|
|
||||||
}
|
|
||||||
|
|
||||||
return result, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// ActionSubmissionRequestChanges invokes actionSubmissionRequestChanges operation.
|
|
||||||
//
|
|
||||||
// (Internal endpoint) Role Validator changes status from Submitting -> ChangesRequested.
|
|
||||||
//
|
|
||||||
// POST /submissions/{SubmissionID}/status/validator-request-changes
|
|
||||||
func (c *Client) ActionSubmissionRequestChanges(ctx context.Context, params ActionSubmissionRequestChangesParams) error {
|
|
||||||
_, err := c.sendActionSubmissionRequestChanges(ctx, params)
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *Client) sendActionSubmissionRequestChanges(ctx context.Context, params ActionSubmissionRequestChangesParams) (res *ActionSubmissionRequestChangesNoContent, err error) {
|
|
||||||
otelAttrs := []attribute.KeyValue{
|
|
||||||
otelogen.OperationID("actionSubmissionRequestChanges"),
|
|
||||||
semconv.HTTPRequestMethodKey.String("POST"),
|
|
||||||
semconv.HTTPRouteKey.String("/submissions/{SubmissionID}/status/validator-request-changes"),
|
|
||||||
}
|
|
||||||
|
|
||||||
// Run stopwatch.
|
|
||||||
startTime := time.Now()
|
|
||||||
defer func() {
|
|
||||||
// Use floating point division here for higher precision (instead of Millisecond method).
|
|
||||||
elapsedDuration := time.Since(startTime)
|
|
||||||
c.duration.Record(ctx, float64(elapsedDuration)/float64(time.Millisecond), metric.WithAttributes(otelAttrs...))
|
|
||||||
}()
|
|
||||||
|
|
||||||
// Increment request counter.
|
|
||||||
c.requests.Add(ctx, 1, metric.WithAttributes(otelAttrs...))
|
|
||||||
|
|
||||||
// Start a span for this request.
|
|
||||||
ctx, span := c.cfg.Tracer.Start(ctx, ActionSubmissionRequestChangesOperation,
|
|
||||||
trace.WithAttributes(otelAttrs...),
|
|
||||||
clientSpanKind,
|
|
||||||
)
|
|
||||||
// Track stage for error reporting.
|
|
||||||
var stage string
|
|
||||||
defer func() {
|
|
||||||
if err != nil {
|
|
||||||
span.RecordError(err)
|
|
||||||
span.SetStatus(codes.Error, stage)
|
|
||||||
c.errors.Add(ctx, 1, metric.WithAttributes(otelAttrs...))
|
|
||||||
}
|
|
||||||
span.End()
|
|
||||||
}()
|
|
||||||
|
|
||||||
stage = "BuildURL"
|
|
||||||
u := uri.Clone(c.requestURL(ctx))
|
|
||||||
var pathParts [3]string
|
|
||||||
pathParts[0] = "/submissions/"
|
|
||||||
{
|
|
||||||
// Encode "SubmissionID" parameter.
|
|
||||||
e := uri.NewPathEncoder(uri.PathEncoderConfig{
|
|
||||||
Param: "SubmissionID",
|
|
||||||
Style: uri.PathStyleSimple,
|
|
||||||
Explode: false,
|
|
||||||
})
|
|
||||||
if err := func() error {
|
|
||||||
return e.EncodeValue(conv.Int64ToString(params.SubmissionID))
|
|
||||||
}(); err != nil {
|
|
||||||
return res, errors.Wrap(err, "encode path")
|
|
||||||
}
|
|
||||||
encoded, err := e.Result()
|
|
||||||
if err != nil {
|
|
||||||
return res, errors.Wrap(err, "encode path")
|
|
||||||
}
|
|
||||||
pathParts[1] = encoded
|
|
||||||
}
|
|
||||||
pathParts[2] = "/status/validator-request-changes"
|
|
||||||
uri.AddPathParts(u, pathParts[:]...)
|
|
||||||
|
|
||||||
stage = "EncodeRequest"
|
|
||||||
r, err := ht.NewRequest(ctx, "POST", u)
|
|
||||||
if err != nil {
|
|
||||||
return res, errors.Wrap(err, "create request")
|
|
||||||
}
|
|
||||||
|
|
||||||
stage = "SendRequest"
|
|
||||||
resp, err := c.cfg.Client.Do(r)
|
|
||||||
if err != nil {
|
|
||||||
return res, errors.Wrap(err, "do request")
|
|
||||||
}
|
|
||||||
defer resp.Body.Close()
|
|
||||||
|
|
||||||
stage = "DecodeResponse"
|
|
||||||
result, err := decodeActionSubmissionRequestChangesResponse(resp)
|
|
||||||
if err != nil {
|
|
||||||
return res, errors.Wrap(err, "decode response")
|
|
||||||
}
|
|
||||||
|
|
||||||
return result, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// ActionSubmissionSubmitted invokes actionSubmissionSubmitted operation.
|
|
||||||
//
|
|
||||||
// (Internal endpoint) Role Validator changes status from Submitting -> Submitted.
|
|
||||||
//
|
|
||||||
// POST /submissions/{SubmissionID}/status/validator-submitted
|
|
||||||
func (c *Client) ActionSubmissionSubmitted(ctx context.Context, params ActionSubmissionSubmittedParams) error {
|
|
||||||
_, err := c.sendActionSubmissionSubmitted(ctx, params)
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *Client) sendActionSubmissionSubmitted(ctx context.Context, params ActionSubmissionSubmittedParams) (res *ActionSubmissionSubmittedNoContent, err error) {
|
|
||||||
otelAttrs := []attribute.KeyValue{
|
|
||||||
otelogen.OperationID("actionSubmissionSubmitted"),
|
|
||||||
semconv.HTTPRequestMethodKey.String("POST"),
|
|
||||||
semconv.HTTPRouteKey.String("/submissions/{SubmissionID}/status/validator-submitted"),
|
|
||||||
}
|
|
||||||
|
|
||||||
// Run stopwatch.
|
|
||||||
startTime := time.Now()
|
|
||||||
defer func() {
|
|
||||||
// Use floating point division here for higher precision (instead of Millisecond method).
|
|
||||||
elapsedDuration := time.Since(startTime)
|
|
||||||
c.duration.Record(ctx, float64(elapsedDuration)/float64(time.Millisecond), metric.WithAttributes(otelAttrs...))
|
|
||||||
}()
|
|
||||||
|
|
||||||
// Increment request counter.
|
|
||||||
c.requests.Add(ctx, 1, metric.WithAttributes(otelAttrs...))
|
|
||||||
|
|
||||||
// Start a span for this request.
|
|
||||||
ctx, span := c.cfg.Tracer.Start(ctx, ActionSubmissionSubmittedOperation,
|
|
||||||
trace.WithAttributes(otelAttrs...),
|
|
||||||
clientSpanKind,
|
|
||||||
)
|
|
||||||
// Track stage for error reporting.
|
|
||||||
var stage string
|
|
||||||
defer func() {
|
|
||||||
if err != nil {
|
|
||||||
span.RecordError(err)
|
|
||||||
span.SetStatus(codes.Error, stage)
|
|
||||||
c.errors.Add(ctx, 1, metric.WithAttributes(otelAttrs...))
|
|
||||||
}
|
|
||||||
span.End()
|
|
||||||
}()
|
|
||||||
|
|
||||||
stage = "BuildURL"
|
|
||||||
u := uri.Clone(c.requestURL(ctx))
|
|
||||||
var pathParts [3]string
|
|
||||||
pathParts[0] = "/submissions/"
|
|
||||||
{
|
|
||||||
// Encode "SubmissionID" parameter.
|
|
||||||
e := uri.NewPathEncoder(uri.PathEncoderConfig{
|
|
||||||
Param: "SubmissionID",
|
|
||||||
Style: uri.PathStyleSimple,
|
|
||||||
Explode: false,
|
|
||||||
})
|
|
||||||
if err := func() error {
|
|
||||||
return e.EncodeValue(conv.Int64ToString(params.SubmissionID))
|
|
||||||
}(); err != nil {
|
|
||||||
return res, errors.Wrap(err, "encode path")
|
|
||||||
}
|
|
||||||
encoded, err := e.Result()
|
|
||||||
if err != nil {
|
|
||||||
return res, errors.Wrap(err, "encode path")
|
|
||||||
}
|
|
||||||
pathParts[1] = encoded
|
|
||||||
}
|
|
||||||
pathParts[2] = "/status/validator-submitted"
|
|
||||||
uri.AddPathParts(u, pathParts[:]...)
|
|
||||||
|
|
||||||
stage = "EncodeQueryParams"
|
stage = "EncodeQueryParams"
|
||||||
q := uri.NewQueryEncoder()
|
q := uri.NewQueryEncoder()
|
||||||
{
|
{
|
||||||
// Encode "ModelVersion" parameter.
|
// Encode "StatusMessage" parameter.
|
||||||
cfg := uri.QueryParameterEncodingConfig{
|
cfg := uri.QueryParameterEncodingConfig{
|
||||||
Name: "ModelVersion",
|
Name: "StatusMessage",
|
||||||
Style: uri.QueryStyleForm,
|
Style: uri.QueryStyleForm,
|
||||||
Explode: true,
|
Explode: true,
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := q.EncodeParam(cfg, func(e uri.Encoder) error {
|
if err := q.EncodeParam(cfg, func(e uri.Encoder) error {
|
||||||
return e.EncodeValue(conv.Int64ToString(params.ModelVersion))
|
return e.EncodeValue(conv.StringToString(params.StatusMessage))
|
||||||
}); err != nil {
|
|
||||||
return res, errors.Wrap(err, "encode query")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
{
|
|
||||||
// Encode "DisplayName" parameter.
|
|
||||||
cfg := uri.QueryParameterEncodingConfig{
|
|
||||||
Name: "DisplayName",
|
|
||||||
Style: uri.QueryStyleForm,
|
|
||||||
Explode: true,
|
|
||||||
}
|
|
||||||
|
|
||||||
if err := q.EncodeParam(cfg, func(e uri.Encoder) error {
|
|
||||||
return e.EncodeValue(conv.StringToString(params.DisplayName))
|
|
||||||
}); err != nil {
|
|
||||||
return res, errors.Wrap(err, "encode query")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
{
|
|
||||||
// Encode "Creator" parameter.
|
|
||||||
cfg := uri.QueryParameterEncodingConfig{
|
|
||||||
Name: "Creator",
|
|
||||||
Style: uri.QueryStyleForm,
|
|
||||||
Explode: true,
|
|
||||||
}
|
|
||||||
|
|
||||||
if err := q.EncodeParam(cfg, func(e uri.Encoder) error {
|
|
||||||
return e.EncodeValue(conv.StringToString(params.Creator))
|
|
||||||
}); err != nil {
|
|
||||||
return res, errors.Wrap(err, "encode query")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
{
|
|
||||||
// Encode "GameID" parameter.
|
|
||||||
cfg := uri.QueryParameterEncodingConfig{
|
|
||||||
Name: "GameID",
|
|
||||||
Style: uri.QueryStyleForm,
|
|
||||||
Explode: true,
|
|
||||||
}
|
|
||||||
|
|
||||||
if err := q.EncodeParam(cfg, func(e uri.Encoder) error {
|
|
||||||
return e.EncodeValue(conv.Int32ToString(params.GameID))
|
|
||||||
}); err != nil {
|
}); err != nil {
|
||||||
return res, errors.Wrap(err, "encode query")
|
return res, errors.Wrap(err, "encode query")
|
||||||
}
|
}
|
||||||
@@ -1170,7 +674,7 @@ func (c *Client) sendActionSubmissionSubmitted(ctx context.Context, params Actio
|
|||||||
defer resp.Body.Close()
|
defer resp.Body.Close()
|
||||||
|
|
||||||
stage = "DecodeResponse"
|
stage = "DecodeResponse"
|
||||||
result, err := decodeActionSubmissionSubmittedResponse(resp)
|
result, err := decodeActionSubmissionAcceptedResponse(resp)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return res, errors.Wrap(err, "decode response")
|
return res, errors.Wrap(err, "decode response")
|
||||||
}
|
}
|
||||||
@@ -1453,209 +957,6 @@ func (c *Client) sendCreateMapfix(ctx context.Context, request *MapfixCreate) (r
|
|||||||
return result, nil
|
return result, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// CreateMapfixAuditCheckList invokes createMapfixAuditCheckList operation.
|
|
||||||
//
|
|
||||||
// Validator posts a checklist to the audit log.
|
|
||||||
//
|
|
||||||
// POST /mapfixes/{MapfixID}/checklist
|
|
||||||
func (c *Client) CreateMapfixAuditCheckList(ctx context.Context, request CheckList, params CreateMapfixAuditCheckListParams) error {
|
|
||||||
_, err := c.sendCreateMapfixAuditCheckList(ctx, request, params)
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *Client) sendCreateMapfixAuditCheckList(ctx context.Context, request CheckList, params CreateMapfixAuditCheckListParams) (res *CreateMapfixAuditCheckListNoContent, err error) {
|
|
||||||
otelAttrs := []attribute.KeyValue{
|
|
||||||
otelogen.OperationID("createMapfixAuditCheckList"),
|
|
||||||
semconv.HTTPRequestMethodKey.String("POST"),
|
|
||||||
semconv.HTTPRouteKey.String("/mapfixes/{MapfixID}/checklist"),
|
|
||||||
}
|
|
||||||
|
|
||||||
// Run stopwatch.
|
|
||||||
startTime := time.Now()
|
|
||||||
defer func() {
|
|
||||||
// Use floating point division here for higher precision (instead of Millisecond method).
|
|
||||||
elapsedDuration := time.Since(startTime)
|
|
||||||
c.duration.Record(ctx, float64(elapsedDuration)/float64(time.Millisecond), metric.WithAttributes(otelAttrs...))
|
|
||||||
}()
|
|
||||||
|
|
||||||
// Increment request counter.
|
|
||||||
c.requests.Add(ctx, 1, metric.WithAttributes(otelAttrs...))
|
|
||||||
|
|
||||||
// Start a span for this request.
|
|
||||||
ctx, span := c.cfg.Tracer.Start(ctx, CreateMapfixAuditCheckListOperation,
|
|
||||||
trace.WithAttributes(otelAttrs...),
|
|
||||||
clientSpanKind,
|
|
||||||
)
|
|
||||||
// Track stage for error reporting.
|
|
||||||
var stage string
|
|
||||||
defer func() {
|
|
||||||
if err != nil {
|
|
||||||
span.RecordError(err)
|
|
||||||
span.SetStatus(codes.Error, stage)
|
|
||||||
c.errors.Add(ctx, 1, metric.WithAttributes(otelAttrs...))
|
|
||||||
}
|
|
||||||
span.End()
|
|
||||||
}()
|
|
||||||
|
|
||||||
stage = "BuildURL"
|
|
||||||
u := uri.Clone(c.requestURL(ctx))
|
|
||||||
var pathParts [3]string
|
|
||||||
pathParts[0] = "/mapfixes/"
|
|
||||||
{
|
|
||||||
// Encode "MapfixID" parameter.
|
|
||||||
e := uri.NewPathEncoder(uri.PathEncoderConfig{
|
|
||||||
Param: "MapfixID",
|
|
||||||
Style: uri.PathStyleSimple,
|
|
||||||
Explode: false,
|
|
||||||
})
|
|
||||||
if err := func() error {
|
|
||||||
return e.EncodeValue(conv.Int64ToString(params.MapfixID))
|
|
||||||
}(); err != nil {
|
|
||||||
return res, errors.Wrap(err, "encode path")
|
|
||||||
}
|
|
||||||
encoded, err := e.Result()
|
|
||||||
if err != nil {
|
|
||||||
return res, errors.Wrap(err, "encode path")
|
|
||||||
}
|
|
||||||
pathParts[1] = encoded
|
|
||||||
}
|
|
||||||
pathParts[2] = "/checklist"
|
|
||||||
uri.AddPathParts(u, pathParts[:]...)
|
|
||||||
|
|
||||||
stage = "EncodeRequest"
|
|
||||||
r, err := ht.NewRequest(ctx, "POST", u)
|
|
||||||
if err != nil {
|
|
||||||
return res, errors.Wrap(err, "create request")
|
|
||||||
}
|
|
||||||
if err := encodeCreateMapfixAuditCheckListRequest(request, r); err != nil {
|
|
||||||
return res, errors.Wrap(err, "encode request")
|
|
||||||
}
|
|
||||||
|
|
||||||
stage = "SendRequest"
|
|
||||||
resp, err := c.cfg.Client.Do(r)
|
|
||||||
if err != nil {
|
|
||||||
return res, errors.Wrap(err, "do request")
|
|
||||||
}
|
|
||||||
defer resp.Body.Close()
|
|
||||||
|
|
||||||
stage = "DecodeResponse"
|
|
||||||
result, err := decodeCreateMapfixAuditCheckListResponse(resp)
|
|
||||||
if err != nil {
|
|
||||||
return res, errors.Wrap(err, "decode response")
|
|
||||||
}
|
|
||||||
|
|
||||||
return result, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// CreateMapfixAuditError invokes createMapfixAuditError operation.
|
|
||||||
//
|
|
||||||
// Validator posts an error to the audit log.
|
|
||||||
//
|
|
||||||
// POST /mapfixes/{MapfixID}/error
|
|
||||||
func (c *Client) CreateMapfixAuditError(ctx context.Context, params CreateMapfixAuditErrorParams) error {
|
|
||||||
_, err := c.sendCreateMapfixAuditError(ctx, params)
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *Client) sendCreateMapfixAuditError(ctx context.Context, params CreateMapfixAuditErrorParams) (res *CreateMapfixAuditErrorNoContent, err error) {
|
|
||||||
otelAttrs := []attribute.KeyValue{
|
|
||||||
otelogen.OperationID("createMapfixAuditError"),
|
|
||||||
semconv.HTTPRequestMethodKey.String("POST"),
|
|
||||||
semconv.HTTPRouteKey.String("/mapfixes/{MapfixID}/error"),
|
|
||||||
}
|
|
||||||
|
|
||||||
// Run stopwatch.
|
|
||||||
startTime := time.Now()
|
|
||||||
defer func() {
|
|
||||||
// Use floating point division here for higher precision (instead of Millisecond method).
|
|
||||||
elapsedDuration := time.Since(startTime)
|
|
||||||
c.duration.Record(ctx, float64(elapsedDuration)/float64(time.Millisecond), metric.WithAttributes(otelAttrs...))
|
|
||||||
}()
|
|
||||||
|
|
||||||
// Increment request counter.
|
|
||||||
c.requests.Add(ctx, 1, metric.WithAttributes(otelAttrs...))
|
|
||||||
|
|
||||||
// Start a span for this request.
|
|
||||||
ctx, span := c.cfg.Tracer.Start(ctx, CreateMapfixAuditErrorOperation,
|
|
||||||
trace.WithAttributes(otelAttrs...),
|
|
||||||
clientSpanKind,
|
|
||||||
)
|
|
||||||
// Track stage for error reporting.
|
|
||||||
var stage string
|
|
||||||
defer func() {
|
|
||||||
if err != nil {
|
|
||||||
span.RecordError(err)
|
|
||||||
span.SetStatus(codes.Error, stage)
|
|
||||||
c.errors.Add(ctx, 1, metric.WithAttributes(otelAttrs...))
|
|
||||||
}
|
|
||||||
span.End()
|
|
||||||
}()
|
|
||||||
|
|
||||||
stage = "BuildURL"
|
|
||||||
u := uri.Clone(c.requestURL(ctx))
|
|
||||||
var pathParts [3]string
|
|
||||||
pathParts[0] = "/mapfixes/"
|
|
||||||
{
|
|
||||||
// Encode "MapfixID" parameter.
|
|
||||||
e := uri.NewPathEncoder(uri.PathEncoderConfig{
|
|
||||||
Param: "MapfixID",
|
|
||||||
Style: uri.PathStyleSimple,
|
|
||||||
Explode: false,
|
|
||||||
})
|
|
||||||
if err := func() error {
|
|
||||||
return e.EncodeValue(conv.Int64ToString(params.MapfixID))
|
|
||||||
}(); err != nil {
|
|
||||||
return res, errors.Wrap(err, "encode path")
|
|
||||||
}
|
|
||||||
encoded, err := e.Result()
|
|
||||||
if err != nil {
|
|
||||||
return res, errors.Wrap(err, "encode path")
|
|
||||||
}
|
|
||||||
pathParts[1] = encoded
|
|
||||||
}
|
|
||||||
pathParts[2] = "/error"
|
|
||||||
uri.AddPathParts(u, pathParts[:]...)
|
|
||||||
|
|
||||||
stage = "EncodeQueryParams"
|
|
||||||
q := uri.NewQueryEncoder()
|
|
||||||
{
|
|
||||||
// Encode "ErrorMessage" parameter.
|
|
||||||
cfg := uri.QueryParameterEncodingConfig{
|
|
||||||
Name: "ErrorMessage",
|
|
||||||
Style: uri.QueryStyleForm,
|
|
||||||
Explode: true,
|
|
||||||
}
|
|
||||||
|
|
||||||
if err := q.EncodeParam(cfg, func(e uri.Encoder) error {
|
|
||||||
return e.EncodeValue(conv.StringToString(params.ErrorMessage))
|
|
||||||
}); err != nil {
|
|
||||||
return res, errors.Wrap(err, "encode query")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
u.RawQuery = q.Values().Encode()
|
|
||||||
|
|
||||||
stage = "EncodeRequest"
|
|
||||||
r, err := ht.NewRequest(ctx, "POST", u)
|
|
||||||
if err != nil {
|
|
||||||
return res, errors.Wrap(err, "create request")
|
|
||||||
}
|
|
||||||
|
|
||||||
stage = "SendRequest"
|
|
||||||
resp, err := c.cfg.Client.Do(r)
|
|
||||||
if err != nil {
|
|
||||||
return res, errors.Wrap(err, "do request")
|
|
||||||
}
|
|
||||||
defer resp.Body.Close()
|
|
||||||
|
|
||||||
stage = "DecodeResponse"
|
|
||||||
result, err := decodeCreateMapfixAuditErrorResponse(resp)
|
|
||||||
if err != nil {
|
|
||||||
return res, errors.Wrap(err, "decode response")
|
|
||||||
}
|
|
||||||
|
|
||||||
return result, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// CreateScript invokes createScript operation.
|
// CreateScript invokes createScript operation.
|
||||||
//
|
//
|
||||||
// Create a new script.
|
// Create a new script.
|
||||||
@@ -1881,209 +1182,6 @@ func (c *Client) sendCreateSubmission(ctx context.Context, request *SubmissionCr
|
|||||||
return result, nil
|
return result, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// CreateSubmissionAuditCheckList invokes createSubmissionAuditCheckList operation.
|
|
||||||
//
|
|
||||||
// Validator posts a checklist to the audit log.
|
|
||||||
//
|
|
||||||
// POST /submissions/{SubmissionID}/checklist
|
|
||||||
func (c *Client) CreateSubmissionAuditCheckList(ctx context.Context, request CheckList, params CreateSubmissionAuditCheckListParams) error {
|
|
||||||
_, err := c.sendCreateSubmissionAuditCheckList(ctx, request, params)
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *Client) sendCreateSubmissionAuditCheckList(ctx context.Context, request CheckList, params CreateSubmissionAuditCheckListParams) (res *CreateSubmissionAuditCheckListNoContent, err error) {
|
|
||||||
otelAttrs := []attribute.KeyValue{
|
|
||||||
otelogen.OperationID("createSubmissionAuditCheckList"),
|
|
||||||
semconv.HTTPRequestMethodKey.String("POST"),
|
|
||||||
semconv.HTTPRouteKey.String("/submissions/{SubmissionID}/checklist"),
|
|
||||||
}
|
|
||||||
|
|
||||||
// Run stopwatch.
|
|
||||||
startTime := time.Now()
|
|
||||||
defer func() {
|
|
||||||
// Use floating point division here for higher precision (instead of Millisecond method).
|
|
||||||
elapsedDuration := time.Since(startTime)
|
|
||||||
c.duration.Record(ctx, float64(elapsedDuration)/float64(time.Millisecond), metric.WithAttributes(otelAttrs...))
|
|
||||||
}()
|
|
||||||
|
|
||||||
// Increment request counter.
|
|
||||||
c.requests.Add(ctx, 1, metric.WithAttributes(otelAttrs...))
|
|
||||||
|
|
||||||
// Start a span for this request.
|
|
||||||
ctx, span := c.cfg.Tracer.Start(ctx, CreateSubmissionAuditCheckListOperation,
|
|
||||||
trace.WithAttributes(otelAttrs...),
|
|
||||||
clientSpanKind,
|
|
||||||
)
|
|
||||||
// Track stage for error reporting.
|
|
||||||
var stage string
|
|
||||||
defer func() {
|
|
||||||
if err != nil {
|
|
||||||
span.RecordError(err)
|
|
||||||
span.SetStatus(codes.Error, stage)
|
|
||||||
c.errors.Add(ctx, 1, metric.WithAttributes(otelAttrs...))
|
|
||||||
}
|
|
||||||
span.End()
|
|
||||||
}()
|
|
||||||
|
|
||||||
stage = "BuildURL"
|
|
||||||
u := uri.Clone(c.requestURL(ctx))
|
|
||||||
var pathParts [3]string
|
|
||||||
pathParts[0] = "/submissions/"
|
|
||||||
{
|
|
||||||
// Encode "SubmissionID" parameter.
|
|
||||||
e := uri.NewPathEncoder(uri.PathEncoderConfig{
|
|
||||||
Param: "SubmissionID",
|
|
||||||
Style: uri.PathStyleSimple,
|
|
||||||
Explode: false,
|
|
||||||
})
|
|
||||||
if err := func() error {
|
|
||||||
return e.EncodeValue(conv.Int64ToString(params.SubmissionID))
|
|
||||||
}(); err != nil {
|
|
||||||
return res, errors.Wrap(err, "encode path")
|
|
||||||
}
|
|
||||||
encoded, err := e.Result()
|
|
||||||
if err != nil {
|
|
||||||
return res, errors.Wrap(err, "encode path")
|
|
||||||
}
|
|
||||||
pathParts[1] = encoded
|
|
||||||
}
|
|
||||||
pathParts[2] = "/checklist"
|
|
||||||
uri.AddPathParts(u, pathParts[:]...)
|
|
||||||
|
|
||||||
stage = "EncodeRequest"
|
|
||||||
r, err := ht.NewRequest(ctx, "POST", u)
|
|
||||||
if err != nil {
|
|
||||||
return res, errors.Wrap(err, "create request")
|
|
||||||
}
|
|
||||||
if err := encodeCreateSubmissionAuditCheckListRequest(request, r); err != nil {
|
|
||||||
return res, errors.Wrap(err, "encode request")
|
|
||||||
}
|
|
||||||
|
|
||||||
stage = "SendRequest"
|
|
||||||
resp, err := c.cfg.Client.Do(r)
|
|
||||||
if err != nil {
|
|
||||||
return res, errors.Wrap(err, "do request")
|
|
||||||
}
|
|
||||||
defer resp.Body.Close()
|
|
||||||
|
|
||||||
stage = "DecodeResponse"
|
|
||||||
result, err := decodeCreateSubmissionAuditCheckListResponse(resp)
|
|
||||||
if err != nil {
|
|
||||||
return res, errors.Wrap(err, "decode response")
|
|
||||||
}
|
|
||||||
|
|
||||||
return result, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// CreateSubmissionAuditError invokes createSubmissionAuditError operation.
|
|
||||||
//
|
|
||||||
// Validator posts an error to the audit log.
|
|
||||||
//
|
|
||||||
// POST /submissions/{SubmissionID}/error
|
|
||||||
func (c *Client) CreateSubmissionAuditError(ctx context.Context, params CreateSubmissionAuditErrorParams) error {
|
|
||||||
_, err := c.sendCreateSubmissionAuditError(ctx, params)
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *Client) sendCreateSubmissionAuditError(ctx context.Context, params CreateSubmissionAuditErrorParams) (res *CreateSubmissionAuditErrorNoContent, err error) {
|
|
||||||
otelAttrs := []attribute.KeyValue{
|
|
||||||
otelogen.OperationID("createSubmissionAuditError"),
|
|
||||||
semconv.HTTPRequestMethodKey.String("POST"),
|
|
||||||
semconv.HTTPRouteKey.String("/submissions/{SubmissionID}/error"),
|
|
||||||
}
|
|
||||||
|
|
||||||
// Run stopwatch.
|
|
||||||
startTime := time.Now()
|
|
||||||
defer func() {
|
|
||||||
// Use floating point division here for higher precision (instead of Millisecond method).
|
|
||||||
elapsedDuration := time.Since(startTime)
|
|
||||||
c.duration.Record(ctx, float64(elapsedDuration)/float64(time.Millisecond), metric.WithAttributes(otelAttrs...))
|
|
||||||
}()
|
|
||||||
|
|
||||||
// Increment request counter.
|
|
||||||
c.requests.Add(ctx, 1, metric.WithAttributes(otelAttrs...))
|
|
||||||
|
|
||||||
// Start a span for this request.
|
|
||||||
ctx, span := c.cfg.Tracer.Start(ctx, CreateSubmissionAuditErrorOperation,
|
|
||||||
trace.WithAttributes(otelAttrs...),
|
|
||||||
clientSpanKind,
|
|
||||||
)
|
|
||||||
// Track stage for error reporting.
|
|
||||||
var stage string
|
|
||||||
defer func() {
|
|
||||||
if err != nil {
|
|
||||||
span.RecordError(err)
|
|
||||||
span.SetStatus(codes.Error, stage)
|
|
||||||
c.errors.Add(ctx, 1, metric.WithAttributes(otelAttrs...))
|
|
||||||
}
|
|
||||||
span.End()
|
|
||||||
}()
|
|
||||||
|
|
||||||
stage = "BuildURL"
|
|
||||||
u := uri.Clone(c.requestURL(ctx))
|
|
||||||
var pathParts [3]string
|
|
||||||
pathParts[0] = "/submissions/"
|
|
||||||
{
|
|
||||||
// Encode "SubmissionID" parameter.
|
|
||||||
e := uri.NewPathEncoder(uri.PathEncoderConfig{
|
|
||||||
Param: "SubmissionID",
|
|
||||||
Style: uri.PathStyleSimple,
|
|
||||||
Explode: false,
|
|
||||||
})
|
|
||||||
if err := func() error {
|
|
||||||
return e.EncodeValue(conv.Int64ToString(params.SubmissionID))
|
|
||||||
}(); err != nil {
|
|
||||||
return res, errors.Wrap(err, "encode path")
|
|
||||||
}
|
|
||||||
encoded, err := e.Result()
|
|
||||||
if err != nil {
|
|
||||||
return res, errors.Wrap(err, "encode path")
|
|
||||||
}
|
|
||||||
pathParts[1] = encoded
|
|
||||||
}
|
|
||||||
pathParts[2] = "/error"
|
|
||||||
uri.AddPathParts(u, pathParts[:]...)
|
|
||||||
|
|
||||||
stage = "EncodeQueryParams"
|
|
||||||
q := uri.NewQueryEncoder()
|
|
||||||
{
|
|
||||||
// Encode "ErrorMessage" parameter.
|
|
||||||
cfg := uri.QueryParameterEncodingConfig{
|
|
||||||
Name: "ErrorMessage",
|
|
||||||
Style: uri.QueryStyleForm,
|
|
||||||
Explode: true,
|
|
||||||
}
|
|
||||||
|
|
||||||
if err := q.EncodeParam(cfg, func(e uri.Encoder) error {
|
|
||||||
return e.EncodeValue(conv.StringToString(params.ErrorMessage))
|
|
||||||
}); err != nil {
|
|
||||||
return res, errors.Wrap(err, "encode query")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
u.RawQuery = q.Values().Encode()
|
|
||||||
|
|
||||||
stage = "EncodeRequest"
|
|
||||||
r, err := ht.NewRequest(ctx, "POST", u)
|
|
||||||
if err != nil {
|
|
||||||
return res, errors.Wrap(err, "create request")
|
|
||||||
}
|
|
||||||
|
|
||||||
stage = "SendRequest"
|
|
||||||
resp, err := c.cfg.Client.Do(r)
|
|
||||||
if err != nil {
|
|
||||||
return res, errors.Wrap(err, "do request")
|
|
||||||
}
|
|
||||||
defer resp.Body.Close()
|
|
||||||
|
|
||||||
stage = "DecodeResponse"
|
|
||||||
result, err := decodeCreateSubmissionAuditErrorResponse(resp)
|
|
||||||
if err != nil {
|
|
||||||
return res, errors.Wrap(err, "decode response")
|
|
||||||
}
|
|
||||||
|
|
||||||
return result, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetScript invokes getScript operation.
|
// GetScript invokes getScript operation.
|
||||||
//
|
//
|
||||||
// Get the specified script by ID.
|
// Get the specified script by ID.
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -12,186 +12,6 @@ import (
|
|||||||
"github.com/ogen-go/ogen/validate"
|
"github.com/ogen-go/ogen/validate"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Encode implements json.Marshaler.
|
|
||||||
func (s *Check) Encode(e *jx.Encoder) {
|
|
||||||
e.ObjStart()
|
|
||||||
s.encodeFields(e)
|
|
||||||
e.ObjEnd()
|
|
||||||
}
|
|
||||||
|
|
||||||
// encodeFields encodes fields.
|
|
||||||
func (s *Check) encodeFields(e *jx.Encoder) {
|
|
||||||
{
|
|
||||||
e.FieldStart("Name")
|
|
||||||
e.Str(s.Name)
|
|
||||||
}
|
|
||||||
{
|
|
||||||
e.FieldStart("Summary")
|
|
||||||
e.Str(s.Summary)
|
|
||||||
}
|
|
||||||
{
|
|
||||||
e.FieldStart("Passed")
|
|
||||||
e.Bool(s.Passed)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
var jsonFieldsNameOfCheck = [3]string{
|
|
||||||
0: "Name",
|
|
||||||
1: "Summary",
|
|
||||||
2: "Passed",
|
|
||||||
}
|
|
||||||
|
|
||||||
// Decode decodes Check from json.
|
|
||||||
func (s *Check) Decode(d *jx.Decoder) error {
|
|
||||||
if s == nil {
|
|
||||||
return errors.New("invalid: unable to decode Check to nil")
|
|
||||||
}
|
|
||||||
var requiredBitSet [1]uint8
|
|
||||||
|
|
||||||
if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error {
|
|
||||||
switch string(k) {
|
|
||||||
case "Name":
|
|
||||||
requiredBitSet[0] |= 1 << 0
|
|
||||||
if err := func() error {
|
|
||||||
v, err := d.Str()
|
|
||||||
s.Name = string(v)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}(); err != nil {
|
|
||||||
return errors.Wrap(err, "decode field \"Name\"")
|
|
||||||
}
|
|
||||||
case "Summary":
|
|
||||||
requiredBitSet[0] |= 1 << 1
|
|
||||||
if err := func() error {
|
|
||||||
v, err := d.Str()
|
|
||||||
s.Summary = string(v)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}(); err != nil {
|
|
||||||
return errors.Wrap(err, "decode field \"Summary\"")
|
|
||||||
}
|
|
||||||
case "Passed":
|
|
||||||
requiredBitSet[0] |= 1 << 2
|
|
||||||
if err := func() error {
|
|
||||||
v, err := d.Bool()
|
|
||||||
s.Passed = bool(v)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}(); err != nil {
|
|
||||||
return errors.Wrap(err, "decode field \"Passed\"")
|
|
||||||
}
|
|
||||||
default:
|
|
||||||
return d.Skip()
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}); err != nil {
|
|
||||||
return errors.Wrap(err, "decode Check")
|
|
||||||
}
|
|
||||||
// Validate required fields.
|
|
||||||
var failures []validate.FieldError
|
|
||||||
for i, mask := range [1]uint8{
|
|
||||||
0b00000111,
|
|
||||||
} {
|
|
||||||
if result := (requiredBitSet[i] & mask) ^ mask; result != 0 {
|
|
||||||
// Mask only required fields and check equality to mask using XOR.
|
|
||||||
//
|
|
||||||
// If XOR result is not zero, result is not equal to expected, so some fields are missed.
|
|
||||||
// Bits of fields which would be set are actually bits of missed fields.
|
|
||||||
missed := bits.OnesCount8(result)
|
|
||||||
for bitN := 0; bitN < missed; bitN++ {
|
|
||||||
bitIdx := bits.TrailingZeros8(result)
|
|
||||||
fieldIdx := i*8 + bitIdx
|
|
||||||
var name string
|
|
||||||
if fieldIdx < len(jsonFieldsNameOfCheck) {
|
|
||||||
name = jsonFieldsNameOfCheck[fieldIdx]
|
|
||||||
} else {
|
|
||||||
name = strconv.Itoa(fieldIdx)
|
|
||||||
}
|
|
||||||
failures = append(failures, validate.FieldError{
|
|
||||||
Name: name,
|
|
||||||
Error: validate.ErrFieldRequired,
|
|
||||||
})
|
|
||||||
// Reset bit.
|
|
||||||
result &^= 1 << bitIdx
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if len(failures) > 0 {
|
|
||||||
return &validate.Error{Fields: failures}
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// MarshalJSON implements stdjson.Marshaler.
|
|
||||||
func (s *Check) MarshalJSON() ([]byte, error) {
|
|
||||||
e := jx.Encoder{}
|
|
||||||
s.Encode(&e)
|
|
||||||
return e.Bytes(), nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// UnmarshalJSON implements stdjson.Unmarshaler.
|
|
||||||
func (s *Check) UnmarshalJSON(data []byte) error {
|
|
||||||
d := jx.DecodeBytes(data)
|
|
||||||
return s.Decode(d)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Encode encodes CheckList as json.
|
|
||||||
func (s CheckList) Encode(e *jx.Encoder) {
|
|
||||||
unwrapped := []Check(s)
|
|
||||||
|
|
||||||
e.ArrStart()
|
|
||||||
for _, elem := range unwrapped {
|
|
||||||
elem.Encode(e)
|
|
||||||
}
|
|
||||||
e.ArrEnd()
|
|
||||||
}
|
|
||||||
|
|
||||||
// Decode decodes CheckList from json.
|
|
||||||
func (s *CheckList) Decode(d *jx.Decoder) error {
|
|
||||||
if s == nil {
|
|
||||||
return errors.New("invalid: unable to decode CheckList to nil")
|
|
||||||
}
|
|
||||||
var unwrapped []Check
|
|
||||||
if err := func() error {
|
|
||||||
unwrapped = make([]Check, 0)
|
|
||||||
if err := d.Arr(func(d *jx.Decoder) error {
|
|
||||||
var elem Check
|
|
||||||
if err := elem.Decode(d); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
unwrapped = append(unwrapped, elem)
|
|
||||||
return nil
|
|
||||||
}); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}(); err != nil {
|
|
||||||
return errors.Wrap(err, "alias")
|
|
||||||
}
|
|
||||||
*s = CheckList(unwrapped)
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// MarshalJSON implements stdjson.Marshaler.
|
|
||||||
func (s CheckList) MarshalJSON() ([]byte, error) {
|
|
||||||
e := jx.Encoder{}
|
|
||||||
s.Encode(&e)
|
|
||||||
return e.Bytes(), nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// UnmarshalJSON implements stdjson.Unmarshaler.
|
|
||||||
func (s *CheckList) UnmarshalJSON(data []byte) error {
|
|
||||||
d := jx.DecodeBytes(data)
|
|
||||||
return s.Decode(d)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Encode implements json.Marshaler.
|
// Encode implements json.Marshaler.
|
||||||
func (s *Error) Encode(e *jx.Encoder) {
|
func (s *Error) Encode(e *jx.Encoder) {
|
||||||
e.ObjStart()
|
e.ObjStart()
|
||||||
@@ -346,13 +166,9 @@ func (s *MapfixCreate) encodeFields(e *jx.Encoder) {
|
|||||||
e.FieldStart("TargetAssetID")
|
e.FieldStart("TargetAssetID")
|
||||||
e.Int64(s.TargetAssetID)
|
e.Int64(s.TargetAssetID)
|
||||||
}
|
}
|
||||||
{
|
|
||||||
e.FieldStart("Description")
|
|
||||||
e.Str(s.Description)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var jsonFieldsNameOfMapfixCreate = [9]string{
|
var jsonFieldsNameOfMapfixCreate = [8]string{
|
||||||
0: "OperationID",
|
0: "OperationID",
|
||||||
1: "AssetOwner",
|
1: "AssetOwner",
|
||||||
2: "DisplayName",
|
2: "DisplayName",
|
||||||
@@ -361,7 +177,6 @@ var jsonFieldsNameOfMapfixCreate = [9]string{
|
|||||||
5: "AssetID",
|
5: "AssetID",
|
||||||
6: "AssetVersion",
|
6: "AssetVersion",
|
||||||
7: "TargetAssetID",
|
7: "TargetAssetID",
|
||||||
8: "Description",
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Decode decodes MapfixCreate from json.
|
// Decode decodes MapfixCreate from json.
|
||||||
@@ -369,7 +184,7 @@ func (s *MapfixCreate) Decode(d *jx.Decoder) error {
|
|||||||
if s == nil {
|
if s == nil {
|
||||||
return errors.New("invalid: unable to decode MapfixCreate to nil")
|
return errors.New("invalid: unable to decode MapfixCreate to nil")
|
||||||
}
|
}
|
||||||
var requiredBitSet [2]uint8
|
var requiredBitSet [1]uint8
|
||||||
|
|
||||||
if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error {
|
if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error {
|
||||||
switch string(k) {
|
switch string(k) {
|
||||||
@@ -469,18 +284,6 @@ func (s *MapfixCreate) Decode(d *jx.Decoder) error {
|
|||||||
}(); err != nil {
|
}(); err != nil {
|
||||||
return errors.Wrap(err, "decode field \"TargetAssetID\"")
|
return errors.Wrap(err, "decode field \"TargetAssetID\"")
|
||||||
}
|
}
|
||||||
case "Description":
|
|
||||||
requiredBitSet[1] |= 1 << 0
|
|
||||||
if err := func() error {
|
|
||||||
v, err := d.Str()
|
|
||||||
s.Description = string(v)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}(); err != nil {
|
|
||||||
return errors.Wrap(err, "decode field \"Description\"")
|
|
||||||
}
|
|
||||||
default:
|
default:
|
||||||
return d.Skip()
|
return d.Skip()
|
||||||
}
|
}
|
||||||
@@ -490,9 +293,8 @@ func (s *MapfixCreate) Decode(d *jx.Decoder) error {
|
|||||||
}
|
}
|
||||||
// Validate required fields.
|
// Validate required fields.
|
||||||
var failures []validate.FieldError
|
var failures []validate.FieldError
|
||||||
for i, mask := range [2]uint8{
|
for i, mask := range [1]uint8{
|
||||||
0b11111111,
|
0b11111111,
|
||||||
0b00000001,
|
|
||||||
} {
|
} {
|
||||||
if result := (requiredBitSet[i] & mask) ^ mask; result != 0 {
|
if result := (requiredBitSet[i] & mask) ^ mask; result != 0 {
|
||||||
// Mask only required fields and check equality to mask using XOR.
|
// Mask only required fields and check equality to mask using XOR.
|
||||||
@@ -1503,17 +1305,9 @@ func (s *SubmissionCreate) encodeFields(e *jx.Encoder) {
|
|||||||
e.FieldStart("AssetVersion")
|
e.FieldStart("AssetVersion")
|
||||||
e.Int64(s.AssetVersion)
|
e.Int64(s.AssetVersion)
|
||||||
}
|
}
|
||||||
{
|
|
||||||
e.FieldStart("Status")
|
|
||||||
e.UInt32(s.Status)
|
|
||||||
}
|
|
||||||
{
|
|
||||||
e.FieldStart("Roles")
|
|
||||||
e.UInt32(s.Roles)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var jsonFieldsNameOfSubmissionCreate = [9]string{
|
var jsonFieldsNameOfSubmissionCreate = [7]string{
|
||||||
0: "OperationID",
|
0: "OperationID",
|
||||||
1: "AssetOwner",
|
1: "AssetOwner",
|
||||||
2: "DisplayName",
|
2: "DisplayName",
|
||||||
@@ -1521,8 +1315,6 @@ var jsonFieldsNameOfSubmissionCreate = [9]string{
|
|||||||
4: "GameID",
|
4: "GameID",
|
||||||
5: "AssetID",
|
5: "AssetID",
|
||||||
6: "AssetVersion",
|
6: "AssetVersion",
|
||||||
7: "Status",
|
|
||||||
8: "Roles",
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Decode decodes SubmissionCreate from json.
|
// Decode decodes SubmissionCreate from json.
|
||||||
@@ -1530,7 +1322,7 @@ func (s *SubmissionCreate) Decode(d *jx.Decoder) error {
|
|||||||
if s == nil {
|
if s == nil {
|
||||||
return errors.New("invalid: unable to decode SubmissionCreate to nil")
|
return errors.New("invalid: unable to decode SubmissionCreate to nil")
|
||||||
}
|
}
|
||||||
var requiredBitSet [2]uint8
|
var requiredBitSet [1]uint8
|
||||||
|
|
||||||
if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error {
|
if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error {
|
||||||
switch string(k) {
|
switch string(k) {
|
||||||
@@ -1618,30 +1410,6 @@ func (s *SubmissionCreate) Decode(d *jx.Decoder) error {
|
|||||||
}(); err != nil {
|
}(); err != nil {
|
||||||
return errors.Wrap(err, "decode field \"AssetVersion\"")
|
return errors.Wrap(err, "decode field \"AssetVersion\"")
|
||||||
}
|
}
|
||||||
case "Status":
|
|
||||||
requiredBitSet[0] |= 1 << 7
|
|
||||||
if err := func() error {
|
|
||||||
v, err := d.UInt32()
|
|
||||||
s.Status = uint32(v)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}(); err != nil {
|
|
||||||
return errors.Wrap(err, "decode field \"Status\"")
|
|
||||||
}
|
|
||||||
case "Roles":
|
|
||||||
requiredBitSet[1] |= 1 << 0
|
|
||||||
if err := func() error {
|
|
||||||
v, err := d.UInt32()
|
|
||||||
s.Roles = uint32(v)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}(); err != nil {
|
|
||||||
return errors.Wrap(err, "decode field \"Roles\"")
|
|
||||||
}
|
|
||||||
default:
|
default:
|
||||||
return d.Skip()
|
return d.Skip()
|
||||||
}
|
}
|
||||||
@@ -1651,9 +1419,8 @@ func (s *SubmissionCreate) Decode(d *jx.Decoder) error {
|
|||||||
}
|
}
|
||||||
// Validate required fields.
|
// Validate required fields.
|
||||||
var failures []validate.FieldError
|
var failures []validate.FieldError
|
||||||
for i, mask := range [2]uint8{
|
for i, mask := range [1]uint8{
|
||||||
0b11111111,
|
0b01111111,
|
||||||
0b00000001,
|
|
||||||
} {
|
} {
|
||||||
if result := (requiredBitSet[i] & mask) ^ mask; result != 0 {
|
if result := (requiredBitSet[i] & mask) ^ mask; result != 0 {
|
||||||
// Mask only required fields and check equality to mask using XOR.
|
// Mask only required fields and check equality to mask using XOR.
|
||||||
|
|||||||
@@ -7,24 +7,16 @@ type OperationName = string
|
|||||||
|
|
||||||
const (
|
const (
|
||||||
ActionMapfixAcceptedOperation OperationName = "ActionMapfixAccepted"
|
ActionMapfixAcceptedOperation OperationName = "ActionMapfixAccepted"
|
||||||
ActionMapfixRequestChangesOperation OperationName = "ActionMapfixRequestChanges"
|
|
||||||
ActionMapfixSubmittedOperation OperationName = "ActionMapfixSubmitted"
|
|
||||||
ActionMapfixUploadedOperation OperationName = "ActionMapfixUploaded"
|
ActionMapfixUploadedOperation OperationName = "ActionMapfixUploaded"
|
||||||
ActionMapfixValidatedOperation OperationName = "ActionMapfixValidated"
|
ActionMapfixValidatedOperation OperationName = "ActionMapfixValidated"
|
||||||
ActionOperationFailedOperation OperationName = "ActionOperationFailed"
|
ActionOperationFailedOperation OperationName = "ActionOperationFailed"
|
||||||
ActionSubmissionAcceptedOperation OperationName = "ActionSubmissionAccepted"
|
ActionSubmissionAcceptedOperation OperationName = "ActionSubmissionAccepted"
|
||||||
ActionSubmissionRequestChangesOperation OperationName = "ActionSubmissionRequestChanges"
|
|
||||||
ActionSubmissionSubmittedOperation OperationName = "ActionSubmissionSubmitted"
|
|
||||||
ActionSubmissionUploadedOperation OperationName = "ActionSubmissionUploaded"
|
ActionSubmissionUploadedOperation OperationName = "ActionSubmissionUploaded"
|
||||||
ActionSubmissionValidatedOperation OperationName = "ActionSubmissionValidated"
|
ActionSubmissionValidatedOperation OperationName = "ActionSubmissionValidated"
|
||||||
CreateMapfixOperation OperationName = "CreateMapfix"
|
CreateMapfixOperation OperationName = "CreateMapfix"
|
||||||
CreateMapfixAuditCheckListOperation OperationName = "CreateMapfixAuditCheckList"
|
|
||||||
CreateMapfixAuditErrorOperation OperationName = "CreateMapfixAuditError"
|
|
||||||
CreateScriptOperation OperationName = "CreateScript"
|
CreateScriptOperation OperationName = "CreateScript"
|
||||||
CreateScriptPolicyOperation OperationName = "CreateScriptPolicy"
|
CreateScriptPolicyOperation OperationName = "CreateScriptPolicy"
|
||||||
CreateSubmissionOperation OperationName = "CreateSubmission"
|
CreateSubmissionOperation OperationName = "CreateSubmission"
|
||||||
CreateSubmissionAuditCheckListOperation OperationName = "CreateSubmissionAuditCheckList"
|
|
||||||
CreateSubmissionAuditErrorOperation OperationName = "CreateSubmissionAuditError"
|
|
||||||
GetScriptOperation OperationName = "GetScript"
|
GetScriptOperation OperationName = "GetScript"
|
||||||
ListScriptPolicyOperation OperationName = "ListScriptPolicy"
|
ListScriptPolicyOperation OperationName = "ListScriptPolicy"
|
||||||
ListScriptsOperation OperationName = "ListScripts"
|
ListScriptsOperation OperationName = "ListScripts"
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -9,6 +9,7 @@ import (
|
|||||||
|
|
||||||
"github.com/go-faster/errors"
|
"github.com/go-faster/errors"
|
||||||
"github.com/go-faster/jx"
|
"github.com/go-faster/jx"
|
||||||
|
"go.uber.org/multierr"
|
||||||
|
|
||||||
"github.com/ogen-go/ogen/ogenerrors"
|
"github.com/ogen-go/ogen/ogenerrors"
|
||||||
"github.com/ogen-go/ogen/validate"
|
"github.com/ogen-go/ogen/validate"
|
||||||
@@ -25,13 +26,13 @@ func (s *Server) decodeCreateMapfixRequest(r *http.Request) (
|
|||||||
// Close in reverse order, to match defer behavior.
|
// Close in reverse order, to match defer behavior.
|
||||||
for i := len(closers) - 1; i >= 0; i-- {
|
for i := len(closers) - 1; i >= 0; i-- {
|
||||||
c := closers[i]
|
c := closers[i]
|
||||||
merr = errors.Join(merr, c())
|
merr = multierr.Append(merr, c())
|
||||||
}
|
}
|
||||||
return merr
|
return merr
|
||||||
}
|
}
|
||||||
defer func() {
|
defer func() {
|
||||||
if rerr != nil {
|
if rerr != nil {
|
||||||
rerr = errors.Join(rerr, close())
|
rerr = multierr.Append(rerr, close())
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
ct, _, err := mime.ParseMediaType(r.Header.Get("Content-Type"))
|
ct, _, err := mime.ParseMediaType(r.Header.Get("Content-Type"))
|
||||||
@@ -85,77 +86,6 @@ func (s *Server) decodeCreateMapfixRequest(r *http.Request) (
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Server) decodeCreateMapfixAuditCheckListRequest(r *http.Request) (
|
|
||||||
req CheckList,
|
|
||||||
close func() error,
|
|
||||||
rerr error,
|
|
||||||
) {
|
|
||||||
var closers []func() error
|
|
||||||
close = func() error {
|
|
||||||
var merr error
|
|
||||||
// Close in reverse order, to match defer behavior.
|
|
||||||
for i := len(closers) - 1; i >= 0; i-- {
|
|
||||||
c := closers[i]
|
|
||||||
merr = errors.Join(merr, c())
|
|
||||||
}
|
|
||||||
return merr
|
|
||||||
}
|
|
||||||
defer func() {
|
|
||||||
if rerr != nil {
|
|
||||||
rerr = errors.Join(rerr, close())
|
|
||||||
}
|
|
||||||
}()
|
|
||||||
ct, _, err := mime.ParseMediaType(r.Header.Get("Content-Type"))
|
|
||||||
if err != nil {
|
|
||||||
return req, close, errors.Wrap(err, "parse media type")
|
|
||||||
}
|
|
||||||
switch {
|
|
||||||
case ct == "application/json":
|
|
||||||
if r.ContentLength == 0 {
|
|
||||||
return req, close, validate.ErrBodyRequired
|
|
||||||
}
|
|
||||||
buf, err := io.ReadAll(r.Body)
|
|
||||||
if err != nil {
|
|
||||||
return req, close, err
|
|
||||||
}
|
|
||||||
|
|
||||||
if len(buf) == 0 {
|
|
||||||
return req, close, validate.ErrBodyRequired
|
|
||||||
}
|
|
||||||
|
|
||||||
d := jx.DecodeBytes(buf)
|
|
||||||
|
|
||||||
var request CheckList
|
|
||||||
if err := func() error {
|
|
||||||
if err := request.Decode(d); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
if err := d.Skip(); err != io.EOF {
|
|
||||||
return errors.New("unexpected trailing data")
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}(); err != nil {
|
|
||||||
err = &ogenerrors.DecodeBodyError{
|
|
||||||
ContentType: ct,
|
|
||||||
Body: buf,
|
|
||||||
Err: err,
|
|
||||||
}
|
|
||||||
return req, close, err
|
|
||||||
}
|
|
||||||
if err := func() error {
|
|
||||||
if err := request.Validate(); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}(); err != nil {
|
|
||||||
return req, close, errors.Wrap(err, "validate")
|
|
||||||
}
|
|
||||||
return request, close, nil
|
|
||||||
default:
|
|
||||||
return req, close, validate.InvalidContentType(ct)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *Server) decodeCreateScriptRequest(r *http.Request) (
|
func (s *Server) decodeCreateScriptRequest(r *http.Request) (
|
||||||
req *ScriptCreate,
|
req *ScriptCreate,
|
||||||
close func() error,
|
close func() error,
|
||||||
@@ -167,13 +97,13 @@ func (s *Server) decodeCreateScriptRequest(r *http.Request) (
|
|||||||
// Close in reverse order, to match defer behavior.
|
// Close in reverse order, to match defer behavior.
|
||||||
for i := len(closers) - 1; i >= 0; i-- {
|
for i := len(closers) - 1; i >= 0; i-- {
|
||||||
c := closers[i]
|
c := closers[i]
|
||||||
merr = errors.Join(merr, c())
|
merr = multierr.Append(merr, c())
|
||||||
}
|
}
|
||||||
return merr
|
return merr
|
||||||
}
|
}
|
||||||
defer func() {
|
defer func() {
|
||||||
if rerr != nil {
|
if rerr != nil {
|
||||||
rerr = errors.Join(rerr, close())
|
rerr = multierr.Append(rerr, close())
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
ct, _, err := mime.ParseMediaType(r.Header.Get("Content-Type"))
|
ct, _, err := mime.ParseMediaType(r.Header.Get("Content-Type"))
|
||||||
@@ -238,13 +168,13 @@ func (s *Server) decodeCreateScriptPolicyRequest(r *http.Request) (
|
|||||||
// Close in reverse order, to match defer behavior.
|
// Close in reverse order, to match defer behavior.
|
||||||
for i := len(closers) - 1; i >= 0; i-- {
|
for i := len(closers) - 1; i >= 0; i-- {
|
||||||
c := closers[i]
|
c := closers[i]
|
||||||
merr = errors.Join(merr, c())
|
merr = multierr.Append(merr, c())
|
||||||
}
|
}
|
||||||
return merr
|
return merr
|
||||||
}
|
}
|
||||||
defer func() {
|
defer func() {
|
||||||
if rerr != nil {
|
if rerr != nil {
|
||||||
rerr = errors.Join(rerr, close())
|
rerr = multierr.Append(rerr, close())
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
ct, _, err := mime.ParseMediaType(r.Header.Get("Content-Type"))
|
ct, _, err := mime.ParseMediaType(r.Header.Get("Content-Type"))
|
||||||
@@ -284,14 +214,6 @@ func (s *Server) decodeCreateScriptPolicyRequest(r *http.Request) (
|
|||||||
}
|
}
|
||||||
return req, close, err
|
return req, close, err
|
||||||
}
|
}
|
||||||
if err := func() error {
|
|
||||||
if err := request.Validate(); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}(); err != nil {
|
|
||||||
return req, close, errors.Wrap(err, "validate")
|
|
||||||
}
|
|
||||||
return &request, close, nil
|
return &request, close, nil
|
||||||
default:
|
default:
|
||||||
return req, close, validate.InvalidContentType(ct)
|
return req, close, validate.InvalidContentType(ct)
|
||||||
@@ -309,13 +231,13 @@ func (s *Server) decodeCreateSubmissionRequest(r *http.Request) (
|
|||||||
// Close in reverse order, to match defer behavior.
|
// Close in reverse order, to match defer behavior.
|
||||||
for i := len(closers) - 1; i >= 0; i-- {
|
for i := len(closers) - 1; i >= 0; i-- {
|
||||||
c := closers[i]
|
c := closers[i]
|
||||||
merr = errors.Join(merr, c())
|
merr = multierr.Append(merr, c())
|
||||||
}
|
}
|
||||||
return merr
|
return merr
|
||||||
}
|
}
|
||||||
defer func() {
|
defer func() {
|
||||||
if rerr != nil {
|
if rerr != nil {
|
||||||
rerr = errors.Join(rerr, close())
|
rerr = multierr.Append(rerr, close())
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
ct, _, err := mime.ParseMediaType(r.Header.Get("Content-Type"))
|
ct, _, err := mime.ParseMediaType(r.Header.Get("Content-Type"))
|
||||||
@@ -368,74 +290,3 @@ func (s *Server) decodeCreateSubmissionRequest(r *http.Request) (
|
|||||||
return req, close, validate.InvalidContentType(ct)
|
return req, close, validate.InvalidContentType(ct)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Server) decodeCreateSubmissionAuditCheckListRequest(r *http.Request) (
|
|
||||||
req CheckList,
|
|
||||||
close func() error,
|
|
||||||
rerr error,
|
|
||||||
) {
|
|
||||||
var closers []func() error
|
|
||||||
close = func() error {
|
|
||||||
var merr error
|
|
||||||
// Close in reverse order, to match defer behavior.
|
|
||||||
for i := len(closers) - 1; i >= 0; i-- {
|
|
||||||
c := closers[i]
|
|
||||||
merr = errors.Join(merr, c())
|
|
||||||
}
|
|
||||||
return merr
|
|
||||||
}
|
|
||||||
defer func() {
|
|
||||||
if rerr != nil {
|
|
||||||
rerr = errors.Join(rerr, close())
|
|
||||||
}
|
|
||||||
}()
|
|
||||||
ct, _, err := mime.ParseMediaType(r.Header.Get("Content-Type"))
|
|
||||||
if err != nil {
|
|
||||||
return req, close, errors.Wrap(err, "parse media type")
|
|
||||||
}
|
|
||||||
switch {
|
|
||||||
case ct == "application/json":
|
|
||||||
if r.ContentLength == 0 {
|
|
||||||
return req, close, validate.ErrBodyRequired
|
|
||||||
}
|
|
||||||
buf, err := io.ReadAll(r.Body)
|
|
||||||
if err != nil {
|
|
||||||
return req, close, err
|
|
||||||
}
|
|
||||||
|
|
||||||
if len(buf) == 0 {
|
|
||||||
return req, close, validate.ErrBodyRequired
|
|
||||||
}
|
|
||||||
|
|
||||||
d := jx.DecodeBytes(buf)
|
|
||||||
|
|
||||||
var request CheckList
|
|
||||||
if err := func() error {
|
|
||||||
if err := request.Decode(d); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
if err := d.Skip(); err != io.EOF {
|
|
||||||
return errors.New("unexpected trailing data")
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}(); err != nil {
|
|
||||||
err = &ogenerrors.DecodeBodyError{
|
|
||||||
ContentType: ct,
|
|
||||||
Body: buf,
|
|
||||||
Err: err,
|
|
||||||
}
|
|
||||||
return req, close, err
|
|
||||||
}
|
|
||||||
if err := func() error {
|
|
||||||
if err := request.Validate(); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}(); err != nil {
|
|
||||||
return req, close, errors.Wrap(err, "validate")
|
|
||||||
}
|
|
||||||
return request, close, nil
|
|
||||||
default:
|
|
||||||
return req, close, validate.InvalidContentType(ct)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -25,20 +25,6 @@ func encodeCreateMapfixRequest(
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func encodeCreateMapfixAuditCheckListRequest(
|
|
||||||
req CheckList,
|
|
||||||
r *http.Request,
|
|
||||||
) error {
|
|
||||||
const contentType = "application/json"
|
|
||||||
e := new(jx.Encoder)
|
|
||||||
{
|
|
||||||
req.Encode(e)
|
|
||||||
}
|
|
||||||
encoded := e.Bytes()
|
|
||||||
ht.SetBody(r, bytes.NewReader(encoded), contentType)
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func encodeCreateScriptRequest(
|
func encodeCreateScriptRequest(
|
||||||
req *ScriptCreate,
|
req *ScriptCreate,
|
||||||
r *http.Request,
|
r *http.Request,
|
||||||
@@ -80,17 +66,3 @@ func encodeCreateSubmissionRequest(
|
|||||||
ht.SetBody(r, bytes.NewReader(encoded), contentType)
|
ht.SetBody(r, bytes.NewReader(encoded), contentType)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func encodeCreateSubmissionAuditCheckListRequest(
|
|
||||||
req CheckList,
|
|
||||||
r *http.Request,
|
|
||||||
) error {
|
|
||||||
const contentType = "application/json"
|
|
||||||
e := new(jx.Encoder)
|
|
||||||
{
|
|
||||||
req.Encode(e)
|
|
||||||
}
|
|
||||||
encoded := e.Bytes()
|
|
||||||
ht.SetBody(r, bytes.NewReader(encoded), contentType)
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -52,135 +52,6 @@ func decodeActionMapfixAcceptedResponse(resp *http.Response) (res *ActionMapfixA
|
|||||||
}
|
}
|
||||||
return res, err
|
return res, err
|
||||||
}
|
}
|
||||||
// Validate response.
|
|
||||||
if err := func() error {
|
|
||||||
if err := response.Validate(); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}(); err != nil {
|
|
||||||
return res, errors.Wrap(err, "validate")
|
|
||||||
}
|
|
||||||
return &ErrorStatusCode{
|
|
||||||
StatusCode: resp.StatusCode,
|
|
||||||
Response: response,
|
|
||||||
}, nil
|
|
||||||
default:
|
|
||||||
return res, validate.InvalidContentType(ct)
|
|
||||||
}
|
|
||||||
}()
|
|
||||||
if err != nil {
|
|
||||||
return res, errors.Wrapf(err, "default (code %d)", resp.StatusCode)
|
|
||||||
}
|
|
||||||
return res, errors.Wrap(defRes, "error")
|
|
||||||
}
|
|
||||||
|
|
||||||
func decodeActionMapfixRequestChangesResponse(resp *http.Response) (res *ActionMapfixRequestChangesNoContent, _ error) {
|
|
||||||
switch resp.StatusCode {
|
|
||||||
case 204:
|
|
||||||
// Code 204.
|
|
||||||
return &ActionMapfixRequestChangesNoContent{}, nil
|
|
||||||
}
|
|
||||||
// Convenient error response.
|
|
||||||
defRes, err := func() (res *ErrorStatusCode, err error) {
|
|
||||||
ct, _, err := mime.ParseMediaType(resp.Header.Get("Content-Type"))
|
|
||||||
if err != nil {
|
|
||||||
return res, errors.Wrap(err, "parse media type")
|
|
||||||
}
|
|
||||||
switch {
|
|
||||||
case ct == "application/json":
|
|
||||||
buf, err := io.ReadAll(resp.Body)
|
|
||||||
if err != nil {
|
|
||||||
return res, err
|
|
||||||
}
|
|
||||||
d := jx.DecodeBytes(buf)
|
|
||||||
|
|
||||||
var response Error
|
|
||||||
if err := func() error {
|
|
||||||
if err := response.Decode(d); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
if err := d.Skip(); err != io.EOF {
|
|
||||||
return errors.New("unexpected trailing data")
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}(); err != nil {
|
|
||||||
err = &ogenerrors.DecodeBodyError{
|
|
||||||
ContentType: ct,
|
|
||||||
Body: buf,
|
|
||||||
Err: err,
|
|
||||||
}
|
|
||||||
return res, err
|
|
||||||
}
|
|
||||||
// Validate response.
|
|
||||||
if err := func() error {
|
|
||||||
if err := response.Validate(); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}(); err != nil {
|
|
||||||
return res, errors.Wrap(err, "validate")
|
|
||||||
}
|
|
||||||
return &ErrorStatusCode{
|
|
||||||
StatusCode: resp.StatusCode,
|
|
||||||
Response: response,
|
|
||||||
}, nil
|
|
||||||
default:
|
|
||||||
return res, validate.InvalidContentType(ct)
|
|
||||||
}
|
|
||||||
}()
|
|
||||||
if err != nil {
|
|
||||||
return res, errors.Wrapf(err, "default (code %d)", resp.StatusCode)
|
|
||||||
}
|
|
||||||
return res, errors.Wrap(defRes, "error")
|
|
||||||
}
|
|
||||||
|
|
||||||
func decodeActionMapfixSubmittedResponse(resp *http.Response) (res *ActionMapfixSubmittedNoContent, _ error) {
|
|
||||||
switch resp.StatusCode {
|
|
||||||
case 204:
|
|
||||||
// Code 204.
|
|
||||||
return &ActionMapfixSubmittedNoContent{}, nil
|
|
||||||
}
|
|
||||||
// Convenient error response.
|
|
||||||
defRes, err := func() (res *ErrorStatusCode, err error) {
|
|
||||||
ct, _, err := mime.ParseMediaType(resp.Header.Get("Content-Type"))
|
|
||||||
if err != nil {
|
|
||||||
return res, errors.Wrap(err, "parse media type")
|
|
||||||
}
|
|
||||||
switch {
|
|
||||||
case ct == "application/json":
|
|
||||||
buf, err := io.ReadAll(resp.Body)
|
|
||||||
if err != nil {
|
|
||||||
return res, err
|
|
||||||
}
|
|
||||||
d := jx.DecodeBytes(buf)
|
|
||||||
|
|
||||||
var response Error
|
|
||||||
if err := func() error {
|
|
||||||
if err := response.Decode(d); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
if err := d.Skip(); err != io.EOF {
|
|
||||||
return errors.New("unexpected trailing data")
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}(); err != nil {
|
|
||||||
err = &ogenerrors.DecodeBodyError{
|
|
||||||
ContentType: ct,
|
|
||||||
Body: buf,
|
|
||||||
Err: err,
|
|
||||||
}
|
|
||||||
return res, err
|
|
||||||
}
|
|
||||||
// Validate response.
|
|
||||||
if err := func() error {
|
|
||||||
if err := response.Validate(); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}(); err != nil {
|
|
||||||
return res, errors.Wrap(err, "validate")
|
|
||||||
}
|
|
||||||
return &ErrorStatusCode{
|
return &ErrorStatusCode{
|
||||||
StatusCode: resp.StatusCode,
|
StatusCode: resp.StatusCode,
|
||||||
Response: response,
|
Response: response,
|
||||||
@@ -232,15 +103,6 @@ func decodeActionMapfixUploadedResponse(resp *http.Response) (res *ActionMapfixU
|
|||||||
}
|
}
|
||||||
return res, err
|
return res, err
|
||||||
}
|
}
|
||||||
// Validate response.
|
|
||||||
if err := func() error {
|
|
||||||
if err := response.Validate(); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}(); err != nil {
|
|
||||||
return res, errors.Wrap(err, "validate")
|
|
||||||
}
|
|
||||||
return &ErrorStatusCode{
|
return &ErrorStatusCode{
|
||||||
StatusCode: resp.StatusCode,
|
StatusCode: resp.StatusCode,
|
||||||
Response: response,
|
Response: response,
|
||||||
@@ -292,15 +154,6 @@ func decodeActionMapfixValidatedResponse(resp *http.Response) (res *ActionMapfix
|
|||||||
}
|
}
|
||||||
return res, err
|
return res, err
|
||||||
}
|
}
|
||||||
// Validate response.
|
|
||||||
if err := func() error {
|
|
||||||
if err := response.Validate(); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}(); err != nil {
|
|
||||||
return res, errors.Wrap(err, "validate")
|
|
||||||
}
|
|
||||||
return &ErrorStatusCode{
|
return &ErrorStatusCode{
|
||||||
StatusCode: resp.StatusCode,
|
StatusCode: resp.StatusCode,
|
||||||
Response: response,
|
Response: response,
|
||||||
@@ -352,15 +205,6 @@ func decodeActionOperationFailedResponse(resp *http.Response) (res *ActionOperat
|
|||||||
}
|
}
|
||||||
return res, err
|
return res, err
|
||||||
}
|
}
|
||||||
// Validate response.
|
|
||||||
if err := func() error {
|
|
||||||
if err := response.Validate(); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}(); err != nil {
|
|
||||||
return res, errors.Wrap(err, "validate")
|
|
||||||
}
|
|
||||||
return &ErrorStatusCode{
|
return &ErrorStatusCode{
|
||||||
StatusCode: resp.StatusCode,
|
StatusCode: resp.StatusCode,
|
||||||
Response: response,
|
Response: response,
|
||||||
@@ -412,135 +256,6 @@ func decodeActionSubmissionAcceptedResponse(resp *http.Response) (res *ActionSub
|
|||||||
}
|
}
|
||||||
return res, err
|
return res, err
|
||||||
}
|
}
|
||||||
// Validate response.
|
|
||||||
if err := func() error {
|
|
||||||
if err := response.Validate(); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}(); err != nil {
|
|
||||||
return res, errors.Wrap(err, "validate")
|
|
||||||
}
|
|
||||||
return &ErrorStatusCode{
|
|
||||||
StatusCode: resp.StatusCode,
|
|
||||||
Response: response,
|
|
||||||
}, nil
|
|
||||||
default:
|
|
||||||
return res, validate.InvalidContentType(ct)
|
|
||||||
}
|
|
||||||
}()
|
|
||||||
if err != nil {
|
|
||||||
return res, errors.Wrapf(err, "default (code %d)", resp.StatusCode)
|
|
||||||
}
|
|
||||||
return res, errors.Wrap(defRes, "error")
|
|
||||||
}
|
|
||||||
|
|
||||||
func decodeActionSubmissionRequestChangesResponse(resp *http.Response) (res *ActionSubmissionRequestChangesNoContent, _ error) {
|
|
||||||
switch resp.StatusCode {
|
|
||||||
case 204:
|
|
||||||
// Code 204.
|
|
||||||
return &ActionSubmissionRequestChangesNoContent{}, nil
|
|
||||||
}
|
|
||||||
// Convenient error response.
|
|
||||||
defRes, err := func() (res *ErrorStatusCode, err error) {
|
|
||||||
ct, _, err := mime.ParseMediaType(resp.Header.Get("Content-Type"))
|
|
||||||
if err != nil {
|
|
||||||
return res, errors.Wrap(err, "parse media type")
|
|
||||||
}
|
|
||||||
switch {
|
|
||||||
case ct == "application/json":
|
|
||||||
buf, err := io.ReadAll(resp.Body)
|
|
||||||
if err != nil {
|
|
||||||
return res, err
|
|
||||||
}
|
|
||||||
d := jx.DecodeBytes(buf)
|
|
||||||
|
|
||||||
var response Error
|
|
||||||
if err := func() error {
|
|
||||||
if err := response.Decode(d); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
if err := d.Skip(); err != io.EOF {
|
|
||||||
return errors.New("unexpected trailing data")
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}(); err != nil {
|
|
||||||
err = &ogenerrors.DecodeBodyError{
|
|
||||||
ContentType: ct,
|
|
||||||
Body: buf,
|
|
||||||
Err: err,
|
|
||||||
}
|
|
||||||
return res, err
|
|
||||||
}
|
|
||||||
// Validate response.
|
|
||||||
if err := func() error {
|
|
||||||
if err := response.Validate(); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}(); err != nil {
|
|
||||||
return res, errors.Wrap(err, "validate")
|
|
||||||
}
|
|
||||||
return &ErrorStatusCode{
|
|
||||||
StatusCode: resp.StatusCode,
|
|
||||||
Response: response,
|
|
||||||
}, nil
|
|
||||||
default:
|
|
||||||
return res, validate.InvalidContentType(ct)
|
|
||||||
}
|
|
||||||
}()
|
|
||||||
if err != nil {
|
|
||||||
return res, errors.Wrapf(err, "default (code %d)", resp.StatusCode)
|
|
||||||
}
|
|
||||||
return res, errors.Wrap(defRes, "error")
|
|
||||||
}
|
|
||||||
|
|
||||||
func decodeActionSubmissionSubmittedResponse(resp *http.Response) (res *ActionSubmissionSubmittedNoContent, _ error) {
|
|
||||||
switch resp.StatusCode {
|
|
||||||
case 204:
|
|
||||||
// Code 204.
|
|
||||||
return &ActionSubmissionSubmittedNoContent{}, nil
|
|
||||||
}
|
|
||||||
// Convenient error response.
|
|
||||||
defRes, err := func() (res *ErrorStatusCode, err error) {
|
|
||||||
ct, _, err := mime.ParseMediaType(resp.Header.Get("Content-Type"))
|
|
||||||
if err != nil {
|
|
||||||
return res, errors.Wrap(err, "parse media type")
|
|
||||||
}
|
|
||||||
switch {
|
|
||||||
case ct == "application/json":
|
|
||||||
buf, err := io.ReadAll(resp.Body)
|
|
||||||
if err != nil {
|
|
||||||
return res, err
|
|
||||||
}
|
|
||||||
d := jx.DecodeBytes(buf)
|
|
||||||
|
|
||||||
var response Error
|
|
||||||
if err := func() error {
|
|
||||||
if err := response.Decode(d); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
if err := d.Skip(); err != io.EOF {
|
|
||||||
return errors.New("unexpected trailing data")
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}(); err != nil {
|
|
||||||
err = &ogenerrors.DecodeBodyError{
|
|
||||||
ContentType: ct,
|
|
||||||
Body: buf,
|
|
||||||
Err: err,
|
|
||||||
}
|
|
||||||
return res, err
|
|
||||||
}
|
|
||||||
// Validate response.
|
|
||||||
if err := func() error {
|
|
||||||
if err := response.Validate(); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}(); err != nil {
|
|
||||||
return res, errors.Wrap(err, "validate")
|
|
||||||
}
|
|
||||||
return &ErrorStatusCode{
|
return &ErrorStatusCode{
|
||||||
StatusCode: resp.StatusCode,
|
StatusCode: resp.StatusCode,
|
||||||
Response: response,
|
Response: response,
|
||||||
@@ -592,15 +307,6 @@ func decodeActionSubmissionUploadedResponse(resp *http.Response) (res *ActionSub
|
|||||||
}
|
}
|
||||||
return res, err
|
return res, err
|
||||||
}
|
}
|
||||||
// Validate response.
|
|
||||||
if err := func() error {
|
|
||||||
if err := response.Validate(); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}(); err != nil {
|
|
||||||
return res, errors.Wrap(err, "validate")
|
|
||||||
}
|
|
||||||
return &ErrorStatusCode{
|
return &ErrorStatusCode{
|
||||||
StatusCode: resp.StatusCode,
|
StatusCode: resp.StatusCode,
|
||||||
Response: response,
|
Response: response,
|
||||||
@@ -652,15 +358,6 @@ func decodeActionSubmissionValidatedResponse(resp *http.Response) (res *ActionSu
|
|||||||
}
|
}
|
||||||
return res, err
|
return res, err
|
||||||
}
|
}
|
||||||
// Validate response.
|
|
||||||
if err := func() error {
|
|
||||||
if err := response.Validate(); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}(); err != nil {
|
|
||||||
return res, errors.Wrap(err, "validate")
|
|
||||||
}
|
|
||||||
return &ErrorStatusCode{
|
return &ErrorStatusCode{
|
||||||
StatusCode: resp.StatusCode,
|
StatusCode: resp.StatusCode,
|
||||||
Response: response,
|
Response: response,
|
||||||
@@ -708,15 +405,6 @@ func decodeCreateMapfixResponse(resp *http.Response) (res *MapfixID, _ error) {
|
|||||||
}
|
}
|
||||||
return res, err
|
return res, err
|
||||||
}
|
}
|
||||||
// Validate response.
|
|
||||||
if err := func() error {
|
|
||||||
if err := response.Validate(); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}(); err != nil {
|
|
||||||
return res, errors.Wrap(err, "validate")
|
|
||||||
}
|
|
||||||
return &response, nil
|
return &response, nil
|
||||||
default:
|
default:
|
||||||
return res, validate.InvalidContentType(ct)
|
return res, validate.InvalidContentType(ct)
|
||||||
@@ -753,135 +441,6 @@ func decodeCreateMapfixResponse(resp *http.Response) (res *MapfixID, _ error) {
|
|||||||
}
|
}
|
||||||
return res, err
|
return res, err
|
||||||
}
|
}
|
||||||
// Validate response.
|
|
||||||
if err := func() error {
|
|
||||||
if err := response.Validate(); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}(); err != nil {
|
|
||||||
return res, errors.Wrap(err, "validate")
|
|
||||||
}
|
|
||||||
return &ErrorStatusCode{
|
|
||||||
StatusCode: resp.StatusCode,
|
|
||||||
Response: response,
|
|
||||||
}, nil
|
|
||||||
default:
|
|
||||||
return res, validate.InvalidContentType(ct)
|
|
||||||
}
|
|
||||||
}()
|
|
||||||
if err != nil {
|
|
||||||
return res, errors.Wrapf(err, "default (code %d)", resp.StatusCode)
|
|
||||||
}
|
|
||||||
return res, errors.Wrap(defRes, "error")
|
|
||||||
}
|
|
||||||
|
|
||||||
func decodeCreateMapfixAuditCheckListResponse(resp *http.Response) (res *CreateMapfixAuditCheckListNoContent, _ error) {
|
|
||||||
switch resp.StatusCode {
|
|
||||||
case 204:
|
|
||||||
// Code 204.
|
|
||||||
return &CreateMapfixAuditCheckListNoContent{}, nil
|
|
||||||
}
|
|
||||||
// Convenient error response.
|
|
||||||
defRes, err := func() (res *ErrorStatusCode, err error) {
|
|
||||||
ct, _, err := mime.ParseMediaType(resp.Header.Get("Content-Type"))
|
|
||||||
if err != nil {
|
|
||||||
return res, errors.Wrap(err, "parse media type")
|
|
||||||
}
|
|
||||||
switch {
|
|
||||||
case ct == "application/json":
|
|
||||||
buf, err := io.ReadAll(resp.Body)
|
|
||||||
if err != nil {
|
|
||||||
return res, err
|
|
||||||
}
|
|
||||||
d := jx.DecodeBytes(buf)
|
|
||||||
|
|
||||||
var response Error
|
|
||||||
if err := func() error {
|
|
||||||
if err := response.Decode(d); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
if err := d.Skip(); err != io.EOF {
|
|
||||||
return errors.New("unexpected trailing data")
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}(); err != nil {
|
|
||||||
err = &ogenerrors.DecodeBodyError{
|
|
||||||
ContentType: ct,
|
|
||||||
Body: buf,
|
|
||||||
Err: err,
|
|
||||||
}
|
|
||||||
return res, err
|
|
||||||
}
|
|
||||||
// Validate response.
|
|
||||||
if err := func() error {
|
|
||||||
if err := response.Validate(); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}(); err != nil {
|
|
||||||
return res, errors.Wrap(err, "validate")
|
|
||||||
}
|
|
||||||
return &ErrorStatusCode{
|
|
||||||
StatusCode: resp.StatusCode,
|
|
||||||
Response: response,
|
|
||||||
}, nil
|
|
||||||
default:
|
|
||||||
return res, validate.InvalidContentType(ct)
|
|
||||||
}
|
|
||||||
}()
|
|
||||||
if err != nil {
|
|
||||||
return res, errors.Wrapf(err, "default (code %d)", resp.StatusCode)
|
|
||||||
}
|
|
||||||
return res, errors.Wrap(defRes, "error")
|
|
||||||
}
|
|
||||||
|
|
||||||
func decodeCreateMapfixAuditErrorResponse(resp *http.Response) (res *CreateMapfixAuditErrorNoContent, _ error) {
|
|
||||||
switch resp.StatusCode {
|
|
||||||
case 204:
|
|
||||||
// Code 204.
|
|
||||||
return &CreateMapfixAuditErrorNoContent{}, nil
|
|
||||||
}
|
|
||||||
// Convenient error response.
|
|
||||||
defRes, err := func() (res *ErrorStatusCode, err error) {
|
|
||||||
ct, _, err := mime.ParseMediaType(resp.Header.Get("Content-Type"))
|
|
||||||
if err != nil {
|
|
||||||
return res, errors.Wrap(err, "parse media type")
|
|
||||||
}
|
|
||||||
switch {
|
|
||||||
case ct == "application/json":
|
|
||||||
buf, err := io.ReadAll(resp.Body)
|
|
||||||
if err != nil {
|
|
||||||
return res, err
|
|
||||||
}
|
|
||||||
d := jx.DecodeBytes(buf)
|
|
||||||
|
|
||||||
var response Error
|
|
||||||
if err := func() error {
|
|
||||||
if err := response.Decode(d); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
if err := d.Skip(); err != io.EOF {
|
|
||||||
return errors.New("unexpected trailing data")
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}(); err != nil {
|
|
||||||
err = &ogenerrors.DecodeBodyError{
|
|
||||||
ContentType: ct,
|
|
||||||
Body: buf,
|
|
||||||
Err: err,
|
|
||||||
}
|
|
||||||
return res, err
|
|
||||||
}
|
|
||||||
// Validate response.
|
|
||||||
if err := func() error {
|
|
||||||
if err := response.Validate(); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}(); err != nil {
|
|
||||||
return res, errors.Wrap(err, "validate")
|
|
||||||
}
|
|
||||||
return &ErrorStatusCode{
|
return &ErrorStatusCode{
|
||||||
StatusCode: resp.StatusCode,
|
StatusCode: resp.StatusCode,
|
||||||
Response: response,
|
Response: response,
|
||||||
@@ -929,15 +488,6 @@ func decodeCreateScriptResponse(resp *http.Response) (res *ScriptID, _ error) {
|
|||||||
}
|
}
|
||||||
return res, err
|
return res, err
|
||||||
}
|
}
|
||||||
// Validate response.
|
|
||||||
if err := func() error {
|
|
||||||
if err := response.Validate(); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}(); err != nil {
|
|
||||||
return res, errors.Wrap(err, "validate")
|
|
||||||
}
|
|
||||||
return &response, nil
|
return &response, nil
|
||||||
default:
|
default:
|
||||||
return res, validate.InvalidContentType(ct)
|
return res, validate.InvalidContentType(ct)
|
||||||
@@ -974,15 +524,6 @@ func decodeCreateScriptResponse(resp *http.Response) (res *ScriptID, _ error) {
|
|||||||
}
|
}
|
||||||
return res, err
|
return res, err
|
||||||
}
|
}
|
||||||
// Validate response.
|
|
||||||
if err := func() error {
|
|
||||||
if err := response.Validate(); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}(); err != nil {
|
|
||||||
return res, errors.Wrap(err, "validate")
|
|
||||||
}
|
|
||||||
return &ErrorStatusCode{
|
return &ErrorStatusCode{
|
||||||
StatusCode: resp.StatusCode,
|
StatusCode: resp.StatusCode,
|
||||||
Response: response,
|
Response: response,
|
||||||
@@ -1030,15 +571,6 @@ func decodeCreateScriptPolicyResponse(resp *http.Response) (res *ScriptPolicyID,
|
|||||||
}
|
}
|
||||||
return res, err
|
return res, err
|
||||||
}
|
}
|
||||||
// Validate response.
|
|
||||||
if err := func() error {
|
|
||||||
if err := response.Validate(); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}(); err != nil {
|
|
||||||
return res, errors.Wrap(err, "validate")
|
|
||||||
}
|
|
||||||
return &response, nil
|
return &response, nil
|
||||||
default:
|
default:
|
||||||
return res, validate.InvalidContentType(ct)
|
return res, validate.InvalidContentType(ct)
|
||||||
@@ -1075,15 +607,6 @@ func decodeCreateScriptPolicyResponse(resp *http.Response) (res *ScriptPolicyID,
|
|||||||
}
|
}
|
||||||
return res, err
|
return res, err
|
||||||
}
|
}
|
||||||
// Validate response.
|
|
||||||
if err := func() error {
|
|
||||||
if err := response.Validate(); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}(); err != nil {
|
|
||||||
return res, errors.Wrap(err, "validate")
|
|
||||||
}
|
|
||||||
return &ErrorStatusCode{
|
return &ErrorStatusCode{
|
||||||
StatusCode: resp.StatusCode,
|
StatusCode: resp.StatusCode,
|
||||||
Response: response,
|
Response: response,
|
||||||
@@ -1131,15 +654,6 @@ func decodeCreateSubmissionResponse(resp *http.Response) (res *SubmissionID, _ e
|
|||||||
}
|
}
|
||||||
return res, err
|
return res, err
|
||||||
}
|
}
|
||||||
// Validate response.
|
|
||||||
if err := func() error {
|
|
||||||
if err := response.Validate(); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}(); err != nil {
|
|
||||||
return res, errors.Wrap(err, "validate")
|
|
||||||
}
|
|
||||||
return &response, nil
|
return &response, nil
|
||||||
default:
|
default:
|
||||||
return res, validate.InvalidContentType(ct)
|
return res, validate.InvalidContentType(ct)
|
||||||
@@ -1176,135 +690,6 @@ func decodeCreateSubmissionResponse(resp *http.Response) (res *SubmissionID, _ e
|
|||||||
}
|
}
|
||||||
return res, err
|
return res, err
|
||||||
}
|
}
|
||||||
// Validate response.
|
|
||||||
if err := func() error {
|
|
||||||
if err := response.Validate(); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}(); err != nil {
|
|
||||||
return res, errors.Wrap(err, "validate")
|
|
||||||
}
|
|
||||||
return &ErrorStatusCode{
|
|
||||||
StatusCode: resp.StatusCode,
|
|
||||||
Response: response,
|
|
||||||
}, nil
|
|
||||||
default:
|
|
||||||
return res, validate.InvalidContentType(ct)
|
|
||||||
}
|
|
||||||
}()
|
|
||||||
if err != nil {
|
|
||||||
return res, errors.Wrapf(err, "default (code %d)", resp.StatusCode)
|
|
||||||
}
|
|
||||||
return res, errors.Wrap(defRes, "error")
|
|
||||||
}
|
|
||||||
|
|
||||||
func decodeCreateSubmissionAuditCheckListResponse(resp *http.Response) (res *CreateSubmissionAuditCheckListNoContent, _ error) {
|
|
||||||
switch resp.StatusCode {
|
|
||||||
case 204:
|
|
||||||
// Code 204.
|
|
||||||
return &CreateSubmissionAuditCheckListNoContent{}, nil
|
|
||||||
}
|
|
||||||
// Convenient error response.
|
|
||||||
defRes, err := func() (res *ErrorStatusCode, err error) {
|
|
||||||
ct, _, err := mime.ParseMediaType(resp.Header.Get("Content-Type"))
|
|
||||||
if err != nil {
|
|
||||||
return res, errors.Wrap(err, "parse media type")
|
|
||||||
}
|
|
||||||
switch {
|
|
||||||
case ct == "application/json":
|
|
||||||
buf, err := io.ReadAll(resp.Body)
|
|
||||||
if err != nil {
|
|
||||||
return res, err
|
|
||||||
}
|
|
||||||
d := jx.DecodeBytes(buf)
|
|
||||||
|
|
||||||
var response Error
|
|
||||||
if err := func() error {
|
|
||||||
if err := response.Decode(d); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
if err := d.Skip(); err != io.EOF {
|
|
||||||
return errors.New("unexpected trailing data")
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}(); err != nil {
|
|
||||||
err = &ogenerrors.DecodeBodyError{
|
|
||||||
ContentType: ct,
|
|
||||||
Body: buf,
|
|
||||||
Err: err,
|
|
||||||
}
|
|
||||||
return res, err
|
|
||||||
}
|
|
||||||
// Validate response.
|
|
||||||
if err := func() error {
|
|
||||||
if err := response.Validate(); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}(); err != nil {
|
|
||||||
return res, errors.Wrap(err, "validate")
|
|
||||||
}
|
|
||||||
return &ErrorStatusCode{
|
|
||||||
StatusCode: resp.StatusCode,
|
|
||||||
Response: response,
|
|
||||||
}, nil
|
|
||||||
default:
|
|
||||||
return res, validate.InvalidContentType(ct)
|
|
||||||
}
|
|
||||||
}()
|
|
||||||
if err != nil {
|
|
||||||
return res, errors.Wrapf(err, "default (code %d)", resp.StatusCode)
|
|
||||||
}
|
|
||||||
return res, errors.Wrap(defRes, "error")
|
|
||||||
}
|
|
||||||
|
|
||||||
func decodeCreateSubmissionAuditErrorResponse(resp *http.Response) (res *CreateSubmissionAuditErrorNoContent, _ error) {
|
|
||||||
switch resp.StatusCode {
|
|
||||||
case 204:
|
|
||||||
// Code 204.
|
|
||||||
return &CreateSubmissionAuditErrorNoContent{}, nil
|
|
||||||
}
|
|
||||||
// Convenient error response.
|
|
||||||
defRes, err := func() (res *ErrorStatusCode, err error) {
|
|
||||||
ct, _, err := mime.ParseMediaType(resp.Header.Get("Content-Type"))
|
|
||||||
if err != nil {
|
|
||||||
return res, errors.Wrap(err, "parse media type")
|
|
||||||
}
|
|
||||||
switch {
|
|
||||||
case ct == "application/json":
|
|
||||||
buf, err := io.ReadAll(resp.Body)
|
|
||||||
if err != nil {
|
|
||||||
return res, err
|
|
||||||
}
|
|
||||||
d := jx.DecodeBytes(buf)
|
|
||||||
|
|
||||||
var response Error
|
|
||||||
if err := func() error {
|
|
||||||
if err := response.Decode(d); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
if err := d.Skip(); err != io.EOF {
|
|
||||||
return errors.New("unexpected trailing data")
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}(); err != nil {
|
|
||||||
err = &ogenerrors.DecodeBodyError{
|
|
||||||
ContentType: ct,
|
|
||||||
Body: buf,
|
|
||||||
Err: err,
|
|
||||||
}
|
|
||||||
return res, err
|
|
||||||
}
|
|
||||||
// Validate response.
|
|
||||||
if err := func() error {
|
|
||||||
if err := response.Validate(); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}(); err != nil {
|
|
||||||
return res, errors.Wrap(err, "validate")
|
|
||||||
}
|
|
||||||
return &ErrorStatusCode{
|
return &ErrorStatusCode{
|
||||||
StatusCode: resp.StatusCode,
|
StatusCode: resp.StatusCode,
|
||||||
Response: response,
|
Response: response,
|
||||||
@@ -1397,15 +782,6 @@ func decodeGetScriptResponse(resp *http.Response) (res *Script, _ error) {
|
|||||||
}
|
}
|
||||||
return res, err
|
return res, err
|
||||||
}
|
}
|
||||||
// Validate response.
|
|
||||||
if err := func() error {
|
|
||||||
if err := response.Validate(); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}(); err != nil {
|
|
||||||
return res, errors.Wrap(err, "validate")
|
|
||||||
}
|
|
||||||
return &ErrorStatusCode{
|
return &ErrorStatusCode{
|
||||||
StatusCode: resp.StatusCode,
|
StatusCode: resp.StatusCode,
|
||||||
Response: response,
|
Response: response,
|
||||||
@@ -1523,15 +899,6 @@ func decodeListScriptPolicyResponse(resp *http.Response) (res []ScriptPolicy, _
|
|||||||
}
|
}
|
||||||
return res, err
|
return res, err
|
||||||
}
|
}
|
||||||
// Validate response.
|
|
||||||
if err := func() error {
|
|
||||||
if err := response.Validate(); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}(); err != nil {
|
|
||||||
return res, errors.Wrap(err, "validate")
|
|
||||||
}
|
|
||||||
return &ErrorStatusCode{
|
return &ErrorStatusCode{
|
||||||
StatusCode: resp.StatusCode,
|
StatusCode: resp.StatusCode,
|
||||||
Response: response,
|
Response: response,
|
||||||
@@ -1649,15 +1016,6 @@ func decodeListScriptsResponse(resp *http.Response) (res []Script, _ error) {
|
|||||||
}
|
}
|
||||||
return res, err
|
return res, err
|
||||||
}
|
}
|
||||||
// Validate response.
|
|
||||||
if err := func() error {
|
|
||||||
if err := response.Validate(); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}(); err != nil {
|
|
||||||
return res, errors.Wrap(err, "validate")
|
|
||||||
}
|
|
||||||
return &ErrorStatusCode{
|
return &ErrorStatusCode{
|
||||||
StatusCode: resp.StatusCode,
|
StatusCode: resp.StatusCode,
|
||||||
Response: response,
|
Response: response,
|
||||||
@@ -1709,15 +1067,6 @@ func decodeUpdateMapfixValidatedModelResponse(resp *http.Response) (res *UpdateM
|
|||||||
}
|
}
|
||||||
return res, err
|
return res, err
|
||||||
}
|
}
|
||||||
// Validate response.
|
|
||||||
if err := func() error {
|
|
||||||
if err := response.Validate(); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}(); err != nil {
|
|
||||||
return res, errors.Wrap(err, "validate")
|
|
||||||
}
|
|
||||||
return &ErrorStatusCode{
|
return &ErrorStatusCode{
|
||||||
StatusCode: resp.StatusCode,
|
StatusCode: resp.StatusCode,
|
||||||
Response: response,
|
Response: response,
|
||||||
@@ -1769,15 +1118,6 @@ func decodeUpdateSubmissionValidatedModelResponse(resp *http.Response) (res *Upd
|
|||||||
}
|
}
|
||||||
return res, err
|
return res, err
|
||||||
}
|
}
|
||||||
// Validate response.
|
|
||||||
if err := func() error {
|
|
||||||
if err := response.Validate(); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}(); err != nil {
|
|
||||||
return res, errors.Wrap(err, "validate")
|
|
||||||
}
|
|
||||||
return &ErrorStatusCode{
|
return &ErrorStatusCode{
|
||||||
StatusCode: resp.StatusCode,
|
StatusCode: resp.StatusCode,
|
||||||
Response: response,
|
Response: response,
|
||||||
|
|||||||
@@ -20,20 +20,6 @@ func encodeActionMapfixAcceptedResponse(response *ActionMapfixAcceptedNoContent,
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func encodeActionMapfixRequestChangesResponse(response *ActionMapfixRequestChangesNoContent, w http.ResponseWriter, span trace.Span) error {
|
|
||||||
w.WriteHeader(204)
|
|
||||||
span.SetStatus(codes.Ok, http.StatusText(204))
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func encodeActionMapfixSubmittedResponse(response *ActionMapfixSubmittedNoContent, w http.ResponseWriter, span trace.Span) error {
|
|
||||||
w.WriteHeader(204)
|
|
||||||
span.SetStatus(codes.Ok, http.StatusText(204))
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func encodeActionMapfixUploadedResponse(response *ActionMapfixUploadedNoContent, w http.ResponseWriter, span trace.Span) error {
|
func encodeActionMapfixUploadedResponse(response *ActionMapfixUploadedNoContent, w http.ResponseWriter, span trace.Span) error {
|
||||||
w.WriteHeader(204)
|
w.WriteHeader(204)
|
||||||
span.SetStatus(codes.Ok, http.StatusText(204))
|
span.SetStatus(codes.Ok, http.StatusText(204))
|
||||||
@@ -62,20 +48,6 @@ func encodeActionSubmissionAcceptedResponse(response *ActionSubmissionAcceptedNo
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func encodeActionSubmissionRequestChangesResponse(response *ActionSubmissionRequestChangesNoContent, w http.ResponseWriter, span trace.Span) error {
|
|
||||||
w.WriteHeader(204)
|
|
||||||
span.SetStatus(codes.Ok, http.StatusText(204))
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func encodeActionSubmissionSubmittedResponse(response *ActionSubmissionSubmittedNoContent, w http.ResponseWriter, span trace.Span) error {
|
|
||||||
w.WriteHeader(204)
|
|
||||||
span.SetStatus(codes.Ok, http.StatusText(204))
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func encodeActionSubmissionUploadedResponse(response *ActionSubmissionUploadedNoContent, w http.ResponseWriter, span trace.Span) error {
|
func encodeActionSubmissionUploadedResponse(response *ActionSubmissionUploadedNoContent, w http.ResponseWriter, span trace.Span) error {
|
||||||
w.WriteHeader(204)
|
w.WriteHeader(204)
|
||||||
span.SetStatus(codes.Ok, http.StatusText(204))
|
span.SetStatus(codes.Ok, http.StatusText(204))
|
||||||
@@ -104,20 +76,6 @@ func encodeCreateMapfixResponse(response *MapfixID, w http.ResponseWriter, span
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func encodeCreateMapfixAuditCheckListResponse(response *CreateMapfixAuditCheckListNoContent, w http.ResponseWriter, span trace.Span) error {
|
|
||||||
w.WriteHeader(204)
|
|
||||||
span.SetStatus(codes.Ok, http.StatusText(204))
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func encodeCreateMapfixAuditErrorResponse(response *CreateMapfixAuditErrorNoContent, w http.ResponseWriter, span trace.Span) error {
|
|
||||||
w.WriteHeader(204)
|
|
||||||
span.SetStatus(codes.Ok, http.StatusText(204))
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func encodeCreateScriptResponse(response *ScriptID, w http.ResponseWriter, span trace.Span) error {
|
func encodeCreateScriptResponse(response *ScriptID, w http.ResponseWriter, span trace.Span) error {
|
||||||
w.Header().Set("Content-Type", "application/json; charset=utf-8")
|
w.Header().Set("Content-Type", "application/json; charset=utf-8")
|
||||||
w.WriteHeader(201)
|
w.WriteHeader(201)
|
||||||
@@ -160,20 +118,6 @@ func encodeCreateSubmissionResponse(response *SubmissionID, w http.ResponseWrite
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func encodeCreateSubmissionAuditCheckListResponse(response *CreateSubmissionAuditCheckListNoContent, w http.ResponseWriter, span trace.Span) error {
|
|
||||||
w.WriteHeader(204)
|
|
||||||
span.SetStatus(codes.Ok, http.StatusText(204))
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func encodeCreateSubmissionAuditErrorResponse(response *CreateSubmissionAuditErrorNoContent, w http.ResponseWriter, span trace.Span) error {
|
|
||||||
w.WriteHeader(204)
|
|
||||||
span.SetStatus(codes.Ok, http.StatusText(204))
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func encodeGetScriptResponse(response *Script, w http.ResponseWriter, span trace.Span) error {
|
func encodeGetScriptResponse(response *Script, w http.ResponseWriter, span trace.Span) error {
|
||||||
w.Header().Set("Content-Type", "application/json; charset=utf-8")
|
w.Header().Set("Content-Type", "application/json; charset=utf-8")
|
||||||
w.WriteHeader(200)
|
w.WriteHeader(200)
|
||||||
|
|||||||
@@ -113,50 +113,6 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
|||||||
break
|
break
|
||||||
}
|
}
|
||||||
switch elem[0] {
|
switch elem[0] {
|
||||||
case 'c': // Prefix: "checklist"
|
|
||||||
|
|
||||||
if l := len("checklist"); len(elem) >= l && elem[0:l] == "checklist" {
|
|
||||||
elem = elem[l:]
|
|
||||||
} else {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
|
|
||||||
if len(elem) == 0 {
|
|
||||||
// Leaf node.
|
|
||||||
switch r.Method {
|
|
||||||
case "POST":
|
|
||||||
s.handleCreateMapfixAuditCheckListRequest([1]string{
|
|
||||||
args[0],
|
|
||||||
}, elemIsEscaped, w, r)
|
|
||||||
default:
|
|
||||||
s.notAllowed(w, r, "POST")
|
|
||||||
}
|
|
||||||
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
case 'e': // Prefix: "error"
|
|
||||||
|
|
||||||
if l := len("error"); len(elem) >= l && elem[0:l] == "error" {
|
|
||||||
elem = elem[l:]
|
|
||||||
} else {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
|
|
||||||
if len(elem) == 0 {
|
|
||||||
// Leaf node.
|
|
||||||
switch r.Method {
|
|
||||||
case "POST":
|
|
||||||
s.handleCreateMapfixAuditErrorRequest([1]string{
|
|
||||||
args[0],
|
|
||||||
}, elemIsEscaped, w, r)
|
|
||||||
default:
|
|
||||||
s.notAllowed(w, r, "POST")
|
|
||||||
}
|
|
||||||
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
case 's': // Prefix: "status/validator-"
|
case 's': // Prefix: "status/validator-"
|
||||||
|
|
||||||
if l := len("status/validator-"); len(elem) >= l && elem[0:l] == "status/validator-" {
|
if l := len("status/validator-"); len(elem) >= l && elem[0:l] == "status/validator-" {
|
||||||
@@ -191,50 +147,6 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
case 'r': // Prefix: "request-changes"
|
|
||||||
|
|
||||||
if l := len("request-changes"); len(elem) >= l && elem[0:l] == "request-changes" {
|
|
||||||
elem = elem[l:]
|
|
||||||
} else {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
|
|
||||||
if len(elem) == 0 {
|
|
||||||
// Leaf node.
|
|
||||||
switch r.Method {
|
|
||||||
case "POST":
|
|
||||||
s.handleActionMapfixRequestChangesRequest([1]string{
|
|
||||||
args[0],
|
|
||||||
}, elemIsEscaped, w, r)
|
|
||||||
default:
|
|
||||||
s.notAllowed(w, r, "POST")
|
|
||||||
}
|
|
||||||
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
case 's': // Prefix: "submitted"
|
|
||||||
|
|
||||||
if l := len("submitted"); len(elem) >= l && elem[0:l] == "submitted" {
|
|
||||||
elem = elem[l:]
|
|
||||||
} else {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
|
|
||||||
if len(elem) == 0 {
|
|
||||||
// Leaf node.
|
|
||||||
switch r.Method {
|
|
||||||
case "POST":
|
|
||||||
s.handleActionMapfixSubmittedRequest([1]string{
|
|
||||||
args[0],
|
|
||||||
}, elemIsEscaped, w, r)
|
|
||||||
default:
|
|
||||||
s.notAllowed(w, r, "POST")
|
|
||||||
}
|
|
||||||
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
case 'u': // Prefix: "uploaded"
|
case 'u': // Prefix: "uploaded"
|
||||||
|
|
||||||
if l := len("uploaded"); len(elem) >= l && elem[0:l] == "uploaded" {
|
if l := len("uploaded"); len(elem) >= l && elem[0:l] == "uploaded" {
|
||||||
@@ -508,50 +420,6 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
|||||||
break
|
break
|
||||||
}
|
}
|
||||||
switch elem[0] {
|
switch elem[0] {
|
||||||
case 'c': // Prefix: "checklist"
|
|
||||||
|
|
||||||
if l := len("checklist"); len(elem) >= l && elem[0:l] == "checklist" {
|
|
||||||
elem = elem[l:]
|
|
||||||
} else {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
|
|
||||||
if len(elem) == 0 {
|
|
||||||
// Leaf node.
|
|
||||||
switch r.Method {
|
|
||||||
case "POST":
|
|
||||||
s.handleCreateSubmissionAuditCheckListRequest([1]string{
|
|
||||||
args[0],
|
|
||||||
}, elemIsEscaped, w, r)
|
|
||||||
default:
|
|
||||||
s.notAllowed(w, r, "POST")
|
|
||||||
}
|
|
||||||
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
case 'e': // Prefix: "error"
|
|
||||||
|
|
||||||
if l := len("error"); len(elem) >= l && elem[0:l] == "error" {
|
|
||||||
elem = elem[l:]
|
|
||||||
} else {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
|
|
||||||
if len(elem) == 0 {
|
|
||||||
// Leaf node.
|
|
||||||
switch r.Method {
|
|
||||||
case "POST":
|
|
||||||
s.handleCreateSubmissionAuditErrorRequest([1]string{
|
|
||||||
args[0],
|
|
||||||
}, elemIsEscaped, w, r)
|
|
||||||
default:
|
|
||||||
s.notAllowed(w, r, "POST")
|
|
||||||
}
|
|
||||||
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
case 's': // Prefix: "status/validator-"
|
case 's': // Prefix: "status/validator-"
|
||||||
|
|
||||||
if l := len("status/validator-"); len(elem) >= l && elem[0:l] == "status/validator-" {
|
if l := len("status/validator-"); len(elem) >= l && elem[0:l] == "status/validator-" {
|
||||||
@@ -586,50 +454,6 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
case 'r': // Prefix: "request-changes"
|
|
||||||
|
|
||||||
if l := len("request-changes"); len(elem) >= l && elem[0:l] == "request-changes" {
|
|
||||||
elem = elem[l:]
|
|
||||||
} else {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
|
|
||||||
if len(elem) == 0 {
|
|
||||||
// Leaf node.
|
|
||||||
switch r.Method {
|
|
||||||
case "POST":
|
|
||||||
s.handleActionSubmissionRequestChangesRequest([1]string{
|
|
||||||
args[0],
|
|
||||||
}, elemIsEscaped, w, r)
|
|
||||||
default:
|
|
||||||
s.notAllowed(w, r, "POST")
|
|
||||||
}
|
|
||||||
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
case 's': // Prefix: "submitted"
|
|
||||||
|
|
||||||
if l := len("submitted"); len(elem) >= l && elem[0:l] == "submitted" {
|
|
||||||
elem = elem[l:]
|
|
||||||
} else {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
|
|
||||||
if len(elem) == 0 {
|
|
||||||
// Leaf node.
|
|
||||||
switch r.Method {
|
|
||||||
case "POST":
|
|
||||||
s.handleActionSubmissionSubmittedRequest([1]string{
|
|
||||||
args[0],
|
|
||||||
}, elemIsEscaped, w, r)
|
|
||||||
default:
|
|
||||||
s.notAllowed(w, r, "POST")
|
|
||||||
}
|
|
||||||
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
case 'u': // Prefix: "uploaded"
|
case 'u': // Prefix: "uploaded"
|
||||||
|
|
||||||
if l := len("uploaded"); len(elem) >= l && elem[0:l] == "uploaded" {
|
if l := len("uploaded"); len(elem) >= l && elem[0:l] == "uploaded" {
|
||||||
@@ -856,54 +680,6 @@ func (s *Server) FindPath(method string, u *url.URL) (r Route, _ bool) {
|
|||||||
break
|
break
|
||||||
}
|
}
|
||||||
switch elem[0] {
|
switch elem[0] {
|
||||||
case 'c': // Prefix: "checklist"
|
|
||||||
|
|
||||||
if l := len("checklist"); len(elem) >= l && elem[0:l] == "checklist" {
|
|
||||||
elem = elem[l:]
|
|
||||||
} else {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
|
|
||||||
if len(elem) == 0 {
|
|
||||||
// Leaf node.
|
|
||||||
switch method {
|
|
||||||
case "POST":
|
|
||||||
r.name = CreateMapfixAuditCheckListOperation
|
|
||||||
r.summary = "Validator posts a checklist to the audit log"
|
|
||||||
r.operationID = "createMapfixAuditCheckList"
|
|
||||||
r.pathPattern = "/mapfixes/{MapfixID}/checklist"
|
|
||||||
r.args = args
|
|
||||||
r.count = 1
|
|
||||||
return r, true
|
|
||||||
default:
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
case 'e': // Prefix: "error"
|
|
||||||
|
|
||||||
if l := len("error"); len(elem) >= l && elem[0:l] == "error" {
|
|
||||||
elem = elem[l:]
|
|
||||||
} else {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
|
|
||||||
if len(elem) == 0 {
|
|
||||||
// Leaf node.
|
|
||||||
switch method {
|
|
||||||
case "POST":
|
|
||||||
r.name = CreateMapfixAuditErrorOperation
|
|
||||||
r.summary = "Validator posts an error to the audit log"
|
|
||||||
r.operationID = "createMapfixAuditError"
|
|
||||||
r.pathPattern = "/mapfixes/{MapfixID}/error"
|
|
||||||
r.args = args
|
|
||||||
r.count = 1
|
|
||||||
return r, true
|
|
||||||
default:
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
case 's': // Prefix: "status/validator-"
|
case 's': // Prefix: "status/validator-"
|
||||||
|
|
||||||
if l := len("status/validator-"); len(elem) >= l && elem[0:l] == "status/validator-" {
|
if l := len("status/validator-"); len(elem) >= l && elem[0:l] == "status/validator-" {
|
||||||
@@ -940,54 +716,6 @@ func (s *Server) FindPath(method string, u *url.URL) (r Route, _ bool) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
case 'r': // Prefix: "request-changes"
|
|
||||||
|
|
||||||
if l := len("request-changes"); len(elem) >= l && elem[0:l] == "request-changes" {
|
|
||||||
elem = elem[l:]
|
|
||||||
} else {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
|
|
||||||
if len(elem) == 0 {
|
|
||||||
// Leaf node.
|
|
||||||
switch method {
|
|
||||||
case "POST":
|
|
||||||
r.name = ActionMapfixRequestChangesOperation
|
|
||||||
r.summary = "(Internal endpoint) Role Validator changes status from Submitting -> ChangesRequested"
|
|
||||||
r.operationID = "actionMapfixRequestChanges"
|
|
||||||
r.pathPattern = "/mapfixes/{MapfixID}/status/validator-request-changes"
|
|
||||||
r.args = args
|
|
||||||
r.count = 1
|
|
||||||
return r, true
|
|
||||||
default:
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
case 's': // Prefix: "submitted"
|
|
||||||
|
|
||||||
if l := len("submitted"); len(elem) >= l && elem[0:l] == "submitted" {
|
|
||||||
elem = elem[l:]
|
|
||||||
} else {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
|
|
||||||
if len(elem) == 0 {
|
|
||||||
// Leaf node.
|
|
||||||
switch method {
|
|
||||||
case "POST":
|
|
||||||
r.name = ActionMapfixSubmittedOperation
|
|
||||||
r.summary = "(Internal endpoint) Role Validator changes status from Submitting -> Submitted"
|
|
||||||
r.operationID = "actionMapfixSubmitted"
|
|
||||||
r.pathPattern = "/mapfixes/{MapfixID}/status/validator-submitted"
|
|
||||||
r.args = args
|
|
||||||
r.count = 1
|
|
||||||
return r, true
|
|
||||||
default:
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
case 'u': // Prefix: "uploaded"
|
case 'u': // Prefix: "uploaded"
|
||||||
|
|
||||||
if l := len("uploaded"); len(elem) >= l && elem[0:l] == "uploaded" {
|
if l := len("uploaded"); len(elem) >= l && elem[0:l] == "uploaded" {
|
||||||
@@ -1295,54 +1023,6 @@ func (s *Server) FindPath(method string, u *url.URL) (r Route, _ bool) {
|
|||||||
break
|
break
|
||||||
}
|
}
|
||||||
switch elem[0] {
|
switch elem[0] {
|
||||||
case 'c': // Prefix: "checklist"
|
|
||||||
|
|
||||||
if l := len("checklist"); len(elem) >= l && elem[0:l] == "checklist" {
|
|
||||||
elem = elem[l:]
|
|
||||||
} else {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
|
|
||||||
if len(elem) == 0 {
|
|
||||||
// Leaf node.
|
|
||||||
switch method {
|
|
||||||
case "POST":
|
|
||||||
r.name = CreateSubmissionAuditCheckListOperation
|
|
||||||
r.summary = "Validator posts a checklist to the audit log"
|
|
||||||
r.operationID = "createSubmissionAuditCheckList"
|
|
||||||
r.pathPattern = "/submissions/{SubmissionID}/checklist"
|
|
||||||
r.args = args
|
|
||||||
r.count = 1
|
|
||||||
return r, true
|
|
||||||
default:
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
case 'e': // Prefix: "error"
|
|
||||||
|
|
||||||
if l := len("error"); len(elem) >= l && elem[0:l] == "error" {
|
|
||||||
elem = elem[l:]
|
|
||||||
} else {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
|
|
||||||
if len(elem) == 0 {
|
|
||||||
// Leaf node.
|
|
||||||
switch method {
|
|
||||||
case "POST":
|
|
||||||
r.name = CreateSubmissionAuditErrorOperation
|
|
||||||
r.summary = "Validator posts an error to the audit log"
|
|
||||||
r.operationID = "createSubmissionAuditError"
|
|
||||||
r.pathPattern = "/submissions/{SubmissionID}/error"
|
|
||||||
r.args = args
|
|
||||||
r.count = 1
|
|
||||||
return r, true
|
|
||||||
default:
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
case 's': // Prefix: "status/validator-"
|
case 's': // Prefix: "status/validator-"
|
||||||
|
|
||||||
if l := len("status/validator-"); len(elem) >= l && elem[0:l] == "status/validator-" {
|
if l := len("status/validator-"); len(elem) >= l && elem[0:l] == "status/validator-" {
|
||||||
@@ -1379,54 +1059,6 @@ func (s *Server) FindPath(method string, u *url.URL) (r Route, _ bool) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
case 'r': // Prefix: "request-changes"
|
|
||||||
|
|
||||||
if l := len("request-changes"); len(elem) >= l && elem[0:l] == "request-changes" {
|
|
||||||
elem = elem[l:]
|
|
||||||
} else {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
|
|
||||||
if len(elem) == 0 {
|
|
||||||
// Leaf node.
|
|
||||||
switch method {
|
|
||||||
case "POST":
|
|
||||||
r.name = ActionSubmissionRequestChangesOperation
|
|
||||||
r.summary = "(Internal endpoint) Role Validator changes status from Submitting -> ChangesRequested"
|
|
||||||
r.operationID = "actionSubmissionRequestChanges"
|
|
||||||
r.pathPattern = "/submissions/{SubmissionID}/status/validator-request-changes"
|
|
||||||
r.args = args
|
|
||||||
r.count = 1
|
|
||||||
return r, true
|
|
||||||
default:
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
case 's': // Prefix: "submitted"
|
|
||||||
|
|
||||||
if l := len("submitted"); len(elem) >= l && elem[0:l] == "submitted" {
|
|
||||||
elem = elem[l:]
|
|
||||||
} else {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
|
|
||||||
if len(elem) == 0 {
|
|
||||||
// Leaf node.
|
|
||||||
switch method {
|
|
||||||
case "POST":
|
|
||||||
r.name = ActionSubmissionSubmittedOperation
|
|
||||||
r.summary = "(Internal endpoint) Role Validator changes status from Submitting -> Submitted"
|
|
||||||
r.operationID = "actionSubmissionSubmitted"
|
|
||||||
r.pathPattern = "/submissions/{SubmissionID}/status/validator-submitted"
|
|
||||||
r.args = args
|
|
||||||
r.count = 1
|
|
||||||
return r, true
|
|
||||||
default:
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
case 'u': // Prefix: "uploaded"
|
case 'u': // Prefix: "uploaded"
|
||||||
|
|
||||||
if l := len("uploaded"); len(elem) >= l && elem[0:l] == "uploaded" {
|
if l := len("uploaded"); len(elem) >= l && elem[0:l] == "uploaded" {
|
||||||
|
|||||||
@@ -13,12 +13,6 @@ func (s *ErrorStatusCode) Error() string {
|
|||||||
// ActionMapfixAcceptedNoContent is response for ActionMapfixAccepted operation.
|
// ActionMapfixAcceptedNoContent is response for ActionMapfixAccepted operation.
|
||||||
type ActionMapfixAcceptedNoContent struct{}
|
type ActionMapfixAcceptedNoContent struct{}
|
||||||
|
|
||||||
// ActionMapfixRequestChangesNoContent is response for ActionMapfixRequestChanges operation.
|
|
||||||
type ActionMapfixRequestChangesNoContent struct{}
|
|
||||||
|
|
||||||
// ActionMapfixSubmittedNoContent is response for ActionMapfixSubmitted operation.
|
|
||||||
type ActionMapfixSubmittedNoContent struct{}
|
|
||||||
|
|
||||||
// ActionMapfixUploadedNoContent is response for ActionMapfixUploaded operation.
|
// ActionMapfixUploadedNoContent is response for ActionMapfixUploaded operation.
|
||||||
type ActionMapfixUploadedNoContent struct{}
|
type ActionMapfixUploadedNoContent struct{}
|
||||||
|
|
||||||
@@ -31,69 +25,12 @@ type ActionOperationFailedNoContent struct{}
|
|||||||
// ActionSubmissionAcceptedNoContent is response for ActionSubmissionAccepted operation.
|
// ActionSubmissionAcceptedNoContent is response for ActionSubmissionAccepted operation.
|
||||||
type ActionSubmissionAcceptedNoContent struct{}
|
type ActionSubmissionAcceptedNoContent struct{}
|
||||||
|
|
||||||
// ActionSubmissionRequestChangesNoContent is response for ActionSubmissionRequestChanges operation.
|
|
||||||
type ActionSubmissionRequestChangesNoContent struct{}
|
|
||||||
|
|
||||||
// ActionSubmissionSubmittedNoContent is response for ActionSubmissionSubmitted operation.
|
|
||||||
type ActionSubmissionSubmittedNoContent struct{}
|
|
||||||
|
|
||||||
// ActionSubmissionUploadedNoContent is response for ActionSubmissionUploaded operation.
|
// ActionSubmissionUploadedNoContent is response for ActionSubmissionUploaded operation.
|
||||||
type ActionSubmissionUploadedNoContent struct{}
|
type ActionSubmissionUploadedNoContent struct{}
|
||||||
|
|
||||||
// ActionSubmissionValidatedNoContent is response for ActionSubmissionValidated operation.
|
// ActionSubmissionValidatedNoContent is response for ActionSubmissionValidated operation.
|
||||||
type ActionSubmissionValidatedNoContent struct{}
|
type ActionSubmissionValidatedNoContent struct{}
|
||||||
|
|
||||||
// Ref: #/components/schemas/Check
|
|
||||||
type Check struct {
|
|
||||||
Name string `json:"Name"`
|
|
||||||
Summary string `json:"Summary"`
|
|
||||||
Passed bool `json:"Passed"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetName returns the value of Name.
|
|
||||||
func (s *Check) GetName() string {
|
|
||||||
return s.Name
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetSummary returns the value of Summary.
|
|
||||||
func (s *Check) GetSummary() string {
|
|
||||||
return s.Summary
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetPassed returns the value of Passed.
|
|
||||||
func (s *Check) GetPassed() bool {
|
|
||||||
return s.Passed
|
|
||||||
}
|
|
||||||
|
|
||||||
// SetName sets the value of Name.
|
|
||||||
func (s *Check) SetName(val string) {
|
|
||||||
s.Name = val
|
|
||||||
}
|
|
||||||
|
|
||||||
// SetSummary sets the value of Summary.
|
|
||||||
func (s *Check) SetSummary(val string) {
|
|
||||||
s.Summary = val
|
|
||||||
}
|
|
||||||
|
|
||||||
// SetPassed sets the value of Passed.
|
|
||||||
func (s *Check) SetPassed(val bool) {
|
|
||||||
s.Passed = val
|
|
||||||
}
|
|
||||||
|
|
||||||
type CheckList []Check
|
|
||||||
|
|
||||||
// CreateMapfixAuditCheckListNoContent is response for CreateMapfixAuditCheckList operation.
|
|
||||||
type CreateMapfixAuditCheckListNoContent struct{}
|
|
||||||
|
|
||||||
// CreateMapfixAuditErrorNoContent is response for CreateMapfixAuditError operation.
|
|
||||||
type CreateMapfixAuditErrorNoContent struct{}
|
|
||||||
|
|
||||||
// CreateSubmissionAuditCheckListNoContent is response for CreateSubmissionAuditCheckList operation.
|
|
||||||
type CreateSubmissionAuditCheckListNoContent struct{}
|
|
||||||
|
|
||||||
// CreateSubmissionAuditErrorNoContent is response for CreateSubmissionAuditError operation.
|
|
||||||
type CreateSubmissionAuditErrorNoContent struct{}
|
|
||||||
|
|
||||||
// Represents error object.
|
// Represents error object.
|
||||||
// Ref: #/components/schemas/Error
|
// Ref: #/components/schemas/Error
|
||||||
type Error struct {
|
type Error struct {
|
||||||
@@ -157,7 +94,6 @@ type MapfixCreate struct {
|
|||||||
AssetID int64 `json:"AssetID"`
|
AssetID int64 `json:"AssetID"`
|
||||||
AssetVersion int64 `json:"AssetVersion"`
|
AssetVersion int64 `json:"AssetVersion"`
|
||||||
TargetAssetID int64 `json:"TargetAssetID"`
|
TargetAssetID int64 `json:"TargetAssetID"`
|
||||||
Description string `json:"Description"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetOperationID returns the value of OperationID.
|
// GetOperationID returns the value of OperationID.
|
||||||
@@ -200,11 +136,6 @@ func (s *MapfixCreate) GetTargetAssetID() int64 {
|
|||||||
return s.TargetAssetID
|
return s.TargetAssetID
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetDescription returns the value of Description.
|
|
||||||
func (s *MapfixCreate) GetDescription() string {
|
|
||||||
return s.Description
|
|
||||||
}
|
|
||||||
|
|
||||||
// SetOperationID sets the value of OperationID.
|
// SetOperationID sets the value of OperationID.
|
||||||
func (s *MapfixCreate) SetOperationID(val int32) {
|
func (s *MapfixCreate) SetOperationID(val int32) {
|
||||||
s.OperationID = val
|
s.OperationID = val
|
||||||
@@ -245,11 +176,6 @@ func (s *MapfixCreate) SetTargetAssetID(val int64) {
|
|||||||
s.TargetAssetID = val
|
s.TargetAssetID = val
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetDescription sets the value of Description.
|
|
||||||
func (s *MapfixCreate) SetDescription(val string) {
|
|
||||||
s.Description = val
|
|
||||||
}
|
|
||||||
|
|
||||||
// Ref: #/components/schemas/MapfixID
|
// Ref: #/components/schemas/MapfixID
|
||||||
type MapfixID struct {
|
type MapfixID struct {
|
||||||
MapfixID int64 `json:"MapfixID"`
|
MapfixID int64 `json:"MapfixID"`
|
||||||
@@ -645,8 +571,6 @@ type SubmissionCreate struct {
|
|||||||
GameID int32 `json:"GameID"`
|
GameID int32 `json:"GameID"`
|
||||||
AssetID int64 `json:"AssetID"`
|
AssetID int64 `json:"AssetID"`
|
||||||
AssetVersion int64 `json:"AssetVersion"`
|
AssetVersion int64 `json:"AssetVersion"`
|
||||||
Status uint32 `json:"Status"`
|
|
||||||
Roles uint32 `json:"Roles"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetOperationID returns the value of OperationID.
|
// GetOperationID returns the value of OperationID.
|
||||||
@@ -684,16 +608,6 @@ func (s *SubmissionCreate) GetAssetVersion() int64 {
|
|||||||
return s.AssetVersion
|
return s.AssetVersion
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetStatus returns the value of Status.
|
|
||||||
func (s *SubmissionCreate) GetStatus() uint32 {
|
|
||||||
return s.Status
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetRoles returns the value of Roles.
|
|
||||||
func (s *SubmissionCreate) GetRoles() uint32 {
|
|
||||||
return s.Roles
|
|
||||||
}
|
|
||||||
|
|
||||||
// SetOperationID sets the value of OperationID.
|
// SetOperationID sets the value of OperationID.
|
||||||
func (s *SubmissionCreate) SetOperationID(val int32) {
|
func (s *SubmissionCreate) SetOperationID(val int32) {
|
||||||
s.OperationID = val
|
s.OperationID = val
|
||||||
@@ -729,16 +643,6 @@ func (s *SubmissionCreate) SetAssetVersion(val int64) {
|
|||||||
s.AssetVersion = val
|
s.AssetVersion = val
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetStatus sets the value of Status.
|
|
||||||
func (s *SubmissionCreate) SetStatus(val uint32) {
|
|
||||||
s.Status = val
|
|
||||||
}
|
|
||||||
|
|
||||||
// SetRoles sets the value of Roles.
|
|
||||||
func (s *SubmissionCreate) SetRoles(val uint32) {
|
|
||||||
s.Roles = val
|
|
||||||
}
|
|
||||||
|
|
||||||
// Ref: #/components/schemas/SubmissionID
|
// Ref: #/components/schemas/SubmissionID
|
||||||
type SubmissionID struct {
|
type SubmissionID struct {
|
||||||
SubmissionID int64 `json:"SubmissionID"`
|
SubmissionID int64 `json:"SubmissionID"`
|
||||||
|
|||||||
@@ -14,18 +14,6 @@ type Handler interface {
|
|||||||
//
|
//
|
||||||
// POST /mapfixes/{MapfixID}/status/validator-failed
|
// POST /mapfixes/{MapfixID}/status/validator-failed
|
||||||
ActionMapfixAccepted(ctx context.Context, params ActionMapfixAcceptedParams) error
|
ActionMapfixAccepted(ctx context.Context, params ActionMapfixAcceptedParams) error
|
||||||
// ActionMapfixRequestChanges implements actionMapfixRequestChanges operation.
|
|
||||||
//
|
|
||||||
// (Internal endpoint) Role Validator changes status from Submitting -> ChangesRequested.
|
|
||||||
//
|
|
||||||
// POST /mapfixes/{MapfixID}/status/validator-request-changes
|
|
||||||
ActionMapfixRequestChanges(ctx context.Context, params ActionMapfixRequestChangesParams) error
|
|
||||||
// ActionMapfixSubmitted implements actionMapfixSubmitted operation.
|
|
||||||
//
|
|
||||||
// (Internal endpoint) Role Validator changes status from Submitting -> Submitted.
|
|
||||||
//
|
|
||||||
// POST /mapfixes/{MapfixID}/status/validator-submitted
|
|
||||||
ActionMapfixSubmitted(ctx context.Context, params ActionMapfixSubmittedParams) error
|
|
||||||
// ActionMapfixUploaded implements actionMapfixUploaded operation.
|
// ActionMapfixUploaded implements actionMapfixUploaded operation.
|
||||||
//
|
//
|
||||||
// (Internal endpoint) Role Validator changes status from Uploading -> Uploaded.
|
// (Internal endpoint) Role Validator changes status from Uploading -> Uploaded.
|
||||||
@@ -50,18 +38,6 @@ type Handler interface {
|
|||||||
//
|
//
|
||||||
// POST /submissions/{SubmissionID}/status/validator-failed
|
// POST /submissions/{SubmissionID}/status/validator-failed
|
||||||
ActionSubmissionAccepted(ctx context.Context, params ActionSubmissionAcceptedParams) error
|
ActionSubmissionAccepted(ctx context.Context, params ActionSubmissionAcceptedParams) error
|
||||||
// ActionSubmissionRequestChanges implements actionSubmissionRequestChanges operation.
|
|
||||||
//
|
|
||||||
// (Internal endpoint) Role Validator changes status from Submitting -> ChangesRequested.
|
|
||||||
//
|
|
||||||
// POST /submissions/{SubmissionID}/status/validator-request-changes
|
|
||||||
ActionSubmissionRequestChanges(ctx context.Context, params ActionSubmissionRequestChangesParams) error
|
|
||||||
// ActionSubmissionSubmitted implements actionSubmissionSubmitted operation.
|
|
||||||
//
|
|
||||||
// (Internal endpoint) Role Validator changes status from Submitting -> Submitted.
|
|
||||||
//
|
|
||||||
// POST /submissions/{SubmissionID}/status/validator-submitted
|
|
||||||
ActionSubmissionSubmitted(ctx context.Context, params ActionSubmissionSubmittedParams) error
|
|
||||||
// ActionSubmissionUploaded implements actionSubmissionUploaded operation.
|
// ActionSubmissionUploaded implements actionSubmissionUploaded operation.
|
||||||
//
|
//
|
||||||
// (Internal endpoint) Role Validator changes status from Uploading -> Uploaded.
|
// (Internal endpoint) Role Validator changes status from Uploading -> Uploaded.
|
||||||
@@ -80,18 +56,6 @@ type Handler interface {
|
|||||||
//
|
//
|
||||||
// POST /mapfixes
|
// POST /mapfixes
|
||||||
CreateMapfix(ctx context.Context, req *MapfixCreate) (*MapfixID, error)
|
CreateMapfix(ctx context.Context, req *MapfixCreate) (*MapfixID, error)
|
||||||
// CreateMapfixAuditCheckList implements createMapfixAuditCheckList operation.
|
|
||||||
//
|
|
||||||
// Validator posts a checklist to the audit log.
|
|
||||||
//
|
|
||||||
// POST /mapfixes/{MapfixID}/checklist
|
|
||||||
CreateMapfixAuditCheckList(ctx context.Context, req CheckList, params CreateMapfixAuditCheckListParams) error
|
|
||||||
// CreateMapfixAuditError implements createMapfixAuditError operation.
|
|
||||||
//
|
|
||||||
// Validator posts an error to the audit log.
|
|
||||||
//
|
|
||||||
// POST /mapfixes/{MapfixID}/error
|
|
||||||
CreateMapfixAuditError(ctx context.Context, params CreateMapfixAuditErrorParams) error
|
|
||||||
// CreateScript implements createScript operation.
|
// CreateScript implements createScript operation.
|
||||||
//
|
//
|
||||||
// Create a new script.
|
// Create a new script.
|
||||||
@@ -110,18 +74,6 @@ type Handler interface {
|
|||||||
//
|
//
|
||||||
// POST /submissions
|
// POST /submissions
|
||||||
CreateSubmission(ctx context.Context, req *SubmissionCreate) (*SubmissionID, error)
|
CreateSubmission(ctx context.Context, req *SubmissionCreate) (*SubmissionID, error)
|
||||||
// CreateSubmissionAuditCheckList implements createSubmissionAuditCheckList operation.
|
|
||||||
//
|
|
||||||
// Validator posts a checklist to the audit log.
|
|
||||||
//
|
|
||||||
// POST /submissions/{SubmissionID}/checklist
|
|
||||||
CreateSubmissionAuditCheckList(ctx context.Context, req CheckList, params CreateSubmissionAuditCheckListParams) error
|
|
||||||
// CreateSubmissionAuditError implements createSubmissionAuditError operation.
|
|
||||||
//
|
|
||||||
// Validator posts an error to the audit log.
|
|
||||||
//
|
|
||||||
// POST /submissions/{SubmissionID}/error
|
|
||||||
CreateSubmissionAuditError(ctx context.Context, params CreateSubmissionAuditErrorParams) error
|
|
||||||
// GetScript implements getScript operation.
|
// GetScript implements getScript operation.
|
||||||
//
|
//
|
||||||
// Get the specified script by ID.
|
// Get the specified script by ID.
|
||||||
|
|||||||
@@ -22,24 +22,6 @@ func (UnimplementedHandler) ActionMapfixAccepted(ctx context.Context, params Act
|
|||||||
return ht.ErrNotImplemented
|
return ht.ErrNotImplemented
|
||||||
}
|
}
|
||||||
|
|
||||||
// ActionMapfixRequestChanges implements actionMapfixRequestChanges operation.
|
|
||||||
//
|
|
||||||
// (Internal endpoint) Role Validator changes status from Submitting -> ChangesRequested.
|
|
||||||
//
|
|
||||||
// POST /mapfixes/{MapfixID}/status/validator-request-changes
|
|
||||||
func (UnimplementedHandler) ActionMapfixRequestChanges(ctx context.Context, params ActionMapfixRequestChangesParams) error {
|
|
||||||
return ht.ErrNotImplemented
|
|
||||||
}
|
|
||||||
|
|
||||||
// ActionMapfixSubmitted implements actionMapfixSubmitted operation.
|
|
||||||
//
|
|
||||||
// (Internal endpoint) Role Validator changes status from Submitting -> Submitted.
|
|
||||||
//
|
|
||||||
// POST /mapfixes/{MapfixID}/status/validator-submitted
|
|
||||||
func (UnimplementedHandler) ActionMapfixSubmitted(ctx context.Context, params ActionMapfixSubmittedParams) error {
|
|
||||||
return ht.ErrNotImplemented
|
|
||||||
}
|
|
||||||
|
|
||||||
// ActionMapfixUploaded implements actionMapfixUploaded operation.
|
// ActionMapfixUploaded implements actionMapfixUploaded operation.
|
||||||
//
|
//
|
||||||
// (Internal endpoint) Role Validator changes status from Uploading -> Uploaded.
|
// (Internal endpoint) Role Validator changes status from Uploading -> Uploaded.
|
||||||
@@ -76,24 +58,6 @@ func (UnimplementedHandler) ActionSubmissionAccepted(ctx context.Context, params
|
|||||||
return ht.ErrNotImplemented
|
return ht.ErrNotImplemented
|
||||||
}
|
}
|
||||||
|
|
||||||
// ActionSubmissionRequestChanges implements actionSubmissionRequestChanges operation.
|
|
||||||
//
|
|
||||||
// (Internal endpoint) Role Validator changes status from Submitting -> ChangesRequested.
|
|
||||||
//
|
|
||||||
// POST /submissions/{SubmissionID}/status/validator-request-changes
|
|
||||||
func (UnimplementedHandler) ActionSubmissionRequestChanges(ctx context.Context, params ActionSubmissionRequestChangesParams) error {
|
|
||||||
return ht.ErrNotImplemented
|
|
||||||
}
|
|
||||||
|
|
||||||
// ActionSubmissionSubmitted implements actionSubmissionSubmitted operation.
|
|
||||||
//
|
|
||||||
// (Internal endpoint) Role Validator changes status from Submitting -> Submitted.
|
|
||||||
//
|
|
||||||
// POST /submissions/{SubmissionID}/status/validator-submitted
|
|
||||||
func (UnimplementedHandler) ActionSubmissionSubmitted(ctx context.Context, params ActionSubmissionSubmittedParams) error {
|
|
||||||
return ht.ErrNotImplemented
|
|
||||||
}
|
|
||||||
|
|
||||||
// ActionSubmissionUploaded implements actionSubmissionUploaded operation.
|
// ActionSubmissionUploaded implements actionSubmissionUploaded operation.
|
||||||
//
|
//
|
||||||
// (Internal endpoint) Role Validator changes status from Uploading -> Uploaded.
|
// (Internal endpoint) Role Validator changes status from Uploading -> Uploaded.
|
||||||
@@ -121,24 +85,6 @@ func (UnimplementedHandler) CreateMapfix(ctx context.Context, req *MapfixCreate)
|
|||||||
return r, ht.ErrNotImplemented
|
return r, ht.ErrNotImplemented
|
||||||
}
|
}
|
||||||
|
|
||||||
// CreateMapfixAuditCheckList implements createMapfixAuditCheckList operation.
|
|
||||||
//
|
|
||||||
// Validator posts a checklist to the audit log.
|
|
||||||
//
|
|
||||||
// POST /mapfixes/{MapfixID}/checklist
|
|
||||||
func (UnimplementedHandler) CreateMapfixAuditCheckList(ctx context.Context, req CheckList, params CreateMapfixAuditCheckListParams) error {
|
|
||||||
return ht.ErrNotImplemented
|
|
||||||
}
|
|
||||||
|
|
||||||
// CreateMapfixAuditError implements createMapfixAuditError operation.
|
|
||||||
//
|
|
||||||
// Validator posts an error to the audit log.
|
|
||||||
//
|
|
||||||
// POST /mapfixes/{MapfixID}/error
|
|
||||||
func (UnimplementedHandler) CreateMapfixAuditError(ctx context.Context, params CreateMapfixAuditErrorParams) error {
|
|
||||||
return ht.ErrNotImplemented
|
|
||||||
}
|
|
||||||
|
|
||||||
// CreateScript implements createScript operation.
|
// CreateScript implements createScript operation.
|
||||||
//
|
//
|
||||||
// Create a new script.
|
// Create a new script.
|
||||||
@@ -166,24 +112,6 @@ func (UnimplementedHandler) CreateSubmission(ctx context.Context, req *Submissio
|
|||||||
return r, ht.ErrNotImplemented
|
return r, ht.ErrNotImplemented
|
||||||
}
|
}
|
||||||
|
|
||||||
// CreateSubmissionAuditCheckList implements createSubmissionAuditCheckList operation.
|
|
||||||
//
|
|
||||||
// Validator posts a checklist to the audit log.
|
|
||||||
//
|
|
||||||
// POST /submissions/{SubmissionID}/checklist
|
|
||||||
func (UnimplementedHandler) CreateSubmissionAuditCheckList(ctx context.Context, req CheckList, params CreateSubmissionAuditCheckListParams) error {
|
|
||||||
return ht.ErrNotImplemented
|
|
||||||
}
|
|
||||||
|
|
||||||
// CreateSubmissionAuditError implements createSubmissionAuditError operation.
|
|
||||||
//
|
|
||||||
// Validator posts an error to the audit log.
|
|
||||||
//
|
|
||||||
// POST /submissions/{SubmissionID}/error
|
|
||||||
func (UnimplementedHandler) CreateSubmissionAuditError(ctx context.Context, params CreateSubmissionAuditErrorParams) error {
|
|
||||||
return ht.ErrNotImplemented
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetScript implements getScript operation.
|
// GetScript implements getScript operation.
|
||||||
//
|
//
|
||||||
// Get the specified script by ID.
|
// Get the specified script by ID.
|
||||||
|
|||||||
@@ -3,189 +3,17 @@
|
|||||||
package api
|
package api
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
|
||||||
|
|
||||||
"github.com/go-faster/errors"
|
"github.com/go-faster/errors"
|
||||||
|
|
||||||
"github.com/ogen-go/ogen/validate"
|
"github.com/ogen-go/ogen/validate"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (s *Check) Validate() error {
|
|
||||||
if s == nil {
|
|
||||||
return validate.ErrNilPointer
|
|
||||||
}
|
|
||||||
|
|
||||||
var failures []validate.FieldError
|
|
||||||
if err := func() error {
|
|
||||||
if err := (validate.String{
|
|
||||||
MinLength: 0,
|
|
||||||
MinLengthSet: false,
|
|
||||||
MaxLength: 128,
|
|
||||||
MaxLengthSet: true,
|
|
||||||
Email: false,
|
|
||||||
Hostname: false,
|
|
||||||
Regex: nil,
|
|
||||||
}).Validate(string(s.Name)); err != nil {
|
|
||||||
return errors.Wrap(err, "string")
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}(); err != nil {
|
|
||||||
failures = append(failures, validate.FieldError{
|
|
||||||
Name: "Name",
|
|
||||||
Error: err,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
if err := func() error {
|
|
||||||
if err := (validate.String{
|
|
||||||
MinLength: 0,
|
|
||||||
MinLengthSet: false,
|
|
||||||
MaxLength: 4096,
|
|
||||||
MaxLengthSet: true,
|
|
||||||
Email: false,
|
|
||||||
Hostname: false,
|
|
||||||
Regex: nil,
|
|
||||||
}).Validate(string(s.Summary)); err != nil {
|
|
||||||
return errors.Wrap(err, "string")
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}(); err != nil {
|
|
||||||
failures = append(failures, validate.FieldError{
|
|
||||||
Name: "Summary",
|
|
||||||
Error: err,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
if len(failures) > 0 {
|
|
||||||
return &validate.Error{Fields: failures}
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s CheckList) Validate() error {
|
|
||||||
alias := ([]Check)(s)
|
|
||||||
if alias == nil {
|
|
||||||
return errors.New("nil is invalid value")
|
|
||||||
}
|
|
||||||
var failures []validate.FieldError
|
|
||||||
for i, elem := range alias {
|
|
||||||
if err := func() error {
|
|
||||||
if err := elem.Validate(); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}(); err != nil {
|
|
||||||
failures = append(failures, validate.FieldError{
|
|
||||||
Name: fmt.Sprintf("[%d]", i),
|
|
||||||
Error: err,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if len(failures) > 0 {
|
|
||||||
return &validate.Error{Fields: failures}
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *Error) Validate() error {
|
|
||||||
if s == nil {
|
|
||||||
return validate.ErrNilPointer
|
|
||||||
}
|
|
||||||
|
|
||||||
var failures []validate.FieldError
|
|
||||||
if err := func() error {
|
|
||||||
if err := (validate.Int{
|
|
||||||
MinSet: true,
|
|
||||||
Min: 0,
|
|
||||||
MaxSet: false,
|
|
||||||
Max: 0,
|
|
||||||
MinExclusive: false,
|
|
||||||
MaxExclusive: false,
|
|
||||||
MultipleOfSet: false,
|
|
||||||
MultipleOf: 0,
|
|
||||||
}).Validate(int64(s.Code)); err != nil {
|
|
||||||
return errors.Wrap(err, "int")
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}(); err != nil {
|
|
||||||
failures = append(failures, validate.FieldError{
|
|
||||||
Name: "code",
|
|
||||||
Error: err,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
if len(failures) > 0 {
|
|
||||||
return &validate.Error{Fields: failures}
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *ErrorStatusCode) Validate() error {
|
|
||||||
if s == nil {
|
|
||||||
return validate.ErrNilPointer
|
|
||||||
}
|
|
||||||
|
|
||||||
var failures []validate.FieldError
|
|
||||||
if err := func() error {
|
|
||||||
if err := s.Response.Validate(); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}(); err != nil {
|
|
||||||
failures = append(failures, validate.FieldError{
|
|
||||||
Name: "Response",
|
|
||||||
Error: err,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
if len(failures) > 0 {
|
|
||||||
return &validate.Error{Fields: failures}
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *MapfixCreate) Validate() error {
|
func (s *MapfixCreate) Validate() error {
|
||||||
if s == nil {
|
if s == nil {
|
||||||
return validate.ErrNilPointer
|
return validate.ErrNilPointer
|
||||||
}
|
}
|
||||||
|
|
||||||
var failures []validate.FieldError
|
var failures []validate.FieldError
|
||||||
if err := func() error {
|
|
||||||
if err := (validate.Int{
|
|
||||||
MinSet: true,
|
|
||||||
Min: 0,
|
|
||||||
MaxSet: false,
|
|
||||||
Max: 0,
|
|
||||||
MinExclusive: false,
|
|
||||||
MaxExclusive: false,
|
|
||||||
MultipleOfSet: false,
|
|
||||||
MultipleOf: 0,
|
|
||||||
}).Validate(int64(s.OperationID)); err != nil {
|
|
||||||
return errors.Wrap(err, "int")
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}(); err != nil {
|
|
||||||
failures = append(failures, validate.FieldError{
|
|
||||||
Name: "OperationID",
|
|
||||||
Error: err,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
if err := func() error {
|
|
||||||
if err := (validate.Int{
|
|
||||||
MinSet: true,
|
|
||||||
Min: 0,
|
|
||||||
MaxSet: false,
|
|
||||||
Max: 0,
|
|
||||||
MinExclusive: false,
|
|
||||||
MaxExclusive: false,
|
|
||||||
MultipleOfSet: false,
|
|
||||||
MultipleOf: 0,
|
|
||||||
}).Validate(int64(s.AssetOwner)); err != nil {
|
|
||||||
return errors.Wrap(err, "int")
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}(); err != nil {
|
|
||||||
failures = append(failures, validate.FieldError{
|
|
||||||
Name: "AssetOwner",
|
|
||||||
Error: err,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
if err := func() error {
|
if err := func() error {
|
||||||
if err := (validate.String{
|
if err := (validate.String{
|
||||||
MinLength: 0,
|
MinLength: 0,
|
||||||
@@ -224,137 +52,6 @@ func (s *MapfixCreate) Validate() error {
|
|||||||
Error: err,
|
Error: err,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
if err := func() error {
|
|
||||||
if err := (validate.Int{
|
|
||||||
MinSet: true,
|
|
||||||
Min: 0,
|
|
||||||
MaxSet: false,
|
|
||||||
Max: 0,
|
|
||||||
MinExclusive: false,
|
|
||||||
MaxExclusive: false,
|
|
||||||
MultipleOfSet: false,
|
|
||||||
MultipleOf: 0,
|
|
||||||
}).Validate(int64(s.GameID)); err != nil {
|
|
||||||
return errors.Wrap(err, "int")
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}(); err != nil {
|
|
||||||
failures = append(failures, validate.FieldError{
|
|
||||||
Name: "GameID",
|
|
||||||
Error: err,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
if err := func() error {
|
|
||||||
if err := (validate.Int{
|
|
||||||
MinSet: true,
|
|
||||||
Min: 0,
|
|
||||||
MaxSet: false,
|
|
||||||
Max: 0,
|
|
||||||
MinExclusive: false,
|
|
||||||
MaxExclusive: false,
|
|
||||||
MultipleOfSet: false,
|
|
||||||
MultipleOf: 0,
|
|
||||||
}).Validate(int64(s.AssetID)); err != nil {
|
|
||||||
return errors.Wrap(err, "int")
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}(); err != nil {
|
|
||||||
failures = append(failures, validate.FieldError{
|
|
||||||
Name: "AssetID",
|
|
||||||
Error: err,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
if err := func() error {
|
|
||||||
if err := (validate.Int{
|
|
||||||
MinSet: true,
|
|
||||||
Min: 0,
|
|
||||||
MaxSet: false,
|
|
||||||
Max: 0,
|
|
||||||
MinExclusive: false,
|
|
||||||
MaxExclusive: false,
|
|
||||||
MultipleOfSet: false,
|
|
||||||
MultipleOf: 0,
|
|
||||||
}).Validate(int64(s.AssetVersion)); err != nil {
|
|
||||||
return errors.Wrap(err, "int")
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}(); err != nil {
|
|
||||||
failures = append(failures, validate.FieldError{
|
|
||||||
Name: "AssetVersion",
|
|
||||||
Error: err,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
if err := func() error {
|
|
||||||
if err := (validate.Int{
|
|
||||||
MinSet: true,
|
|
||||||
Min: 0,
|
|
||||||
MaxSet: false,
|
|
||||||
Max: 0,
|
|
||||||
MinExclusive: false,
|
|
||||||
MaxExclusive: false,
|
|
||||||
MultipleOfSet: false,
|
|
||||||
MultipleOf: 0,
|
|
||||||
}).Validate(int64(s.TargetAssetID)); err != nil {
|
|
||||||
return errors.Wrap(err, "int")
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}(); err != nil {
|
|
||||||
failures = append(failures, validate.FieldError{
|
|
||||||
Name: "TargetAssetID",
|
|
||||||
Error: err,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
if err := func() error {
|
|
||||||
if err := (validate.String{
|
|
||||||
MinLength: 0,
|
|
||||||
MinLengthSet: false,
|
|
||||||
MaxLength: 256,
|
|
||||||
MaxLengthSet: true,
|
|
||||||
Email: false,
|
|
||||||
Hostname: false,
|
|
||||||
Regex: nil,
|
|
||||||
}).Validate(string(s.Description)); err != nil {
|
|
||||||
return errors.Wrap(err, "string")
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}(); err != nil {
|
|
||||||
failures = append(failures, validate.FieldError{
|
|
||||||
Name: "Description",
|
|
||||||
Error: err,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
if len(failures) > 0 {
|
|
||||||
return &validate.Error{Fields: failures}
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *MapfixID) Validate() error {
|
|
||||||
if s == nil {
|
|
||||||
return validate.ErrNilPointer
|
|
||||||
}
|
|
||||||
|
|
||||||
var failures []validate.FieldError
|
|
||||||
if err := func() error {
|
|
||||||
if err := (validate.Int{
|
|
||||||
MinSet: true,
|
|
||||||
Min: 0,
|
|
||||||
MaxSet: false,
|
|
||||||
Max: 0,
|
|
||||||
MinExclusive: false,
|
|
||||||
MaxExclusive: false,
|
|
||||||
MultipleOfSet: false,
|
|
||||||
MultipleOf: 0,
|
|
||||||
}).Validate(int64(s.MapfixID)); err != nil {
|
|
||||||
return errors.Wrap(err, "int")
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}(); err != nil {
|
|
||||||
failures = append(failures, validate.FieldError{
|
|
||||||
Name: "MapfixID",
|
|
||||||
Error: err,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
if len(failures) > 0 {
|
if len(failures) > 0 {
|
||||||
return &validate.Error{Fields: failures}
|
return &validate.Error{Fields: failures}
|
||||||
}
|
}
|
||||||
@@ -367,26 +64,6 @@ func (s *Script) Validate() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var failures []validate.FieldError
|
var failures []validate.FieldError
|
||||||
if err := func() error {
|
|
||||||
if err := (validate.Int{
|
|
||||||
MinSet: true,
|
|
||||||
Min: 0,
|
|
||||||
MaxSet: false,
|
|
||||||
Max: 0,
|
|
||||||
MinExclusive: false,
|
|
||||||
MaxExclusive: false,
|
|
||||||
MultipleOfSet: false,
|
|
||||||
MultipleOf: 0,
|
|
||||||
}).Validate(int64(s.ID)); err != nil {
|
|
||||||
return errors.Wrap(err, "int")
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}(); err != nil {
|
|
||||||
failures = append(failures, validate.FieldError{
|
|
||||||
Name: "ID",
|
|
||||||
Error: err,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
if err := func() error {
|
if err := func() error {
|
||||||
if err := (validate.String{
|
if err := (validate.String{
|
||||||
MinLength: 0,
|
MinLength: 0,
|
||||||
@@ -444,46 +121,6 @@ func (s *Script) Validate() error {
|
|||||||
Error: err,
|
Error: err,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
if err := func() error {
|
|
||||||
if err := (validate.Int{
|
|
||||||
MinSet: true,
|
|
||||||
Min: 0,
|
|
||||||
MaxSet: false,
|
|
||||||
Max: 0,
|
|
||||||
MinExclusive: false,
|
|
||||||
MaxExclusive: false,
|
|
||||||
MultipleOfSet: false,
|
|
||||||
MultipleOf: 0,
|
|
||||||
}).Validate(int64(s.ResourceType)); err != nil {
|
|
||||||
return errors.Wrap(err, "int")
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}(); err != nil {
|
|
||||||
failures = append(failures, validate.FieldError{
|
|
||||||
Name: "ResourceType",
|
|
||||||
Error: err,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
if err := func() error {
|
|
||||||
if err := (validate.Int{
|
|
||||||
MinSet: true,
|
|
||||||
Min: 0,
|
|
||||||
MaxSet: false,
|
|
||||||
Max: 0,
|
|
||||||
MinExclusive: false,
|
|
||||||
MaxExclusive: false,
|
|
||||||
MultipleOfSet: false,
|
|
||||||
MultipleOf: 0,
|
|
||||||
}).Validate(int64(s.ResourceID)); err != nil {
|
|
||||||
return errors.Wrap(err, "int")
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}(); err != nil {
|
|
||||||
failures = append(failures, validate.FieldError{
|
|
||||||
Name: "ResourceID",
|
|
||||||
Error: err,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
if len(failures) > 0 {
|
if len(failures) > 0 {
|
||||||
return &validate.Error{Fields: failures}
|
return &validate.Error{Fields: failures}
|
||||||
}
|
}
|
||||||
@@ -534,85 +171,6 @@ func (s *ScriptCreate) Validate() error {
|
|||||||
Error: err,
|
Error: err,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
if err := func() error {
|
|
||||||
if err := (validate.Int{
|
|
||||||
MinSet: true,
|
|
||||||
Min: 0,
|
|
||||||
MaxSet: false,
|
|
||||||
Max: 0,
|
|
||||||
MinExclusive: false,
|
|
||||||
MaxExclusive: false,
|
|
||||||
MultipleOfSet: false,
|
|
||||||
MultipleOf: 0,
|
|
||||||
}).Validate(int64(s.ResourceType)); err != nil {
|
|
||||||
return errors.Wrap(err, "int")
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}(); err != nil {
|
|
||||||
failures = append(failures, validate.FieldError{
|
|
||||||
Name: "ResourceType",
|
|
||||||
Error: err,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
if err := func() error {
|
|
||||||
if value, ok := s.ResourceID.Get(); ok {
|
|
||||||
if err := func() error {
|
|
||||||
if err := (validate.Int{
|
|
||||||
MinSet: true,
|
|
||||||
Min: 0,
|
|
||||||
MaxSet: false,
|
|
||||||
Max: 0,
|
|
||||||
MinExclusive: false,
|
|
||||||
MaxExclusive: false,
|
|
||||||
MultipleOfSet: false,
|
|
||||||
MultipleOf: 0,
|
|
||||||
}).Validate(int64(value)); err != nil {
|
|
||||||
return errors.Wrap(err, "int")
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}(); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}(); err != nil {
|
|
||||||
failures = append(failures, validate.FieldError{
|
|
||||||
Name: "ResourceID",
|
|
||||||
Error: err,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
if len(failures) > 0 {
|
|
||||||
return &validate.Error{Fields: failures}
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *ScriptID) Validate() error {
|
|
||||||
if s == nil {
|
|
||||||
return validate.ErrNilPointer
|
|
||||||
}
|
|
||||||
|
|
||||||
var failures []validate.FieldError
|
|
||||||
if err := func() error {
|
|
||||||
if err := (validate.Int{
|
|
||||||
MinSet: true,
|
|
||||||
Min: 0,
|
|
||||||
MaxSet: false,
|
|
||||||
Max: 0,
|
|
||||||
MinExclusive: false,
|
|
||||||
MaxExclusive: false,
|
|
||||||
MultipleOfSet: false,
|
|
||||||
MultipleOf: 0,
|
|
||||||
}).Validate(int64(s.ScriptID)); err != nil {
|
|
||||||
return errors.Wrap(err, "int")
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}(); err != nil {
|
|
||||||
failures = append(failures, validate.FieldError{
|
|
||||||
Name: "ScriptID",
|
|
||||||
Error: err,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
if len(failures) > 0 {
|
if len(failures) > 0 {
|
||||||
return &validate.Error{Fields: failures}
|
return &validate.Error{Fields: failures}
|
||||||
}
|
}
|
||||||
@@ -625,26 +183,6 @@ func (s *ScriptPolicy) Validate() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var failures []validate.FieldError
|
var failures []validate.FieldError
|
||||||
if err := func() error {
|
|
||||||
if err := (validate.Int{
|
|
||||||
MinSet: true,
|
|
||||||
Min: 0,
|
|
||||||
MaxSet: false,
|
|
||||||
Max: 0,
|
|
||||||
MinExclusive: false,
|
|
||||||
MaxExclusive: false,
|
|
||||||
MultipleOfSet: false,
|
|
||||||
MultipleOf: 0,
|
|
||||||
}).Validate(int64(s.ID)); err != nil {
|
|
||||||
return errors.Wrap(err, "int")
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}(); err != nil {
|
|
||||||
failures = append(failures, validate.FieldError{
|
|
||||||
Name: "ID",
|
|
||||||
Error: err,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
if err := func() error {
|
if err := func() error {
|
||||||
if err := (validate.String{
|
if err := (validate.String{
|
||||||
MinLength: 16,
|
MinLength: 16,
|
||||||
@@ -664,150 +202,6 @@ func (s *ScriptPolicy) Validate() error {
|
|||||||
Error: err,
|
Error: err,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
if err := func() error {
|
|
||||||
if err := (validate.Int{
|
|
||||||
MinSet: true,
|
|
||||||
Min: 0,
|
|
||||||
MaxSet: false,
|
|
||||||
Max: 0,
|
|
||||||
MinExclusive: false,
|
|
||||||
MaxExclusive: false,
|
|
||||||
MultipleOfSet: false,
|
|
||||||
MultipleOf: 0,
|
|
||||||
}).Validate(int64(s.ToScriptID)); err != nil {
|
|
||||||
return errors.Wrap(err, "int")
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}(); err != nil {
|
|
||||||
failures = append(failures, validate.FieldError{
|
|
||||||
Name: "ToScriptID",
|
|
||||||
Error: err,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
if err := func() error {
|
|
||||||
if err := (validate.Int{
|
|
||||||
MinSet: true,
|
|
||||||
Min: 0,
|
|
||||||
MaxSet: false,
|
|
||||||
Max: 0,
|
|
||||||
MinExclusive: false,
|
|
||||||
MaxExclusive: false,
|
|
||||||
MultipleOfSet: false,
|
|
||||||
MultipleOf: 0,
|
|
||||||
}).Validate(int64(s.Policy)); err != nil {
|
|
||||||
return errors.Wrap(err, "int")
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}(); err != nil {
|
|
||||||
failures = append(failures, validate.FieldError{
|
|
||||||
Name: "Policy",
|
|
||||||
Error: err,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
if len(failures) > 0 {
|
|
||||||
return &validate.Error{Fields: failures}
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *ScriptPolicyCreate) Validate() error {
|
|
||||||
if s == nil {
|
|
||||||
return validate.ErrNilPointer
|
|
||||||
}
|
|
||||||
|
|
||||||
var failures []validate.FieldError
|
|
||||||
if err := func() error {
|
|
||||||
if err := (validate.Int{
|
|
||||||
MinSet: true,
|
|
||||||
Min: 0,
|
|
||||||
MaxSet: false,
|
|
||||||
Max: 0,
|
|
||||||
MinExclusive: false,
|
|
||||||
MaxExclusive: false,
|
|
||||||
MultipleOfSet: false,
|
|
||||||
MultipleOf: 0,
|
|
||||||
}).Validate(int64(s.FromScriptID)); err != nil {
|
|
||||||
return errors.Wrap(err, "int")
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}(); err != nil {
|
|
||||||
failures = append(failures, validate.FieldError{
|
|
||||||
Name: "FromScriptID",
|
|
||||||
Error: err,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
if err := func() error {
|
|
||||||
if err := (validate.Int{
|
|
||||||
MinSet: true,
|
|
||||||
Min: 0,
|
|
||||||
MaxSet: false,
|
|
||||||
Max: 0,
|
|
||||||
MinExclusive: false,
|
|
||||||
MaxExclusive: false,
|
|
||||||
MultipleOfSet: false,
|
|
||||||
MultipleOf: 0,
|
|
||||||
}).Validate(int64(s.ToScriptID)); err != nil {
|
|
||||||
return errors.Wrap(err, "int")
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}(); err != nil {
|
|
||||||
failures = append(failures, validate.FieldError{
|
|
||||||
Name: "ToScriptID",
|
|
||||||
Error: err,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
if err := func() error {
|
|
||||||
if err := (validate.Int{
|
|
||||||
MinSet: true,
|
|
||||||
Min: 0,
|
|
||||||
MaxSet: false,
|
|
||||||
Max: 0,
|
|
||||||
MinExclusive: false,
|
|
||||||
MaxExclusive: false,
|
|
||||||
MultipleOfSet: false,
|
|
||||||
MultipleOf: 0,
|
|
||||||
}).Validate(int64(s.Policy)); err != nil {
|
|
||||||
return errors.Wrap(err, "int")
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}(); err != nil {
|
|
||||||
failures = append(failures, validate.FieldError{
|
|
||||||
Name: "Policy",
|
|
||||||
Error: err,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
if len(failures) > 0 {
|
|
||||||
return &validate.Error{Fields: failures}
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *ScriptPolicyID) Validate() error {
|
|
||||||
if s == nil {
|
|
||||||
return validate.ErrNilPointer
|
|
||||||
}
|
|
||||||
|
|
||||||
var failures []validate.FieldError
|
|
||||||
if err := func() error {
|
|
||||||
if err := (validate.Int{
|
|
||||||
MinSet: true,
|
|
||||||
Min: 0,
|
|
||||||
MaxSet: false,
|
|
||||||
Max: 0,
|
|
||||||
MinExclusive: false,
|
|
||||||
MaxExclusive: false,
|
|
||||||
MultipleOfSet: false,
|
|
||||||
MultipleOf: 0,
|
|
||||||
}).Validate(int64(s.ScriptPolicyID)); err != nil {
|
|
||||||
return errors.Wrap(err, "int")
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}(); err != nil {
|
|
||||||
failures = append(failures, validate.FieldError{
|
|
||||||
Name: "ScriptPolicyID",
|
|
||||||
Error: err,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
if len(failures) > 0 {
|
if len(failures) > 0 {
|
||||||
return &validate.Error{Fields: failures}
|
return &validate.Error{Fields: failures}
|
||||||
}
|
}
|
||||||
@@ -820,46 +214,6 @@ func (s *SubmissionCreate) Validate() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var failures []validate.FieldError
|
var failures []validate.FieldError
|
||||||
if err := func() error {
|
|
||||||
if err := (validate.Int{
|
|
||||||
MinSet: true,
|
|
||||||
Min: 0,
|
|
||||||
MaxSet: false,
|
|
||||||
Max: 0,
|
|
||||||
MinExclusive: false,
|
|
||||||
MaxExclusive: false,
|
|
||||||
MultipleOfSet: false,
|
|
||||||
MultipleOf: 0,
|
|
||||||
}).Validate(int64(s.OperationID)); err != nil {
|
|
||||||
return errors.Wrap(err, "int")
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}(); err != nil {
|
|
||||||
failures = append(failures, validate.FieldError{
|
|
||||||
Name: "OperationID",
|
|
||||||
Error: err,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
if err := func() error {
|
|
||||||
if err := (validate.Int{
|
|
||||||
MinSet: true,
|
|
||||||
Min: 0,
|
|
||||||
MaxSet: false,
|
|
||||||
Max: 0,
|
|
||||||
MinExclusive: false,
|
|
||||||
MaxExclusive: false,
|
|
||||||
MultipleOfSet: false,
|
|
||||||
MultipleOf: 0,
|
|
||||||
}).Validate(int64(s.AssetOwner)); err != nil {
|
|
||||||
return errors.Wrap(err, "int")
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}(); err != nil {
|
|
||||||
failures = append(failures, validate.FieldError{
|
|
||||||
Name: "AssetOwner",
|
|
||||||
Error: err,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
if err := func() error {
|
if err := func() error {
|
||||||
if err := (validate.String{
|
if err := (validate.String{
|
||||||
MinLength: 0,
|
MinLength: 0,
|
||||||
@@ -898,118 +252,6 @@ func (s *SubmissionCreate) Validate() error {
|
|||||||
Error: err,
|
Error: err,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
if err := func() error {
|
|
||||||
if err := (validate.Int{
|
|
||||||
MinSet: true,
|
|
||||||
Min: 0,
|
|
||||||
MaxSet: false,
|
|
||||||
Max: 0,
|
|
||||||
MinExclusive: false,
|
|
||||||
MaxExclusive: false,
|
|
||||||
MultipleOfSet: false,
|
|
||||||
MultipleOf: 0,
|
|
||||||
}).Validate(int64(s.GameID)); err != nil {
|
|
||||||
return errors.Wrap(err, "int")
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}(); err != nil {
|
|
||||||
failures = append(failures, validate.FieldError{
|
|
||||||
Name: "GameID",
|
|
||||||
Error: err,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
if err := func() error {
|
|
||||||
if err := (validate.Int{
|
|
||||||
MinSet: true,
|
|
||||||
Min: 0,
|
|
||||||
MaxSet: false,
|
|
||||||
Max: 0,
|
|
||||||
MinExclusive: false,
|
|
||||||
MaxExclusive: false,
|
|
||||||
MultipleOfSet: false,
|
|
||||||
MultipleOf: 0,
|
|
||||||
}).Validate(int64(s.AssetID)); err != nil {
|
|
||||||
return errors.Wrap(err, "int")
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}(); err != nil {
|
|
||||||
failures = append(failures, validate.FieldError{
|
|
||||||
Name: "AssetID",
|
|
||||||
Error: err,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
if err := func() error {
|
|
||||||
if err := (validate.Int{
|
|
||||||
MinSet: true,
|
|
||||||
Min: 0,
|
|
||||||
MaxSet: false,
|
|
||||||
Max: 0,
|
|
||||||
MinExclusive: false,
|
|
||||||
MaxExclusive: false,
|
|
||||||
MultipleOfSet: false,
|
|
||||||
MultipleOf: 0,
|
|
||||||
}).Validate(int64(s.AssetVersion)); err != nil {
|
|
||||||
return errors.Wrap(err, "int")
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}(); err != nil {
|
|
||||||
failures = append(failures, validate.FieldError{
|
|
||||||
Name: "AssetVersion",
|
|
||||||
Error: err,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
if err := func() error {
|
|
||||||
if err := (validate.Int{
|
|
||||||
MinSet: true,
|
|
||||||
Min: 0,
|
|
||||||
MaxSet: true,
|
|
||||||
Max: 9,
|
|
||||||
MinExclusive: false,
|
|
||||||
MaxExclusive: false,
|
|
||||||
MultipleOfSet: false,
|
|
||||||
MultipleOf: 0,
|
|
||||||
}).Validate(int64(s.Status)); err != nil {
|
|
||||||
return errors.Wrap(err, "int")
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}(); err != nil {
|
|
||||||
failures = append(failures, validate.FieldError{
|
|
||||||
Name: "Status",
|
|
||||||
Error: err,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
if len(failures) > 0 {
|
|
||||||
return &validate.Error{Fields: failures}
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *SubmissionID) Validate() error {
|
|
||||||
if s == nil {
|
|
||||||
return validate.ErrNilPointer
|
|
||||||
}
|
|
||||||
|
|
||||||
var failures []validate.FieldError
|
|
||||||
if err := func() error {
|
|
||||||
if err := (validate.Int{
|
|
||||||
MinSet: true,
|
|
||||||
Min: 0,
|
|
||||||
MaxSet: false,
|
|
||||||
Max: 0,
|
|
||||||
MinExclusive: false,
|
|
||||||
MaxExclusive: false,
|
|
||||||
MultipleOfSet: false,
|
|
||||||
MultipleOf: 0,
|
|
||||||
}).Validate(int64(s.SubmissionID)); err != nil {
|
|
||||||
return errors.Wrap(err, "int")
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}(); err != nil {
|
|
||||||
failures = append(failures, validate.FieldError{
|
|
||||||
Name: "SubmissionID",
|
|
||||||
Error: err,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
if len(failures) > 0 {
|
if len(failures) > 0 {
|
||||||
return &validate.Error{Fields: failures}
|
return &validate.Error{Fields: failures}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,72 +0,0 @@
|
|||||||
package model
|
|
||||||
|
|
||||||
import (
|
|
||||||
"encoding/json"
|
|
||||||
"time"
|
|
||||||
)
|
|
||||||
|
|
||||||
type AuditEventType int32
|
|
||||||
|
|
||||||
// User clicked "Submit", "Accept" etc
|
|
||||||
const AuditEventTypeAction AuditEventType = 0
|
|
||||||
type AuditEventDataAction struct {
|
|
||||||
TargetStatus uint32 `json:"target_status"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// User wrote a comment
|
|
||||||
const AuditEventTypeComment AuditEventType = 1
|
|
||||||
type AuditEventDataComment struct {
|
|
||||||
Comment string `json:"comment"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// User changed Model
|
|
||||||
const AuditEventTypeChangeModel AuditEventType = 2
|
|
||||||
type AuditEventDataChangeModel struct {
|
|
||||||
OldModelID uint64 `json:"old_model_id"`
|
|
||||||
OldModelVersion uint64 `json:"old_model_version"`
|
|
||||||
NewModelID uint64 `json:"new_model_id"`
|
|
||||||
NewModelVersion uint64 `json:"new_model_version"`
|
|
||||||
}
|
|
||||||
// Validator validates model
|
|
||||||
const AuditEventTypeChangeValidatedModel AuditEventType = 3
|
|
||||||
type AuditEventDataChangeValidatedModel struct {
|
|
||||||
ValidatedModelID uint64 `json:"validated_model_id"`
|
|
||||||
ValidatedModelVersion uint64 `json:"validated_model_version"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// User changed DisplayName / Creator
|
|
||||||
const AuditEventTypeChangeDisplayName AuditEventType = 4
|
|
||||||
const AuditEventTypeChangeCreator AuditEventType = 5
|
|
||||||
type AuditEventDataChangeName struct {
|
|
||||||
OldName string `json:"old_name"`
|
|
||||||
NewName string `json:"new_name"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// Validator had an error
|
|
||||||
const AuditEventTypeError AuditEventType = 6
|
|
||||||
type AuditEventDataError struct {
|
|
||||||
Error string `json:"error"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type Check struct {
|
|
||||||
Name string `json:"name"`
|
|
||||||
Summary string `json:"summary"`
|
|
||||||
Passed bool `json:"passed"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// Validator map checks details
|
|
||||||
const AuditEventTypeCheckList AuditEventType = 7
|
|
||||||
|
|
||||||
type AuditEventDataCheckList struct {
|
|
||||||
CheckList []Check `json:"check_list"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type AuditEvent struct {
|
|
||||||
ID int64 `gorm:"primaryKey"`
|
|
||||||
CreatedAt time.Time
|
|
||||||
User uint64
|
|
||||||
ResourceType ResourceType // is this a submission or is it a mapfix
|
|
||||||
ResourceID int64 // submission / mapfix / map ID
|
|
||||||
EventType AuditEventType
|
|
||||||
EventData json.RawMessage `gorm:"type:jsonb"`
|
|
||||||
}
|
|
||||||
@@ -5,39 +5,36 @@ import "time"
|
|||||||
type MapfixStatus int32
|
type MapfixStatus int32
|
||||||
|
|
||||||
const (
|
const (
|
||||||
// Phase: Creation
|
// Phase: Final MapfixStatus
|
||||||
MapfixStatusUnderConstruction MapfixStatus = 0
|
MapfixStatusRejected MapfixStatus = 8
|
||||||
MapfixStatusChangesRequested MapfixStatus = 1
|
MapfixStatusUploaded MapfixStatus = 7 // uploaded to the group, final status for mapfixes
|
||||||
|
|
||||||
// Phase: Review
|
|
||||||
MapfixStatusSubmitting MapfixStatus = 2
|
|
||||||
MapfixStatusSubmitted MapfixStatus = 3
|
|
||||||
|
|
||||||
// Phase: Testing
|
// Phase: Testing
|
||||||
MapfixStatusAcceptedUnvalidated MapfixStatus = 4 // pending script review, can re-trigger validation
|
MapfixStatusUploading MapfixStatus = 6
|
||||||
MapfixStatusValidating MapfixStatus = 5
|
MapfixStatusValidated MapfixStatus = 5
|
||||||
MapfixStatusValidated MapfixStatus = 6
|
MapfixStatusValidating MapfixStatus = 4
|
||||||
MapfixStatusUploading MapfixStatus = 7
|
MapfixStatusAccepted MapfixStatus = 3 // pending script review, can re-trigger validation
|
||||||
|
|
||||||
// Phase: Final MapfixStatus
|
// Phase: Creation
|
||||||
MapfixStatusUploaded MapfixStatus = 8 // uploaded to the group, but pending release
|
MapfixStatusChangesRequested MapfixStatus = 2
|
||||||
MapfixStatusRejected MapfixStatus = 9
|
MapfixStatusSubmitted MapfixStatus = 1
|
||||||
|
MapfixStatusUnderConstruction MapfixStatus = 0
|
||||||
)
|
)
|
||||||
|
|
||||||
type Mapfix struct {
|
type Mapfix struct {
|
||||||
ID int64 `gorm:"primaryKey"`
|
ID int64 `gorm:"primaryKey"`
|
||||||
DisplayName string
|
DisplayName string
|
||||||
Creator string
|
Creator string
|
||||||
GameID uint32
|
GameID int32
|
||||||
CreatedAt time.Time
|
CreatedAt time.Time
|
||||||
UpdatedAt time.Time
|
UpdatedAt time.Time
|
||||||
Submitter uint64 // UserID
|
Submitter int64 // UserID
|
||||||
AssetID uint64
|
AssetID int64
|
||||||
AssetVersion uint64
|
AssetVersion int64
|
||||||
ValidatedAssetID uint64
|
ValidatedAssetID int64
|
||||||
ValidatedAssetVersion uint64
|
ValidatedAssetVersion int64
|
||||||
Completed bool // Has this version of the map been completed at least once on maptest
|
Completed bool // Has this version of the map been completed at least once on maptest
|
||||||
TargetAssetID uint64 // where to upload map fix. if the TargetAssetID is 0, it's a new map.
|
TargetAssetID int64 // where to upload map fix. if the TargetAssetID is 0, it's a new map.
|
||||||
StatusID MapfixStatus
|
StatusID MapfixStatus
|
||||||
Description string // mapfix description
|
StatusMessage string
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,61 +7,42 @@ package model
|
|||||||
|
|
||||||
type CreateSubmissionRequest struct {
|
type CreateSubmissionRequest struct {
|
||||||
// operation_id is passed back in the response message
|
// operation_id is passed back in the response message
|
||||||
OperationID int32
|
OperationID int32
|
||||||
ModelID uint64
|
ModelID int64
|
||||||
DisplayName string
|
|
||||||
Creator string
|
|
||||||
GameID uint32
|
|
||||||
Status uint32
|
|
||||||
Roles uint32
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type CreateMapfixRequest struct {
|
type CreateMapfixRequest struct {
|
||||||
OperationID int32
|
OperationID int32
|
||||||
ModelID uint64
|
ModelID int64
|
||||||
TargetAssetID uint64
|
TargetAssetID int64
|
||||||
Description string
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
type CheckSubmissionRequest struct{
|
|
||||||
SubmissionID int64
|
|
||||||
ModelID uint64
|
|
||||||
SkipChecks bool
|
|
||||||
}
|
|
||||||
|
|
||||||
type CheckMapfixRequest struct{
|
|
||||||
MapfixID int64
|
|
||||||
ModelID uint64
|
|
||||||
SkipChecks bool
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type ValidateSubmissionRequest struct {
|
type ValidateSubmissionRequest struct {
|
||||||
// submission_id is passed back in the response message
|
// submission_id is passed back in the response message
|
||||||
SubmissionID int64
|
SubmissionID int64
|
||||||
ModelID uint64
|
ModelID int64
|
||||||
ModelVersion uint64
|
ModelVersion int64
|
||||||
ValidatedModelID *uint64 // optional value
|
ValidatedModelID *int64 // optional value
|
||||||
}
|
}
|
||||||
|
|
||||||
type ValidateMapfixRequest struct {
|
type ValidateMapfixRequest struct {
|
||||||
MapfixID int64
|
MapfixID int64
|
||||||
ModelID uint64
|
ModelID int64
|
||||||
ModelVersion uint64
|
ModelVersion int64
|
||||||
ValidatedModelID *uint64 // optional value
|
ValidatedModelID *int64 // optional value
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create a new map
|
// Create a new map
|
||||||
type UploadSubmissionRequest struct {
|
type UploadSubmissionRequest struct {
|
||||||
SubmissionID int64
|
SubmissionID int64
|
||||||
ModelID uint64
|
ModelID int64
|
||||||
ModelVersion uint64
|
ModelVersion int64
|
||||||
ModelName string
|
ModelName string
|
||||||
}
|
}
|
||||||
|
|
||||||
type UploadMapfixRequest struct {
|
type UploadMapfixRequest struct {
|
||||||
MapfixID int64
|
MapfixID int64
|
||||||
ModelID uint64
|
ModelID int64
|
||||||
ModelVersion uint64
|
ModelVersion int64
|
||||||
TargetAssetID uint64
|
TargetAssetID int64
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ const (
|
|||||||
type Operation struct {
|
type Operation struct {
|
||||||
ID int32 `gorm:"primaryKey"`
|
ID int32 `gorm:"primaryKey"`
|
||||||
CreatedAt time.Time
|
CreatedAt time.Time
|
||||||
Owner uint64 // UserID
|
Owner int64 // UserID
|
||||||
StatusID OperationStatus
|
StatusID OperationStatus
|
||||||
StatusMessage string
|
StatusMessage string
|
||||||
Path string // redirect to view completed operation e.g. "/mapfixes/4"
|
Path string // redirect to view completed operation e.g. "/mapfixes/4"
|
||||||
|
|||||||
@@ -1,13 +0,0 @@
|
|||||||
package model
|
|
||||||
|
|
||||||
type ResourceType int32
|
|
||||||
const (
|
|
||||||
ResourceUnknown ResourceType = 0
|
|
||||||
ResourceMapfix ResourceType = 1
|
|
||||||
ResourceSubmission ResourceType = 2
|
|
||||||
)
|
|
||||||
|
|
||||||
type Resource struct{
|
|
||||||
ID int64
|
|
||||||
Type ResourceType
|
|
||||||
}
|
|
||||||
@@ -23,6 +23,13 @@ func HashParse(hash string) (uint64, error){
|
|||||||
return strconv.ParseUint(hash, 16, 64)
|
return strconv.ParseUint(hash, 16, 64)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type ResourceType int32
|
||||||
|
const (
|
||||||
|
ResourceUnknown ResourceType = 0
|
||||||
|
ResourceMapfix ResourceType = 1
|
||||||
|
ResourceSubmission ResourceType = 2
|
||||||
|
)
|
||||||
|
|
||||||
type Script struct {
|
type Script struct {
|
||||||
ID int64 `gorm:"primaryKey"`
|
ID int64 `gorm:"primaryKey"`
|
||||||
Name string
|
Name string
|
||||||
|
|||||||
@@ -5,39 +5,37 @@ import "time"
|
|||||||
type SubmissionStatus int32
|
type SubmissionStatus int32
|
||||||
|
|
||||||
const (
|
const (
|
||||||
// Phase: Creation
|
// Phase: Final SubmissionStatus
|
||||||
SubmissionStatusUnderConstruction SubmissionStatus = 0
|
SubmissionStatusReleased SubmissionStatus = 9
|
||||||
SubmissionStatusChangesRequested SubmissionStatus = 1
|
SubmissionStatusRejected SubmissionStatus = 8
|
||||||
|
|
||||||
// Phase: Review
|
|
||||||
SubmissionStatusSubmitting SubmissionStatus = 2
|
|
||||||
SubmissionStatusSubmitted SubmissionStatus = 3
|
|
||||||
|
|
||||||
// Phase: Testing
|
// Phase: Testing
|
||||||
SubmissionStatusAcceptedUnvalidated SubmissionStatus = 4 // pending script review, can re-trigger validation
|
SubmissionStatusUploaded SubmissionStatus = 7 // uploaded to the group, but pending release
|
||||||
SubmissionStatusValidating SubmissionStatus = 5
|
SubmissionStatusUploading SubmissionStatus = 6
|
||||||
SubmissionStatusValidated SubmissionStatus = 6
|
SubmissionStatusValidated SubmissionStatus = 5
|
||||||
SubmissionStatusUploading SubmissionStatus = 7
|
SubmissionStatusValidating SubmissionStatus = 4
|
||||||
SubmissionStatusUploaded SubmissionStatus = 8 // uploaded to the group, but pending release
|
SubmissionStatusAccepted SubmissionStatus = 3 // pending script review, can re-trigger validation
|
||||||
|
|
||||||
// Phase: Final SubmissionStatus
|
// Phase: Creation
|
||||||
SubmissionStatusRejected SubmissionStatus = 9
|
SubmissionStatusChangesRequested SubmissionStatus = 2
|
||||||
SubmissionStatusReleased SubmissionStatus = 10
|
SubmissionStatusSubmitted SubmissionStatus = 1
|
||||||
|
SubmissionStatusUnderConstruction SubmissionStatus = 0
|
||||||
)
|
)
|
||||||
|
|
||||||
type Submission struct {
|
type Submission struct {
|
||||||
ID int64 `gorm:"primaryKey"`
|
ID int64 `gorm:"primaryKey"`
|
||||||
DisplayName string
|
DisplayName string
|
||||||
Creator string
|
Creator string
|
||||||
GameID uint32
|
GameID int32
|
||||||
CreatedAt time.Time
|
CreatedAt time.Time
|
||||||
UpdatedAt time.Time
|
UpdatedAt time.Time
|
||||||
Submitter uint64 // UserID
|
Submitter int64 // UserID
|
||||||
AssetID uint64
|
AssetID int64
|
||||||
AssetVersion uint64
|
AssetVersion int64
|
||||||
ValidatedAssetID uint64
|
ValidatedAssetID int64
|
||||||
ValidatedAssetVersion uint64
|
ValidatedAssetVersion int64
|
||||||
Completed bool // Has this version of the map been completed at least once on maptest
|
Completed bool // Has this version of the map been completed at least once on maptest
|
||||||
UploadedAssetID uint64 // where to upload map fix. if the TargetAssetID is 0, it's a new map.
|
UploadedAssetID int64 // where to upload map fix. if the TargetAssetID is 0, it's a new map.
|
||||||
StatusID SubmissionStatus
|
StatusID SubmissionStatus
|
||||||
|
StatusMessage string
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,77 +0,0 @@
|
|||||||
package roblox
|
|
||||||
|
|
||||||
import (
|
|
||||||
"encoding/json"
|
|
||||||
"fmt"
|
|
||||||
"io"
|
|
||||||
"net/http"
|
|
||||||
"net/url"
|
|
||||||
)
|
|
||||||
|
|
||||||
type AssetMetadata struct {
|
|
||||||
MetadataType uint32 `json:"metadataType"`
|
|
||||||
Value string `json:"value"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// Struct equivalent to Rust's AssetLocationInfo
|
|
||||||
type AssetLocationInfo struct {
|
|
||||||
Location string `json:"location"`
|
|
||||||
RequestId string `json:"requestId"`
|
|
||||||
IsArchived bool `json:"isArchived"`
|
|
||||||
AssetTypeId uint32 `json:"assetTypeId"`
|
|
||||||
AssetMetadatas []AssetMetadata `json:"assetMetadatas"`
|
|
||||||
IsRecordable bool `json:"isRecordable"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// Input struct for getAssetLocation
|
|
||||||
type GetAssetLatestRequest struct {
|
|
||||||
AssetID uint64
|
|
||||||
}
|
|
||||||
|
|
||||||
// Custom error type if needed
|
|
||||||
type GetError string
|
|
||||||
|
|
||||||
func (e GetError) Error() string { return string(e) }
|
|
||||||
|
|
||||||
// Example client with a Get method
|
|
||||||
type Client struct {
|
|
||||||
HttpClient *http.Client
|
|
||||||
ApiKey string
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *Client) GetAssetLocation(config GetAssetLatestRequest) (*AssetLocationInfo, error) {
|
|
||||||
rawURL := fmt.Sprintf("https://apis.roblox.com/asset-delivery-api/v1/assetId/%d", config.AssetID)
|
|
||||||
parsedURL, err := url.Parse(rawURL)
|
|
||||||
if err != nil {
|
|
||||||
return nil, GetError("ParseError: " + err.Error())
|
|
||||||
}
|
|
||||||
|
|
||||||
req, err := http.NewRequest("GET", parsedURL.String(), nil)
|
|
||||||
if err != nil {
|
|
||||||
return nil, GetError("RequestCreationError: " + err.Error())
|
|
||||||
}
|
|
||||||
|
|
||||||
req.Header.Set("x-api-key", c.ApiKey)
|
|
||||||
|
|
||||||
resp, err := c.HttpClient.Do(req)
|
|
||||||
if err != nil {
|
|
||||||
return nil, GetError("ReqwestError: " + err.Error())
|
|
||||||
}
|
|
||||||
defer resp.Body.Close()
|
|
||||||
|
|
||||||
if resp.StatusCode != http.StatusOK {
|
|
||||||
return nil, GetError(fmt.Sprintf("ResponseError: status code %d", resp.StatusCode))
|
|
||||||
}
|
|
||||||
|
|
||||||
body, err := io.ReadAll(resp.Body)
|
|
||||||
if err != nil {
|
|
||||||
return nil, GetError("ReadBodyError: " + err.Error())
|
|
||||||
}
|
|
||||||
|
|
||||||
var info AssetLocationInfo
|
|
||||||
if err := json.Unmarshal(body, &info); err != nil {
|
|
||||||
return nil, GetError("JSONError: " + err.Error())
|
|
||||||
}
|
|
||||||
|
|
||||||
return &info, nil
|
|
||||||
}
|
|
||||||
@@ -1,132 +0,0 @@
|
|||||||
package service
|
|
||||||
|
|
||||||
import (
|
|
||||||
"context"
|
|
||||||
"encoding/json"
|
|
||||||
|
|
||||||
"git.itzana.me/strafesnet/go-grpc/users"
|
|
||||||
"git.itzana.me/strafesnet/maps-service/pkg/api"
|
|
||||||
"git.itzana.me/strafesnet/maps-service/pkg/datastore"
|
|
||||||
"git.itzana.me/strafesnet/maps-service/pkg/model"
|
|
||||||
)
|
|
||||||
|
|
||||||
func (svc *Service) ListAuditEvents(ctx context.Context, resource model.Resource, page model.Page) ([]api.AuditEvent, error){
|
|
||||||
filter := datastore.Optional()
|
|
||||||
|
|
||||||
filter.Add("resource_type", resource.Type)
|
|
||||||
filter.Add("resource_id", resource.ID)
|
|
||||||
|
|
||||||
items, err := svc.DB.AuditEvents().List(ctx, filter, page)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
idMap := make(map[int64]bool)
|
|
||||||
for _, item := range items {
|
|
||||||
idMap[int64(item.User)] = true
|
|
||||||
}
|
|
||||||
|
|
||||||
var idList users.IdList
|
|
||||||
idList.ID = make([]int64,len(idMap))
|
|
||||||
for userId := range idMap {
|
|
||||||
idList.ID = append(idList.ID, userId)
|
|
||||||
}
|
|
||||||
|
|
||||||
userList, err := svc.Users.GetList(ctx, &idList)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
userMap := make(map[int64]*users.UserResponse)
|
|
||||||
for _,user := range userList.Users {
|
|
||||||
userMap[user.ID] = user
|
|
||||||
}
|
|
||||||
|
|
||||||
var resp []api.AuditEvent
|
|
||||||
for _, item := range items {
|
|
||||||
EventData := api.AuditEventEventData{}
|
|
||||||
err = EventData.UnmarshalJSON(item.EventData)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
username := ""
|
|
||||||
if userMap[int64(item.User)] != nil {
|
|
||||||
username = userMap[int64(item.User)].Username
|
|
||||||
}
|
|
||||||
resp = append(resp, api.AuditEvent{
|
|
||||||
ID: item.ID,
|
|
||||||
Date: item.CreatedAt.Unix(),
|
|
||||||
User: int64(item.User),
|
|
||||||
Username: username,
|
|
||||||
ResourceType: int32(item.ResourceType),
|
|
||||||
ResourceID: item.ResourceID,
|
|
||||||
EventType: int32(item.EventType),
|
|
||||||
EventData: EventData,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
return resp, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (svc *Service) CreateAuditEventAction(ctx context.Context, userId uint64, resource model.Resource, event_data model.AuditEventDataAction) error {
|
|
||||||
EventData, err := json.Marshal(event_data)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
_, err = svc.DB.AuditEvents().Create(ctx, model.AuditEvent{
|
|
||||||
ID: 0,
|
|
||||||
User: userId,
|
|
||||||
ResourceType: resource.Type,
|
|
||||||
ResourceID: resource.ID,
|
|
||||||
EventType: model.AuditEventTypeAction,
|
|
||||||
EventData: EventData,
|
|
||||||
})
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (svc *Service) CreateAuditEventComment(ctx context.Context, userId uint64, resource model.Resource, event_data model.AuditEventDataComment) error {
|
|
||||||
EventData, err := json.Marshal(event_data)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
_, err = svc.DB.AuditEvents().Create(ctx, model.AuditEvent{
|
|
||||||
ID: 0,
|
|
||||||
User: userId,
|
|
||||||
ResourceType: resource.Type,
|
|
||||||
ResourceID: resource.ID,
|
|
||||||
EventType: model.AuditEventTypeComment,
|
|
||||||
EventData: EventData,
|
|
||||||
})
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (svc *Service) CreateAuditEventChangeModel(ctx context.Context, userId uint64, resource model.Resource, event_data model.AuditEventDataChangeModel) error {
|
|
||||||
EventData, err := json.Marshal(event_data)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
_, err = svc.DB.AuditEvents().Create(ctx, model.AuditEvent{
|
|
||||||
ID: 0,
|
|
||||||
User: userId,
|
|
||||||
ResourceType: resource.Type,
|
|
||||||
ResourceID: resource.ID,
|
|
||||||
EventType: model.AuditEventTypeChangeModel,
|
|
||||||
EventData: EventData,
|
|
||||||
})
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
@@ -5,7 +5,6 @@ import (
|
|||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"git.itzana.me/strafesnet/go-grpc/maps"
|
"git.itzana.me/strafesnet/go-grpc/maps"
|
||||||
@@ -26,29 +25,18 @@ var(
|
|||||||
model.MapfixStatusUploading,
|
model.MapfixStatusUploading,
|
||||||
model.MapfixStatusValidated,
|
model.MapfixStatusValidated,
|
||||||
model.MapfixStatusValidating,
|
model.MapfixStatusValidating,
|
||||||
model.MapfixStatusAcceptedUnvalidated,
|
model.MapfixStatusAccepted,
|
||||||
}
|
}
|
||||||
// Allow 5 mapfixes every 10 minutes
|
|
||||||
CreateMapfixRateLimit int64 = 5
|
|
||||||
CreateMapfixRecencyWindow = time.Second*600
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
ErrCreationPhaseMapfixesLimit = errors.New("Active mapfixes limited to 20")
|
ErrCreationPhaseMapfixesLimit = errors.New("Active mapfixes limited to 20")
|
||||||
ErrActiveMapfixSameTargetAssetID = errors.New("There is an active mapfix for this map already")
|
ErrActiveMapfixSameTargetAssetID = errors.New("There is an active mapfix with the same TargetAssetID")
|
||||||
ErrAcceptOwnMapfix = fmt.Errorf("%w: You cannot accept your own mapfix as the submitter", ErrPermissionDenied)
|
ErrAcceptOwnMapfix = fmt.Errorf("%w: You cannot accept your own mapfix as the submitter", ErrPermissionDenied)
|
||||||
ErrCreateMapfixRateLimit = errors.New("You must not create more than 5 mapfixes every 10 minutes")
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// POST /mapfixes
|
// POST /mapfixes
|
||||||
func (svc *Service) CreateMapfix(ctx context.Context, request *api.MapfixTriggerCreate) (*api.OperationID, error) {
|
func (svc *Service) CreateMapfix(ctx context.Context, request *api.MapfixTriggerCreate) (*api.OperationID, error) {
|
||||||
// sanitization
|
|
||||||
if request.AssetID<0 || request.TargetAssetID<0{
|
|
||||||
return nil, ErrNegativeID
|
|
||||||
}
|
|
||||||
var ModelID=uint64(request.AssetID);
|
|
||||||
var TargetAssetID=uint64(request.TargetAssetID);
|
|
||||||
|
|
||||||
userInfo, ok := ctx.Value("UserInfo").(UserInfoHandle)
|
userInfo, ok := ctx.Value("UserInfo").(UserInfoHandle)
|
||||||
if !ok {
|
if !ok {
|
||||||
return nil, ErrUserInfo
|
return nil, ErrUserInfo
|
||||||
@@ -77,27 +65,9 @@ func (svc *Service) CreateMapfix(ctx context.Context, request *api.MapfixTrigger
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if a mapfix targetting the same map exists in creation phase
|
|
||||||
{
|
|
||||||
filter := datastore.Optional()
|
|
||||||
filter.Add("submitter", int64(userId))
|
|
||||||
filter.Add("target_asset_id", request.TargetAssetID)
|
|
||||||
filter.Add("status_id", CreationPhaseMapfixStatuses)
|
|
||||||
active_mapfixes, err := svc.DB.Mapfixes().List(ctx, filter, model.Page{
|
|
||||||
Number: 1,
|
|
||||||
Size: 1,
|
|
||||||
},datastore.ListSortDisabled)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
if len(active_mapfixes) != 0{
|
|
||||||
return nil, ErrActiveMapfixSameTargetAssetID
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check if TargetAssetID actually exists
|
// Check if TargetAssetID actually exists
|
||||||
{
|
{
|
||||||
_, err := svc.Maps.Get(ctx, &maps.IdMessage{
|
_, err := svc.Client.Get(ctx, &maps.IdMessage{
|
||||||
ID: request.TargetAssetID,
|
ID: request.TargetAssetID,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -106,23 +76,8 @@ func (svc *Service) CreateMapfix(ctx context.Context, request *api.MapfixTrigger
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if too many operations have been created recently
|
|
||||||
{
|
|
||||||
count, err := svc.DB.Operations().CountSince(ctx,
|
|
||||||
int64(userId),
|
|
||||||
time.Now().Add(-CreateMapfixRecencyWindow),
|
|
||||||
)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
if CreateMapfixRateLimit < count {
|
|
||||||
return nil, ErrCreateMapfixRateLimit
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
operation, err := svc.DB.Operations().Create(ctx, model.Operation{
|
operation, err := svc.DB.Operations().Create(ctx, model.Operation{
|
||||||
Owner: userId,
|
Owner: int64(userId),
|
||||||
StatusID: model.OperationStatusCreated,
|
StatusID: model.OperationStatusCreated,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -131,9 +86,8 @@ func (svc *Service) CreateMapfix(ctx context.Context, request *api.MapfixTrigger
|
|||||||
|
|
||||||
create_request := model.CreateMapfixRequest{
|
create_request := model.CreateMapfixRequest{
|
||||||
OperationID: operation.ID,
|
OperationID: operation.ID,
|
||||||
ModelID: ModelID,
|
ModelID: request.AssetID,
|
||||||
TargetAssetID: TargetAssetID,
|
TargetAssetID: request.TargetAssetID,
|
||||||
Description: request.Description,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
j, err := json.Marshal(create_request)
|
j, err := json.Marshal(create_request)
|
||||||
@@ -141,10 +95,7 @@ func (svc *Service) CreateMapfix(ctx context.Context, request *api.MapfixTrigger
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err = svc.Nats.Publish("maptest.mapfixes.create", []byte(j))
|
svc.Nats.Publish("maptest.mapfixes.create", []byte(j))
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return &api.OperationID{
|
return &api.OperationID{
|
||||||
OperationID: operation.ID,
|
OperationID: operation.ID,
|
||||||
@@ -165,7 +116,7 @@ func (svc *Service) GetMapfix(ctx context.Context, params api.GetMapfixParams) (
|
|||||||
ID: mapfix.ID,
|
ID: mapfix.ID,
|
||||||
DisplayName: mapfix.DisplayName,
|
DisplayName: mapfix.DisplayName,
|
||||||
Creator: mapfix.Creator,
|
Creator: mapfix.Creator,
|
||||||
GameID: int32(mapfix.GameID),
|
GameID: mapfix.GameID,
|
||||||
CreatedAt: mapfix.CreatedAt.Unix(),
|
CreatedAt: mapfix.CreatedAt.Unix(),
|
||||||
UpdatedAt: mapfix.UpdatedAt.Unix(),
|
UpdatedAt: mapfix.UpdatedAt.Unix(),
|
||||||
Submitter: int64(mapfix.Submitter),
|
Submitter: int64(mapfix.Submitter),
|
||||||
@@ -174,7 +125,7 @@ func (svc *Service) GetMapfix(ctx context.Context, params api.GetMapfixParams) (
|
|||||||
Completed: mapfix.Completed,
|
Completed: mapfix.Completed,
|
||||||
TargetAssetID: int64(mapfix.TargetAssetID),
|
TargetAssetID: int64(mapfix.TargetAssetID),
|
||||||
StatusID: int32(mapfix.StatusID),
|
StatusID: int32(mapfix.StatusID),
|
||||||
Description: mapfix.Description,
|
StatusMessage: mapfix.StatusMessage,
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -183,7 +134,7 @@ func (svc *Service) GetMapfix(ctx context.Context, params api.GetMapfixParams) (
|
|||||||
// Get list of mapfixes.
|
// Get list of mapfixes.
|
||||||
//
|
//
|
||||||
// GET /mapfixes
|
// GET /mapfixes
|
||||||
func (svc *Service) ListMapfixes(ctx context.Context, params api.ListMapfixesParams) (*api.Mapfixes, error) {
|
func (svc *Service) ListMapfixes(ctx context.Context, params api.ListMapfixesParams) ([]api.Mapfix, error) {
|
||||||
filter := datastore.Optional()
|
filter := datastore.Optional()
|
||||||
|
|
||||||
if params.DisplayName.IsSet(){
|
if params.DisplayName.IsSet(){
|
||||||
@@ -195,22 +146,10 @@ func (svc *Service) ListMapfixes(ctx context.Context, params api.ListMapfixesPar
|
|||||||
if params.GameID.IsSet(){
|
if params.GameID.IsSet(){
|
||||||
filter.Add("game_id", params.GameID.Value)
|
filter.Add("game_id", params.GameID.Value)
|
||||||
}
|
}
|
||||||
if params.Submitter.IsSet(){
|
|
||||||
filter.Add("submitter", params.Submitter.Value)
|
|
||||||
}
|
|
||||||
if params.AssetID.IsSet(){
|
|
||||||
filter.Add("asset_id", params.AssetID.Value)
|
|
||||||
}
|
|
||||||
if params.TargetAssetID.IsSet(){
|
|
||||||
filter.Add("target_asset_id", params.TargetAssetID.Value)
|
|
||||||
}
|
|
||||||
if params.StatusID.IsSet(){
|
|
||||||
filter.Add("status_id", params.StatusID.Value)
|
|
||||||
}
|
|
||||||
|
|
||||||
sort := datastore.ListSort(params.Sort.Or(int32(datastore.ListSortDisabled)))
|
sort := datastore.ListSort(params.Sort.Or(int32(datastore.ListSortDisabled)))
|
||||||
|
|
||||||
total, items, err := svc.DB.Mapfixes().ListWithTotal(ctx, filter, model.Page{
|
items, err := svc.DB.Mapfixes().List(ctx, filter, model.Page{
|
||||||
Number: params.Page,
|
Number: params.Page,
|
||||||
Size: params.Limit,
|
Size: params.Limit,
|
||||||
},sort)
|
},sort)
|
||||||
@@ -218,14 +157,13 @@ func (svc *Service) ListMapfixes(ctx context.Context, params api.ListMapfixesPar
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
var resp api.Mapfixes
|
var resp []api.Mapfix
|
||||||
resp.Total=total
|
|
||||||
for _, item := range items {
|
for _, item := range items {
|
||||||
resp.Mapfixes = append(resp.Mapfixes, api.Mapfix{
|
resp = append(resp, api.Mapfix{
|
||||||
ID: item.ID,
|
ID: item.ID,
|
||||||
DisplayName: item.DisplayName,
|
DisplayName: item.DisplayName,
|
||||||
Creator: item.Creator,
|
Creator: item.Creator,
|
||||||
GameID: int32(item.GameID),
|
GameID: item.GameID,
|
||||||
CreatedAt: item.CreatedAt.Unix(),
|
CreatedAt: item.CreatedAt.Unix(),
|
||||||
UpdatedAt: item.UpdatedAt.Unix(),
|
UpdatedAt: item.UpdatedAt.Unix(),
|
||||||
Submitter: int64(item.Submitter),
|
Submitter: int64(item.Submitter),
|
||||||
@@ -234,11 +172,10 @@ func (svc *Service) ListMapfixes(ctx context.Context, params api.ListMapfixesPar
|
|||||||
Completed: item.Completed,
|
Completed: item.Completed,
|
||||||
TargetAssetID: int64(item.TargetAssetID),
|
TargetAssetID: int64(item.TargetAssetID),
|
||||||
StatusID: int32(item.StatusID),
|
StatusID: int32(item.StatusID),
|
||||||
Description: item.Description,
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
return &resp, nil
|
return resp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// PatchMapfixCompleted implements patchMapfixCompleted operation.
|
// PatchMapfixCompleted implements patchMapfixCompleted operation.
|
||||||
@@ -283,49 +220,22 @@ func (svc *Service) UpdateMapfixModel(ctx context.Context, params api.UpdateMapf
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
userId, err := userInfo.GetUserID()
|
has_role, err := userInfo.IsSubmitter(uint64(mapfix.Submitter))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// check if caller is the submitter
|
// check if caller is the submitter
|
||||||
has_role := userId == mapfix.Submitter
|
|
||||||
if !has_role {
|
if !has_role {
|
||||||
return ErrPermissionDeniedNotSubmitter
|
return ErrPermissionDeniedNotSubmitter
|
||||||
}
|
}
|
||||||
|
|
||||||
OldModelID := mapfix.AssetID
|
|
||||||
OldModelVersion := mapfix.AssetVersion
|
|
||||||
NewModelID := uint64(params.ModelID)
|
|
||||||
NewModelVersion := uint64(params.ModelVersion)
|
|
||||||
|
|
||||||
// check if Status is ChangesRequested|Submitted|UnderConstruction
|
// check if Status is ChangesRequested|Submitted|UnderConstruction
|
||||||
pmap := datastore.Optional()
|
pmap := datastore.Optional()
|
||||||
pmap.Add("asset_id", NewModelID)
|
pmap.AddNotNil("asset_id", params.ModelID)
|
||||||
pmap.Add("asset_version", NewModelVersion)
|
pmap.AddNotNil("asset_version", params.VersionID)
|
||||||
//always reset completed when model changes
|
//always reset completed when model changes
|
||||||
pmap.Add("completed", false)
|
pmap.Add("completed", false)
|
||||||
err = svc.DB.Mapfixes().IfStatusThenUpdate(ctx, params.MapfixID, []model.MapfixStatus{model.MapfixStatusChangesRequested, model.MapfixStatusSubmitted, model.MapfixStatusUnderConstruction}, pmap)
|
return svc.DB.Mapfixes().IfStatusThenUpdate(ctx, params.MapfixID, []model.MapfixStatus{model.MapfixStatusChangesRequested, model.MapfixStatusSubmitted, model.MapfixStatusUnderConstruction}, pmap)
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
event_data := model.AuditEventDataChangeModel{
|
|
||||||
OldModelID: OldModelID,
|
|
||||||
OldModelVersion: OldModelVersion,
|
|
||||||
NewModelID: NewModelID,
|
|
||||||
NewModelVersion: NewModelVersion,
|
|
||||||
}
|
|
||||||
|
|
||||||
return svc.CreateAuditEventChangeModel(
|
|
||||||
ctx,
|
|
||||||
userId,
|
|
||||||
model.Resource{
|
|
||||||
ID: params.MapfixID,
|
|
||||||
Type: model.ResourceMapfix,
|
|
||||||
},
|
|
||||||
event_data,
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ActionMapfixReject invokes actionMapfixReject operation.
|
// ActionMapfixReject invokes actionMapfixReject operation.
|
||||||
@@ -345,36 +255,13 @@ func (svc *Service) ActionMapfixReject(ctx context.Context, params api.ActionMap
|
|||||||
}
|
}
|
||||||
// check if caller has required role
|
// check if caller has required role
|
||||||
if !has_role {
|
if !has_role {
|
||||||
return ErrPermissionDeniedNeedRoleMapfixReview
|
return ErrPermissionDeniedNeedRoleMapReview
|
||||||
}
|
|
||||||
|
|
||||||
userId, err := userInfo.GetUserID()
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// transaction
|
// transaction
|
||||||
target_status := model.MapfixStatusRejected
|
|
||||||
smap := datastore.Optional()
|
smap := datastore.Optional()
|
||||||
smap.Add("status_id", target_status)
|
smap.Add("status_id", model.MapfixStatusRejected)
|
||||||
err = svc.DB.Mapfixes().IfStatusThenUpdate(ctx, params.MapfixID, []model.MapfixStatus{model.MapfixStatusSubmitted}, smap)
|
return svc.DB.Mapfixes().IfStatusThenUpdate(ctx, params.MapfixID, []model.MapfixStatus{model.MapfixStatusSubmitted}, smap)
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
event_data := model.AuditEventDataAction{
|
|
||||||
TargetStatus: uint32(target_status),
|
|
||||||
}
|
|
||||||
|
|
||||||
return svc.CreateAuditEventAction(
|
|
||||||
ctx,
|
|
||||||
userId,
|
|
||||||
model.Resource{
|
|
||||||
ID: params.MapfixID,
|
|
||||||
Type: model.ResourceMapfix,
|
|
||||||
},
|
|
||||||
event_data,
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ActionMapfixRequestChanges invokes actionMapfixRequestChanges operation.
|
// ActionMapfixRequestChanges invokes actionMapfixRequestChanges operation.
|
||||||
@@ -394,36 +281,13 @@ func (svc *Service) ActionMapfixRequestChanges(ctx context.Context, params api.A
|
|||||||
}
|
}
|
||||||
// check if caller has required role
|
// check if caller has required role
|
||||||
if !has_role {
|
if !has_role {
|
||||||
return ErrPermissionDeniedNeedRoleMapfixReview
|
return ErrPermissionDeniedNeedRoleMapReview
|
||||||
}
|
|
||||||
|
|
||||||
userId, err := userInfo.GetUserID()
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// transaction
|
// transaction
|
||||||
target_status := model.MapfixStatusChangesRequested
|
|
||||||
smap := datastore.Optional()
|
smap := datastore.Optional()
|
||||||
smap.Add("status_id", target_status)
|
smap.Add("status_id", model.MapfixStatusChangesRequested)
|
||||||
err = svc.DB.Mapfixes().IfStatusThenUpdate(ctx, params.MapfixID, []model.MapfixStatus{model.MapfixStatusValidated, model.MapfixStatusAcceptedUnvalidated, model.MapfixStatusSubmitted}, smap)
|
return svc.DB.Mapfixes().IfStatusThenUpdate(ctx, params.MapfixID, []model.MapfixStatus{model.MapfixStatusValidated, model.MapfixStatusAccepted, model.MapfixStatusSubmitted}, smap)
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
event_data := model.AuditEventDataAction{
|
|
||||||
TargetStatus: uint32(target_status),
|
|
||||||
}
|
|
||||||
|
|
||||||
return svc.CreateAuditEventAction(
|
|
||||||
ctx,
|
|
||||||
userId,
|
|
||||||
model.Resource{
|
|
||||||
ID: params.MapfixID,
|
|
||||||
Type: model.ResourceMapfix,
|
|
||||||
},
|
|
||||||
event_data,
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ActionMapfixRevoke invokes actionMapfixRevoke operation.
|
// ActionMapfixRevoke invokes actionMapfixRevoke operation.
|
||||||
@@ -443,47 +307,27 @@ func (svc *Service) ActionMapfixRevoke(ctx context.Context, params api.ActionMap
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
userId, err := userInfo.GetUserID()
|
has_role, err := userInfo.IsSubmitter(uint64(mapfix.Submitter))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// check if caller is the submitter
|
// check if caller is the submitter
|
||||||
has_role := userId == mapfix.Submitter
|
|
||||||
if !has_role {
|
if !has_role {
|
||||||
return ErrPermissionDeniedNotSubmitter
|
return ErrPermissionDeniedNotSubmitter
|
||||||
}
|
}
|
||||||
|
|
||||||
// transaction
|
// transaction
|
||||||
target_status := model.MapfixStatusUnderConstruction
|
|
||||||
smap := datastore.Optional()
|
smap := datastore.Optional()
|
||||||
smap.Add("status_id", target_status)
|
smap.Add("status_id", model.MapfixStatusUnderConstruction)
|
||||||
err = svc.DB.Mapfixes().IfStatusThenUpdate(ctx, params.MapfixID, []model.MapfixStatus{model.MapfixStatusSubmitted, model.MapfixStatusChangesRequested}, smap)
|
return svc.DB.Mapfixes().IfStatusThenUpdate(ctx, params.MapfixID, []model.MapfixStatus{model.MapfixStatusSubmitted, model.MapfixStatusChangesRequested}, smap)
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
event_data := model.AuditEventDataAction{
|
|
||||||
TargetStatus: uint32(target_status),
|
|
||||||
}
|
|
||||||
|
|
||||||
return svc.CreateAuditEventAction(
|
|
||||||
ctx,
|
|
||||||
userId,
|
|
||||||
model.Resource{
|
|
||||||
ID: params.MapfixID,
|
|
||||||
Type: model.ResourceMapfix,
|
|
||||||
},
|
|
||||||
event_data,
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ActionMapfixTriggerSubmit invokes actionMapfixTriggerSubmit operation.
|
// ActionMapfixSubmit invokes actionMapfixSubmit operation.
|
||||||
//
|
//
|
||||||
// Role Submitter changes status from UnderConstruction|ChangesRequested -> Submitting.
|
// Role Submitter changes status from UnderConstruction|ChangesRequested -> Submitted.
|
||||||
//
|
//
|
||||||
// POST /mapfixes/{MapfixID}/status/trigger-submit
|
// POST /mapfixes/{MapfixID}/status/submit
|
||||||
func (svc *Service) ActionMapfixTriggerSubmit(ctx context.Context, params api.ActionMapfixTriggerSubmitParams) error {
|
func (svc *Service) ActionMapfixSubmit(ctx context.Context, params api.ActionMapfixSubmitParams) error {
|
||||||
userInfo, ok := ctx.Value("UserInfo").(UserInfoHandle)
|
userInfo, ok := ctx.Value("UserInfo").(UserInfoHandle)
|
||||||
if !ok {
|
if !ok {
|
||||||
return ErrUserInfo
|
return ErrUserInfo
|
||||||
@@ -495,188 +339,19 @@ func (svc *Service) ActionMapfixTriggerSubmit(ctx context.Context, params api.Ac
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
userId, err := userInfo.GetUserID()
|
has_role, err := userInfo.IsSubmitter(uint64(mapfix.Submitter))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// check if caller is the submitter
|
// check if caller is the submitter
|
||||||
has_role := userId == mapfix.Submitter
|
|
||||||
if !has_role {
|
if !has_role {
|
||||||
return ErrPermissionDeniedNotSubmitter
|
return ErrPermissionDeniedNotSubmitter
|
||||||
}
|
}
|
||||||
|
|
||||||
// transaction
|
// transaction
|
||||||
target_status := model.MapfixStatusSubmitting
|
|
||||||
smap := datastore.Optional()
|
smap := datastore.Optional()
|
||||||
smap.Add("status_id", target_status)
|
smap.Add("status_id", model.MapfixStatusSubmitted)
|
||||||
err = svc.DB.Mapfixes().IfStatusThenUpdate(ctx, params.MapfixID, []model.MapfixStatus{model.MapfixStatusUnderConstruction, model.MapfixStatusChangesRequested}, smap)
|
return svc.DB.Mapfixes().IfStatusThenUpdate(ctx, params.MapfixID, []model.MapfixStatus{model.MapfixStatusUnderConstruction, model.MapfixStatusChangesRequested}, smap)
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
validate_request := model.CheckMapfixRequest{
|
|
||||||
MapfixID: mapfix.ID,
|
|
||||||
ModelID: mapfix.AssetID,
|
|
||||||
SkipChecks: false,
|
|
||||||
}
|
|
||||||
|
|
||||||
j, err := json.Marshal(validate_request)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
_, err = svc.Nats.Publish("maptest.mapfixes.check", []byte(j))
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
event_data := model.AuditEventDataAction{
|
|
||||||
TargetStatus: uint32(target_status),
|
|
||||||
}
|
|
||||||
|
|
||||||
return svc.CreateAuditEventAction(
|
|
||||||
ctx,
|
|
||||||
userId,
|
|
||||||
model.Resource{
|
|
||||||
ID: params.MapfixID,
|
|
||||||
Type: model.ResourceMapfix,
|
|
||||||
},
|
|
||||||
event_data,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
// ActionMapfixTriggerSubmitUnchecked invokes actionMapfixTriggerSubmitUnchecked operation.
|
|
||||||
//
|
|
||||||
// Role Reviewer changes status from ChangesRequested -> Submitting.
|
|
||||||
//
|
|
||||||
// POST /mapfixes/{MapfixID}/status/trigger-submit-unchecked
|
|
||||||
func (svc *Service) ActionMapfixTriggerSubmitUnchecked(ctx context.Context, params api.ActionMapfixTriggerSubmitUncheckedParams) error {
|
|
||||||
userInfo, ok := ctx.Value("UserInfo").(UserInfoHandle)
|
|
||||||
if !ok {
|
|
||||||
return ErrUserInfo
|
|
||||||
}
|
|
||||||
|
|
||||||
// read mapfix (this could be done with a transaction WHERE clause)
|
|
||||||
mapfix, err := svc.DB.Mapfixes().Get(ctx, params.MapfixID)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
userId, err := userInfo.GetUserID()
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
// check if caller is the submitter
|
|
||||||
is_submitter := userId == mapfix.Submitter
|
|
||||||
if is_submitter {
|
|
||||||
return ErrAcceptOwnMapfix
|
|
||||||
}
|
|
||||||
|
|
||||||
has_mapfix_review, err := userInfo.HasRoleMapfixReview()
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
if !has_mapfix_review {
|
|
||||||
return ErrPermissionDeniedNeedRoleMapfixReview
|
|
||||||
}
|
|
||||||
|
|
||||||
// transaction
|
|
||||||
target_status := model.MapfixStatusSubmitting
|
|
||||||
smap := datastore.Optional()
|
|
||||||
smap.Add("status_id", target_status)
|
|
||||||
err = svc.DB.Mapfixes().IfStatusThenUpdate(ctx, params.MapfixID, []model.MapfixStatus{model.MapfixStatusChangesRequested}, smap)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
validate_request := model.CheckMapfixRequest{
|
|
||||||
MapfixID: mapfix.ID,
|
|
||||||
ModelID: mapfix.AssetID,
|
|
||||||
SkipChecks: true,
|
|
||||||
}
|
|
||||||
|
|
||||||
j, err := json.Marshal(validate_request)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
_, err = svc.Nats.Publish("maptest.mapfixes.check", []byte(j))
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
event_data := model.AuditEventDataAction{
|
|
||||||
TargetStatus: uint32(target_status),
|
|
||||||
}
|
|
||||||
|
|
||||||
return svc.CreateAuditEventAction(
|
|
||||||
ctx,
|
|
||||||
userId,
|
|
||||||
model.Resource{
|
|
||||||
ID: params.MapfixID,
|
|
||||||
Type: model.ResourceMapfix,
|
|
||||||
},
|
|
||||||
event_data,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
// ActionMapfixResetSubmitting implements actionMapfixResetSubmitting operation.
|
|
||||||
//
|
|
||||||
// Role MapfixReview changes status from Submitting -> UnderConstruction.
|
|
||||||
//
|
|
||||||
// POST /mapfixes/{MapfixID}/status/reset-submitting
|
|
||||||
func (svc *Service) ActionMapfixResetSubmitting(ctx context.Context, params api.ActionMapfixResetSubmittingParams) error {
|
|
||||||
userInfo, ok := ctx.Value("UserInfo").(UserInfoHandle)
|
|
||||||
if !ok {
|
|
||||||
return ErrUserInfo
|
|
||||||
}
|
|
||||||
|
|
||||||
userId, err := userInfo.GetUserID()
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
// check when mapfix was updated
|
|
||||||
mapfix, err := svc.DB.Mapfixes().Get(ctx, params.MapfixID)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
if time.Now().Before(mapfix.UpdatedAt.Add(time.Second*10)) {
|
|
||||||
// the last time the mapfix was updated must be longer than 10 seconds ago
|
|
||||||
return ErrDelayReset
|
|
||||||
}
|
|
||||||
|
|
||||||
// check if caller has required role
|
|
||||||
has_role := userId == mapfix.Submitter
|
|
||||||
if !has_role {
|
|
||||||
return ErrPermissionDeniedNotSubmitter
|
|
||||||
}
|
|
||||||
|
|
||||||
// transaction
|
|
||||||
target_status := model.MapfixStatusUnderConstruction
|
|
||||||
smap := datastore.Optional()
|
|
||||||
smap.Add("status_id", target_status)
|
|
||||||
err = svc.DB.Mapfixes().IfStatusThenUpdate(ctx, params.MapfixID, []model.MapfixStatus{model.MapfixStatusSubmitting}, smap)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
event_data := model.AuditEventDataAction{
|
|
||||||
TargetStatus: uint32(target_status),
|
|
||||||
}
|
|
||||||
|
|
||||||
return svc.CreateAuditEventAction(
|
|
||||||
ctx,
|
|
||||||
userId,
|
|
||||||
model.Resource{
|
|
||||||
ID: params.MapfixID,
|
|
||||||
Type: model.ResourceMapfix,
|
|
||||||
},
|
|
||||||
event_data,
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ActionMapfixTriggerUpload invokes actionMapfixTriggerUpload operation.
|
// ActionMapfixTriggerUpload invokes actionMapfixTriggerUpload operation.
|
||||||
@@ -696,18 +371,12 @@ func (svc *Service) ActionMapfixTriggerUpload(ctx context.Context, params api.Ac
|
|||||||
}
|
}
|
||||||
// check if caller has required role
|
// check if caller has required role
|
||||||
if !has_role {
|
if !has_role {
|
||||||
return ErrPermissionDeniedNeedRoleMapfixUpload
|
return ErrPermissionDeniedNeedRoleMapUpload
|
||||||
}
|
|
||||||
|
|
||||||
userId, err := userInfo.GetUserID()
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// transaction
|
// transaction
|
||||||
target_status := model.MapfixStatusUploading
|
|
||||||
smap := datastore.Optional()
|
smap := datastore.Optional()
|
||||||
smap.Add("status_id", target_status)
|
smap.Add("status_id", model.MapfixStatusUploading)
|
||||||
mapfix, err := svc.DB.Mapfixes().IfStatusThenUpdateAndGet(ctx, params.MapfixID, []model.MapfixStatus{model.MapfixStatusValidated}, smap)
|
mapfix, err := svc.DB.Mapfixes().IfStatusThenUpdateAndGet(ctx, params.MapfixID, []model.MapfixStatus{model.MapfixStatusValidated}, smap)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@@ -726,24 +395,9 @@ func (svc *Service) ActionMapfixTriggerUpload(ctx context.Context, params api.Ac
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err = svc.Nats.Publish("maptest.mapfixes.upload", []byte(j))
|
svc.Nats.Publish("maptest.mapfixes.uploadfix", []byte(j))
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
event_data := model.AuditEventDataAction{
|
return nil
|
||||||
TargetStatus: uint32(target_status),
|
|
||||||
}
|
|
||||||
|
|
||||||
return svc.CreateAuditEventAction(
|
|
||||||
ctx,
|
|
||||||
userId,
|
|
||||||
model.Resource{
|
|
||||||
ID: params.MapfixID,
|
|
||||||
Type: model.ResourceMapfix,
|
|
||||||
},
|
|
||||||
event_data,
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ActionMapfixValidate invokes actionMapfixValidate operation.
|
// ActionMapfixValidate invokes actionMapfixValidate operation.
|
||||||
@@ -763,12 +417,7 @@ func (svc *Service) ActionMapfixValidated(ctx context.Context, params api.Action
|
|||||||
}
|
}
|
||||||
// check if caller has required role
|
// check if caller has required role
|
||||||
if !has_role {
|
if !has_role {
|
||||||
return ErrPermissionDeniedNeedRoleMapfixUpload
|
return ErrPermissionDeniedNeedRoleMapUpload
|
||||||
}
|
|
||||||
|
|
||||||
userId, err := userInfo.GetUserID()
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// check when mapfix was updated
|
// check when mapfix was updated
|
||||||
@@ -782,27 +431,9 @@ func (svc *Service) ActionMapfixValidated(ctx context.Context, params api.Action
|
|||||||
}
|
}
|
||||||
|
|
||||||
// transaction
|
// transaction
|
||||||
target_status := model.MapfixStatusValidated
|
|
||||||
smap := datastore.Optional()
|
smap := datastore.Optional()
|
||||||
smap.Add("status_id", target_status)
|
smap.Add("status_id", model.MapfixStatusValidated)
|
||||||
err = svc.DB.Mapfixes().IfStatusThenUpdate(ctx, params.MapfixID, []model.MapfixStatus{model.MapfixStatusUploading}, smap)
|
return svc.DB.Mapfixes().IfStatusThenUpdate(ctx, params.MapfixID, []model.MapfixStatus{model.MapfixStatusUploading}, smap)
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
event_data := model.AuditEventDataAction{
|
|
||||||
TargetStatus: uint32(target_status),
|
|
||||||
}
|
|
||||||
|
|
||||||
return svc.CreateAuditEventAction(
|
|
||||||
ctx,
|
|
||||||
userId,
|
|
||||||
model.Resource{
|
|
||||||
ID: params.MapfixID,
|
|
||||||
Type: model.ResourceMapfix,
|
|
||||||
},
|
|
||||||
event_data,
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ActionMapfixTriggerValidate invokes actionMapfixTriggerValidate operation.
|
// ActionMapfixTriggerValidate invokes actionMapfixTriggerValidate operation.
|
||||||
@@ -822,7 +453,7 @@ func (svc *Service) ActionMapfixTriggerValidate(ctx context.Context, params api.
|
|||||||
}
|
}
|
||||||
// check if caller has required role
|
// check if caller has required role
|
||||||
if !has_role {
|
if !has_role {
|
||||||
return ErrPermissionDeniedNeedRoleMapfixReview
|
return ErrPermissionDeniedNeedRoleMapReview
|
||||||
}
|
}
|
||||||
|
|
||||||
// read mapfix (this could be done with a transaction WHERE clause)
|
// read mapfix (this could be done with a transaction WHERE clause)
|
||||||
@@ -831,13 +462,11 @@ func (svc *Service) ActionMapfixTriggerValidate(ctx context.Context, params api.
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
userId, err := userInfo.GetUserID()
|
has_role, err = userInfo.IsSubmitter(uint64(mapfix.Submitter))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// check if caller is NOT the submitter
|
// check if caller is NOT the submitter
|
||||||
has_role = userId == mapfix.Submitter
|
|
||||||
if has_role {
|
if has_role {
|
||||||
return ErrAcceptOwnMapfix
|
return ErrAcceptOwnMapfix
|
||||||
}
|
}
|
||||||
@@ -860,9 +489,8 @@ func (svc *Service) ActionMapfixTriggerValidate(ctx context.Context, params api.
|
|||||||
}
|
}
|
||||||
|
|
||||||
// transaction
|
// transaction
|
||||||
target_status := model.MapfixStatusValidating
|
|
||||||
smap := datastore.Optional()
|
smap := datastore.Optional()
|
||||||
smap.Add("status_id", target_status)
|
smap.Add("status_id", model.MapfixStatusValidating)
|
||||||
mapfix, err = svc.DB.Mapfixes().IfStatusThenUpdateAndGet(ctx, params.MapfixID, []model.MapfixStatus{model.MapfixStatusSubmitted}, smap)
|
mapfix, err = svc.DB.Mapfixes().IfStatusThenUpdateAndGet(ctx, params.MapfixID, []model.MapfixStatus{model.MapfixStatusSubmitted}, smap)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@@ -885,24 +513,9 @@ func (svc *Service) ActionMapfixTriggerValidate(ctx context.Context, params api.
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err = svc.Nats.Publish("maptest.mapfixes.validate", []byte(j))
|
svc.Nats.Publish("maptest.mapfixes.validate", []byte(j))
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
event_data := model.AuditEventDataAction{
|
return nil
|
||||||
TargetStatus: uint32(target_status),
|
|
||||||
}
|
|
||||||
|
|
||||||
return svc.CreateAuditEventAction(
|
|
||||||
ctx,
|
|
||||||
userId,
|
|
||||||
model.Resource{
|
|
||||||
ID: params.MapfixID,
|
|
||||||
Type: model.ResourceMapfix,
|
|
||||||
},
|
|
||||||
event_data,
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ActionMapfixRetryValidate invokes actionMapfixRetryValidate operation.
|
// ActionMapfixRetryValidate invokes actionMapfixRetryValidate operation.
|
||||||
@@ -922,19 +535,13 @@ func (svc *Service) ActionMapfixRetryValidate(ctx context.Context, params api.Ac
|
|||||||
}
|
}
|
||||||
// check if caller has required role
|
// check if caller has required role
|
||||||
if !has_role {
|
if !has_role {
|
||||||
return ErrPermissionDeniedNeedRoleMapfixReview
|
return ErrPermissionDeniedNeedRoleMapReview
|
||||||
}
|
|
||||||
|
|
||||||
userId, err := userInfo.GetUserID()
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// transaction
|
// transaction
|
||||||
target_status := model.MapfixStatusValidating
|
|
||||||
smap := datastore.Optional()
|
smap := datastore.Optional()
|
||||||
smap.Add("status_id", target_status)
|
smap.Add("status_id", model.MapfixStatusValidating)
|
||||||
mapfix, err := svc.DB.Mapfixes().IfStatusThenUpdateAndGet(ctx, params.MapfixID, []model.MapfixStatus{model.MapfixStatusAcceptedUnvalidated}, smap)
|
mapfix, err := svc.DB.Mapfixes().IfStatusThenUpdateAndGet(ctx, params.MapfixID, []model.MapfixStatus{model.MapfixStatusAccepted}, smap)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -956,24 +563,9 @@ func (svc *Service) ActionMapfixRetryValidate(ctx context.Context, params api.Ac
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err = svc.Nats.Publish("maptest.mapfixes.validate", []byte(j))
|
svc.Nats.Publish("maptest.mapfixes.validate", []byte(j))
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
event_data := model.AuditEventDataAction{
|
return nil
|
||||||
TargetStatus: uint32(target_status),
|
|
||||||
}
|
|
||||||
|
|
||||||
return svc.CreateAuditEventAction(
|
|
||||||
ctx,
|
|
||||||
userId,
|
|
||||||
model.Resource{
|
|
||||||
ID: params.MapfixID,
|
|
||||||
Type: model.ResourceMapfix,
|
|
||||||
},
|
|
||||||
event_data,
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ActionMapfixAccepted implements actionMapfixAccepted operation.
|
// ActionMapfixAccepted implements actionMapfixAccepted operation.
|
||||||
@@ -993,12 +585,7 @@ func (svc *Service) ActionMapfixAccepted(ctx context.Context, params api.ActionM
|
|||||||
}
|
}
|
||||||
// check if caller has required role
|
// check if caller has required role
|
||||||
if !has_role {
|
if !has_role {
|
||||||
return ErrPermissionDeniedNeedRoleMapfixReview
|
return ErrPermissionDeniedNeedRoleMapReview
|
||||||
}
|
|
||||||
|
|
||||||
userId, err := userInfo.GetUserID()
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// check when mapfix was updated
|
// check when mapfix was updated
|
||||||
@@ -1012,97 +599,8 @@ func (svc *Service) ActionMapfixAccepted(ctx context.Context, params api.ActionM
|
|||||||
}
|
}
|
||||||
|
|
||||||
// transaction
|
// transaction
|
||||||
target_status := model.MapfixStatusAcceptedUnvalidated
|
|
||||||
smap := datastore.Optional()
|
smap := datastore.Optional()
|
||||||
smap.Add("status_id", target_status)
|
smap.Add("status_id", model.MapfixStatusAccepted)
|
||||||
err = svc.DB.Mapfixes().IfStatusThenUpdate(ctx, params.MapfixID, []model.MapfixStatus{model.MapfixStatusValidating}, smap)
|
smap.Add("status_message", "Manually forced reset")
|
||||||
if err != nil {
|
return svc.DB.Mapfixes().IfStatusThenUpdate(ctx, params.MapfixID, []model.MapfixStatus{model.MapfixStatusValidating}, smap)
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
event_data := model.AuditEventDataAction{
|
|
||||||
TargetStatus: uint32(target_status),
|
|
||||||
}
|
|
||||||
|
|
||||||
return svc.CreateAuditEventAction(
|
|
||||||
ctx,
|
|
||||||
userId,
|
|
||||||
model.Resource{
|
|
||||||
ID: params.MapfixID,
|
|
||||||
Type: model.ResourceMapfix,
|
|
||||||
},
|
|
||||||
event_data,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
// CreateMapfixAuditComment implements createMapfixAuditComment operation.
|
|
||||||
//
|
|
||||||
// Post a comment to the audit log
|
|
||||||
//
|
|
||||||
// POST /mapfixes/{MapfixID}/comment
|
|
||||||
func (svc *Service) CreateMapfixAuditComment(ctx context.Context, req api.CreateMapfixAuditCommentReq, params api.CreateMapfixAuditCommentParams) (error) {
|
|
||||||
userInfo, ok := ctx.Value("UserInfo").(UserInfoHandle)
|
|
||||||
if !ok {
|
|
||||||
return ErrUserInfo
|
|
||||||
}
|
|
||||||
|
|
||||||
has_role, err := userInfo.HasRoleMapfixReview()
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
userId, err := userInfo.GetUserID()
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
if !has_role {
|
|
||||||
// Submitter has special permission to comment on their mapfix
|
|
||||||
mapfix, err := svc.DB.Mapfixes().Get(ctx, params.MapfixID)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
if mapfix.Submitter != userId {
|
|
||||||
return ErrPermissionDeniedNeedRoleMapfixReview
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
data, err := io.ReadAll(req)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
event_data := model.AuditEventDataComment{
|
|
||||||
Comment: string(data),
|
|
||||||
}
|
|
||||||
|
|
||||||
return svc.CreateAuditEventComment(
|
|
||||||
ctx,
|
|
||||||
userId,
|
|
||||||
model.Resource{
|
|
||||||
ID: params.MapfixID,
|
|
||||||
Type: model.ResourceMapfix,
|
|
||||||
},
|
|
||||||
event_data,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
// ListMapfixAuditEvents invokes listMapfixAuditEvents operation.
|
|
||||||
//
|
|
||||||
// Retrieve a list of audit events.
|
|
||||||
//
|
|
||||||
// GET /mapfixes/{MapfixID}/audit-events
|
|
||||||
func (svc *Service) ListMapfixAuditEvents(ctx context.Context, params api.ListMapfixAuditEventsParams) ([]api.AuditEvent, error) {
|
|
||||||
return svc.ListAuditEvents(
|
|
||||||
ctx,
|
|
||||||
model.Resource{
|
|
||||||
ID: params.MapfixID,
|
|
||||||
Type: model.ResourceMapfix,
|
|
||||||
},
|
|
||||||
model.Page{
|
|
||||||
Number: params.Page,
|
|
||||||
Size: params.Limit,
|
|
||||||
},
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,11 +2,9 @@ package service
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"strings"
|
|
||||||
|
|
||||||
"git.itzana.me/strafesnet/go-grpc/maps"
|
"git.itzana.me/strafesnet/go-grpc/maps"
|
||||||
"git.itzana.me/strafesnet/maps-service/pkg/api"
|
"git.itzana.me/strafesnet/maps-service/pkg/api"
|
||||||
"git.itzana.me/strafesnet/maps-service/pkg/roblox"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// ListMaps implements listMaps operation.
|
// ListMaps implements listMaps operation.
|
||||||
@@ -27,7 +25,7 @@ func (svc *Service) ListMaps(ctx context.Context, params api.ListMapsParams) ([]
|
|||||||
filter.GameID = ¶ms.GameID.Value
|
filter.GameID = ¶ms.GameID.Value
|
||||||
}
|
}
|
||||||
|
|
||||||
mapList, err := svc.Maps.List(ctx, &maps.ListRequest{
|
mapList, err := svc.Client.List(ctx, &maps.ListRequest{
|
||||||
Filter: &filter,
|
Filter: &filter,
|
||||||
Page: &maps.Pagination{
|
Page: &maps.Pagination{
|
||||||
Size: params.Limit,
|
Size: params.Limit,
|
||||||
@@ -58,7 +56,7 @@ func (svc *Service) ListMaps(ctx context.Context, params api.ListMapsParams) ([]
|
|||||||
//
|
//
|
||||||
// GET /maps/{MapID}
|
// GET /maps/{MapID}
|
||||||
func (svc *Service) GetMap(ctx context.Context, params api.GetMapParams) (*api.Map, error) {
|
func (svc *Service) GetMap(ctx context.Context, params api.GetMapParams) (*api.Map, error) {
|
||||||
mapResponse, err := svc.Maps.Get(ctx, &maps.IdMessage{
|
mapResponse, err := svc.Client.Get(ctx, &maps.IdMessage{
|
||||||
ID: params.MapID,
|
ID: params.MapID,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -73,43 +71,3 @@ func (svc *Service) GetMap(ctx context.Context, params api.GetMapParams) (*api.M
|
|||||||
Date: mapResponse.Date,
|
Date: mapResponse.Date,
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetMapAssetLocation invokes getMapAssetLocation operation.
|
|
||||||
//
|
|
||||||
// Get location of map asset.
|
|
||||||
//
|
|
||||||
// GET /maps/{MapID}/location
|
|
||||||
func (svc *Service) GetMapAssetLocation(ctx context.Context, params api.GetMapAssetLocationParams) (ok api.GetMapAssetLocationOK, err error) {
|
|
||||||
userInfo, success := ctx.Value("UserInfo").(UserInfoHandle)
|
|
||||||
if !success {
|
|
||||||
return ok, ErrUserInfo
|
|
||||||
}
|
|
||||||
|
|
||||||
has_role, err := userInfo.HasRoleMapDownload()
|
|
||||||
if err != nil {
|
|
||||||
return ok, err
|
|
||||||
}
|
|
||||||
|
|
||||||
if !has_role {
|
|
||||||
return ok, ErrPermissionDeniedNeedRoleMapDownload
|
|
||||||
}
|
|
||||||
|
|
||||||
// Ensure map exists in the db!
|
|
||||||
// This could otherwise be used to access any asset
|
|
||||||
_, err = svc.Maps.Get(ctx, &maps.IdMessage{
|
|
||||||
ID: params.MapID,
|
|
||||||
})
|
|
||||||
if err != nil {
|
|
||||||
return ok, err
|
|
||||||
}
|
|
||||||
|
|
||||||
info, err := svc.Roblox.GetAssetLocation(roblox.GetAssetLatestRequest{
|
|
||||||
AssetID: uint64(params.MapID),
|
|
||||||
})
|
|
||||||
if err != nil{
|
|
||||||
return ok, err
|
|
||||||
}
|
|
||||||
|
|
||||||
ok.Data = strings.NewReader(info.Location)
|
|
||||||
return ok, nil
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -24,13 +24,11 @@ func (svc *Service) GetOperation(ctx context.Context, params api.GetOperationPar
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
userId, err := userInfo.GetUserID()
|
has_role, err := userInfo.IsSubmitter(uint64(operation.Owner))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
// check if caller is operation owner
|
||||||
// check if caller is the submitter
|
|
||||||
has_role := userId == operation.Owner
|
|
||||||
if !has_role {
|
if !has_role {
|
||||||
return nil, ErrPermissionDeniedNotSubmitter
|
return nil, ErrPermissionDeniedNotSubmitter
|
||||||
}
|
}
|
||||||
@@ -38,7 +36,7 @@ func (svc *Service) GetOperation(ctx context.Context, params api.GetOperationPar
|
|||||||
return &api.Operation{
|
return &api.Operation{
|
||||||
OperationID: operation.ID,
|
OperationID: operation.ID,
|
||||||
Date: operation.CreatedAt.Unix(),
|
Date: operation.CreatedAt.Unix(),
|
||||||
Owner: int64(operation.Owner),
|
Owner: operation.Owner,
|
||||||
Status: int32(operation.StatusID),
|
Status: int32(operation.StatusID),
|
||||||
StatusMessage: operation.StatusMessage,
|
StatusMessage: operation.StatusMessage,
|
||||||
Path: operation.Path,
|
Path: operation.Path,
|
||||||
|
|||||||
@@ -63,13 +63,13 @@ func (svc *Service) ListScriptPolicy(ctx context.Context, params api.ListScriptP
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
filter.Add("from_script_hash", int64(hash)) // No type safety!
|
filter.AddNotNil("from_script_hash", int64(hash)) // No type safety!
|
||||||
}
|
}
|
||||||
if params.ToScriptID.IsSet(){
|
if params.ToScriptID.IsSet(){
|
||||||
filter.Add("to_script_id", params.ToScriptID.Value)
|
filter.AddNotNil("to_script_id", params.ToScriptID.Value)
|
||||||
}
|
}
|
||||||
if params.Policy.IsSet(){
|
if params.Policy.IsSet(){
|
||||||
filter.Add("policy", params.Policy.Value)
|
filter.AddNotNil("policy", params.Policy.Value)
|
||||||
}
|
}
|
||||||
|
|
||||||
items, err := svc.DB.ScriptPolicy().List(ctx, filter, model.Page{
|
items, err := svc.DB.ScriptPolicy().List(ctx, filter, model.Page{
|
||||||
@@ -121,6 +121,13 @@ func (svc *Service) DeleteScriptPolicy(ctx context.Context, params api.DeleteScr
|
|||||||
//
|
//
|
||||||
// GET /script-policy/{ScriptPolicyID}
|
// GET /script-policy/{ScriptPolicyID}
|
||||||
func (svc *Service) GetScriptPolicy(ctx context.Context, params api.GetScriptPolicyParams) (*api.ScriptPolicy, error) {
|
func (svc *Service) GetScriptPolicy(ctx context.Context, params api.GetScriptPolicyParams) (*api.ScriptPolicy, error) {
|
||||||
|
_, ok := ctx.Value("UserInfo").(UserInfoHandle)
|
||||||
|
if !ok {
|
||||||
|
return nil, ErrUserInfo
|
||||||
|
}
|
||||||
|
|
||||||
|
// Read permission for script policy only requires you to be logged in
|
||||||
|
|
||||||
policy, err := svc.DB.ScriptPolicy().Get(ctx, params.ScriptPolicyID)
|
policy, err := svc.DB.ScriptPolicy().Get(ctx, params.ScriptPolicyID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|||||||
@@ -57,19 +57,19 @@ func (svc *Service) ListScripts(ctx context.Context, params api.ListScriptsParam
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
filter.Add("hash", int64(hash)) // No type safety!
|
filter.AddNotNil("hash", int64(hash)) // No type safety!
|
||||||
}
|
}
|
||||||
if params.Name.IsSet(){
|
if params.Name.IsSet(){
|
||||||
filter.Add("name", params.Name.Value)
|
filter.AddNotNil("name", params.Name.Value)
|
||||||
}
|
}
|
||||||
if params.Source.IsSet(){
|
if params.Source.IsSet(){
|
||||||
filter.Add("source", params.Source.Value)
|
filter.AddNotNil("source", params.Source.Value)
|
||||||
}
|
}
|
||||||
if params.ResourceType.IsSet(){
|
if params.ResourceType.IsSet(){
|
||||||
filter.Add("resource_type", params.ResourceType.Value)
|
filter.AddNotNil("resource_type", params.ResourceType.Value)
|
||||||
}
|
}
|
||||||
if params.ResourceID.IsSet(){
|
if params.ResourceID.IsSet(){
|
||||||
filter.Add("resource_id", params.ResourceID.Value)
|
filter.AddNotNil("resource_id", params.ResourceID.Value)
|
||||||
}
|
}
|
||||||
|
|
||||||
items, err := svc.DB.Scripts().List(ctx, filter, model.Page{
|
items, err := svc.DB.Scripts().List(ctx, filter, model.Page{
|
||||||
@@ -84,7 +84,6 @@ func (svc *Service) ListScripts(ctx context.Context, params api.ListScriptsParam
|
|||||||
for _, item := range items {
|
for _, item := range items {
|
||||||
resp = append(resp, api.Script{
|
resp = append(resp, api.Script{
|
||||||
ID: item.ID,
|
ID: item.ID,
|
||||||
Name: item.Name,
|
|
||||||
Hash: model.HashFormat(uint64(item.Hash)),
|
Hash: model.HashFormat(uint64(item.Hash)),
|
||||||
Source: item.Source,
|
Source: item.Source,
|
||||||
ResourceType: int32(item.ResourceType),
|
ResourceType: int32(item.ResourceType),
|
||||||
@@ -123,6 +122,13 @@ func (svc *Service) DeleteScript(ctx context.Context, params api.DeleteScriptPar
|
|||||||
//
|
//
|
||||||
// GET /scripts/{ScriptID}
|
// GET /scripts/{ScriptID}
|
||||||
func (svc *Service) GetScript(ctx context.Context, params api.GetScriptParams) (*api.Script, error) {
|
func (svc *Service) GetScript(ctx context.Context, params api.GetScriptParams) (*api.Script, error) {
|
||||||
|
_, ok := ctx.Value("UserInfo").(UserInfoHandle)
|
||||||
|
if !ok {
|
||||||
|
return nil, ErrUserInfo
|
||||||
|
}
|
||||||
|
|
||||||
|
// Read permission for scripts only requires you to be logged in
|
||||||
|
|
||||||
script, err := svc.DB.Scripts().Get(ctx, params.ScriptID)
|
script, err := svc.DB.Scripts().Get(ctx, params.ScriptID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|||||||
@@ -88,6 +88,13 @@ func (usr UserInfoHandle) Validate() (bool, error) {
|
|||||||
}
|
}
|
||||||
return validate.Valid, nil
|
return validate.Valid, nil
|
||||||
}
|
}
|
||||||
|
func (usr UserInfoHandle) IsSubmitter(submitter uint64) (bool, error) {
|
||||||
|
userId, err := usr.GetUserID()
|
||||||
|
if err != nil {
|
||||||
|
return false, err
|
||||||
|
}
|
||||||
|
return userId == submitter, nil
|
||||||
|
}
|
||||||
func (usr UserInfoHandle) hasRoles(wantRoles Roles) (bool, error) {
|
func (usr UserInfoHandle) hasRoles(wantRoles Roles) (bool, error) {
|
||||||
haveroles, err := usr.GetRoles()
|
haveroles, err := usr.GetRoles()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@@ -6,10 +6,8 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"git.itzana.me/strafesnet/go-grpc/maps"
|
"git.itzana.me/strafesnet/go-grpc/maps"
|
||||||
"git.itzana.me/strafesnet/go-grpc/users"
|
|
||||||
"git.itzana.me/strafesnet/maps-service/pkg/api"
|
"git.itzana.me/strafesnet/maps-service/pkg/api"
|
||||||
"git.itzana.me/strafesnet/maps-service/pkg/datastore"
|
"git.itzana.me/strafesnet/maps-service/pkg/datastore"
|
||||||
"git.itzana.me/strafesnet/maps-service/pkg/roblox"
|
|
||||||
"github.com/nats-io/nats.go"
|
"github.com/nats-io/nats.go"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -21,22 +19,17 @@ var (
|
|||||||
ErrDelayReset = errors.New("Please give the validator at least 10 seconds to operate before attempting to reset the status")
|
ErrDelayReset = errors.New("Please give the validator at least 10 seconds to operate before attempting to reset the status")
|
||||||
ErrPermissionDeniedNotSubmitter = fmt.Errorf("%w: You must be the submitter to perform this action", ErrPermissionDenied)
|
ErrPermissionDeniedNotSubmitter = fmt.Errorf("%w: You must be the submitter to perform this action", ErrPermissionDenied)
|
||||||
ErrPermissionDeniedNeedRoleSubmissionRelease = fmt.Errorf("%w: Need Role SubmissionRelease", ErrPermissionDenied)
|
ErrPermissionDeniedNeedRoleSubmissionRelease = fmt.Errorf("%w: Need Role SubmissionRelease", ErrPermissionDenied)
|
||||||
ErrPermissionDeniedNeedRoleMapfixUpload = fmt.Errorf("%w: Need Role MapfixUpload", ErrPermissionDenied)
|
ErrPermissionDeniedNeedRoleMapUpload = fmt.Errorf("%w: Need Role MapUpload", ErrPermissionDenied)
|
||||||
ErrPermissionDeniedNeedRoleMapfixReview = fmt.Errorf("%w: Need Role MapfixReview", ErrPermissionDenied)
|
ErrPermissionDeniedNeedRoleMapReview = fmt.Errorf("%w: Need Role MapReview", ErrPermissionDenied)
|
||||||
ErrPermissionDeniedNeedRoleSubmissionUpload = fmt.Errorf("%w: Need Role SubmissionUpload", ErrPermissionDenied)
|
|
||||||
ErrPermissionDeniedNeedRoleSubmissionReview = fmt.Errorf("%w: Need Role SubmissionReview", ErrPermissionDenied)
|
|
||||||
ErrPermissionDeniedNeedRoleMapDownload = fmt.Errorf("%w: Need Role MapDownload", ErrPermissionDenied)
|
ErrPermissionDeniedNeedRoleMapDownload = fmt.Errorf("%w: Need Role MapDownload", ErrPermissionDenied)
|
||||||
ErrPermissionDeniedNeedRoleScriptWrite = fmt.Errorf("%w: Need Role ScriptWrite", ErrPermissionDenied)
|
ErrPermissionDeniedNeedRoleScriptWrite = fmt.Errorf("%w: Need Role ScriptWrite", ErrPermissionDenied)
|
||||||
ErrPermissionDeniedNeedRoleMaptest = fmt.Errorf("%w: Need Role Maptest", ErrPermissionDenied)
|
ErrPermissionDeniedNeedRoleMaptest = fmt.Errorf("%w: Need Role Maptest", ErrPermissionDenied)
|
||||||
ErrNegativeID = errors.New("A negative ID was provided")
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type Service struct {
|
type Service struct {
|
||||||
DB datastore.Datastore
|
DB datastore.Datastore
|
||||||
Nats nats.JetStreamContext
|
Nats nats.JetStreamContext
|
||||||
Maps maps.MapsServiceClient
|
Client maps.MapsServiceClient
|
||||||
Users users.UsersServiceClient
|
|
||||||
Roblox roblox.Client
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewError creates *ErrorStatusCode from error returned by handler.
|
// NewError creates *ErrorStatusCode from error returned by handler.
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ import (
|
|||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"git.itzana.me/strafesnet/go-grpc/maps"
|
"git.itzana.me/strafesnet/go-grpc/maps"
|
||||||
@@ -21,16 +20,13 @@ var(
|
|||||||
model.SubmissionStatusSubmitted,
|
model.SubmissionStatusSubmitted,
|
||||||
model.SubmissionStatusUnderConstruction,
|
model.SubmissionStatusUnderConstruction,
|
||||||
}
|
}
|
||||||
// limit submissions in the pipeline to one per target map
|
// limit mapfixes in the pipeline to one per target map
|
||||||
ActiveAcceptedSubmissionStatuses = []model.SubmissionStatus{
|
ActiveAcceptedSubmissionStatuses = []model.SubmissionStatus{
|
||||||
model.SubmissionStatusUploading,
|
model.SubmissionStatusUploading,
|
||||||
model.SubmissionStatusValidated,
|
model.SubmissionStatusValidated,
|
||||||
model.SubmissionStatusValidating,
|
model.SubmissionStatusValidating,
|
||||||
model.SubmissionStatusAcceptedUnvalidated,
|
model.SubmissionStatusAccepted,
|
||||||
}
|
}
|
||||||
// Allow 5 submissions every 10 minutes
|
|
||||||
CreateSubmissionRateLimit int64 = 5
|
|
||||||
CreateSubmissionRecencyWindow = time.Second*600
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@@ -39,17 +35,10 @@ var (
|
|||||||
ErrReleaseInvalidStatus = errors.New("Only submissions with Uploaded status can be released")
|
ErrReleaseInvalidStatus = errors.New("Only submissions with Uploaded status can be released")
|
||||||
ErrReleaseNoUploadedAssetID = errors.New("Only submissions with a UploadedAssetID can be released")
|
ErrReleaseNoUploadedAssetID = errors.New("Only submissions with a UploadedAssetID can be released")
|
||||||
ErrAcceptOwnSubmission = fmt.Errorf("%w: You cannot accept your own submission as the submitter", ErrPermissionDenied)
|
ErrAcceptOwnSubmission = fmt.Errorf("%w: You cannot accept your own submission as the submitter", ErrPermissionDenied)
|
||||||
ErrCreateSubmissionRateLimit = errors.New("You must not create more than 5 submissions every 10 minutes")
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// POST /submissions
|
// POST /submissions
|
||||||
func (svc *Service) CreateSubmission(ctx context.Context, request *api.SubmissionTriggerCreate) (*api.OperationID, error) {
|
func (svc *Service) CreateSubmission(ctx context.Context, request *api.SubmissionTriggerCreate) (*api.OperationID, error) {
|
||||||
// sanitization
|
|
||||||
if request.AssetID<0{
|
|
||||||
return nil, ErrNegativeID
|
|
||||||
}
|
|
||||||
var ModelID=uint64(request.AssetID);
|
|
||||||
|
|
||||||
userInfo, ok := ctx.Value("UserInfo").(UserInfoHandle)
|
userInfo, ok := ctx.Value("UserInfo").(UserInfoHandle)
|
||||||
if !ok {
|
if !ok {
|
||||||
return nil, ErrUserInfo
|
return nil, ErrUserInfo
|
||||||
@@ -77,24 +66,8 @@ func (svc *Service) CreateSubmission(ctx context.Context, request *api.Submissio
|
|||||||
return nil, ErrCreationPhaseSubmissionsLimit
|
return nil, ErrCreationPhaseSubmissionsLimit
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if too many operations have been created recently
|
|
||||||
{
|
|
||||||
count, err := svc.DB.Operations().CountSince(ctx,
|
|
||||||
int64(userId),
|
|
||||||
time.Now().Add(-CreateSubmissionRecencyWindow),
|
|
||||||
)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
if CreateSubmissionRateLimit < count {
|
|
||||||
return nil, ErrCreateSubmissionRateLimit
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
operation, err := svc.DB.Operations().Create(ctx, model.Operation{
|
operation, err := svc.DB.Operations().Create(ctx, model.Operation{
|
||||||
Owner: userId,
|
Owner: int64(userId),
|
||||||
StatusID: model.OperationStatusCreated,
|
StatusID: model.OperationStatusCreated,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -102,13 +75,8 @@ func (svc *Service) CreateSubmission(ctx context.Context, request *api.Submissio
|
|||||||
}
|
}
|
||||||
|
|
||||||
create_request := model.CreateSubmissionRequest{
|
create_request := model.CreateSubmissionRequest{
|
||||||
OperationID: operation.ID,
|
OperationID: operation.ID,
|
||||||
ModelID: ModelID,
|
ModelID: request.AssetID,
|
||||||
DisplayName: request.DisplayName,
|
|
||||||
Creator: request.Creator,
|
|
||||||
GameID: uint32(request.GameID),
|
|
||||||
Status: uint32(model.SubmissionStatusUnderConstruction),
|
|
||||||
Roles: uint32(RolesEmpty),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
j, err := json.Marshal(create_request)
|
j, err := json.Marshal(create_request)
|
||||||
@@ -116,86 +84,7 @@ func (svc *Service) CreateSubmission(ctx context.Context, request *api.Submissio
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err = svc.Nats.Publish("maptest.submissions.create", []byte(j))
|
svc.Nats.Publish("maptest.submissions.create", []byte(j))
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return &api.OperationID{
|
|
||||||
OperationID: operation.ID,
|
|
||||||
}, nil
|
|
||||||
}
|
|
||||||
// POST /submissions-admin
|
|
||||||
func (svc *Service) CreateSubmissionAdmin(ctx context.Context, request *api.SubmissionTriggerCreate) (*api.OperationID, error) {
|
|
||||||
// sanitization
|
|
||||||
if request.AssetID<0{
|
|
||||||
return nil, ErrNegativeID
|
|
||||||
}
|
|
||||||
var ModelID=uint64(request.AssetID);
|
|
||||||
|
|
||||||
userInfo, ok := ctx.Value("UserInfo").(UserInfoHandle)
|
|
||||||
if !ok {
|
|
||||||
return nil, ErrUserInfo
|
|
||||||
}
|
|
||||||
|
|
||||||
userId, err := userInfo.GetUserID()
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
roles, err := userInfo.GetRoles()
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
// check if caller has required role
|
|
||||||
has_role := roles & RolesSubmissionReview == RolesSubmissionReview
|
|
||||||
if !has_role {
|
|
||||||
return nil, ErrPermissionDeniedNeedRoleSubmissionReview
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check if too many operations have been created recently
|
|
||||||
{
|
|
||||||
count, err := svc.DB.Operations().CountSince(ctx,
|
|
||||||
int64(userId),
|
|
||||||
time.Now().Add(-CreateSubmissionRecencyWindow),
|
|
||||||
)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
if CreateSubmissionRateLimit < count {
|
|
||||||
return nil, ErrCreateSubmissionRateLimit
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
operation, err := svc.DB.Operations().Create(ctx, model.Operation{
|
|
||||||
Owner: userId,
|
|
||||||
StatusID: model.OperationStatusCreated,
|
|
||||||
})
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
create_request := model.CreateSubmissionRequest{
|
|
||||||
OperationID: operation.ID,
|
|
||||||
ModelID: ModelID,
|
|
||||||
DisplayName: request.DisplayName,
|
|
||||||
Creator: request.Creator,
|
|
||||||
GameID: uint32(request.GameID),
|
|
||||||
Status: uint32(model.SubmissionStatusChangesRequested),
|
|
||||||
Roles: uint32(roles),
|
|
||||||
}
|
|
||||||
|
|
||||||
j, err := json.Marshal(create_request)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
_, err = svc.Nats.Publish("maptest.submissions.create", []byte(j))
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return &api.OperationID{
|
return &api.OperationID{
|
||||||
OperationID: operation.ID,
|
OperationID: operation.ID,
|
||||||
@@ -216,7 +105,7 @@ func (svc *Service) GetSubmission(ctx context.Context, params api.GetSubmissionP
|
|||||||
ID: submission.ID,
|
ID: submission.ID,
|
||||||
DisplayName: submission.DisplayName,
|
DisplayName: submission.DisplayName,
|
||||||
Creator: submission.Creator,
|
Creator: submission.Creator,
|
||||||
GameID: int32(submission.GameID),
|
GameID: submission.GameID,
|
||||||
CreatedAt: submission.CreatedAt.Unix(),
|
CreatedAt: submission.CreatedAt.Unix(),
|
||||||
UpdatedAt: submission.UpdatedAt.Unix(),
|
UpdatedAt: submission.UpdatedAt.Unix(),
|
||||||
Submitter: int64(submission.Submitter),
|
Submitter: int64(submission.Submitter),
|
||||||
@@ -225,6 +114,7 @@ func (svc *Service) GetSubmission(ctx context.Context, params api.GetSubmissionP
|
|||||||
Completed: submission.Completed,
|
Completed: submission.Completed,
|
||||||
UploadedAssetID: api.NewOptInt64(int64(submission.UploadedAssetID)),
|
UploadedAssetID: api.NewOptInt64(int64(submission.UploadedAssetID)),
|
||||||
StatusID: int32(submission.StatusID),
|
StatusID: int32(submission.StatusID),
|
||||||
|
StatusMessage: submission.StatusMessage,
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -233,7 +123,7 @@ func (svc *Service) GetSubmission(ctx context.Context, params api.GetSubmissionP
|
|||||||
// Get list of submissions.
|
// Get list of submissions.
|
||||||
//
|
//
|
||||||
// GET /submissions
|
// GET /submissions
|
||||||
func (svc *Service) ListSubmissions(ctx context.Context, params api.ListSubmissionsParams) (*api.Submissions, error) {
|
func (svc *Service) ListSubmissions(ctx context.Context, params api.ListSubmissionsParams) ([]api.Submission, error) {
|
||||||
filter := datastore.Optional()
|
filter := datastore.Optional()
|
||||||
|
|
||||||
if params.DisplayName.IsSet(){
|
if params.DisplayName.IsSet(){
|
||||||
@@ -245,22 +135,10 @@ func (svc *Service) ListSubmissions(ctx context.Context, params api.ListSubmissi
|
|||||||
if params.GameID.IsSet(){
|
if params.GameID.IsSet(){
|
||||||
filter.Add("game_id", params.GameID.Value)
|
filter.Add("game_id", params.GameID.Value)
|
||||||
}
|
}
|
||||||
if params.Submitter.IsSet(){
|
|
||||||
filter.Add("submitter", params.Submitter.Value)
|
|
||||||
}
|
|
||||||
if params.AssetID.IsSet(){
|
|
||||||
filter.Add("asset_id", params.AssetID.Value)
|
|
||||||
}
|
|
||||||
if params.UploadedAssetID.IsSet(){
|
|
||||||
filter.Add("uploaded_asset_id", params.UploadedAssetID.Value)
|
|
||||||
}
|
|
||||||
if params.StatusID.IsSet(){
|
|
||||||
filter.Add("status_id", params.StatusID.Value)
|
|
||||||
}
|
|
||||||
|
|
||||||
sort := datastore.ListSort(params.Sort.Or(int32(datastore.ListSortDisabled)))
|
sort := datastore.ListSort(params.Sort.Or(int32(datastore.ListSortDisabled)))
|
||||||
|
|
||||||
total, items, err := svc.DB.Submissions().ListWithTotal(ctx, filter, model.Page{
|
items, err := svc.DB.Submissions().List(ctx, filter, model.Page{
|
||||||
Number: params.Page,
|
Number: params.Page,
|
||||||
Size: params.Limit,
|
Size: params.Limit,
|
||||||
},sort)
|
},sort)
|
||||||
@@ -268,14 +146,13 @@ func (svc *Service) ListSubmissions(ctx context.Context, params api.ListSubmissi
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
var resp api.Submissions
|
var resp []api.Submission
|
||||||
resp.Total=total
|
|
||||||
for _, item := range items {
|
for _, item := range items {
|
||||||
resp.Submissions = append(resp.Submissions, api.Submission{
|
resp = append(resp, api.Submission{
|
||||||
ID: item.ID,
|
ID: item.ID,
|
||||||
DisplayName: item.DisplayName,
|
DisplayName: item.DisplayName,
|
||||||
Creator: item.Creator,
|
Creator: item.Creator,
|
||||||
GameID: int32(item.GameID),
|
GameID: item.GameID,
|
||||||
CreatedAt: item.CreatedAt.Unix(),
|
CreatedAt: item.CreatedAt.Unix(),
|
||||||
UpdatedAt: item.UpdatedAt.Unix(),
|
UpdatedAt: item.UpdatedAt.Unix(),
|
||||||
Submitter: int64(item.Submitter),
|
Submitter: int64(item.Submitter),
|
||||||
@@ -287,7 +164,7 @@ func (svc *Service) ListSubmissions(ctx context.Context, params api.ListSubmissi
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
return &resp, nil
|
return resp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// PatchSubmissionCompleted implements patchSubmissionCompleted operation.
|
// PatchSubmissionCompleted implements patchSubmissionCompleted operation.
|
||||||
@@ -332,49 +209,22 @@ func (svc *Service) UpdateSubmissionModel(ctx context.Context, params api.Update
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
userId, err := userInfo.GetUserID()
|
has_role, err := userInfo.IsSubmitter(uint64(submission.Submitter))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// check if caller is the submitter
|
// check if caller is the submitter
|
||||||
has_role := userId == submission.Submitter
|
|
||||||
if !has_role {
|
if !has_role {
|
||||||
return ErrPermissionDeniedNotSubmitter
|
return ErrPermissionDeniedNotSubmitter
|
||||||
}
|
}
|
||||||
|
|
||||||
OldModelID := submission.AssetID
|
|
||||||
OldModelVersion := submission.AssetVersion
|
|
||||||
NewModelID := uint64(params.ModelID)
|
|
||||||
NewModelVersion := uint64(params.ModelVersion)
|
|
||||||
|
|
||||||
// check if Status is ChangesRequested|Submitted|UnderConstruction
|
// check if Status is ChangesRequested|Submitted|UnderConstruction
|
||||||
pmap := datastore.Optional()
|
pmap := datastore.Optional()
|
||||||
pmap.Add("asset_id", NewModelID)
|
pmap.AddNotNil("asset_id", params.ModelID)
|
||||||
pmap.Add("asset_version", NewModelVersion)
|
pmap.AddNotNil("asset_version", params.VersionID)
|
||||||
//always reset completed when model changes
|
//always reset completed when model changes
|
||||||
pmap.Add("completed", false)
|
pmap.Add("completed", false)
|
||||||
err = svc.DB.Submissions().IfStatusThenUpdate(ctx, params.SubmissionID, []model.SubmissionStatus{model.SubmissionStatusChangesRequested, model.SubmissionStatusUnderConstruction}, pmap)
|
return svc.DB.Submissions().IfStatusThenUpdate(ctx, params.SubmissionID, []model.SubmissionStatus{model.SubmissionStatusChangesRequested, model.SubmissionStatusSubmitted, model.SubmissionStatusUnderConstruction}, pmap)
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
event_data := model.AuditEventDataChangeModel{
|
|
||||||
OldModelID: OldModelID,
|
|
||||||
OldModelVersion: OldModelVersion,
|
|
||||||
NewModelID: NewModelID,
|
|
||||||
NewModelVersion: NewModelVersion,
|
|
||||||
}
|
|
||||||
|
|
||||||
return svc.CreateAuditEventChangeModel(
|
|
||||||
ctx,
|
|
||||||
userId,
|
|
||||||
model.Resource{
|
|
||||||
ID: params.SubmissionID,
|
|
||||||
Type: model.ResourceSubmission,
|
|
||||||
},
|
|
||||||
event_data,
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ActionSubmissionReject invokes actionSubmissionReject operation.
|
// ActionSubmissionReject invokes actionSubmissionReject operation.
|
||||||
@@ -394,36 +244,13 @@ func (svc *Service) ActionSubmissionReject(ctx context.Context, params api.Actio
|
|||||||
}
|
}
|
||||||
// check if caller has required role
|
// check if caller has required role
|
||||||
if !has_role {
|
if !has_role {
|
||||||
return ErrPermissionDeniedNeedRoleSubmissionReview
|
return ErrPermissionDeniedNeedRoleMapReview
|
||||||
}
|
|
||||||
|
|
||||||
userId, err := userInfo.GetUserID()
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// transaction
|
// transaction
|
||||||
target_status := model.SubmissionStatusRejected
|
|
||||||
smap := datastore.Optional()
|
smap := datastore.Optional()
|
||||||
smap.Add("status_id", target_status)
|
smap.Add("status_id", model.SubmissionStatusRejected)
|
||||||
err = svc.DB.Submissions().IfStatusThenUpdate(ctx, params.SubmissionID, []model.SubmissionStatus{model.SubmissionStatusSubmitted}, smap)
|
return svc.DB.Submissions().IfStatusThenUpdate(ctx, params.SubmissionID, []model.SubmissionStatus{model.SubmissionStatusSubmitted}, smap)
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
event_data := model.AuditEventDataAction{
|
|
||||||
TargetStatus: uint32(target_status),
|
|
||||||
}
|
|
||||||
|
|
||||||
return svc.CreateAuditEventAction(
|
|
||||||
ctx,
|
|
||||||
userId,
|
|
||||||
model.Resource{
|
|
||||||
ID: params.SubmissionID,
|
|
||||||
Type: model.ResourceSubmission,
|
|
||||||
},
|
|
||||||
event_data,
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ActionSubmissionRequestChanges invokes actionSubmissionRequestChanges operation.
|
// ActionSubmissionRequestChanges invokes actionSubmissionRequestChanges operation.
|
||||||
@@ -443,36 +270,13 @@ func (svc *Service) ActionSubmissionRequestChanges(ctx context.Context, params a
|
|||||||
}
|
}
|
||||||
// check if caller has required role
|
// check if caller has required role
|
||||||
if !has_role {
|
if !has_role {
|
||||||
return ErrPermissionDeniedNeedRoleSubmissionReview
|
return ErrPermissionDeniedNeedRoleMapReview
|
||||||
}
|
|
||||||
|
|
||||||
userId, err := userInfo.GetUserID()
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// transaction
|
// transaction
|
||||||
target_status := model.SubmissionStatusChangesRequested
|
|
||||||
smap := datastore.Optional()
|
smap := datastore.Optional()
|
||||||
smap.Add("status_id", target_status)
|
smap.Add("status_id", model.SubmissionStatusChangesRequested)
|
||||||
err = svc.DB.Submissions().IfStatusThenUpdate(ctx, params.SubmissionID, []model.SubmissionStatus{model.SubmissionStatusValidated, model.SubmissionStatusAcceptedUnvalidated, model.SubmissionStatusSubmitted}, smap)
|
return svc.DB.Submissions().IfStatusThenUpdate(ctx, params.SubmissionID, []model.SubmissionStatus{model.SubmissionStatusValidated, model.SubmissionStatusAccepted, model.SubmissionStatusSubmitted}, smap)
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
event_data := model.AuditEventDataAction{
|
|
||||||
TargetStatus: uint32(target_status),
|
|
||||||
}
|
|
||||||
|
|
||||||
return svc.CreateAuditEventAction(
|
|
||||||
ctx,
|
|
||||||
userId,
|
|
||||||
model.Resource{
|
|
||||||
ID: params.SubmissionID,
|
|
||||||
Type: model.ResourceSubmission,
|
|
||||||
},
|
|
||||||
event_data,
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ActionSubmissionRevoke invokes actionSubmissionRevoke operation.
|
// ActionSubmissionRevoke invokes actionSubmissionRevoke operation.
|
||||||
@@ -492,47 +296,27 @@ func (svc *Service) ActionSubmissionRevoke(ctx context.Context, params api.Actio
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
userId, err := userInfo.GetUserID()
|
has_role, err := userInfo.IsSubmitter(uint64(submission.Submitter))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// check if caller is the submitter
|
// check if caller is the submitter
|
||||||
has_role := userId == submission.Submitter
|
|
||||||
if !has_role {
|
if !has_role {
|
||||||
return ErrPermissionDeniedNotSubmitter
|
return ErrPermissionDeniedNotSubmitter
|
||||||
}
|
}
|
||||||
|
|
||||||
// transaction
|
// transaction
|
||||||
target_status := model.SubmissionStatusUnderConstruction
|
|
||||||
smap := datastore.Optional()
|
smap := datastore.Optional()
|
||||||
smap.Add("status_id", target_status)
|
smap.Add("status_id", model.SubmissionStatusUnderConstruction)
|
||||||
err = svc.DB.Submissions().IfStatusThenUpdate(ctx, params.SubmissionID, []model.SubmissionStatus{model.SubmissionStatusSubmitted, model.SubmissionStatusChangesRequested}, smap)
|
return svc.DB.Submissions().IfStatusThenUpdate(ctx, params.SubmissionID, []model.SubmissionStatus{model.SubmissionStatusSubmitted, model.SubmissionStatusChangesRequested}, smap)
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
event_data := model.AuditEventDataAction{
|
|
||||||
TargetStatus: uint32(target_status),
|
|
||||||
}
|
|
||||||
|
|
||||||
return svc.CreateAuditEventAction(
|
|
||||||
ctx,
|
|
||||||
userId,
|
|
||||||
model.Resource{
|
|
||||||
ID: params.SubmissionID,
|
|
||||||
Type: model.ResourceSubmission,
|
|
||||||
},
|
|
||||||
event_data,
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ActionSubmissionTriggerSubmit invokes actionSubmissionTriggerSubmit operation.
|
// ActionSubmissionSubmit invokes actionSubmissionSubmit operation.
|
||||||
//
|
//
|
||||||
// Role Submitter changes status from UnderConstruction|ChangesRequested -> Submitting.
|
// Role Submitter changes status from UnderConstruction|ChangesRequested -> Submitted.
|
||||||
//
|
//
|
||||||
// POST /submissions/{SubmissionID}/status/trigger-submit
|
// POST /submissions/{SubmissionID}/status/submit
|
||||||
func (svc *Service) ActionSubmissionTriggerSubmit(ctx context.Context, params api.ActionSubmissionTriggerSubmitParams) error {
|
func (svc *Service) ActionSubmissionSubmit(ctx context.Context, params api.ActionSubmissionSubmitParams) error {
|
||||||
userInfo, ok := ctx.Value("UserInfo").(UserInfoHandle)
|
userInfo, ok := ctx.Value("UserInfo").(UserInfoHandle)
|
||||||
if !ok {
|
if !ok {
|
||||||
return ErrUserInfo
|
return ErrUserInfo
|
||||||
@@ -544,196 +328,19 @@ func (svc *Service) ActionSubmissionTriggerSubmit(ctx context.Context, params ap
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
userId, err := userInfo.GetUserID()
|
has_role, err := userInfo.IsSubmitter(uint64(submission.Submitter))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// check if caller is the submitter
|
// check if caller is the submitter
|
||||||
is_submitter := userId == submission.Submitter
|
|
||||||
// neither = deny
|
|
||||||
if !is_submitter {
|
|
||||||
has_submission_review, err := userInfo.HasRoleSubmissionReview()
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
if !has_submission_review {
|
|
||||||
return ErrPermissionDeniedNotSubmitter
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// transaction
|
|
||||||
target_status := model.SubmissionStatusSubmitting
|
|
||||||
smap := datastore.Optional()
|
|
||||||
smap.Add("status_id", target_status)
|
|
||||||
err = svc.DB.Submissions().IfStatusThenUpdate(ctx, params.SubmissionID, []model.SubmissionStatus{model.SubmissionStatusUnderConstruction, model.SubmissionStatusChangesRequested}, smap)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
validate_request := model.CheckSubmissionRequest{
|
|
||||||
SubmissionID: submission.ID,
|
|
||||||
ModelID: submission.AssetID,
|
|
||||||
SkipChecks: false,
|
|
||||||
}
|
|
||||||
|
|
||||||
j, err := json.Marshal(validate_request)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
_, err = svc.Nats.Publish("maptest.submissions.check", []byte(j))
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
event_data := model.AuditEventDataAction{
|
|
||||||
TargetStatus: uint32(target_status),
|
|
||||||
}
|
|
||||||
|
|
||||||
return svc.CreateAuditEventAction(
|
|
||||||
ctx,
|
|
||||||
userId,
|
|
||||||
model.Resource{
|
|
||||||
ID: params.SubmissionID,
|
|
||||||
Type: model.ResourceSubmission,
|
|
||||||
},
|
|
||||||
event_data,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
// ActionSubmissionTriggerSubmitUnchecked invokes actionSubmissionTriggerSubmitUnchecked operation.
|
|
||||||
//
|
|
||||||
// Role Reviewer changes status from ChangesRequested -> Submitting.
|
|
||||||
//
|
|
||||||
// POST /submissions/{SubmissionID}/status/trigger-submit-unchecked
|
|
||||||
func (svc *Service) ActionSubmissionTriggerSubmitUnchecked(ctx context.Context, params api.ActionSubmissionTriggerSubmitUncheckedParams) error {
|
|
||||||
userInfo, ok := ctx.Value("UserInfo").(UserInfoHandle)
|
|
||||||
if !ok {
|
|
||||||
return ErrUserInfo
|
|
||||||
}
|
|
||||||
|
|
||||||
// read submission (this could be done with a transaction WHERE clause)
|
|
||||||
submission, err := svc.DB.Submissions().Get(ctx, params.SubmissionID)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
userId, err := userInfo.GetUserID()
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
// check if caller is the submitter
|
|
||||||
is_submitter := userId == submission.Submitter
|
|
||||||
if is_submitter {
|
|
||||||
return ErrAcceptOwnSubmission
|
|
||||||
}
|
|
||||||
|
|
||||||
has_submission_review, err := userInfo.HasRoleSubmissionReview()
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
if !has_submission_review {
|
|
||||||
return ErrPermissionDeniedNeedRoleSubmissionReview
|
|
||||||
}
|
|
||||||
|
|
||||||
// transaction
|
|
||||||
target_status := model.SubmissionStatusSubmitting
|
|
||||||
smap := datastore.Optional()
|
|
||||||
smap.Add("status_id", target_status)
|
|
||||||
err = svc.DB.Submissions().IfStatusThenUpdate(ctx, params.SubmissionID, []model.SubmissionStatus{model.SubmissionStatusChangesRequested}, smap)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
validate_request := model.CheckSubmissionRequest{
|
|
||||||
SubmissionID: submission.ID,
|
|
||||||
ModelID: submission.AssetID,
|
|
||||||
SkipChecks: true,
|
|
||||||
}
|
|
||||||
|
|
||||||
j, err := json.Marshal(validate_request)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
_, err = svc.Nats.Publish("maptest.submissions.check", []byte(j))
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
event_data := model.AuditEventDataAction{
|
|
||||||
TargetStatus: uint32(target_status),
|
|
||||||
}
|
|
||||||
|
|
||||||
return svc.CreateAuditEventAction(
|
|
||||||
ctx,
|
|
||||||
userId,
|
|
||||||
model.Resource{
|
|
||||||
ID: params.SubmissionID,
|
|
||||||
Type: model.ResourceSubmission,
|
|
||||||
},
|
|
||||||
event_data,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
// ActionSubmissionResetSubmitting implements actionSubmissionResetSubmitting operation.
|
|
||||||
//
|
|
||||||
// Role SubmissionReview changes status from Submitting -> UnderConstruction.
|
|
||||||
//
|
|
||||||
// POST /submissions/{SubmissionID}/status/reset-submitting
|
|
||||||
func (svc *Service) ActionSubmissionResetSubmitting(ctx context.Context, params api.ActionSubmissionResetSubmittingParams) error {
|
|
||||||
userInfo, ok := ctx.Value("UserInfo").(UserInfoHandle)
|
|
||||||
if !ok {
|
|
||||||
return ErrUserInfo
|
|
||||||
}
|
|
||||||
|
|
||||||
userId, err := userInfo.GetUserID()
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
// check when submission was updated
|
|
||||||
submission, err := svc.DB.Submissions().Get(ctx, params.SubmissionID)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
if time.Now().Before(submission.UpdatedAt.Add(time.Second*10)) {
|
|
||||||
// the last time the submission was updated must be longer than 10 seconds ago
|
|
||||||
return ErrDelayReset
|
|
||||||
}
|
|
||||||
|
|
||||||
// check if caller has required role
|
|
||||||
has_role := userId == submission.Submitter
|
|
||||||
if !has_role {
|
if !has_role {
|
||||||
return ErrPermissionDeniedNotSubmitter
|
return ErrPermissionDeniedNotSubmitter
|
||||||
}
|
}
|
||||||
|
|
||||||
// transaction
|
// transaction
|
||||||
target_status := model.SubmissionStatusUnderConstruction
|
|
||||||
smap := datastore.Optional()
|
smap := datastore.Optional()
|
||||||
smap.Add("status_id", target_status)
|
smap.Add("status_id", model.SubmissionStatusSubmitted)
|
||||||
err = svc.DB.Submissions().IfStatusThenUpdate(ctx, params.SubmissionID, []model.SubmissionStatus{model.SubmissionStatusSubmitting}, smap)
|
return svc.DB.Submissions().IfStatusThenUpdate(ctx, params.SubmissionID, []model.SubmissionStatus{model.SubmissionStatusUnderConstruction, model.SubmissionStatusChangesRequested}, smap)
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
event_data := model.AuditEventDataAction{
|
|
||||||
TargetStatus: uint32(target_status),
|
|
||||||
}
|
|
||||||
|
|
||||||
return svc.CreateAuditEventAction(
|
|
||||||
ctx,
|
|
||||||
userId,
|
|
||||||
model.Resource{
|
|
||||||
ID: params.SubmissionID,
|
|
||||||
Type: model.ResourceSubmission,
|
|
||||||
},
|
|
||||||
event_data,
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ActionSubmissionTriggerUpload invokes actionSubmissionTriggerUpload operation.
|
// ActionSubmissionTriggerUpload invokes actionSubmissionTriggerUpload operation.
|
||||||
@@ -753,18 +360,12 @@ func (svc *Service) ActionSubmissionTriggerUpload(ctx context.Context, params ap
|
|||||||
}
|
}
|
||||||
// check if caller has required role
|
// check if caller has required role
|
||||||
if !has_role {
|
if !has_role {
|
||||||
return ErrPermissionDeniedNeedRoleSubmissionUpload
|
return ErrPermissionDeniedNeedRoleMapUpload
|
||||||
}
|
|
||||||
|
|
||||||
userId, err := userInfo.GetUserID()
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// transaction
|
// transaction
|
||||||
target_status := model.SubmissionStatusUploading
|
|
||||||
smap := datastore.Optional()
|
smap := datastore.Optional()
|
||||||
smap.Add("status_id", target_status)
|
smap.Add("status_id", model.SubmissionStatusUploading)
|
||||||
submission, err := svc.DB.Submissions().IfStatusThenUpdateAndGet(ctx, params.SubmissionID, []model.SubmissionStatus{model.SubmissionStatusValidated}, smap)
|
submission, err := svc.DB.Submissions().IfStatusThenUpdateAndGet(ctx, params.SubmissionID, []model.SubmissionStatus{model.SubmissionStatusValidated}, smap)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@@ -786,28 +387,13 @@ func (svc *Service) ActionSubmissionTriggerUpload(ctx context.Context, params ap
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err = svc.Nats.Publish("maptest.submissions.upload", []byte(j))
|
svc.Nats.Publish("maptest.submissions.upload", []byte(j))
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
// refuse to operate
|
// refuse to operate
|
||||||
return ErrUploadedAssetIDAlreadyExists
|
return ErrUploadedAssetIDAlreadyExists
|
||||||
}
|
}
|
||||||
|
|
||||||
event_data := model.AuditEventDataAction{
|
return nil
|
||||||
TargetStatus: uint32(target_status),
|
|
||||||
}
|
|
||||||
|
|
||||||
return svc.CreateAuditEventAction(
|
|
||||||
ctx,
|
|
||||||
userId,
|
|
||||||
model.Resource{
|
|
||||||
ID: params.SubmissionID,
|
|
||||||
Type: model.ResourceSubmission,
|
|
||||||
},
|
|
||||||
event_data,
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ActionSubmissionValidate invokes actionSubmissionValidate operation.
|
// ActionSubmissionValidate invokes actionSubmissionValidate operation.
|
||||||
@@ -827,12 +413,7 @@ func (svc *Service) ActionSubmissionValidated(ctx context.Context, params api.Ac
|
|||||||
}
|
}
|
||||||
// check if caller has required role
|
// check if caller has required role
|
||||||
if !has_role {
|
if !has_role {
|
||||||
return ErrPermissionDeniedNeedRoleSubmissionUpload
|
return ErrPermissionDeniedNeedRoleMapUpload
|
||||||
}
|
|
||||||
|
|
||||||
userId, err := userInfo.GetUserID()
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// check when submission was updated
|
// check when submission was updated
|
||||||
@@ -846,27 +427,9 @@ func (svc *Service) ActionSubmissionValidated(ctx context.Context, params api.Ac
|
|||||||
}
|
}
|
||||||
|
|
||||||
// transaction
|
// transaction
|
||||||
target_status := model.SubmissionStatusValidated
|
|
||||||
smap := datastore.Optional()
|
smap := datastore.Optional()
|
||||||
smap.Add("status_id", target_status)
|
smap.Add("status_id", model.SubmissionStatusValidated)
|
||||||
err = svc.DB.Submissions().IfStatusThenUpdate(ctx, params.SubmissionID, []model.SubmissionStatus{model.SubmissionStatusUploading}, smap)
|
return svc.DB.Submissions().IfStatusThenUpdate(ctx, params.SubmissionID, []model.SubmissionStatus{model.SubmissionStatusUploading}, smap)
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
event_data := model.AuditEventDataAction{
|
|
||||||
TargetStatus: uint32(target_status),
|
|
||||||
}
|
|
||||||
|
|
||||||
return svc.CreateAuditEventAction(
|
|
||||||
ctx,
|
|
||||||
userId,
|
|
||||||
model.Resource{
|
|
||||||
ID: params.SubmissionID,
|
|
||||||
Type: model.ResourceSubmission,
|
|
||||||
},
|
|
||||||
event_data,
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ActionSubmissionTriggerValidate invokes actionSubmissionTriggerValidate operation.
|
// ActionSubmissionTriggerValidate invokes actionSubmissionTriggerValidate operation.
|
||||||
@@ -886,7 +449,7 @@ func (svc *Service) ActionSubmissionTriggerValidate(ctx context.Context, params
|
|||||||
}
|
}
|
||||||
// check if caller has required role
|
// check if caller has required role
|
||||||
if !has_role {
|
if !has_role {
|
||||||
return ErrPermissionDeniedNeedRoleSubmissionReview
|
return ErrPermissionDeniedNeedRoleMapReview
|
||||||
}
|
}
|
||||||
|
|
||||||
// read submission (this could be done with a transaction WHERE clause)
|
// read submission (this could be done with a transaction WHERE clause)
|
||||||
@@ -895,21 +458,18 @@ func (svc *Service) ActionSubmissionTriggerValidate(ctx context.Context, params
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
userId, err := userInfo.GetUserID()
|
has_role, err = userInfo.IsSubmitter(uint64(submission.Submitter))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// check if caller is NOT the submitter
|
// check if caller is NOT the submitter
|
||||||
has_role = userId == submission.Submitter
|
|
||||||
if has_role {
|
if has_role {
|
||||||
return ErrAcceptOwnSubmission
|
return ErrAcceptOwnSubmission
|
||||||
}
|
}
|
||||||
|
|
||||||
// transaction
|
// transaction
|
||||||
target_status := model.SubmissionStatusValidating
|
|
||||||
smap := datastore.Optional()
|
smap := datastore.Optional()
|
||||||
smap.Add("status_id", target_status)
|
smap.Add("status_id", model.SubmissionStatusValidating)
|
||||||
submission, err = svc.DB.Submissions().IfStatusThenUpdateAndGet(ctx, params.SubmissionID, []model.SubmissionStatus{model.SubmissionStatusSubmitted}, smap)
|
submission, err = svc.DB.Submissions().IfStatusThenUpdateAndGet(ctx, params.SubmissionID, []model.SubmissionStatus{model.SubmissionStatusSubmitted}, smap)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@@ -932,24 +492,9 @@ func (svc *Service) ActionSubmissionTriggerValidate(ctx context.Context, params
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err = svc.Nats.Publish("maptest.submissions.validate", []byte(j))
|
svc.Nats.Publish("maptest.submissions.validate", []byte(j))
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
event_data := model.AuditEventDataAction{
|
return nil
|
||||||
TargetStatus: uint32(target_status),
|
|
||||||
}
|
|
||||||
|
|
||||||
return svc.CreateAuditEventAction(
|
|
||||||
ctx,
|
|
||||||
userId,
|
|
||||||
model.Resource{
|
|
||||||
ID: params.SubmissionID,
|
|
||||||
Type: model.ResourceSubmission,
|
|
||||||
},
|
|
||||||
event_data,
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ActionSubmissionRetryValidate invokes actionSubmissionRetryValidate operation.
|
// ActionSubmissionRetryValidate invokes actionSubmissionRetryValidate operation.
|
||||||
@@ -969,19 +514,13 @@ func (svc *Service) ActionSubmissionRetryValidate(ctx context.Context, params ap
|
|||||||
}
|
}
|
||||||
// check if caller has required role
|
// check if caller has required role
|
||||||
if !has_role {
|
if !has_role {
|
||||||
return ErrPermissionDeniedNeedRoleSubmissionReview
|
return ErrPermissionDeniedNeedRoleMapReview
|
||||||
}
|
|
||||||
|
|
||||||
userId, err := userInfo.GetUserID()
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// transaction
|
// transaction
|
||||||
target_status := model.SubmissionStatusValidating
|
|
||||||
smap := datastore.Optional()
|
smap := datastore.Optional()
|
||||||
smap.Add("status_id", target_status)
|
smap.Add("status_id", model.SubmissionStatusValidating)
|
||||||
submission, err := svc.DB.Submissions().IfStatusThenUpdateAndGet(ctx, params.SubmissionID, []model.SubmissionStatus{model.SubmissionStatusAcceptedUnvalidated}, smap)
|
submission, err := svc.DB.Submissions().IfStatusThenUpdateAndGet(ctx, params.SubmissionID, []model.SubmissionStatus{model.SubmissionStatusAccepted}, smap)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -1003,24 +542,9 @@ func (svc *Service) ActionSubmissionRetryValidate(ctx context.Context, params ap
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err = svc.Nats.Publish("maptest.submissions.validate", []byte(j))
|
svc.Nats.Publish("maptest.submissions.validate", []byte(j))
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
event_data := model.AuditEventDataAction{
|
return nil
|
||||||
TargetStatus: uint32(target_status),
|
|
||||||
}
|
|
||||||
|
|
||||||
return svc.CreateAuditEventAction(
|
|
||||||
ctx,
|
|
||||||
userId,
|
|
||||||
model.Resource{
|
|
||||||
ID: params.SubmissionID,
|
|
||||||
Type: model.ResourceSubmission,
|
|
||||||
},
|
|
||||||
event_data,
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ActionSubmissionAccepted implements actionSubmissionAccepted operation.
|
// ActionSubmissionAccepted implements actionSubmissionAccepted operation.
|
||||||
@@ -1040,12 +564,7 @@ func (svc *Service) ActionSubmissionAccepted(ctx context.Context, params api.Act
|
|||||||
}
|
}
|
||||||
// check if caller has required role
|
// check if caller has required role
|
||||||
if !has_role {
|
if !has_role {
|
||||||
return ErrPermissionDeniedNeedRoleSubmissionReview
|
return ErrPermissionDeniedNeedRoleMapReview
|
||||||
}
|
|
||||||
|
|
||||||
userId, err := userInfo.GetUserID()
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// check when submission was updated
|
// check when submission was updated
|
||||||
@@ -1059,27 +578,10 @@ func (svc *Service) ActionSubmissionAccepted(ctx context.Context, params api.Act
|
|||||||
}
|
}
|
||||||
|
|
||||||
// transaction
|
// transaction
|
||||||
target_status := model.SubmissionStatusAcceptedUnvalidated
|
|
||||||
smap := datastore.Optional()
|
smap := datastore.Optional()
|
||||||
smap.Add("status_id", target_status)
|
smap.Add("status_id", model.SubmissionStatusAccepted)
|
||||||
err = svc.DB.Submissions().IfStatusThenUpdate(ctx, params.SubmissionID, []model.SubmissionStatus{model.SubmissionStatusValidating}, smap)
|
smap.Add("status_message", "Manually forced reset")
|
||||||
if err != nil {
|
return svc.DB.Submissions().IfStatusThenUpdate(ctx, params.SubmissionID, []model.SubmissionStatus{model.SubmissionStatusValidating}, smap)
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
event_data := model.AuditEventDataAction{
|
|
||||||
TargetStatus: uint32(target_status),
|
|
||||||
}
|
|
||||||
|
|
||||||
return svc.CreateAuditEventAction(
|
|
||||||
ctx,
|
|
||||||
userId,
|
|
||||||
model.Resource{
|
|
||||||
ID: params.SubmissionID,
|
|
||||||
Type: model.ResourceSubmission,
|
|
||||||
},
|
|
||||||
event_data,
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ReleaseSubmissions invokes releaseSubmissions operation.
|
// ReleaseSubmissions invokes releaseSubmissions operation.
|
||||||
@@ -1125,13 +627,12 @@ func (svc *Service) ReleaseSubmissions(ctx context.Context, request []api.Releas
|
|||||||
|
|
||||||
for i,submission := range submissions{
|
for i,submission := range submissions{
|
||||||
date := request[i].Date.Unix()
|
date := request[i].Date.Unix()
|
||||||
var GameID = int32(submission.GameID)
|
|
||||||
// create each map with go-grpc
|
// create each map with go-grpc
|
||||||
_, err := svc.Maps.Create(ctx, &maps.MapRequest{
|
_, err := svc.Client.Create(ctx, &maps.MapRequest{
|
||||||
ID: int64(submission.UploadedAssetID),
|
ID: submission.UploadedAssetID,
|
||||||
DisplayName: &submission.DisplayName,
|
DisplayName: &submission.DisplayName,
|
||||||
Creator: &submission.Creator,
|
Creator: &submission.Creator,
|
||||||
GameID: &GameID,
|
GameID: &submission.GameID,
|
||||||
Date: &date,
|
Date: &date,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -1149,75 +650,3 @@ func (svc *Service) ReleaseSubmissions(ctx context.Context, request []api.Releas
|
|||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// CreateSubmissionAuditComment implements createSubmissionAuditComment operation.
|
|
||||||
//
|
|
||||||
// Post a comment to the audit log
|
|
||||||
//
|
|
||||||
// POST /submissions/{SubmissionID}/comment
|
|
||||||
func (svc *Service) CreateSubmissionAuditComment(ctx context.Context, req api.CreateSubmissionAuditCommentReq, params api.CreateSubmissionAuditCommentParams) (error) {
|
|
||||||
userInfo, ok := ctx.Value("UserInfo").(UserInfoHandle)
|
|
||||||
if !ok {
|
|
||||||
return ErrUserInfo
|
|
||||||
}
|
|
||||||
|
|
||||||
has_role, err := userInfo.HasRoleSubmissionReview()
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
userId, err := userInfo.GetUserID()
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
if !has_role {
|
|
||||||
// Submitter has special permission to comment on their submission
|
|
||||||
submission, err := svc.DB.Submissions().Get(ctx, params.SubmissionID)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
if submission.Submitter != userId {
|
|
||||||
return ErrPermissionDeniedNeedRoleSubmissionReview
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
data, err := io.ReadAll(req)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
event_data := model.AuditEventDataComment{
|
|
||||||
Comment: string(data),
|
|
||||||
}
|
|
||||||
|
|
||||||
return svc.CreateAuditEventComment(
|
|
||||||
ctx,
|
|
||||||
userId,
|
|
||||||
model.Resource{
|
|
||||||
ID: params.SubmissionID,
|
|
||||||
Type: model.ResourceSubmission,
|
|
||||||
},
|
|
||||||
event_data,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
// ListSubmissionAuditEvents invokes listSubmissionAuditEvents operation.
|
|
||||||
//
|
|
||||||
// Retrieve a list of audit events.
|
|
||||||
//
|
|
||||||
// GET /submissions/{SubmissionID}/audit-events
|
|
||||||
func (svc *Service) ListSubmissionAuditEvents(ctx context.Context, params api.ListSubmissionAuditEventsParams) ([]api.AuditEvent, error) {
|
|
||||||
return svc.ListAuditEvents(
|
|
||||||
ctx,
|
|
||||||
model.Resource{
|
|
||||||
ID: params.SubmissionID,
|
|
||||||
Type: model.ResourceSubmission,
|
|
||||||
},
|
|
||||||
model.Page{
|
|
||||||
Number: params.Page,
|
|
||||||
Size: params.Limit,
|
|
||||||
},
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,92 +0,0 @@
|
|||||||
package service_internal
|
|
||||||
|
|
||||||
import (
|
|
||||||
"context"
|
|
||||||
"encoding/json"
|
|
||||||
|
|
||||||
"git.itzana.me/strafesnet/maps-service/pkg/model"
|
|
||||||
)
|
|
||||||
|
|
||||||
func (svc *Service) CreateAuditEventAction(ctx context.Context, userId uint64, resource model.Resource, event_data model.AuditEventDataAction) error {
|
|
||||||
EventData, err := json.Marshal(event_data)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
_, err = svc.DB.AuditEvents().Create(ctx, model.AuditEvent{
|
|
||||||
ID: 0,
|
|
||||||
User: userId,
|
|
||||||
ResourceType: resource.Type,
|
|
||||||
ResourceID: resource.ID,
|
|
||||||
EventType: model.AuditEventTypeAction,
|
|
||||||
EventData: EventData,
|
|
||||||
})
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (svc *Service) CreateAuditEventChangeValidatedModel(ctx context.Context, userId uint64, resource model.Resource, event_data model.AuditEventDataChangeValidatedModel) error {
|
|
||||||
EventData, err := json.Marshal(event_data)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
_, err = svc.DB.AuditEvents().Create(ctx, model.AuditEvent{
|
|
||||||
ID: 0,
|
|
||||||
User: userId,
|
|
||||||
ResourceType: resource.Type,
|
|
||||||
ResourceID: resource.ID,
|
|
||||||
EventType: model.AuditEventTypeChangeValidatedModel,
|
|
||||||
EventData: EventData,
|
|
||||||
})
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (svc *Service) CreateAuditEventError(ctx context.Context, userId uint64, resource model.Resource, event_data model.AuditEventDataError) error {
|
|
||||||
EventData, err := json.Marshal(event_data)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
_, err = svc.DB.AuditEvents().Create(ctx, model.AuditEvent{
|
|
||||||
ID: 0,
|
|
||||||
User: userId,
|
|
||||||
ResourceType: resource.Type,
|
|
||||||
ResourceID: resource.ID,
|
|
||||||
EventType: model.AuditEventTypeError,
|
|
||||||
EventData: EventData,
|
|
||||||
})
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (svc *Service) CreateAuditEventCheckList(ctx context.Context, userId uint64, resource model.Resource, event_data model.AuditEventDataCheckList) error {
|
|
||||||
EventData, err := json.Marshal(event_data)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
_, err = svc.DB.AuditEvents().Create(ctx, model.AuditEvent{
|
|
||||||
ID: 0,
|
|
||||||
User: userId,
|
|
||||||
ResourceType: resource.Type,
|
|
||||||
ResourceID: resource.ID,
|
|
||||||
EventType: model.AuditEventTypeCheckList,
|
|
||||||
EventData: EventData,
|
|
||||||
})
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
@@ -16,7 +16,7 @@ var(
|
|||||||
model.MapfixStatusUploading,
|
model.MapfixStatusUploading,
|
||||||
model.MapfixStatusValidated,
|
model.MapfixStatusValidated,
|
||||||
model.MapfixStatusValidating,
|
model.MapfixStatusValidating,
|
||||||
model.MapfixStatusAcceptedUnvalidated,
|
model.MapfixStatusAccepted,
|
||||||
model.MapfixStatusChangesRequested,
|
model.MapfixStatusChangesRequested,
|
||||||
model.MapfixStatusSubmitted,
|
model.MapfixStatusSubmitted,
|
||||||
model.MapfixStatusUnderConstruction,
|
model.MapfixStatusUnderConstruction,
|
||||||
@@ -34,98 +34,13 @@ var(
|
|||||||
//
|
//
|
||||||
// POST /mapfixes/{MapfixID}/validated-model
|
// POST /mapfixes/{MapfixID}/validated-model
|
||||||
func (svc *Service) UpdateMapfixValidatedModel(ctx context.Context, params internal.UpdateMapfixValidatedModelParams) error {
|
func (svc *Service) UpdateMapfixValidatedModel(ctx context.Context, params internal.UpdateMapfixValidatedModelParams) error {
|
||||||
ValidatedModelID := uint64(params.ValidatedModelID)
|
|
||||||
ValidatedModelVersion := uint64(params.ValidatedModelVersion)
|
|
||||||
|
|
||||||
// check if Status is ChangesRequested|Submitted|UnderConstruction
|
// check if Status is ChangesRequested|Submitted|UnderConstruction
|
||||||
pmap := datastore.Optional()
|
pmap := datastore.Optional()
|
||||||
pmap.Add("validated_asset_id", ValidatedModelID)
|
pmap.AddNotNil("validated_asset_id", params.ValidatedModelID)
|
||||||
pmap.Add("validated_asset_version", ValidatedModelVersion)
|
pmap.AddNotNil("validated_asset_version", params.ValidatedModelVersion)
|
||||||
// DO NOT reset completed when validated model is updated
|
// DO NOT reset completed when validated model is updated
|
||||||
// pmap.Add("completed", false)
|
// pmap.Add("completed", false)
|
||||||
err := svc.DB.Mapfixes().IfStatusThenUpdate(ctx, params.MapfixID, []model.MapfixStatus{model.MapfixStatusValidating}, pmap)
|
return svc.DB.Mapfixes().IfStatusThenUpdate(ctx, params.MapfixID, []model.MapfixStatus{model.MapfixStatusValidating}, pmap)
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
event_data := model.AuditEventDataChangeValidatedModel{
|
|
||||||
ValidatedModelID: ValidatedModelID,
|
|
||||||
ValidatedModelVersion: ValidatedModelVersion,
|
|
||||||
}
|
|
||||||
|
|
||||||
return svc.CreateAuditEventChangeValidatedModel(
|
|
||||||
ctx,
|
|
||||||
ValidtorUserID,
|
|
||||||
model.Resource{
|
|
||||||
ID: params.MapfixID,
|
|
||||||
Type: model.ResourceMapfix,
|
|
||||||
},
|
|
||||||
event_data,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
// ActionMapfixSubmitted invokes actionMapfixSubmitted operation.
|
|
||||||
//
|
|
||||||
// Role Validator changes status from Submitting -> Submitted.
|
|
||||||
//
|
|
||||||
// POST /mapfixes/{MapfixID}/status/validator-submitted
|
|
||||||
func (svc *Service) ActionMapfixSubmitted(ctx context.Context, params internal.ActionMapfixSubmittedParams) error {
|
|
||||||
// transaction
|
|
||||||
target_status := model.MapfixStatusSubmitted
|
|
||||||
smap := datastore.Optional()
|
|
||||||
smap.Add("status_id", target_status)
|
|
||||||
smap.Add("asset_version", params.ModelVersion)
|
|
||||||
smap.Add("display_name", params.DisplayName)
|
|
||||||
smap.Add("creator", params.Creator)
|
|
||||||
smap.Add("game_id", params.GameID)
|
|
||||||
err := svc.DB.Mapfixes().IfStatusThenUpdate(ctx, params.MapfixID, []model.MapfixStatus{model.MapfixStatusSubmitting}, smap)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
event_data := model.AuditEventDataAction{
|
|
||||||
TargetStatus: uint32(target_status),
|
|
||||||
}
|
|
||||||
|
|
||||||
return svc.CreateAuditEventAction(
|
|
||||||
ctx,
|
|
||||||
ValidtorUserID,
|
|
||||||
model.Resource{
|
|
||||||
ID: params.MapfixID,
|
|
||||||
Type: model.ResourceMapfix,
|
|
||||||
},
|
|
||||||
event_data,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
// ActionMapfixRequestChanges implements actionMapfixRequestChanges operation.
|
|
||||||
//
|
|
||||||
// (Internal endpoint) Role Validator changes status from Submitting -> RequestChanges.
|
|
||||||
//
|
|
||||||
// POST /mapfixes/{MapfixID}/status/validator-request-changes
|
|
||||||
func (svc *Service) ActionMapfixRequestChanges(ctx context.Context, params internal.ActionMapfixRequestChangesParams) error {
|
|
||||||
// transaction
|
|
||||||
target_status := model.MapfixStatusChangesRequested
|
|
||||||
smap := datastore.Optional()
|
|
||||||
smap.Add("status_id", target_status)
|
|
||||||
err := svc.DB.Mapfixes().IfStatusThenUpdate(ctx, params.MapfixID, []model.MapfixStatus{model.MapfixStatusSubmitting}, smap)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
event_data := model.AuditEventDataAction{
|
|
||||||
TargetStatus: uint32(target_status),
|
|
||||||
}
|
|
||||||
|
|
||||||
return svc.CreateAuditEventAction(
|
|
||||||
ctx,
|
|
||||||
ValidtorUserID,
|
|
||||||
model.Resource{
|
|
||||||
ID: params.MapfixID,
|
|
||||||
Type: model.ResourceMapfix,
|
|
||||||
},
|
|
||||||
event_data,
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ActionMapfixValidate invokes actionMapfixValidate operation.
|
// ActionMapfixValidate invokes actionMapfixValidate operation.
|
||||||
@@ -147,28 +62,10 @@ func (svc *Service) ActionMapfixValidated(ctx context.Context, params internal.A
|
|||||||
// POST /mapfixes/{MapfixID}/status/validator-failed
|
// POST /mapfixes/{MapfixID}/status/validator-failed
|
||||||
func (svc *Service) ActionMapfixAccepted(ctx context.Context, params internal.ActionMapfixAcceptedParams) error {
|
func (svc *Service) ActionMapfixAccepted(ctx context.Context, params internal.ActionMapfixAcceptedParams) error {
|
||||||
// transaction
|
// transaction
|
||||||
target_status := model.MapfixStatusAcceptedUnvalidated
|
|
||||||
smap := datastore.Optional()
|
smap := datastore.Optional()
|
||||||
smap.Add("status_id", target_status)
|
smap.Add("status_id", model.MapfixStatusAccepted)
|
||||||
err := svc.DB.Mapfixes().IfStatusThenUpdate(ctx, params.MapfixID, []model.MapfixStatus{model.MapfixStatusValidating}, smap)
|
smap.Add("status_message", params.StatusMessage)
|
||||||
if err != nil {
|
return svc.DB.Mapfixes().IfStatusThenUpdate(ctx, params.MapfixID, []model.MapfixStatus{model.MapfixStatusValidating}, smap)
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
// push an action audit event
|
|
||||||
event_data := model.AuditEventDataAction{
|
|
||||||
TargetStatus: uint32(target_status),
|
|
||||||
}
|
|
||||||
|
|
||||||
return svc.CreateAuditEventAction(
|
|
||||||
ctx,
|
|
||||||
ValidtorUserID,
|
|
||||||
model.Resource{
|
|
||||||
ID: params.MapfixID,
|
|
||||||
Type: model.ResourceMapfix,
|
|
||||||
},
|
|
||||||
event_data,
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ActionMapfixUploaded implements actionMapfixUploaded operation.
|
// ActionMapfixUploaded implements actionMapfixUploaded operation.
|
||||||
@@ -178,96 +75,13 @@ func (svc *Service) ActionMapfixAccepted(ctx context.Context, params internal.Ac
|
|||||||
// POST /mapfixes/{MapfixID}/status/validator-uploaded
|
// POST /mapfixes/{MapfixID}/status/validator-uploaded
|
||||||
func (svc *Service) ActionMapfixUploaded(ctx context.Context, params internal.ActionMapfixUploadedParams) error {
|
func (svc *Service) ActionMapfixUploaded(ctx context.Context, params internal.ActionMapfixUploadedParams) error {
|
||||||
// transaction
|
// transaction
|
||||||
target_status := model.MapfixStatusUploaded
|
|
||||||
smap := datastore.Optional()
|
smap := datastore.Optional()
|
||||||
smap.Add("status_id", target_status)
|
smap.Add("status_id", model.MapfixStatusUploaded)
|
||||||
err := svc.DB.Mapfixes().IfStatusThenUpdate(ctx, params.MapfixID, []model.MapfixStatus{model.MapfixStatusUploading}, smap)
|
return svc.DB.Mapfixes().IfStatusThenUpdate(ctx, params.MapfixID, []model.MapfixStatus{model.MapfixStatusUploading}, smap)
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
event_data := model.AuditEventDataAction{
|
|
||||||
TargetStatus: uint32(target_status),
|
|
||||||
}
|
|
||||||
|
|
||||||
return svc.CreateAuditEventAction(
|
|
||||||
ctx,
|
|
||||||
ValidtorUserID,
|
|
||||||
model.Resource{
|
|
||||||
ID: params.MapfixID,
|
|
||||||
Type: model.ResourceMapfix,
|
|
||||||
},
|
|
||||||
event_data,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
// CreateMapfixAuditError implements createMapfixAuditError operation.
|
|
||||||
//
|
|
||||||
// Post an error to the audit log
|
|
||||||
//
|
|
||||||
// POST /mapfixes/{MapfixID}/error
|
|
||||||
func (svc *Service) CreateMapfixAuditError(ctx context.Context, params internal.CreateMapfixAuditErrorParams) (error) {
|
|
||||||
event_data := model.AuditEventDataError{
|
|
||||||
Error: params.ErrorMessage,
|
|
||||||
}
|
|
||||||
|
|
||||||
return svc.CreateAuditEventError(
|
|
||||||
ctx,
|
|
||||||
ValidtorUserID,
|
|
||||||
model.Resource{
|
|
||||||
ID: params.MapfixID,
|
|
||||||
Type: model.ResourceMapfix,
|
|
||||||
},
|
|
||||||
event_data,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
// CreateMapfixAuditCheckList implements createMapfixAuditCheckList operation.
|
|
||||||
//
|
|
||||||
// Post a checklist to the audit log
|
|
||||||
//
|
|
||||||
// POST /mapfixes/{MapfixID}/checklist
|
|
||||||
func (svc *Service) CreateMapfixAuditCheckList(ctx context.Context, check_list internal.CheckList, params internal.CreateMapfixAuditCheckListParams) (error) {
|
|
||||||
check_list2 := make([]model.Check, len(check_list))
|
|
||||||
for i, check := range check_list {
|
|
||||||
check_list2[i] = model.Check{
|
|
||||||
Name: check.Name,
|
|
||||||
Summary: check.Summary,
|
|
||||||
Passed: check.Passed,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
event_data := model.AuditEventDataCheckList{
|
|
||||||
CheckList: check_list2,
|
|
||||||
}
|
|
||||||
|
|
||||||
return svc.CreateAuditEventCheckList(
|
|
||||||
ctx,
|
|
||||||
ValidtorUserID,
|
|
||||||
model.Resource{
|
|
||||||
ID: params.MapfixID,
|
|
||||||
Type: model.ResourceMapfix,
|
|
||||||
},
|
|
||||||
event_data,
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// POST /mapfixes
|
// POST /mapfixes
|
||||||
func (svc *Service) CreateMapfix(ctx context.Context, request *internal.MapfixCreate) (*internal.MapfixID, error) {
|
func (svc *Service) CreateMapfix(ctx context.Context, request *internal.MapfixCreate) (*internal.MapfixID, error) {
|
||||||
// sanitization
|
|
||||||
if request.GameID<0||
|
|
||||||
request.AssetOwner<0||
|
|
||||||
request.AssetID<0||
|
|
||||||
request.AssetVersion<0||
|
|
||||||
request.TargetAssetID<0{
|
|
||||||
return nil, ErrNegativeID
|
|
||||||
}
|
|
||||||
var GameID=uint32(request.GameID);
|
|
||||||
var Submitter=uint64(request.AssetOwner);
|
|
||||||
var AssetID=uint64(request.AssetID);
|
|
||||||
var AssetVersion=uint64(request.AssetVersion);
|
|
||||||
var TargetAssetID=uint64(request.TargetAssetID);
|
|
||||||
|
|
||||||
// Check if an active mapfix with the same asset id exists
|
// Check if an active mapfix with the same asset id exists
|
||||||
{
|
{
|
||||||
filter := datastore.Optional()
|
filter := datastore.Optional()
|
||||||
@@ -293,7 +107,7 @@ func (svc *Service) CreateMapfix(ctx context.Context, request *internal.MapfixCr
|
|||||||
|
|
||||||
// check if user owns asset
|
// check if user owns asset
|
||||||
// TODO: allow bypass by admin
|
// TODO: allow bypass by admin
|
||||||
if operation.Owner != Submitter {
|
if operation.Owner != request.AssetOwner {
|
||||||
return nil, ErrNotAssetOwner
|
return nil, ErrNotAssetOwner
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -301,14 +115,13 @@ func (svc *Service) CreateMapfix(ctx context.Context, request *internal.MapfixCr
|
|||||||
ID: 0,
|
ID: 0,
|
||||||
DisplayName: request.DisplayName,
|
DisplayName: request.DisplayName,
|
||||||
Creator: request.Creator,
|
Creator: request.Creator,
|
||||||
GameID: GameID,
|
GameID: request.GameID,
|
||||||
Submitter: Submitter,
|
Submitter: request.AssetOwner,
|
||||||
AssetID: AssetID,
|
AssetID: request.AssetID,
|
||||||
AssetVersion: AssetVersion,
|
AssetVersion: request.AssetVersion,
|
||||||
Completed: false,
|
Completed: false,
|
||||||
TargetAssetID: TargetAssetID,
|
TargetAssetID: request.TargetAssetID,
|
||||||
StatusID: model.MapfixStatusUnderConstruction,
|
StatusID: model.MapfixStatusUnderConstruction,
|
||||||
Description: request.Description,
|
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
|
|
||||||
"git.itzana.me/strafesnet/maps-service/pkg/datastore"
|
"git.itzana.me/strafesnet/maps-service/pkg/datastore"
|
||||||
api "git.itzana.me/strafesnet/maps-service/pkg/internal"
|
"git.itzana.me/strafesnet/maps-service/pkg/internal"
|
||||||
"git.itzana.me/strafesnet/maps-service/pkg/model"
|
"git.itzana.me/strafesnet/maps-service/pkg/model"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -49,13 +49,13 @@ func (svc *Service) ListScriptPolicy(ctx context.Context, params api.ListScriptP
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
filter.Add("from_script_hash", int64(hash)) // No type safety!
|
filter.AddNotNil("from_script_hash", int64(hash)) // No type safety!
|
||||||
}
|
}
|
||||||
if params.ToScriptID.IsSet(){
|
if params.ToScriptID.IsSet(){
|
||||||
filter.Add("to_script_id", params.ToScriptID.Value)
|
filter.AddNotNil("to_script_id", params.ToScriptID.Value)
|
||||||
}
|
}
|
||||||
if params.Policy.IsSet(){
|
if params.Policy.IsSet(){
|
||||||
filter.Add("policy", params.Policy.Value)
|
filter.AddNotNil("policy", params.Policy.Value)
|
||||||
}
|
}
|
||||||
|
|
||||||
items, err := svc.DB.ScriptPolicy().List(ctx, filter, model.Page{
|
items, err := svc.DB.ScriptPolicy().List(ctx, filter, model.Page{
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
|
|
||||||
"git.itzana.me/strafesnet/maps-service/pkg/datastore"
|
"git.itzana.me/strafesnet/maps-service/pkg/datastore"
|
||||||
api "git.itzana.me/strafesnet/maps-service/pkg/internal"
|
"git.itzana.me/strafesnet/maps-service/pkg/internal"
|
||||||
"git.itzana.me/strafesnet/maps-service/pkg/model"
|
"git.itzana.me/strafesnet/maps-service/pkg/model"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -44,19 +44,19 @@ func (svc *Service) ListScripts(ctx context.Context, params api.ListScriptsParam
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
filter.Add("hash", int64(hash)) // No type safety!
|
filter.AddNotNil("hash", int64(hash)) // No type safety!
|
||||||
}
|
}
|
||||||
if params.Name.IsSet(){
|
if params.Name.IsSet(){
|
||||||
filter.Add("name", params.Name.Value)
|
filter.AddNotNil("name", params.Name.Value)
|
||||||
}
|
}
|
||||||
if params.Source.IsSet(){
|
if params.Source.IsSet(){
|
||||||
filter.Add("source", params.Source.Value)
|
filter.AddNotNil("source", params.Source.Value)
|
||||||
}
|
}
|
||||||
if params.ResourceType.IsSet(){
|
if params.ResourceType.IsSet(){
|
||||||
filter.Add("resource_type", params.ResourceType.Value)
|
filter.AddNotNil("resource_type", params.ResourceType.Value)
|
||||||
}
|
}
|
||||||
if params.ResourceID.IsSet(){
|
if params.ResourceID.IsSet(){
|
||||||
filter.Add("resource_id", params.ResourceID.Value)
|
filter.AddNotNil("resource_id", params.ResourceID.Value)
|
||||||
}
|
}
|
||||||
|
|
||||||
items, err := svc.DB.Scripts().List(ctx, filter, model.Page{
|
items, err := svc.DB.Scripts().List(ctx, filter, model.Page{
|
||||||
@@ -71,7 +71,6 @@ func (svc *Service) ListScripts(ctx context.Context, params api.ListScriptsParam
|
|||||||
for _, item := range items {
|
for _, item := range items {
|
||||||
resp = append(resp, api.Script{
|
resp = append(resp, api.Script{
|
||||||
ID: item.ID,
|
ID: item.ID,
|
||||||
Name: item.Name,
|
|
||||||
Hash: model.HashFormat(uint64(item.Hash)),
|
Hash: model.HashFormat(uint64(item.Hash)),
|
||||||
Source: item.Source,
|
Source: item.Source,
|
||||||
ResourceType: int32(item.ResourceType),
|
ResourceType: int32(item.ResourceType),
|
||||||
|
|||||||
@@ -3,21 +3,12 @@ package service_internal
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
"math"
|
|
||||||
|
|
||||||
"git.itzana.me/strafesnet/maps-service/pkg/datastore"
|
"git.itzana.me/strafesnet/maps-service/pkg/datastore"
|
||||||
internal "git.itzana.me/strafesnet/maps-service/pkg/internal"
|
internal "git.itzana.me/strafesnet/maps-service/pkg/internal"
|
||||||
"github.com/nats-io/nats.go"
|
"github.com/nats-io/nats.go"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
|
||||||
ValidtorUserID uint64 = uint64(math.MaxInt64)
|
|
||||||
)
|
|
||||||
|
|
||||||
var (
|
|
||||||
ErrNegativeID = errors.New("A negative ID was provided")
|
|
||||||
)
|
|
||||||
|
|
||||||
type Service struct {
|
type Service struct {
|
||||||
DB datastore.Datastore
|
DB datastore.Datastore
|
||||||
Nats nats.JetStreamContext
|
Nats nats.JetStreamContext
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ import (
|
|||||||
"git.itzana.me/strafesnet/maps-service/pkg/datastore"
|
"git.itzana.me/strafesnet/maps-service/pkg/datastore"
|
||||||
internal "git.itzana.me/strafesnet/maps-service/pkg/internal"
|
internal "git.itzana.me/strafesnet/maps-service/pkg/internal"
|
||||||
"git.itzana.me/strafesnet/maps-service/pkg/model"
|
"git.itzana.me/strafesnet/maps-service/pkg/model"
|
||||||
"git.itzana.me/strafesnet/maps-service/pkg/service"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var(
|
var(
|
||||||
@@ -17,7 +16,7 @@ var(
|
|||||||
model.SubmissionStatusUploading,
|
model.SubmissionStatusUploading,
|
||||||
model.SubmissionStatusValidated,
|
model.SubmissionStatusValidated,
|
||||||
model.SubmissionStatusValidating,
|
model.SubmissionStatusValidating,
|
||||||
model.SubmissionStatusAcceptedUnvalidated,
|
model.SubmissionStatusAccepted,
|
||||||
model.SubmissionStatusChangesRequested,
|
model.SubmissionStatusChangesRequested,
|
||||||
model.SubmissionStatusSubmitted,
|
model.SubmissionStatusSubmitted,
|
||||||
model.SubmissionStatusUnderConstruction,
|
model.SubmissionStatusUnderConstruction,
|
||||||
@@ -34,99 +33,13 @@ var(
|
|||||||
//
|
//
|
||||||
// POST /submissions/{SubmissionID}/validated-model
|
// POST /submissions/{SubmissionID}/validated-model
|
||||||
func (svc *Service) UpdateSubmissionValidatedModel(ctx context.Context, params internal.UpdateSubmissionValidatedModelParams) error {
|
func (svc *Service) UpdateSubmissionValidatedModel(ctx context.Context, params internal.UpdateSubmissionValidatedModelParams) error {
|
||||||
ValidatedModelID := uint64(params.ValidatedModelID)
|
|
||||||
ValidatedModelVersion := uint64(params.ValidatedModelVersion)
|
|
||||||
|
|
||||||
// check if Status is ChangesRequested|Submitted|UnderConstruction
|
// check if Status is ChangesRequested|Submitted|UnderConstruction
|
||||||
pmap := datastore.Optional()
|
pmap := datastore.Optional()
|
||||||
pmap.Add("validated_asset_id", ValidatedModelID)
|
pmap.AddNotNil("validated_asset_id", params.ValidatedModelID)
|
||||||
pmap.Add("validated_asset_version", ValidatedModelVersion)
|
pmap.AddNotNil("validated_asset_version", params.ValidatedModelVersion)
|
||||||
// DO NOT reset completed when validated model is updated
|
// DO NOT reset completed when validated model is updated
|
||||||
// pmap.Add("completed", false)
|
// pmap.Add("completed", false)
|
||||||
err := svc.DB.Submissions().IfStatusThenUpdate(ctx, params.SubmissionID, []model.SubmissionStatus{model.SubmissionStatusValidating}, pmap)
|
return svc.DB.Submissions().IfStatusThenUpdate(ctx, params.SubmissionID, []model.SubmissionStatus{model.SubmissionStatusValidating}, pmap)
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
event_data := model.AuditEventDataChangeValidatedModel{
|
|
||||||
ValidatedModelID: ValidatedModelID,
|
|
||||||
ValidatedModelVersion: ValidatedModelVersion,
|
|
||||||
}
|
|
||||||
|
|
||||||
return svc.CreateAuditEventChangeValidatedModel(
|
|
||||||
ctx,
|
|
||||||
ValidtorUserID,
|
|
||||||
model.Resource{
|
|
||||||
ID: params.SubmissionID,
|
|
||||||
Type: model.ResourceSubmission,
|
|
||||||
},
|
|
||||||
event_data,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
// ActionSubmissionSubmitted invokes actionSubmissionSubmitted operation.
|
|
||||||
//
|
|
||||||
// Role Validator changes status from Submitting -> Submitted.
|
|
||||||
//
|
|
||||||
// POST /submissions/{SubmissionID}/status/validator-submitted
|
|
||||||
func (svc *Service) ActionSubmissionSubmitted(ctx context.Context, params internal.ActionSubmissionSubmittedParams) error {
|
|
||||||
// transaction
|
|
||||||
target_status := model.SubmissionStatusSubmitted
|
|
||||||
smap := datastore.Optional()
|
|
||||||
smap.Add("status_id", target_status)
|
|
||||||
smap.Add("asset_version", params.ModelVersion)
|
|
||||||
smap.Add("display_name", params.DisplayName)
|
|
||||||
smap.Add("creator", params.Creator)
|
|
||||||
smap.Add("game_id", params.GameID)
|
|
||||||
err := svc.DB.Submissions().IfStatusThenUpdate(ctx, params.SubmissionID, []model.SubmissionStatus{model.SubmissionStatusSubmitting}, smap)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
event_data := model.AuditEventDataAction{
|
|
||||||
TargetStatus: uint32(target_status),
|
|
||||||
}
|
|
||||||
|
|
||||||
return svc.CreateAuditEventAction(
|
|
||||||
ctx,
|
|
||||||
ValidtorUserID,
|
|
||||||
model.Resource{
|
|
||||||
ID: params.SubmissionID,
|
|
||||||
Type: model.ResourceSubmission,
|
|
||||||
},
|
|
||||||
event_data,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
// ActionSubmissionRequestChanges implements actionSubmissionRequestChanges operation.
|
|
||||||
//
|
|
||||||
// (Internal endpoint) Role Validator changes status from Submitting -> RequestChanges.
|
|
||||||
//
|
|
||||||
// POST /submissions/{SubmissionID}/status/validator-request-changes
|
|
||||||
func (svc *Service) ActionSubmissionRequestChanges(ctx context.Context, params internal.ActionSubmissionRequestChangesParams) error {
|
|
||||||
// transaction
|
|
||||||
target_status := model.SubmissionStatusChangesRequested
|
|
||||||
smap := datastore.Optional()
|
|
||||||
smap.Add("status_id", target_status)
|
|
||||||
err := svc.DB.Submissions().IfStatusThenUpdate(ctx, params.SubmissionID, []model.SubmissionStatus{model.SubmissionStatusSubmitting}, smap)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
// push an action audit event
|
|
||||||
event_data := model.AuditEventDataAction{
|
|
||||||
TargetStatus: uint32(target_status),
|
|
||||||
}
|
|
||||||
|
|
||||||
return svc.CreateAuditEventAction(
|
|
||||||
ctx,
|
|
||||||
ValidtorUserID,
|
|
||||||
model.Resource{
|
|
||||||
ID: params.SubmissionID,
|
|
||||||
Type: model.ResourceSubmission,
|
|
||||||
},
|
|
||||||
event_data,
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ActionSubmissionValidate invokes actionSubmissionValidate operation.
|
// ActionSubmissionValidate invokes actionSubmissionValidate operation.
|
||||||
@@ -136,27 +49,9 @@ func (svc *Service) ActionSubmissionRequestChanges(ctx context.Context, params i
|
|||||||
// POST /submissions/{SubmissionID}/status/validator-validated
|
// POST /submissions/{SubmissionID}/status/validator-validated
|
||||||
func (svc *Service) ActionSubmissionValidated(ctx context.Context, params internal.ActionSubmissionValidatedParams) error {
|
func (svc *Service) ActionSubmissionValidated(ctx context.Context, params internal.ActionSubmissionValidatedParams) error {
|
||||||
// transaction
|
// transaction
|
||||||
target_status := model.SubmissionStatusValidated
|
|
||||||
smap := datastore.Optional()
|
smap := datastore.Optional()
|
||||||
smap.Add("status_id", target_status)
|
smap.Add("status_id", model.SubmissionStatusValidated)
|
||||||
err := svc.DB.Submissions().IfStatusThenUpdate(ctx, params.SubmissionID, []model.SubmissionStatus{model.SubmissionStatusValidating}, smap)
|
return svc.DB.Submissions().IfStatusThenUpdate(ctx, params.SubmissionID, []model.SubmissionStatus{model.SubmissionStatusValidating}, smap)
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
event_data := model.AuditEventDataAction{
|
|
||||||
TargetStatus: uint32(target_status),
|
|
||||||
}
|
|
||||||
|
|
||||||
return svc.CreateAuditEventAction(
|
|
||||||
ctx,
|
|
||||||
ValidtorUserID,
|
|
||||||
model.Resource{
|
|
||||||
ID: params.SubmissionID,
|
|
||||||
Type: model.ResourceSubmission,
|
|
||||||
},
|
|
||||||
event_data,
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ActionSubmissionAccepted implements actionSubmissionAccepted operation.
|
// ActionSubmissionAccepted implements actionSubmissionAccepted operation.
|
||||||
@@ -166,28 +61,10 @@ func (svc *Service) ActionSubmissionValidated(ctx context.Context, params intern
|
|||||||
// POST /submissions/{SubmissionID}/status/validator-failed
|
// POST /submissions/{SubmissionID}/status/validator-failed
|
||||||
func (svc *Service) ActionSubmissionAccepted(ctx context.Context, params internal.ActionSubmissionAcceptedParams) error {
|
func (svc *Service) ActionSubmissionAccepted(ctx context.Context, params internal.ActionSubmissionAcceptedParams) error {
|
||||||
// transaction
|
// transaction
|
||||||
target_status := model.SubmissionStatusAcceptedUnvalidated
|
|
||||||
smap := datastore.Optional()
|
smap := datastore.Optional()
|
||||||
smap.Add("status_id", target_status)
|
smap.Add("status_id", model.SubmissionStatusAccepted)
|
||||||
err := svc.DB.Submissions().IfStatusThenUpdate(ctx, params.SubmissionID, []model.SubmissionStatus{model.SubmissionStatusValidating}, smap)
|
smap.Add("status_message", params.StatusMessage)
|
||||||
if err != nil {
|
return svc.DB.Submissions().IfStatusThenUpdate(ctx, params.SubmissionID, []model.SubmissionStatus{model.SubmissionStatusValidating}, smap)
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
// push an action audit event
|
|
||||||
event_data := model.AuditEventDataAction{
|
|
||||||
TargetStatus: uint32(target_status),
|
|
||||||
}
|
|
||||||
|
|
||||||
return svc.CreateAuditEventAction(
|
|
||||||
ctx,
|
|
||||||
ValidtorUserID,
|
|
||||||
model.Resource{
|
|
||||||
ID: params.SubmissionID,
|
|
||||||
Type: model.ResourceSubmission,
|
|
||||||
},
|
|
||||||
event_data,
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ActionSubmissionUploaded implements actionSubmissionUploaded operation.
|
// ActionSubmissionUploaded implements actionSubmissionUploaded operation.
|
||||||
@@ -197,97 +74,14 @@ func (svc *Service) ActionSubmissionAccepted(ctx context.Context, params interna
|
|||||||
// POST /submissions/{SubmissionID}/status/validator-uploaded
|
// POST /submissions/{SubmissionID}/status/validator-uploaded
|
||||||
func (svc *Service) ActionSubmissionUploaded(ctx context.Context, params internal.ActionSubmissionUploadedParams) error {
|
func (svc *Service) ActionSubmissionUploaded(ctx context.Context, params internal.ActionSubmissionUploadedParams) error {
|
||||||
// transaction
|
// transaction
|
||||||
target_status := model.SubmissionStatusUploaded
|
|
||||||
smap := datastore.Optional()
|
smap := datastore.Optional()
|
||||||
smap.Add("status_id", target_status)
|
smap.Add("status_id", model.SubmissionStatusUploaded)
|
||||||
smap.Add("uploaded_asset_id", params.UploadedAssetID)
|
smap.Add("uploaded_asset_id", params.UploadedAssetID)
|
||||||
err := svc.DB.Submissions().IfStatusThenUpdate(ctx, params.SubmissionID, []model.SubmissionStatus{model.SubmissionStatusUploading}, smap)
|
return svc.DB.Submissions().IfStatusThenUpdate(ctx, params.SubmissionID, []model.SubmissionStatus{model.SubmissionStatusUploading}, smap)
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
event_data := model.AuditEventDataAction{
|
|
||||||
TargetStatus: uint32(target_status),
|
|
||||||
}
|
|
||||||
|
|
||||||
return svc.CreateAuditEventAction(
|
|
||||||
ctx,
|
|
||||||
ValidtorUserID,
|
|
||||||
model.Resource{
|
|
||||||
ID: params.SubmissionID,
|
|
||||||
Type: model.ResourceSubmission,
|
|
||||||
},
|
|
||||||
event_data,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
// CreateSubmissionAuditError implements createSubmissionAuditError operation.
|
|
||||||
//
|
|
||||||
// Post an error to the audit log
|
|
||||||
//
|
|
||||||
// POST /submissions/{SubmissionID}/error
|
|
||||||
func (svc *Service) CreateSubmissionAuditError(ctx context.Context, params internal.CreateSubmissionAuditErrorParams) (error) {
|
|
||||||
event_data := model.AuditEventDataError{
|
|
||||||
Error: params.ErrorMessage,
|
|
||||||
}
|
|
||||||
|
|
||||||
return svc.CreateAuditEventError(
|
|
||||||
ctx,
|
|
||||||
ValidtorUserID,
|
|
||||||
model.Resource{
|
|
||||||
ID: params.SubmissionID,
|
|
||||||
Type: model.ResourceSubmission,
|
|
||||||
},
|
|
||||||
event_data,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
// CreateSubmissionAuditCheckList implements createSubmissionAuditCheckList operation.
|
|
||||||
//
|
|
||||||
// Post a checklist to the audit log
|
|
||||||
//
|
|
||||||
// POST /submissions/{SubmissionID}/checklist
|
|
||||||
func (svc *Service) CreateSubmissionAuditCheckList(ctx context.Context, check_list internal.CheckList, params internal.CreateSubmissionAuditCheckListParams) (error) {
|
|
||||||
check_list2 := make([]model.Check, len(check_list))
|
|
||||||
for i, check := range check_list {
|
|
||||||
check_list2[i] = model.Check{
|
|
||||||
Name: check.Name,
|
|
||||||
Summary: check.Summary,
|
|
||||||
Passed: check.Passed,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
event_data := model.AuditEventDataCheckList{
|
|
||||||
CheckList: check_list2,
|
|
||||||
}
|
|
||||||
|
|
||||||
return svc.CreateAuditEventCheckList(
|
|
||||||
ctx,
|
|
||||||
ValidtorUserID,
|
|
||||||
model.Resource{
|
|
||||||
ID: params.SubmissionID,
|
|
||||||
Type: model.ResourceSubmission,
|
|
||||||
},
|
|
||||||
event_data,
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// POST /submissions
|
// POST /submissions
|
||||||
func (svc *Service) CreateSubmission(ctx context.Context, request *internal.SubmissionCreate) (*internal.SubmissionID, error) {
|
func (svc *Service) CreateSubmission(ctx context.Context, request *internal.SubmissionCreate) (*internal.SubmissionID, error) {
|
||||||
// sanitization
|
|
||||||
if request.GameID<0||
|
|
||||||
request.AssetOwner<0||
|
|
||||||
request.AssetID<0||
|
|
||||||
request.AssetVersion<0{
|
|
||||||
return nil, ErrNegativeID
|
|
||||||
}
|
|
||||||
var GameID=uint32(request.GameID);
|
|
||||||
var Submitter=uint64(request.AssetOwner);
|
|
||||||
var AssetID=uint64(request.AssetID);
|
|
||||||
var AssetVersion=uint64(request.AssetVersion);
|
|
||||||
var Status=model.SubmissionStatus(request.Status);
|
|
||||||
var roles=service.Roles(request.Roles);
|
|
||||||
|
|
||||||
// Check if an active submission with the same asset id exists
|
// Check if an active submission with the same asset id exists
|
||||||
{
|
{
|
||||||
filter := datastore.Optional()
|
filter := datastore.Optional()
|
||||||
@@ -312,11 +106,8 @@ func (svc *Service) CreateSubmission(ctx context.Context, request *internal.Subm
|
|||||||
}
|
}
|
||||||
|
|
||||||
// check if user owns asset
|
// check if user owns asset
|
||||||
is_submitter := operation.Owner == Submitter
|
// TODO: allow bypass by admin
|
||||||
// check if user is map admin
|
if operation.Owner != request.AssetOwner {
|
||||||
has_submission_review := roles & service.RolesSubmissionReview == service.RolesSubmissionReview
|
|
||||||
// if neither, u not allowed
|
|
||||||
if !is_submitter && !has_submission_review {
|
|
||||||
return nil, ErrNotAssetOwner
|
return nil, ErrNotAssetOwner
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -324,12 +115,12 @@ func (svc *Service) CreateSubmission(ctx context.Context, request *internal.Subm
|
|||||||
ID: 0,
|
ID: 0,
|
||||||
DisplayName: request.DisplayName,
|
DisplayName: request.DisplayName,
|
||||||
Creator: request.Creator,
|
Creator: request.Creator,
|
||||||
GameID: GameID,
|
GameID: request.GameID,
|
||||||
Submitter: Submitter,
|
Submitter: request.AssetOwner,
|
||||||
AssetID: AssetID,
|
AssetID: request.AssetID,
|
||||||
AssetVersion: AssetVersion,
|
AssetVersion: request.AssetVersion,
|
||||||
Completed: false,
|
Completed: false,
|
||||||
StatusID: Status,
|
StatusID: model.SubmissionStatusUnderConstruction,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|||||||
@@ -5,16 +5,14 @@ edition = "2021"
|
|||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
submissions-api = { path = "api", features = ["internal"], default-features = false, registry = "strafesnet" }
|
submissions-api = { path = "api", features = ["internal"], default-features = false, registry = "strafesnet" }
|
||||||
async-nats = "0.42.0"
|
async-nats = "0.40.0"
|
||||||
futures = "0.3.31"
|
futures = "0.3.31"
|
||||||
rbx_asset = { version = "0.4.7", registry = "strafesnet" }
|
rbx_asset = { version = "0.3.3", registry = "strafesnet" }
|
||||||
rbx_binary = "1.0.0"
|
rbx_binary = { version = "0.7.4", registry = "strafesnet"}
|
||||||
rbx_dom_weak = "3.0.0"
|
rbx_dom_weak = { version = "2.9.0", registry = "strafesnet"}
|
||||||
rbx_reflection_database = "1.0.3"
|
rbx_reflection_database = { version = "0.2.12", registry = "strafesnet"}
|
||||||
rbx_xml = "1.0.0"
|
rbx_xml = { version = "0.13.3", registry = "strafesnet"}
|
||||||
serde = { version = "1.0.215", features = ["derive"] }
|
serde = { version = "1.0.215", features = ["derive"] }
|
||||||
serde_json = "1.0.133"
|
serde_json = "1.0.133"
|
||||||
siphasher = "1.0.1"
|
siphasher = "1.0.1"
|
||||||
tokio = { version = "1.41.1", features = ["macros", "rt-multi-thread", "signal"] }
|
tokio = { version = "1.41.1", features = ["macros", "rt-multi-thread", "signal"] }
|
||||||
heck = "0.5.0"
|
|
||||||
lazy-regex = "3.4.1"
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
# Using the `rust-musl-builder` as base image, instead of
|
# Using the `rust-musl-builder` as base image, instead of
|
||||||
# the official Rust toolchain
|
# the official Rust toolchain
|
||||||
FROM registry.itzana.me/docker-proxy/clux/muslrust:1.86.0-stable AS chef
|
FROM docker.io/clux/muslrust:stable AS chef
|
||||||
USER root
|
USER root
|
||||||
RUN cargo install cargo-chef
|
RUN cargo install cargo-chef
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
@@ -17,7 +17,7 @@ RUN cargo chef cook --release --target x86_64-unknown-linux-musl --recipe-path r
|
|||||||
COPY . .
|
COPY . .
|
||||||
RUN cargo build --release --target x86_64-unknown-linux-musl --bin maps-validation
|
RUN cargo build --release --target x86_64-unknown-linux-musl --bin maps-validation
|
||||||
|
|
||||||
FROM registry.itzana.me/docker-proxy/alpine:3.21 AS runtime
|
FROM docker.io/alpine:latest AS runtime
|
||||||
RUN addgroup -S myuser && adduser -S myuser -G myuser
|
RUN addgroup -S myuser && adduser -S myuser -G myuser
|
||||||
COPY --from=builder /app/target/x86_64-unknown-linux-musl/release/maps-validation /usr/local/bin/
|
COPY --from=builder /app/target/x86_64-unknown-linux-musl/release/maps-validation /usr/local/bin/
|
||||||
USER myuser
|
USER myuser
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "submissions-api"
|
name = "submissions-api"
|
||||||
version = "0.8.1"
|
version = "0.6.1"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
publish = ["strafesnet"]
|
publish = ["strafesnet"]
|
||||||
repository = "https://git.itzana.me/StrafesNET/maps-service"
|
repository = "https://git.itzana.me/StrafesNET/maps-service"
|
||||||
@@ -11,7 +11,6 @@ authors = ["Rhys Lloyd <krakow20@gmail.com>"]
|
|||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
chrono = { version = "0.4.41", features = ["serde"] }
|
|
||||||
reqwest = { version = "0", features = ["json"] }
|
reqwest = { version = "0", features = ["json"] }
|
||||||
serde = { version = "1", features = ["derive"] }
|
serde = { version = "1", features = ["derive"] }
|
||||||
serde_json = "1"
|
serde_json = "1"
|
||||||
|
|||||||
@@ -44,8 +44,4 @@ impl Context{
|
|||||||
.body(body)
|
.body(body)
|
||||||
.send().await
|
.send().await
|
||||||
}
|
}
|
||||||
pub async fn delete(&self,url:impl reqwest::IntoUrl)->Result<reqwest::Response,reqwest::Error>{
|
|
||||||
self.client.delete(url)
|
|
||||||
.send().await
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ impl Context{
|
|||||||
).await.map_err(Error::Response)?
|
).await.map_err(Error::Response)?
|
||||||
.json().await.map_err(Error::ReqwestJson)
|
.json().await.map_err(Error::ReqwestJson)
|
||||||
}
|
}
|
||||||
pub async fn get_scripts(&self,config:GetScriptsRequest<'_>)->Result<Vec<ScriptResponse>,Error>{
|
pub async fn get_scripts<'a>(&self,config:GetScriptsRequest<'a>)->Result<Vec<ScriptResponse>,Error>{
|
||||||
let url_raw=format!("{}/scripts",self.0.base_url);
|
let url_raw=format!("{}/scripts",self.0.base_url);
|
||||||
let mut url=reqwest::Url::parse(url_raw.as_str()).map_err(Error::Parse)?;
|
let mut url=reqwest::Url::parse(url_raw.as_str()).map_err(Error::Parse)?;
|
||||||
|
|
||||||
@@ -36,7 +36,7 @@ impl Context{
|
|||||||
if let Some(resource_type)=config.ResourceType{
|
if let Some(resource_type)=config.ResourceType{
|
||||||
query_pairs.append_pair("ResourceType",(resource_type as i32).to_string().as_str());
|
query_pairs.append_pair("ResourceType",(resource_type as i32).to_string().as_str());
|
||||||
}
|
}
|
||||||
if let Some(ResourceID(resource_id))=config.ResourceID{
|
if let Some(resource_id)=config.ResourceID{
|
||||||
query_pairs.append_pair("ResourceID",resource_id.to_string().as_str());
|
query_pairs.append_pair("ResourceID",resource_id.to_string().as_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -46,7 +46,7 @@ impl Context{
|
|||||||
).await.map_err(Error::Response)?
|
).await.map_err(Error::Response)?
|
||||||
.json().await.map_err(Error::ReqwestJson)
|
.json().await.map_err(Error::ReqwestJson)
|
||||||
}
|
}
|
||||||
pub async fn get_script_from_hash(&self,config:HashRequest<'_>)->Result<Option<ScriptResponse>,ScriptSingleItemError>{
|
pub async fn get_script_from_hash<'a>(&self,config:HashRequest<'a>)->Result<Option<ScriptResponse>,SingleItemError>{
|
||||||
let scripts=self.get_scripts(GetScriptsRequest{
|
let scripts=self.get_scripts(GetScriptsRequest{
|
||||||
Page:1,
|
Page:1,
|
||||||
Limit:2,
|
Limit:2,
|
||||||
@@ -57,11 +57,11 @@ impl Context{
|
|||||||
ResourceID:None,
|
ResourceID:None,
|
||||||
}).await.map_err(SingleItemError::Other)?;
|
}).await.map_err(SingleItemError::Other)?;
|
||||||
if 1<scripts.len(){
|
if 1<scripts.len(){
|
||||||
return Err(SingleItemError::DuplicateItems(scripts.into_iter().map(|item|item.ID).collect()));
|
return Err(SingleItemError::DuplicateItems);
|
||||||
}
|
}
|
||||||
Ok(scripts.into_iter().next())
|
Ok(scripts.into_iter().next())
|
||||||
}
|
}
|
||||||
pub async fn create_script(&self,config:CreateScriptRequest<'_>)->Result<ScriptIDResponse,Error>{
|
pub async fn create_script<'a>(&self,config:CreateScriptRequest<'a>)->Result<ScriptIDResponse,Error>{
|
||||||
let url_raw=format!("{}/scripts",self.0.base_url);
|
let url_raw=format!("{}/scripts",self.0.base_url);
|
||||||
let url=reqwest::Url::parse(url_raw.as_str()).map_err(Error::Parse)?;
|
let url=reqwest::Url::parse(url_raw.as_str()).map_err(Error::Parse)?;
|
||||||
|
|
||||||
@@ -72,17 +72,7 @@ impl Context{
|
|||||||
).await.map_err(Error::Response)?
|
).await.map_err(Error::Response)?
|
||||||
.json().await.map_err(Error::ReqwestJson)
|
.json().await.map_err(Error::ReqwestJson)
|
||||||
}
|
}
|
||||||
pub async fn delete_script(&self,config:GetScriptRequest)->Result<(),Error>{
|
pub async fn get_script_policies<'a>(&self,config:GetScriptPoliciesRequest<'a>)->Result<Vec<ScriptPolicyResponse>,Error>{
|
||||||
let url_raw=format!("{}/scripts/{}",self.0.base_url,config.ScriptID.0);
|
|
||||||
let url=reqwest::Url::parse(url_raw.as_str()).map_err(Error::Parse)?;
|
|
||||||
|
|
||||||
response_ok(
|
|
||||||
self.0.delete(url).await.map_err(Error::Reqwest)?
|
|
||||||
).await.map_err(Error::Response)?;
|
|
||||||
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
pub async fn get_script_policies(&self,config:GetScriptPoliciesRequest<'_>)->Result<Vec<ScriptPolicyResponse>,Error>{
|
|
||||||
let url_raw=format!("{}/script-policy",self.0.base_url);
|
let url_raw=format!("{}/script-policy",self.0.base_url);
|
||||||
let mut url=reqwest::Url::parse(url_raw.as_str()).map_err(Error::Parse)?;
|
let mut url=reqwest::Url::parse(url_raw.as_str()).map_err(Error::Parse)?;
|
||||||
|
|
||||||
@@ -106,7 +96,7 @@ impl Context{
|
|||||||
).await.map_err(Error::Response)?
|
).await.map_err(Error::Response)?
|
||||||
.json().await.map_err(Error::ReqwestJson)
|
.json().await.map_err(Error::ReqwestJson)
|
||||||
}
|
}
|
||||||
pub async fn get_script_policy_from_hash(&self,config:HashRequest<'_>)->Result<Option<ScriptPolicyResponse>,ScriptPolicySingleItemError>{
|
pub async fn get_script_policy_from_hash<'a>(&self,config:HashRequest<'a>)->Result<Option<ScriptPolicyResponse>,SingleItemError>{
|
||||||
let policies=self.get_script_policies(GetScriptPoliciesRequest{
|
let policies=self.get_script_policies(GetScriptPoliciesRequest{
|
||||||
Page:1,
|
Page:1,
|
||||||
Limit:2,
|
Limit:2,
|
||||||
@@ -115,7 +105,7 @@ impl Context{
|
|||||||
Policy:None,
|
Policy:None,
|
||||||
}).await.map_err(SingleItemError::Other)?;
|
}).await.map_err(SingleItemError::Other)?;
|
||||||
if 1<policies.len(){
|
if 1<policies.len(){
|
||||||
return Err(SingleItemError::DuplicateItems(policies.into_iter().map(|item|item.ID).collect()));
|
return Err(SingleItemError::DuplicateItems);
|
||||||
}
|
}
|
||||||
Ok(policies.into_iter().next())
|
Ok(policies.into_iter().next())
|
||||||
}
|
}
|
||||||
@@ -140,94 +130,6 @@ impl Context{
|
|||||||
self.0.post(url,body).await.map_err(Error::Reqwest)?
|
self.0.post(url,body).await.map_err(Error::Reqwest)?
|
||||||
).await.map_err(Error::Response)?;
|
).await.map_err(Error::Response)?;
|
||||||
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
pub async fn delete_script_policy(&self,config:GetScriptPolicyRequest)->Result<(),Error>{
|
|
||||||
let url_raw=format!("{}/script-policy/{}",self.0.base_url,config.ScriptPolicyID.0);
|
|
||||||
let url=reqwest::Url::parse(url_raw.as_str()).map_err(Error::Parse)?;
|
|
||||||
|
|
||||||
response_ok(
|
|
||||||
self.0.delete(url).await.map_err(Error::Reqwest)?
|
|
||||||
).await.map_err(Error::Response)?;
|
|
||||||
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
pub async fn get_submissions(&self,config:GetSubmissionsRequest<'_>)->Result<SubmissionsResponse,Error>{
|
|
||||||
let url_raw=format!("{}/submissions",self.0.base_url);
|
|
||||||
let mut url=reqwest::Url::parse(url_raw.as_str()).map_err(Error::Parse)?;
|
|
||||||
|
|
||||||
{
|
|
||||||
let mut query_pairs=url.query_pairs_mut();
|
|
||||||
query_pairs.append_pair("Page",config.Page.to_string().as_str());
|
|
||||||
query_pairs.append_pair("Limit",config.Limit.to_string().as_str());
|
|
||||||
if let Some(sort)=config.Sort{
|
|
||||||
query_pairs.append_pair("Sort",(sort as u8).to_string().as_str());
|
|
||||||
}
|
|
||||||
if let Some(display_name)=config.DisplayName{
|
|
||||||
query_pairs.append_pair("DisplayName",display_name);
|
|
||||||
}
|
|
||||||
if let Some(creator)=config.Creator{
|
|
||||||
query_pairs.append_pair("Creator",creator);
|
|
||||||
}
|
|
||||||
if let Some(game_id)=config.GameID{
|
|
||||||
query_pairs.append_pair("GameID",(game_id as u8).to_string().as_str());
|
|
||||||
}
|
|
||||||
if let Some(submitter)=config.Submitter{
|
|
||||||
query_pairs.append_pair("Submitter",submitter.to_string().as_str());
|
|
||||||
}
|
|
||||||
if let Some(asset_id)=config.AssetID{
|
|
||||||
query_pairs.append_pair("AssetID",asset_id.to_string().as_str());
|
|
||||||
}
|
|
||||||
if let Some(uploaded_asset_id)=config.UploadedAssetID{
|
|
||||||
query_pairs.append_pair("UploadedAssetID",uploaded_asset_id.to_string().as_str());
|
|
||||||
}
|
|
||||||
if let Some(status_id)=config.StatusID{
|
|
||||||
query_pairs.append_pair("StatusID",(status_id as u8).to_string().as_str());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
response_ok(
|
|
||||||
self.0.get(url).await.map_err(Error::Reqwest)?
|
|
||||||
).await.map_err(Error::Response)?
|
|
||||||
.json().await.map_err(Error::ReqwestJson)
|
|
||||||
}
|
|
||||||
pub async fn get_maps(&self,config:GetMapsRequest<'_>)->Result<Vec<MapResponse>,Error>{
|
|
||||||
let url_raw=format!("{}/maps",self.0.base_url);
|
|
||||||
let mut url=reqwest::Url::parse(url_raw.as_str()).map_err(Error::Parse)?;
|
|
||||||
|
|
||||||
{
|
|
||||||
let mut query_pairs=url.query_pairs_mut();
|
|
||||||
query_pairs.append_pair("Page",config.Page.to_string().as_str());
|
|
||||||
query_pairs.append_pair("Limit",config.Limit.to_string().as_str());
|
|
||||||
if let Some(sort)=config.Sort{
|
|
||||||
query_pairs.append_pair("Sort",(sort as u8).to_string().as_str());
|
|
||||||
}
|
|
||||||
if let Some(display_name)=config.DisplayName{
|
|
||||||
query_pairs.append_pair("DisplayName",display_name);
|
|
||||||
}
|
|
||||||
if let Some(creator)=config.Creator{
|
|
||||||
query_pairs.append_pair("Creator",creator);
|
|
||||||
}
|
|
||||||
if let Some(game_id)=config.GameID{
|
|
||||||
query_pairs.append_pair("GameID",(game_id as u8).to_string().as_str());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
response_ok(
|
|
||||||
self.0.get(url).await.map_err(Error::Reqwest)?
|
|
||||||
).await.map_err(Error::Response)?
|
|
||||||
.json().await.map_err(Error::ReqwestJson)
|
|
||||||
}
|
|
||||||
pub async fn release_submissions(&self,config:ReleaseRequest<'_>)->Result<(),Error>{
|
|
||||||
let url_raw=format!("{}/release-submissions",self.0.base_url);
|
|
||||||
let url=reqwest::Url::parse(url_raw.as_str()).map_err(Error::Parse)?;
|
|
||||||
|
|
||||||
let body=serde_json::to_string(config.schedule).map_err(Error::JSON)?;
|
|
||||||
|
|
||||||
response_ok(
|
|
||||||
self.0.post(url,body).await.map_err(Error::Reqwest)?
|
|
||||||
).await.map_err(Error::Response)?;
|
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ macro_rules! query_pairs{
|
|||||||
macro_rules! action{
|
macro_rules! action{
|
||||||
($system:expr,$fname:ident,$config:ident,$config_type:ident,$action:expr,$config_submission_id:expr,$(($param:expr,$value:expr))*)=>{
|
($system:expr,$fname:ident,$config:ident,$config_type:ident,$action:expr,$config_submission_id:expr,$(($param:expr,$value:expr))*)=>{
|
||||||
pub async fn $fname(&self,$config:$config_type)->Result<(),Error>{
|
pub async fn $fname(&self,$config:$config_type)->Result<(),Error>{
|
||||||
let url_raw=format!(concat!("{}/",$system,"/{}/",$action),self.0.base_url,$config_submission_id);
|
let url_raw=format!(concat!("{}/",$system,"/{}/status/",$action),self.0.base_url,$config_submission_id);
|
||||||
let url=query_pairs!(reqwest::Url::parse(url_raw.as_str()).map_err(Error::Parse)?,$(($param,$value))*);
|
let url=query_pairs!(reqwest::Url::parse(url_raw.as_str()).map_err(Error::Parse)?,$(($param,$value))*);
|
||||||
|
|
||||||
response_ok(
|
response_ok(
|
||||||
@@ -46,7 +46,7 @@ impl Context{
|
|||||||
).await.map_err(Error::Response)?
|
).await.map_err(Error::Response)?
|
||||||
.json().await.map_err(Error::ReqwestJson)
|
.json().await.map_err(Error::ReqwestJson)
|
||||||
}
|
}
|
||||||
pub async fn get_scripts(&self,config:GetScriptsRequest<'_>)->Result<Vec<ScriptResponse>,Error>{
|
pub async fn get_scripts<'a>(&self,config:GetScriptsRequest<'a>)->Result<Vec<ScriptResponse>,Error>{
|
||||||
let url_raw=format!("{}/scripts",self.0.base_url);
|
let url_raw=format!("{}/scripts",self.0.base_url);
|
||||||
let mut url=reqwest::Url::parse(url_raw.as_str()).map_err(Error::Parse)?;
|
let mut url=reqwest::Url::parse(url_raw.as_str()).map_err(Error::Parse)?;
|
||||||
|
|
||||||
@@ -66,7 +66,7 @@ impl Context{
|
|||||||
if let Some(resource_type)=config.ResourceType{
|
if let Some(resource_type)=config.ResourceType{
|
||||||
query_pairs.append_pair("ResourceType",(resource_type as i32).to_string().as_str());
|
query_pairs.append_pair("ResourceType",(resource_type as i32).to_string().as_str());
|
||||||
}
|
}
|
||||||
if let Some(ResourceID(resource_id))=config.ResourceID{
|
if let Some(resource_id)=config.ResourceID{
|
||||||
query_pairs.append_pair("ResourceID",resource_id.to_string().as_str());
|
query_pairs.append_pair("ResourceID",resource_id.to_string().as_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -76,7 +76,7 @@ impl Context{
|
|||||||
).await.map_err(Error::Response)?
|
).await.map_err(Error::Response)?
|
||||||
.json().await.map_err(Error::ReqwestJson)
|
.json().await.map_err(Error::ReqwestJson)
|
||||||
}
|
}
|
||||||
pub async fn get_script_from_hash(&self,config:HashRequest<'_>)->Result<Option<ScriptResponse>,ScriptSingleItemError>{
|
pub async fn get_script_from_hash<'a>(&self,config:HashRequest<'a>)->Result<Option<ScriptResponse>,SingleItemError>{
|
||||||
let scripts=self.get_scripts(GetScriptsRequest{
|
let scripts=self.get_scripts(GetScriptsRequest{
|
||||||
Page:1,
|
Page:1,
|
||||||
Limit:2,
|
Limit:2,
|
||||||
@@ -87,11 +87,11 @@ impl Context{
|
|||||||
ResourceID:None,
|
ResourceID:None,
|
||||||
}).await.map_err(SingleItemError::Other)?;
|
}).await.map_err(SingleItemError::Other)?;
|
||||||
if 1<scripts.len(){
|
if 1<scripts.len(){
|
||||||
return Err(SingleItemError::DuplicateItems(scripts.into_iter().map(|item|item.ID).collect()));
|
return Err(SingleItemError::DuplicateItems);
|
||||||
}
|
}
|
||||||
Ok(scripts.into_iter().next())
|
Ok(scripts.into_iter().next())
|
||||||
}
|
}
|
||||||
pub async fn create_script(&self,config:CreateScriptRequest<'_>)->Result<ScriptIDResponse,Error>{
|
pub async fn create_script<'a>(&self,config:CreateScriptRequest<'a>)->Result<ScriptIDResponse,Error>{
|
||||||
let url_raw=format!("{}/scripts",self.0.base_url);
|
let url_raw=format!("{}/scripts",self.0.base_url);
|
||||||
let url=reqwest::Url::parse(url_raw.as_str()).map_err(Error::Parse)?;
|
let url=reqwest::Url::parse(url_raw.as_str()).map_err(Error::Parse)?;
|
||||||
|
|
||||||
@@ -102,7 +102,7 @@ impl Context{
|
|||||||
).await.map_err(Error::Response)?
|
).await.map_err(Error::Response)?
|
||||||
.json().await.map_err(Error::ReqwestJson)
|
.json().await.map_err(Error::ReqwestJson)
|
||||||
}
|
}
|
||||||
pub async fn get_script_policies(&self,config:GetScriptPoliciesRequest<'_>)->Result<Vec<ScriptPolicyResponse>,Error>{
|
pub async fn get_script_policies<'a>(&self,config:GetScriptPoliciesRequest<'a>)->Result<Vec<ScriptPolicyResponse>,Error>{
|
||||||
let url_raw=format!("{}/script-policy",self.0.base_url);
|
let url_raw=format!("{}/script-policy",self.0.base_url);
|
||||||
let mut url=reqwest::Url::parse(url_raw.as_str()).map_err(Error::Parse)?;
|
let mut url=reqwest::Url::parse(url_raw.as_str()).map_err(Error::Parse)?;
|
||||||
|
|
||||||
@@ -126,7 +126,7 @@ impl Context{
|
|||||||
).await.map_err(Error::Response)?
|
).await.map_err(Error::Response)?
|
||||||
.json().await.map_err(Error::ReqwestJson)
|
.json().await.map_err(Error::ReqwestJson)
|
||||||
}
|
}
|
||||||
pub async fn get_script_policy_from_hash(&self,config:HashRequest<'_>)->Result<Option<ScriptPolicyResponse>,ScriptPolicySingleItemError>{
|
pub async fn get_script_policy_from_hash<'a>(&self,config:HashRequest<'a>)->Result<Option<ScriptPolicyResponse>,SingleItemError>{
|
||||||
let policies=self.get_script_policies(GetScriptPoliciesRequest{
|
let policies=self.get_script_policies(GetScriptPoliciesRequest{
|
||||||
Page:1,
|
Page:1,
|
||||||
Limit:2,
|
Limit:2,
|
||||||
@@ -135,7 +135,7 @@ impl Context{
|
|||||||
Policy:None,
|
Policy:None,
|
||||||
}).await.map_err(SingleItemError::Other)?;
|
}).await.map_err(SingleItemError::Other)?;
|
||||||
if 1<policies.len(){
|
if 1<policies.len(){
|
||||||
return Err(SingleItemError::DuplicateItems(policies.into_iter().map(|item|item.ID).collect()));
|
return Err(SingleItemError::DuplicateItems);
|
||||||
}
|
}
|
||||||
Ok(policies.into_iter().next())
|
Ok(policies.into_iter().next())
|
||||||
}
|
}
|
||||||
@@ -150,7 +150,7 @@ impl Context{
|
|||||||
).await.map_err(Error::Response)?
|
).await.map_err(Error::Response)?
|
||||||
.json().await.map_err(Error::ReqwestJson)
|
.json().await.map_err(Error::ReqwestJson)
|
||||||
}
|
}
|
||||||
pub async fn create_submission(&self,config:CreateSubmissionRequest<'_>)->Result<SubmissionIDResponse,Error>{
|
pub async fn create_submission<'a>(&self,config:CreateSubmissionRequest<'a>)->Result<SubmissionIDResponse,Error>{
|
||||||
let url_raw=format!("{}/submissions",self.0.base_url);
|
let url_raw=format!("{}/submissions",self.0.base_url);
|
||||||
let url=reqwest::Url::parse(url_raw.as_str()).map_err(Error::Parse)?;
|
let url=reqwest::Url::parse(url_raw.as_str()).map_err(Error::Parse)?;
|
||||||
|
|
||||||
@@ -161,39 +161,19 @@ impl Context{
|
|||||||
).await.map_err(Error::Response)?
|
).await.map_err(Error::Response)?
|
||||||
.json().await.map_err(Error::ReqwestJson)
|
.json().await.map_err(Error::ReqwestJson)
|
||||||
}
|
}
|
||||||
pub async fn create_submission_audit_check_list(&self,config:CreateSubmissionAuditCheckListRequest<'_>)->Result<(),Error>{
|
|
||||||
let url_raw=format!("{}/submissions/{}/checklist",self.0.base_url,config.SubmissionID.0);
|
|
||||||
let url=reqwest::Url::parse(url_raw.as_str()).map_err(Error::Parse)?;
|
|
||||||
|
|
||||||
let body=serde_json::to_string(&config.CheckList).map_err(Error::JSON)?;
|
|
||||||
|
|
||||||
response_ok(
|
|
||||||
self.0.post(url,body).await.map_err(Error::Reqwest)?
|
|
||||||
).await.map_err(Error::Response)?;
|
|
||||||
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
// simple submission endpoints
|
// simple submission endpoints
|
||||||
action!("submissions",action_submission_request_changes,config,ActionSubmissionRequestChangesRequest,"status/validator-request-changes",config.SubmissionID.0,);
|
action!("submissions",action_submission_validated,config,SubmissionID,"validator-validated",config.0,);
|
||||||
action!("submissions",action_submission_submitted,config,ActionSubmissionSubmittedRequest,"status/validator-submitted",config.SubmissionID.0,
|
action!("submissions",update_submission_validated_model,config,UpdateSubmissionModelRequest,"validated-model",config.SubmissionID,
|
||||||
("ModelVersion",config.ModelVersion.to_string().as_str())
|
|
||||||
("DisplayName",config.DisplayName.as_str())
|
|
||||||
("Creator",config.Creator.as_str())
|
|
||||||
("GameID",(config.GameID as u8).to_string().as_str())
|
|
||||||
);
|
|
||||||
action!("submissions",action_submission_validated,config,SubmissionID,"status/validator-validated",config.0,);
|
|
||||||
action!("submissions",update_submission_validated_model,config,UpdateSubmissionModelRequest,"validated-model",config.SubmissionID.0,
|
|
||||||
("ValidatedModelID",config.ModelID.to_string().as_str())
|
("ValidatedModelID",config.ModelID.to_string().as_str())
|
||||||
("ValidatedModelVersion",config.ModelVersion.to_string().as_str())
|
("ValidatedModelVersion",config.ModelVersion.to_string().as_str())
|
||||||
);
|
);
|
||||||
action!("submissions",action_submission_uploaded,config,ActionSubmissionUploadedRequest,"status/validator-uploaded",config.SubmissionID.0,
|
action!("submissions",action_submission_uploaded,config,ActionSubmissionUploadedRequest,"validator-uploaded",config.SubmissionID,
|
||||||
("UploadedAssetID",config.UploadedAssetID.to_string().as_str())
|
("UploadedAssetID",config.UploadedAssetID.to_string().as_str())
|
||||||
);
|
);
|
||||||
action!("submissions",action_submission_accepted,config,ActionSubmissionAcceptedRequest,"status/validator-failed",config.SubmissionID.0,);
|
action!("submissions",action_submission_accepted,config,ActionSubmissionAcceptedRequest,"validator-failed",config.SubmissionID,
|
||||||
action!("submissions",create_submission_audit_error,config,CreateSubmissionAuditErrorRequest,"error",config.SubmissionID.0,
|
("StatusMessage",config.StatusMessage.as_str())
|
||||||
("ErrorMessage",config.ErrorMessage.as_str())
|
|
||||||
);
|
);
|
||||||
pub async fn create_mapfix(&self,config:CreateMapfixRequest<'_>)->Result<MapfixIDResponse,Error>{
|
pub async fn create_mapfix<'a>(&self,config:CreateMapfixRequest<'a>)->Result<MapfixIDResponse,Error>{
|
||||||
let url_raw=format!("{}/mapfixes",self.0.base_url);
|
let url_raw=format!("{}/mapfixes",self.0.base_url);
|
||||||
let url=reqwest::Url::parse(url_raw.as_str()).map_err(Error::Parse)?;
|
let url=reqwest::Url::parse(url_raw.as_str()).map_err(Error::Parse)?;
|
||||||
|
|
||||||
@@ -204,38 +184,18 @@ impl Context{
|
|||||||
).await.map_err(Error::Response)?
|
).await.map_err(Error::Response)?
|
||||||
.json().await.map_err(Error::ReqwestJson)
|
.json().await.map_err(Error::ReqwestJson)
|
||||||
}
|
}
|
||||||
pub async fn create_mapfix_audit_check_list(&self,config:CreateMapfixAuditCheckListRequest<'_>)->Result<(),Error>{
|
|
||||||
let url_raw=format!("{}/mapfixes/{}/checklist",self.0.base_url,config.MapfixID.0);
|
|
||||||
let url=reqwest::Url::parse(url_raw.as_str()).map_err(Error::Parse)?;
|
|
||||||
|
|
||||||
let body=serde_json::to_string(&config.CheckList).map_err(Error::JSON)?;
|
|
||||||
|
|
||||||
response_ok(
|
|
||||||
self.0.post(url,body).await.map_err(Error::Reqwest)?
|
|
||||||
).await.map_err(Error::Response)?;
|
|
||||||
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
// simple mapfixes endpoints
|
// simple mapfixes endpoints
|
||||||
action!("mapfixes",action_mapfix_request_changes,config,ActionMapfixRequestChangesRequest,"status/validator-request-changes",config.MapfixID.0,);
|
action!("mapfixes",action_mapfix_validated,config,MapfixID,"validator-validated",config.0,);
|
||||||
action!("mapfixes",action_mapfix_submitted,config,ActionMapfixSubmittedRequest,"status/validator-submitted",config.MapfixID.0,
|
action!("mapfixes",update_mapfix_validated_model,config,UpdateMapfixModelRequest,"validated-model",config.MapfixID,
|
||||||
("ModelVersion",config.ModelVersion.to_string().as_str())
|
|
||||||
("DisplayName",config.DisplayName.as_str())
|
|
||||||
("Creator",config.Creator.as_str())
|
|
||||||
("GameID",(config.GameID as u8).to_string().as_str())
|
|
||||||
);
|
|
||||||
action!("mapfixes",action_mapfix_validated,config,MapfixID,"status/validator-validated",config.0,);
|
|
||||||
action!("mapfixes",update_mapfix_validated_model,config,UpdateMapfixModelRequest,"validated-model",config.MapfixID.0,
|
|
||||||
("ValidatedModelID",config.ModelID.to_string().as_str())
|
("ValidatedModelID",config.ModelID.to_string().as_str())
|
||||||
("ValidatedModelVersion",config.ModelVersion.to_string().as_str())
|
("ValidatedModelVersion",config.ModelVersion.to_string().as_str())
|
||||||
);
|
);
|
||||||
action!("mapfixes",action_mapfix_uploaded,config,ActionMapfixUploadedRequest,"status/validator-uploaded",config.MapfixID.0,);
|
action!("mapfixes",action_mapfix_uploaded,config,ActionMapfixUploadedRequest,"validator-uploaded",config.MapfixID,);
|
||||||
action!("mapfixes",action_mapfix_accepted,config,ActionMapfixAcceptedRequest,"status/validator-failed",config.MapfixID.0,);
|
action!("mapfixes",action_mapfix_accepted,config,ActionMapfixAcceptedRequest,"validator-failed",config.MapfixID,
|
||||||
// simple operation endpoint
|
|
||||||
action!("operations",action_operation_failed,config,ActionOperationFailedRequest,"status/operation-failed",config.OperationID.0,
|
|
||||||
("StatusMessage",config.StatusMessage.as_str())
|
("StatusMessage",config.StatusMessage.as_str())
|
||||||
);
|
);
|
||||||
action!("mapfixes",create_mapfix_audit_error,config,CreateMapfixAuditErrorRequest,"error",config.MapfixID.0,
|
// simple operation endpoint
|
||||||
("ErrorMessage",config.ErrorMessage.as_str())
|
action!("operations",action_operation_failed,config,ActionOperationFailedRequest,"operation-failed",config.OperationID,
|
||||||
|
("StatusMessage",config.StatusMessage.as_str())
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,25 +14,21 @@ impl std::fmt::Display for Error{
|
|||||||
impl std::error::Error for Error{}
|
impl std::error::Error for Error{}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub enum SingleItemError<Items>{
|
pub enum SingleItemError{
|
||||||
DuplicateItems(Items),
|
DuplicateItems,
|
||||||
Other(Error),
|
Other(Error),
|
||||||
}
|
}
|
||||||
impl<Items> std::fmt::Display for SingleItemError<Items>
|
impl std::fmt::Display for SingleItemError{
|
||||||
where
|
|
||||||
Items:std::fmt::Debug
|
|
||||||
{
|
|
||||||
fn fmt(&self,f:&mut std::fmt::Formatter<'_>)->std::fmt::Result{
|
fn fmt(&self,f:&mut std::fmt::Formatter<'_>)->std::fmt::Result{
|
||||||
write!(f,"{self:?}")
|
write!(f,"{self:?}")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl<Items> std::error::Error for SingleItemError<Items> where Items:std::fmt::Debug{}
|
impl std::error::Error for SingleItemError{}
|
||||||
pub type ScriptSingleItemError=SingleItemError<Vec<ScriptID>>;
|
|
||||||
pub type ScriptPolicySingleItemError=SingleItemError<Vec<ScriptPolicyID>>;
|
|
||||||
|
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct UrlAndBody{
|
pub struct StatusCodeWithUrlAndBody{
|
||||||
|
pub status_code:reqwest::StatusCode,
|
||||||
pub url:url::Url,
|
pub url:url::Url,
|
||||||
pub body:String,
|
pub body:String,
|
||||||
}
|
}
|
||||||
@@ -40,10 +36,7 @@ pub struct UrlAndBody{
|
|||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub enum ResponseError{
|
pub enum ResponseError{
|
||||||
Reqwest(reqwest::Error),
|
Reqwest(reqwest::Error),
|
||||||
Details{
|
StatusCodeWithUrlAndBody(StatusCodeWithUrlAndBody),
|
||||||
status_code:reqwest::StatusCode,
|
|
||||||
url_and_body:Box<UrlAndBody>,
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
impl std::fmt::Display for ResponseError{
|
impl std::fmt::Display for ResponseError{
|
||||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||||
@@ -60,34 +53,26 @@ pub async fn response_ok(response:reqwest::Response)->Result<reqwest::Response,R
|
|||||||
let url=response.url().to_owned();
|
let url=response.url().to_owned();
|
||||||
let bytes=response.bytes().await.map_err(ResponseError::Reqwest)?;
|
let bytes=response.bytes().await.map_err(ResponseError::Reqwest)?;
|
||||||
let body=String::from_utf8_lossy(&bytes).to_string();
|
let body=String::from_utf8_lossy(&bytes).to_string();
|
||||||
Err(ResponseError::Details{
|
Err(ResponseError::StatusCodeWithUrlAndBody(StatusCodeWithUrlAndBody{
|
||||||
status_code,
|
status_code,
|
||||||
url_and_body:Box::new(UrlAndBody{url,body})
|
url,
|
||||||
})
|
body,
|
||||||
|
}))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone,Copy,Debug,Hash,Eq,PartialEq,Ord,PartialOrd,serde_repr::Serialize_repr,serde_repr::Deserialize_repr)]
|
|
||||||
#[repr(u8)]
|
|
||||||
pub enum GameID{
|
|
||||||
Bhop=1,
|
|
||||||
Surf=2,
|
|
||||||
KreedzClimb=3,
|
|
||||||
FlyTrials=5,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[allow(nonstandard_style)]
|
#[allow(nonstandard_style)]
|
||||||
#[derive(Clone,Debug,serde::Serialize)]
|
#[derive(Clone,Debug,serde::Serialize)]
|
||||||
pub struct CreateMapfixRequest<'a>{
|
pub struct CreateMapfixRequest<'a>{
|
||||||
pub OperationID:OperationID,
|
pub OperationID:i32,
|
||||||
pub AssetOwner:i64,
|
pub AssetOwner:i64,
|
||||||
pub DisplayName:&'a str,
|
pub DisplayName:&'a str,
|
||||||
pub Creator:&'a str,
|
pub Creator:&'a str,
|
||||||
pub GameID:GameID,
|
pub GameID:i32,
|
||||||
pub AssetID:u64,
|
pub AssetID:u64,
|
||||||
pub AssetVersion:u64,
|
pub AssetVersion:u64,
|
||||||
pub TargetAssetID:u64,
|
pub TargetAssetID:u64,
|
||||||
pub Description:&'a str,
|
|
||||||
}
|
}
|
||||||
#[allow(nonstandard_style)]
|
#[allow(nonstandard_style)]
|
||||||
#[derive(Clone,Debug,serde::Deserialize)]
|
#[derive(Clone,Debug,serde::Deserialize)]
|
||||||
@@ -98,15 +83,13 @@ pub struct MapfixIDResponse{
|
|||||||
#[allow(nonstandard_style)]
|
#[allow(nonstandard_style)]
|
||||||
#[derive(Clone,Debug,serde::Serialize)]
|
#[derive(Clone,Debug,serde::Serialize)]
|
||||||
pub struct CreateSubmissionRequest<'a>{
|
pub struct CreateSubmissionRequest<'a>{
|
||||||
pub OperationID:OperationID,
|
pub OperationID:i32,
|
||||||
pub AssetOwner:i64,
|
pub AssetOwner:i64,
|
||||||
pub DisplayName:&'a str,
|
pub DisplayName:&'a str,
|
||||||
pub Creator:&'a str,
|
pub Creator:&'a str,
|
||||||
pub GameID:GameID,
|
pub GameID:i32,
|
||||||
pub AssetID:u64,
|
pub AssetID:u64,
|
||||||
pub AssetVersion:u64,
|
pub AssetVersion:u64,
|
||||||
pub Status:u32,
|
|
||||||
pub Roles:u32,
|
|
||||||
}
|
}
|
||||||
#[allow(nonstandard_style)]
|
#[allow(nonstandard_style)]
|
||||||
#[derive(Clone,Debug,serde::Deserialize)]
|
#[derive(Clone,Debug,serde::Deserialize)]
|
||||||
@@ -145,7 +128,7 @@ pub struct GetScriptsRequest<'a>{
|
|||||||
#[serde(skip_serializing_if="Option::is_none")]
|
#[serde(skip_serializing_if="Option::is_none")]
|
||||||
pub ResourceType:Option<ResourceType>,
|
pub ResourceType:Option<ResourceType>,
|
||||||
#[serde(skip_serializing_if="Option::is_none")]
|
#[serde(skip_serializing_if="Option::is_none")]
|
||||||
pub ResourceID:Option<ResourceID>,
|
pub ResourceID:Option<i64>,
|
||||||
}
|
}
|
||||||
#[derive(Clone,Copy,Debug)]
|
#[derive(Clone,Copy,Debug)]
|
||||||
pub struct HashRequest<'a>{
|
pub struct HashRequest<'a>{
|
||||||
@@ -159,7 +142,7 @@ pub struct ScriptResponse{
|
|||||||
pub Hash:String,
|
pub Hash:String,
|
||||||
pub Source:String,
|
pub Source:String,
|
||||||
pub ResourceType:ResourceType,
|
pub ResourceType:ResourceType,
|
||||||
pub ResourceID:ResourceID,
|
pub ResourceID:i64,
|
||||||
}
|
}
|
||||||
#[allow(nonstandard_style)]
|
#[allow(nonstandard_style)]
|
||||||
#[derive(Clone,Debug,serde::Serialize)]
|
#[derive(Clone,Debug,serde::Serialize)]
|
||||||
@@ -168,7 +151,7 @@ pub struct CreateScriptRequest<'a>{
|
|||||||
pub Source:&'a str,
|
pub Source:&'a str,
|
||||||
pub ResourceType:ResourceType,
|
pub ResourceType:ResourceType,
|
||||||
#[serde(skip_serializing_if="Option::is_none")]
|
#[serde(skip_serializing_if="Option::is_none")]
|
||||||
pub ResourceID:Option<ResourceID>,
|
pub ResourceID:Option<i64>,
|
||||||
}
|
}
|
||||||
#[allow(nonstandard_style)]
|
#[allow(nonstandard_style)]
|
||||||
#[derive(Clone,Debug,serde::Deserialize)]
|
#[derive(Clone,Debug,serde::Deserialize)]
|
||||||
@@ -186,10 +169,6 @@ pub enum Policy{
|
|||||||
Replace=4,
|
Replace=4,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(nonstandard_style)]
|
|
||||||
pub struct GetScriptPolicyRequest{
|
|
||||||
pub ScriptPolicyID:ScriptPolicyID,
|
|
||||||
}
|
|
||||||
#[allow(nonstandard_style)]
|
#[allow(nonstandard_style)]
|
||||||
#[derive(Clone,Debug,serde::Serialize)]
|
#[derive(Clone,Debug,serde::Serialize)]
|
||||||
pub struct GetScriptPoliciesRequest<'a>{
|
pub struct GetScriptPoliciesRequest<'a>{
|
||||||
@@ -238,243 +217,55 @@ pub struct UpdateScriptPolicyRequest{
|
|||||||
#[allow(nonstandard_style)]
|
#[allow(nonstandard_style)]
|
||||||
#[derive(Clone,Debug)]
|
#[derive(Clone,Debug)]
|
||||||
pub struct UpdateSubmissionModelRequest{
|
pub struct UpdateSubmissionModelRequest{
|
||||||
pub SubmissionID:SubmissionID,
|
pub SubmissionID:i64,
|
||||||
pub ModelID:u64,
|
pub ModelID:u64,
|
||||||
pub ModelVersion:u64,
|
pub ModelVersion:u64,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone,Debug)]
|
|
||||||
pub enum Sort{
|
|
||||||
Disabled=0,
|
|
||||||
DisplayNameAscending=1,
|
|
||||||
DisplayNameDescending=2,
|
|
||||||
DateAscending=3,
|
|
||||||
DateDescending=4,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone,Debug,serde_repr::Deserialize_repr)]
|
|
||||||
#[repr(u8)]
|
|
||||||
pub enum SubmissionStatus{
|
|
||||||
// Phase: Creation
|
|
||||||
UnderConstruction=0,
|
|
||||||
ChangesRequested=1,
|
|
||||||
|
|
||||||
// Phase: Review
|
|
||||||
Submitting=2,
|
|
||||||
Submitted=3,
|
|
||||||
|
|
||||||
// Phase: Testing
|
|
||||||
AcceptedUnvalidated=4, // pending script review, can re-trigger validation
|
|
||||||
Validating=5,
|
|
||||||
Validated=6,
|
|
||||||
Uploading=7,
|
|
||||||
Uploaded=8, // uploaded to the group, but pending release
|
|
||||||
|
|
||||||
// Phase: Final SubmissionStatus
|
|
||||||
Rejected=9,
|
|
||||||
Released=10,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[allow(nonstandard_style)]
|
|
||||||
#[derive(Clone,Debug)]
|
|
||||||
pub struct GetSubmissionsRequest<'a>{
|
|
||||||
pub Page:u32,
|
|
||||||
pub Limit:u32,
|
|
||||||
pub Sort:Option<Sort>,
|
|
||||||
pub DisplayName:Option<&'a str>,
|
|
||||||
pub Creator:Option<&'a str>,
|
|
||||||
pub GameID:Option<GameID>,
|
|
||||||
pub Submitter:Option<u64>,
|
|
||||||
pub AssetID:Option<u64>,
|
|
||||||
pub UploadedAssetID:Option<u64>,
|
|
||||||
pub StatusID:Option<SubmissionStatus>,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[allow(nonstandard_style)]
|
|
||||||
#[derive(Clone,Debug,serde::Deserialize)]
|
|
||||||
pub struct SubmissionResponse{
|
|
||||||
pub ID:SubmissionID,
|
|
||||||
pub DisplayName:String,
|
|
||||||
pub Creator:String,
|
|
||||||
pub GameID:GameID,
|
|
||||||
pub CreatedAt:i64,
|
|
||||||
pub UpdatedAt:i64,
|
|
||||||
pub Submitter:u64,
|
|
||||||
pub AssetID:u64,
|
|
||||||
pub AssetVersion:u64,
|
|
||||||
pub UploadedAssetID:u64,
|
|
||||||
pub StatusID:SubmissionStatus,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[allow(nonstandard_style)]
|
|
||||||
#[derive(Clone,Debug,serde::Deserialize)]
|
|
||||||
pub struct SubmissionsResponse{
|
|
||||||
pub Total:u64,
|
|
||||||
pub Submissions:Vec<SubmissionResponse>,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[allow(nonstandard_style)]
|
|
||||||
#[derive(Clone,Debug)]
|
|
||||||
pub struct GetMapsRequest<'a>{
|
|
||||||
pub Page:u32,
|
|
||||||
pub Limit:u32,
|
|
||||||
pub Sort:Option<Sort>,
|
|
||||||
pub DisplayName:Option<&'a str>,
|
|
||||||
pub Creator:Option<&'a str>,
|
|
||||||
pub GameID:Option<GameID>,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[allow(nonstandard_style)]
|
|
||||||
#[derive(Clone,Debug,serde::Deserialize)]
|
|
||||||
pub struct MapResponse{
|
|
||||||
pub ID:i64,
|
|
||||||
pub DisplayName:String,
|
|
||||||
pub Creator:String,
|
|
||||||
pub GameID:GameID,
|
|
||||||
pub Date:i64,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[allow(nonstandard_style)]
|
|
||||||
#[derive(Clone,Debug,serde::Serialize)]
|
|
||||||
pub struct Check{
|
|
||||||
pub Name:&'static str,
|
|
||||||
pub Summary:String,
|
|
||||||
pub Passed:bool,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[allow(nonstandard_style)]
|
|
||||||
#[derive(Clone,Debug)]
|
|
||||||
pub struct ActionSubmissionSubmittedRequest{
|
|
||||||
pub SubmissionID:SubmissionID,
|
|
||||||
pub ModelVersion:u64,
|
|
||||||
pub DisplayName:String,
|
|
||||||
pub Creator:String,
|
|
||||||
pub GameID:GameID,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[allow(nonstandard_style)]
|
|
||||||
#[derive(Clone,Debug)]
|
|
||||||
pub struct ActionSubmissionRequestChangesRequest{
|
|
||||||
pub SubmissionID:SubmissionID,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[allow(nonstandard_style)]
|
#[allow(nonstandard_style)]
|
||||||
#[derive(Clone,Debug)]
|
#[derive(Clone,Debug)]
|
||||||
pub struct ActionSubmissionUploadedRequest{
|
pub struct ActionSubmissionUploadedRequest{
|
||||||
pub SubmissionID:SubmissionID,
|
pub SubmissionID:i64,
|
||||||
pub UploadedAssetID:u64,
|
pub UploadedAssetID:u64,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(nonstandard_style)]
|
#[allow(nonstandard_style)]
|
||||||
#[derive(Clone,Debug)]
|
#[derive(Clone,Debug)]
|
||||||
pub struct ActionSubmissionAcceptedRequest{
|
pub struct ActionSubmissionAcceptedRequest{
|
||||||
pub SubmissionID:SubmissionID,
|
pub SubmissionID:i64,
|
||||||
|
pub StatusMessage:String,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(nonstandard_style)]
|
#[derive(Clone,Copy,Debug,serde::Deserialize)]
|
||||||
#[derive(Clone,Debug)]
|
pub struct SubmissionID(pub i64);
|
||||||
pub struct CreateSubmissionAuditErrorRequest{
|
|
||||||
pub SubmissionID:SubmissionID,
|
|
||||||
pub ErrorMessage:String,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[allow(nonstandard_style)]
|
|
||||||
#[derive(Clone,Debug)]
|
|
||||||
pub struct CreateSubmissionAuditCheckListRequest<'a>{
|
|
||||||
pub SubmissionID:SubmissionID,
|
|
||||||
pub CheckList:&'a [Check],
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone,Copy,Debug,serde::Serialize,serde::Deserialize)]
|
|
||||||
pub struct SubmissionID(pub(crate)i64);
|
|
||||||
|
|
||||||
#[allow(nonstandard_style)]
|
#[allow(nonstandard_style)]
|
||||||
#[derive(Clone,Debug)]
|
#[derive(Clone,Debug)]
|
||||||
pub struct UpdateMapfixModelRequest{
|
pub struct UpdateMapfixModelRequest{
|
||||||
pub MapfixID:MapfixID,
|
pub MapfixID:i64,
|
||||||
pub ModelID:u64,
|
pub ModelID:u64,
|
||||||
pub ModelVersion:u64,
|
pub ModelVersion:u64,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(nonstandard_style)]
|
|
||||||
#[derive(Clone,Debug)]
|
|
||||||
pub struct ActionMapfixSubmittedRequest{
|
|
||||||
pub MapfixID:MapfixID,
|
|
||||||
pub ModelVersion:u64,
|
|
||||||
pub DisplayName:String,
|
|
||||||
pub Creator:String,
|
|
||||||
pub GameID:GameID,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[allow(nonstandard_style)]
|
|
||||||
#[derive(Clone,Debug)]
|
|
||||||
pub struct ActionMapfixRequestChangesRequest{
|
|
||||||
pub MapfixID:MapfixID,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[allow(nonstandard_style)]
|
#[allow(nonstandard_style)]
|
||||||
#[derive(Clone,Debug)]
|
#[derive(Clone,Debug)]
|
||||||
pub struct ActionMapfixUploadedRequest{
|
pub struct ActionMapfixUploadedRequest{
|
||||||
pub MapfixID:MapfixID,
|
pub MapfixID:i64,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(nonstandard_style)]
|
#[allow(nonstandard_style)]
|
||||||
#[derive(Clone,Debug)]
|
#[derive(Clone,Debug)]
|
||||||
pub struct ActionMapfixAcceptedRequest{
|
pub struct ActionMapfixAcceptedRequest{
|
||||||
pub MapfixID:MapfixID,
|
pub MapfixID:i64,
|
||||||
|
pub StatusMessage:String,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(nonstandard_style)]
|
#[derive(Clone,Copy,Debug,serde::Deserialize)]
|
||||||
#[derive(Clone,Debug)]
|
pub struct MapfixID(pub i64);
|
||||||
pub struct CreateMapfixAuditErrorRequest{
|
|
||||||
pub MapfixID:MapfixID,
|
|
||||||
pub ErrorMessage:String,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[allow(nonstandard_style)]
|
|
||||||
#[derive(Clone,Debug)]
|
|
||||||
pub struct CreateMapfixAuditCheckListRequest<'a>{
|
|
||||||
pub MapfixID:MapfixID,
|
|
||||||
pub CheckList:&'a [Check],
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone,Copy,Debug,serde::Serialize,serde::Deserialize)]
|
|
||||||
pub struct MapfixID(pub(crate)i64);
|
|
||||||
|
|
||||||
#[allow(nonstandard_style)]
|
#[allow(nonstandard_style)]
|
||||||
#[derive(Clone,Debug)]
|
#[derive(Clone,Debug)]
|
||||||
pub struct ActionOperationFailedRequest{
|
pub struct ActionOperationFailedRequest{
|
||||||
pub OperationID:OperationID,
|
pub OperationID:i32,
|
||||||
pub StatusMessage:String,
|
pub StatusMessage:String,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone,Copy,Debug,serde::Serialize,serde::Deserialize)]
|
|
||||||
pub struct OperationID(pub(crate)i64);
|
|
||||||
|
|
||||||
#[derive(Clone,Copy,Debug,serde::Serialize,serde::Deserialize)]
|
|
||||||
pub struct ResourceID(pub(crate)i64);
|
|
||||||
|
|
||||||
#[derive(Clone,Copy,Debug)]
|
|
||||||
pub enum Resource{
|
|
||||||
Submission(SubmissionID),
|
|
||||||
Mapfix(MapfixID),
|
|
||||||
}
|
|
||||||
impl Resource{
|
|
||||||
pub fn split(self)->(ResourceType,ResourceID){
|
|
||||||
match self{
|
|
||||||
Resource::Mapfix(MapfixID(mapfix_id))=>(ResourceType::Mapfix,ResourceID(mapfix_id)),
|
|
||||||
Resource::Submission(SubmissionID(submission_id))=>(ResourceType::Submission,ResourceID(submission_id)),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[allow(nonstandard_style)]
|
|
||||||
#[derive(Clone,Debug,serde::Serialize)]
|
|
||||||
pub struct ReleaseInfo{
|
|
||||||
pub SubmissionID:SubmissionID,
|
|
||||||
pub Date:chrono::DateTime<chrono::Utc>,
|
|
||||||
}
|
|
||||||
|
|
||||||
pub struct ReleaseRequest<'a>{
|
|
||||||
pub schedule:&'a [ReleaseInfo],
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,863 +0,0 @@
|
|||||||
use std::collections::{HashSet,HashMap};
|
|
||||||
use crate::download::download_asset_version;
|
|
||||||
use crate::rbx_util::{get_mapinfo,get_root_instance,read_dom,ReadDomError,GameID,ParseGameIDError,MapInfo,GetRootInstanceError,StringValueError};
|
|
||||||
|
|
||||||
use heck::{ToSnakeCase,ToTitleCase};
|
|
||||||
use submissions_api::types::Check;
|
|
||||||
|
|
||||||
#[allow(dead_code)]
|
|
||||||
#[derive(Debug)]
|
|
||||||
pub enum Error{
|
|
||||||
ModelInfoDownload(rbx_asset::cloud::GetError),
|
|
||||||
CreatorTypeMustBeUser,
|
|
||||||
Download(crate::download::Error),
|
|
||||||
ModelFileDecode(ReadDomError),
|
|
||||||
GetRootInstance(GetRootInstanceError),
|
|
||||||
IntoMapInfoOwned(IntoMapInfoOwnedError),
|
|
||||||
ToJsonValue(serde_json::Error),
|
|
||||||
}
|
|
||||||
impl std::fmt::Display for Error{
|
|
||||||
fn fmt(&self,f:&mut std::fmt::Formatter<'_>)->std::fmt::Result{
|
|
||||||
write!(f,"{self:?}")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
impl std::error::Error for Error{}
|
|
||||||
|
|
||||||
#[allow(nonstandard_style)]
|
|
||||||
pub struct CheckRequest{
|
|
||||||
ModelID:u64,
|
|
||||||
SkipChecks:bool,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl From<crate::nats_types::CheckMapfixRequest> for CheckRequest{
|
|
||||||
fn from(value:crate::nats_types::CheckMapfixRequest)->Self{
|
|
||||||
Self{
|
|
||||||
ModelID:value.ModelID,
|
|
||||||
SkipChecks:value.SkipChecks,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
impl From<crate::nats_types::CheckSubmissionRequest> for CheckRequest{
|
|
||||||
fn from(value:crate::nats_types::CheckSubmissionRequest)->Self{
|
|
||||||
Self{
|
|
||||||
ModelID:value.ModelID,
|
|
||||||
SkipChecks:value.SkipChecks,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone,Copy,Debug,Hash,Eq,PartialEq)]
|
|
||||||
struct ModeID(u64);
|
|
||||||
impl ModeID{
|
|
||||||
const MAIN:Self=Self(0);
|
|
||||||
const BONUS:Self=Self(1);
|
|
||||||
}
|
|
||||||
enum Zone{
|
|
||||||
Start,
|
|
||||||
Finish,
|
|
||||||
Anticheat,
|
|
||||||
}
|
|
||||||
struct ModeElement{
|
|
||||||
zone:Zone,
|
|
||||||
mode_id:ModeID,
|
|
||||||
}
|
|
||||||
#[allow(dead_code)]
|
|
||||||
pub enum IDParseError{
|
|
||||||
NoCaptures,
|
|
||||||
ParseInt(core::num::ParseIntError),
|
|
||||||
}
|
|
||||||
// Parse a Zone from a part name
|
|
||||||
impl std::str::FromStr for ModeElement{
|
|
||||||
type Err=IDParseError;
|
|
||||||
fn from_str(s:&str)->Result<Self,Self::Err>{
|
|
||||||
match s{
|
|
||||||
"MapStart"=>Ok(Self{zone:Zone::Start,mode_id:ModeID::MAIN}),
|
|
||||||
"MapFinish"=>Ok(Self{zone:Zone::Finish,mode_id:ModeID::MAIN}),
|
|
||||||
"MapAnticheat"=>Ok(Self{zone:Zone::Anticheat,mode_id:ModeID::MAIN}),
|
|
||||||
"BonusStart"=>Ok(Self{zone:Zone::Start,mode_id:ModeID::BONUS}),
|
|
||||||
"BonusFinish"=>Ok(Self{zone:Zone::Finish,mode_id:ModeID::BONUS}),
|
|
||||||
"BonusAnticheat"=>Ok(Self{zone:Zone::Anticheat,mode_id:ModeID::BONUS}),
|
|
||||||
other=>{
|
|
||||||
let everything_pattern=lazy_regex::lazy_regex!(r"^Bonus(\d+)Start$|^BonusStart(\d+)$|^Bonus(\d+)Finish$|^BonusFinish(\d+)$|^Bonus(\d+)Anticheat$|^BonusAnticheat(\d+)$");
|
|
||||||
if let Some(captures)=everything_pattern.captures(other){
|
|
||||||
if let Some(mode_id)=captures.get(1).or(captures.get(2)){
|
|
||||||
return Ok(Self{
|
|
||||||
zone:Zone::Start,
|
|
||||||
mode_id:ModeID(mode_id.as_str().parse().map_err(IDParseError::ParseInt)?),
|
|
||||||
});
|
|
||||||
}
|
|
||||||
if let Some(mode_id)=captures.get(3).or(captures.get(4)){
|
|
||||||
return Ok(Self{
|
|
||||||
zone:Zone::Finish,
|
|
||||||
mode_id:ModeID(mode_id.as_str().parse().map_err(IDParseError::ParseInt)?),
|
|
||||||
});
|
|
||||||
}
|
|
||||||
if let Some(mode_id)=captures.get(5).or(captures.get(6)){
|
|
||||||
return Ok(Self{
|
|
||||||
zone:Zone::Anticheat,
|
|
||||||
mode_id:ModeID(mode_id.as_str().parse().map_err(IDParseError::ParseInt)?),
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Err(IDParseError::NoCaptures)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
impl std::fmt::Display for ModeElement{
|
|
||||||
fn fmt(&self,f:&mut std::fmt::Formatter<'_>)->std::fmt::Result{
|
|
||||||
match self{
|
|
||||||
ModeElement{zone:Zone::Start,mode_id:ModeID::MAIN}=>write!(f,"MapStart"),
|
|
||||||
ModeElement{zone:Zone::Start,mode_id:ModeID::BONUS}=>write!(f,"BonusStart"),
|
|
||||||
ModeElement{zone:Zone::Start,mode_id:ModeID(mode_id)}=>write!(f,"Bonus{mode_id}Start"),
|
|
||||||
ModeElement{zone:Zone::Finish,mode_id:ModeID::MAIN}=>write!(f,"MapFinish"),
|
|
||||||
ModeElement{zone:Zone::Finish,mode_id:ModeID::BONUS}=>write!(f,"BonusFinish"),
|
|
||||||
ModeElement{zone:Zone::Finish,mode_id:ModeID(mode_id)}=>write!(f,"Bonus{mode_id}Finish"),
|
|
||||||
ModeElement{zone:Zone::Anticheat,mode_id:ModeID::MAIN}=>write!(f,"MapAnticheat"),
|
|
||||||
ModeElement{zone:Zone::Anticheat,mode_id:ModeID::BONUS}=>write!(f,"BonusAnticheat"),
|
|
||||||
ModeElement{zone:Zone::Anticheat,mode_id:ModeID(mode_id)}=>write!(f,"Bonus{mode_id}Anticheat"),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone,Copy,Debug,Hash,Eq,PartialEq)]
|
|
||||||
struct StageID(u64);
|
|
||||||
impl StageID{
|
|
||||||
const FIRST:Self=Self(1);
|
|
||||||
}
|
|
||||||
enum StageElementBehaviour{
|
|
||||||
Teleport,
|
|
||||||
Spawn,
|
|
||||||
}
|
|
||||||
struct StageElement{
|
|
||||||
stage_id:StageID,
|
|
||||||
behaviour:StageElementBehaviour,
|
|
||||||
}
|
|
||||||
// Parse a SpawnTeleport from a part name
|
|
||||||
impl std::str::FromStr for StageElement{
|
|
||||||
type Err=IDParseError;
|
|
||||||
fn from_str(s:&str)->Result<Self,Self::Err>{
|
|
||||||
// Trigger ForceTrigger Teleport ForceTeleport SpawnAt ForceSpawnAt
|
|
||||||
let bonus_start_pattern=lazy_regex::lazy_regex!(r"^(?:Force)?(Teleport|SpawnAt|Trigger)(\d+)$");
|
|
||||||
if let Some(captures)=bonus_start_pattern.captures(s){
|
|
||||||
return Ok(StageElement{
|
|
||||||
behaviour:StageElementBehaviour::Teleport,
|
|
||||||
stage_id:StageID(captures[1].parse().map_err(IDParseError::ParseInt)?),
|
|
||||||
});
|
|
||||||
}
|
|
||||||
// Spawn
|
|
||||||
let bonus_finish_pattern=lazy_regex::lazy_regex!(r"^Spawn(\d+)$");
|
|
||||||
if let Some(captures)=bonus_finish_pattern.captures(s){
|
|
||||||
return Ok(StageElement{
|
|
||||||
behaviour:StageElementBehaviour::Spawn,
|
|
||||||
stage_id:StageID(captures[1].parse().map_err(IDParseError::ParseInt)?),
|
|
||||||
});
|
|
||||||
}
|
|
||||||
Err(IDParseError::NoCaptures)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
impl std::fmt::Display for StageElement{
|
|
||||||
fn fmt(&self,f:&mut std::fmt::Formatter<'_>)->std::fmt::Result{
|
|
||||||
match self{
|
|
||||||
StageElement{behaviour:StageElementBehaviour::Spawn,stage_id:StageID(stage_id)}=>write!(f,"Spawn{stage_id}"),
|
|
||||||
StageElement{behaviour:StageElementBehaviour::Teleport,stage_id:StageID(stage_id)}=>write!(f,"Teleport{stage_id}"),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone,Copy,Debug,Hash,Eq,PartialEq)]
|
|
||||||
struct WormholeID(u64);
|
|
||||||
enum WormholeBehaviour{
|
|
||||||
In,
|
|
||||||
Out,
|
|
||||||
}
|
|
||||||
struct WormholeElement{
|
|
||||||
behaviour:WormholeBehaviour,
|
|
||||||
wormhole_id:WormholeID,
|
|
||||||
}
|
|
||||||
// Parse a Wormhole from a part name
|
|
||||||
impl std::str::FromStr for WormholeElement{
|
|
||||||
type Err=IDParseError;
|
|
||||||
fn from_str(s:&str)->Result<Self,Self::Err>{
|
|
||||||
let bonus_start_pattern=lazy_regex::lazy_regex!(r"^WormholeIn(\d+)$");
|
|
||||||
if let Some(captures)=bonus_start_pattern.captures(s){
|
|
||||||
return Ok(Self{
|
|
||||||
behaviour:WormholeBehaviour::In,
|
|
||||||
wormhole_id:WormholeID(captures[1].parse().map_err(IDParseError::ParseInt)?),
|
|
||||||
});
|
|
||||||
}
|
|
||||||
let bonus_finish_pattern=lazy_regex::lazy_regex!(r"^WormholeOut(\d+)$");
|
|
||||||
if let Some(captures)=bonus_finish_pattern.captures(s){
|
|
||||||
return Ok(Self{
|
|
||||||
behaviour:WormholeBehaviour::Out,
|
|
||||||
wormhole_id:WormholeID(captures[1].parse().map_err(IDParseError::ParseInt)?),
|
|
||||||
});
|
|
||||||
}
|
|
||||||
Err(IDParseError::NoCaptures)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
impl std::fmt::Display for WormholeElement{
|
|
||||||
fn fmt(&self,f:&mut std::fmt::Formatter<'_>)->std::fmt::Result{
|
|
||||||
match self{
|
|
||||||
WormholeElement{behaviour:WormholeBehaviour::In,wormhole_id:WormholeID(wormhole_id)}=>write!(f,"WormholeIn{wormhole_id}"),
|
|
||||||
WormholeElement{behaviour:WormholeBehaviour::Out,wormhole_id:WormholeID(wormhole_id)}=>write!(f,"WormholeOut{wormhole_id}"),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Count various map elements
|
|
||||||
#[derive(Default)]
|
|
||||||
struct Counts<'a>{
|
|
||||||
mode_start_counts:HashMap<ModeID,Vec<&'a str>>,
|
|
||||||
mode_finish_counts:HashMap<ModeID,Vec<&'a str>>,
|
|
||||||
mode_anticheat_counts:HashMap<ModeID,Vec<&'a str>>,
|
|
||||||
teleport_counts:HashMap<StageID,Vec<&'a str>>,
|
|
||||||
spawn_counts:HashMap<StageID,u64>,
|
|
||||||
wormhole_in_counts:HashMap<WormholeID,u64>,
|
|
||||||
wormhole_out_counts:HashMap<WormholeID,u64>,
|
|
||||||
}
|
|
||||||
|
|
||||||
pub struct ModelInfo<'a>{
|
|
||||||
model_class:&'a str,
|
|
||||||
model_name:&'a str,
|
|
||||||
map_info:MapInfo<'a>,
|
|
||||||
counts:Counts<'a>,
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn get_model_info<'a>(dom:&'a rbx_dom_weak::WeakDom,model_instance:&'a rbx_dom_weak::Instance)->ModelInfo<'a>{
|
|
||||||
// extract model info
|
|
||||||
let map_info=get_mapinfo(dom,model_instance);
|
|
||||||
|
|
||||||
// count objects (default count is 0)
|
|
||||||
let mut counts=Counts::default();
|
|
||||||
|
|
||||||
let db=rbx_reflection_database::get();
|
|
||||||
let base_part=&db.classes["BasePart"];
|
|
||||||
let base_parts=dom.descendants_of(model_instance.referent()).filter(|&instance|
|
|
||||||
db.classes.get(instance.class.as_str()).is_some_and(|class|
|
|
||||||
db.has_superclass(class,base_part)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
for instance in base_parts{
|
|
||||||
// Zones
|
|
||||||
match instance.name.parse(){
|
|
||||||
Ok(ModeElement{zone:Zone::Start,mode_id})=>counts.mode_start_counts.entry(mode_id).or_default().push(instance.name.as_str()),
|
|
||||||
Ok(ModeElement{zone:Zone::Finish,mode_id})=>counts.mode_finish_counts.entry(mode_id).or_default().push(instance.name.as_str()),
|
|
||||||
Ok(ModeElement{zone:Zone::Anticheat,mode_id})=>counts.mode_anticheat_counts.entry(mode_id).or_default().push(instance.name.as_str()),
|
|
||||||
Err(_)=>(),
|
|
||||||
}
|
|
||||||
// Spawns & Teleports
|
|
||||||
match instance.name.parse(){
|
|
||||||
Ok(StageElement{behaviour:StageElementBehaviour::Teleport,stage_id})=>counts.teleport_counts.entry(stage_id).or_default().push(instance.name.as_str()),
|
|
||||||
Ok(StageElement{behaviour:StageElementBehaviour::Spawn,stage_id})=>*counts.spawn_counts.entry(stage_id).or_insert(0)+=1,
|
|
||||||
Err(_)=>(),
|
|
||||||
}
|
|
||||||
// Wormholes
|
|
||||||
match instance.name.parse(){
|
|
||||||
Ok(WormholeElement{behaviour:WormholeBehaviour::In,wormhole_id})=>*counts.wormhole_in_counts.entry(wormhole_id).or_insert(0)+=1,
|
|
||||||
Ok(WormholeElement{behaviour:WormholeBehaviour::Out,wormhole_id})=>*counts.wormhole_out_counts.entry(wormhole_id).or_insert(0)+=1,
|
|
||||||
Err(_)=>(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ModelInfo{
|
|
||||||
model_class:model_instance.class.as_str(),
|
|
||||||
model_name:model_instance.name.as_str(),
|
|
||||||
map_info,
|
|
||||||
counts,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// check if an observed string matches an expected string
|
|
||||||
pub struct StringCheck<'a,T,Str>(Result<T,StringCheckContext<'a,Str>>);
|
|
||||||
pub struct StringCheckContext<'a,Str>{
|
|
||||||
observed:&'a str,
|
|
||||||
expected:Str,
|
|
||||||
}
|
|
||||||
impl<'a,Str> StringCheckContext<'a,Str>
|
|
||||||
where
|
|
||||||
&'a str:PartialEq<Str>,
|
|
||||||
{
|
|
||||||
/// Compute the StringCheck, passing through the provided value on success.
|
|
||||||
fn check<T>(self,value:T)->StringCheck<'a,T,Str>{
|
|
||||||
if self.observed==self.expected{
|
|
||||||
StringCheck(Ok(value))
|
|
||||||
}else{
|
|
||||||
StringCheck(Err(self))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
impl<Str:std::fmt::Display> std::fmt::Display for StringCheckContext<'_,Str>{
|
|
||||||
fn fmt(&self,f:&mut std::fmt::Formatter<'_>)->std::fmt::Result{
|
|
||||||
write!(f,"expected: {}, observed: {}",self.expected,self.observed)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// check if a string is empty
|
|
||||||
pub struct StringEmpty;
|
|
||||||
impl std::fmt::Display for StringEmpty{
|
|
||||||
fn fmt(&self,f:&mut std::fmt::Formatter<'_>)->std::fmt::Result{
|
|
||||||
write!(f,"Empty string")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
fn check_empty(value:&str)->Result<&str,StringEmpty>{
|
|
||||||
(!value.is_empty()).then_some(value).ok_or(StringEmpty)
|
|
||||||
}
|
|
||||||
|
|
||||||
// check for duplicate objects
|
|
||||||
pub struct DuplicateCheckContext<ID,T>(HashMap<ID,T>);
|
|
||||||
pub struct DuplicateCheck<ID,T>(Result<(),DuplicateCheckContext<ID,T>>);
|
|
||||||
impl<ID,T> DuplicateCheckContext<ID,T>{
|
|
||||||
/// Compute the DuplicateCheck using the contents predicate.
|
|
||||||
fn check(self,f:impl Fn(&T)->bool)->DuplicateCheck<ID,T>{
|
|
||||||
let Self(mut set)=self;
|
|
||||||
// remove correct entries
|
|
||||||
set.retain(|_,c|f(c));
|
|
||||||
// if any entries remain, they are incorrect
|
|
||||||
if set.is_empty(){
|
|
||||||
DuplicateCheck(Ok(()))
|
|
||||||
}else{
|
|
||||||
DuplicateCheck(Err(Self(set)))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check that there are no items which do not have a matching item in a reference set
|
|
||||||
pub struct SetDifferenceCheckContextAllowNone<ID,T>{
|
|
||||||
extra:HashMap<ID,T>,
|
|
||||||
}
|
|
||||||
// Check that there is at least one matching item for each item in a reference set, and no extra items
|
|
||||||
pub struct SetDifferenceCheckContextAtLeastOne<ID,T>{
|
|
||||||
extra:HashMap<ID,T>,
|
|
||||||
missing:HashSet<ID>,
|
|
||||||
}
|
|
||||||
pub struct SetDifferenceCheck<Context>(Result<(),Context>);
|
|
||||||
impl<ID,T> SetDifferenceCheckContextAllowNone<ID,T>{
|
|
||||||
fn new(initial_set:HashMap<ID,T>)->Self{
|
|
||||||
Self{
|
|
||||||
extra:initial_set,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
impl<ID:Eq+std::hash::Hash,T> SetDifferenceCheckContextAllowNone<ID,T>{
|
|
||||||
/// Compute the SetDifferenceCheck result for the specified reference set.
|
|
||||||
fn check<U>(mut self,reference_set:&HashMap<ID,U>)->SetDifferenceCheck<Self>{
|
|
||||||
// remove correct entries
|
|
||||||
for id in reference_set.keys(){
|
|
||||||
self.extra.remove(id);
|
|
||||||
}
|
|
||||||
// if any entries remain, they are incorrect
|
|
||||||
if self.extra.is_empty(){
|
|
||||||
SetDifferenceCheck(Ok(()))
|
|
||||||
}else{
|
|
||||||
SetDifferenceCheck(Err(self))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
impl<ID,T> SetDifferenceCheckContextAtLeastOne<ID,T>{
|
|
||||||
fn new(initial_set:HashMap<ID,T>)->Self{
|
|
||||||
Self{
|
|
||||||
extra:initial_set,
|
|
||||||
missing:HashSet::new(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
impl<ID:Copy+Eq+std::hash::Hash,T> SetDifferenceCheckContextAtLeastOne<ID,T>{
|
|
||||||
/// Compute the SetDifferenceCheck result for the specified reference set.
|
|
||||||
fn check<U>(mut self,reference_set:&HashMap<ID,U>)->SetDifferenceCheck<Self>{
|
|
||||||
// remove correct entries
|
|
||||||
for id in reference_set.keys(){
|
|
||||||
if self.extra.remove(id).is_none(){
|
|
||||||
// the set did not contain a required item. This is a fail
|
|
||||||
self.missing.insert(*id);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// if any entries remain, they are incorrect
|
|
||||||
if self.extra.is_empty()&&self.missing.is_empty(){
|
|
||||||
SetDifferenceCheck(Ok(()))
|
|
||||||
}else{
|
|
||||||
SetDifferenceCheck(Err(self))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Info lifted out of a fully compliant map
|
|
||||||
pub struct MapInfoOwned{
|
|
||||||
pub display_name:String,
|
|
||||||
pub creator:String,
|
|
||||||
pub game_id:GameID,
|
|
||||||
}
|
|
||||||
#[allow(dead_code)]
|
|
||||||
#[derive(Debug)]
|
|
||||||
pub enum IntoMapInfoOwnedError{
|
|
||||||
DisplayName(StringValueError),
|
|
||||||
Creator(StringValueError),
|
|
||||||
GameID(ParseGameIDError),
|
|
||||||
}
|
|
||||||
impl TryFrom<MapInfo<'_>> for MapInfoOwned{
|
|
||||||
type Error=IntoMapInfoOwnedError;
|
|
||||||
fn try_from(value:MapInfo<'_>)->Result<Self,Self::Error>{
|
|
||||||
Ok(Self{
|
|
||||||
display_name:value.display_name.map_err(IntoMapInfoOwnedError::DisplayName)?.to_owned(),
|
|
||||||
creator:value.creator.map_err(IntoMapInfoOwnedError::Creator)?.to_owned(),
|
|
||||||
game_id:value.game_id.map_err(IntoMapInfoOwnedError::GameID)?,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Named dummy types for readability
|
|
||||||
struct Exists;
|
|
||||||
struct Absent;
|
|
||||||
|
|
||||||
/// The result of every map check.
|
|
||||||
struct MapCheck<'a>{
|
|
||||||
// === METADATA CHECKS ===
|
|
||||||
// The root must be of class Model
|
|
||||||
model_class:StringCheck<'a,(),&'static str>,
|
|
||||||
// Model's name must be in snake case
|
|
||||||
model_name:StringCheck<'a,(),String>,
|
|
||||||
// Map must have a StringValue named DisplayName.
|
|
||||||
// Value must not be empty, must be in title case.
|
|
||||||
display_name:Result<Result<StringCheck<'a,&'a str,String>,StringEmpty>,StringValueError>,
|
|
||||||
// Map must have a StringValue named Creator.
|
|
||||||
// Value must not be empty.
|
|
||||||
creator:Result<Result<&'a str,StringEmpty>,StringValueError>,
|
|
||||||
// The prefix of the model's name must match the game it was submitted for.
|
|
||||||
// bhop_ for bhop, and surf_ for surf
|
|
||||||
game_id:Result<GameID,ParseGameIDError>,
|
|
||||||
|
|
||||||
// === MODE CHECKS ===
|
|
||||||
// MapStart must exist
|
|
||||||
mapstart:Result<Exists,Absent>,
|
|
||||||
// No duplicate map starts (including bonuses)
|
|
||||||
mode_start_counts:DuplicateCheck<ModeID,Vec<&'a str>>,
|
|
||||||
// At least one finish zone for each start zone, and no finishes with no start
|
|
||||||
mode_finish_counts:SetDifferenceCheck<SetDifferenceCheckContextAtLeastOne<ModeID,Vec<&'a str>>>,
|
|
||||||
// Check for dangling MapAnticheat zones (no associated MapStart)
|
|
||||||
mode_anticheat_counts:SetDifferenceCheck<SetDifferenceCheckContextAllowNone<ModeID,Vec<&'a str>>>,
|
|
||||||
// Spawn1 must exist
|
|
||||||
spawn1:Result<Exists,Absent>,
|
|
||||||
// Check for dangling Teleport# (no associated Spawn#)
|
|
||||||
teleport_counts:SetDifferenceCheck<SetDifferenceCheckContextAllowNone<StageID,Vec<&'a str>>>,
|
|
||||||
// No duplicate Spawn#
|
|
||||||
spawn_counts:DuplicateCheck<StageID,u64>,
|
|
||||||
// Check for dangling WormholeIn# (no associated WormholeOut#)
|
|
||||||
wormhole_in_counts:SetDifferenceCheck<SetDifferenceCheckContextAtLeastOne<WormholeID,u64>>,
|
|
||||||
// No duplicate WormholeOut# (duplicate WormholeIn# ok)
|
|
||||||
// No dangling WormholeOut#
|
|
||||||
wormhole_out_counts:DuplicateCheck<WormholeID,u64>,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<'a> ModelInfo<'a>{
|
|
||||||
fn check(self)->MapCheck<'a>{
|
|
||||||
// Check class is exactly "Model"
|
|
||||||
let model_class=StringCheckContext{
|
|
||||||
observed:self.model_class,
|
|
||||||
expected:"Model",
|
|
||||||
}.check(());
|
|
||||||
|
|
||||||
// Check model name is snake case
|
|
||||||
let model_name=StringCheckContext{
|
|
||||||
observed:self.model_name,
|
|
||||||
expected:self.model_name.to_snake_case(),
|
|
||||||
}.check(());
|
|
||||||
|
|
||||||
// Check display name is not empty and has title case
|
|
||||||
let display_name=self.map_info.display_name.map(|display_name|{
|
|
||||||
check_empty(display_name).map(|display_name|StringCheckContext{
|
|
||||||
observed:display_name,
|
|
||||||
expected:display_name.to_title_case(),
|
|
||||||
}.check(display_name))
|
|
||||||
});
|
|
||||||
|
|
||||||
// Check Creator is not empty
|
|
||||||
let creator=self.map_info.creator.map(check_empty);
|
|
||||||
|
|
||||||
// Check GameID (model name was prefixed with bhop_ surf_ etc)
|
|
||||||
let game_id=self.map_info.game_id;
|
|
||||||
|
|
||||||
// MapStart must exist
|
|
||||||
let mapstart=if self.counts.mode_start_counts.contains_key(&ModeID::MAIN){
|
|
||||||
Ok(Exists)
|
|
||||||
}else{
|
|
||||||
Err(Absent)
|
|
||||||
};
|
|
||||||
|
|
||||||
// Spawn1 must exist
|
|
||||||
let spawn1=if self.counts.spawn_counts.contains_key(&StageID::FIRST){
|
|
||||||
Ok(Exists)
|
|
||||||
}else{
|
|
||||||
Err(Absent)
|
|
||||||
};
|
|
||||||
|
|
||||||
// Check that at least one finish zone exists for each start zone.
|
|
||||||
// This also checks that there are no finish zones without a corresponding start zone.
|
|
||||||
let mode_finish_counts=SetDifferenceCheckContextAtLeastOne::new(self.counts.mode_finish_counts)
|
|
||||||
.check(&self.counts.mode_start_counts);
|
|
||||||
|
|
||||||
// Check that there are no anticheat zones without a corresponding start zone.
|
|
||||||
// Modes are allowed to have 0 anticheat zones.
|
|
||||||
let mode_anticheat_counts=SetDifferenceCheckContextAllowNone::new(self.counts.mode_anticheat_counts)
|
|
||||||
.check(&self.counts.mode_start_counts);
|
|
||||||
|
|
||||||
// There must be exactly one start zone for every mode in the map.
|
|
||||||
let mode_start_counts=DuplicateCheckContext(self.counts.mode_start_counts).check(|c|1<c.len());
|
|
||||||
|
|
||||||
// Check that there are no Teleports without a corresponding Spawn.
|
|
||||||
// Spawns are allowed to have 0 Teleports.
|
|
||||||
let teleport_counts=SetDifferenceCheckContextAllowNone::new(self.counts.teleport_counts)
|
|
||||||
.check(&self.counts.spawn_counts);
|
|
||||||
|
|
||||||
// There must be exactly one of any perticular spawn id in the map.
|
|
||||||
let spawn_counts=DuplicateCheckContext(self.counts.spawn_counts).check(|&c|1<c);
|
|
||||||
|
|
||||||
// Check that at least one WormholeIn exists for each WormholeOut.
|
|
||||||
// This also checks that there are no WormholeIn without a corresponding WormholeOut.
|
|
||||||
let wormhole_in_counts=SetDifferenceCheckContextAtLeastOne::new(self.counts.wormhole_in_counts)
|
|
||||||
.check(&self.counts.wormhole_out_counts);
|
|
||||||
|
|
||||||
// There must be exactly one of any perticular wormhole out id in the map.
|
|
||||||
let wormhole_out_counts=DuplicateCheckContext(self.counts.wormhole_out_counts).check(|&c|1<c);
|
|
||||||
|
|
||||||
MapCheck{
|
|
||||||
model_class,
|
|
||||||
model_name,
|
|
||||||
display_name,
|
|
||||||
creator,
|
|
||||||
game_id,
|
|
||||||
mapstart,
|
|
||||||
mode_start_counts,
|
|
||||||
mode_finish_counts,
|
|
||||||
mode_anticheat_counts,
|
|
||||||
spawn1,
|
|
||||||
teleport_counts,
|
|
||||||
spawn_counts,
|
|
||||||
wormhole_in_counts,
|
|
||||||
wormhole_out_counts,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl MapCheck<'_>{
|
|
||||||
fn result(self)->Result<MapInfoOwned,Result<MapCheckList,serde_json::Error>>{
|
|
||||||
match self{
|
|
||||||
MapCheck{
|
|
||||||
model_class:StringCheck(Ok(())),
|
|
||||||
model_name:StringCheck(Ok(())),
|
|
||||||
display_name:Ok(Ok(StringCheck(Ok(display_name)))),
|
|
||||||
creator:Ok(Ok(creator)),
|
|
||||||
game_id:Ok(game_id),
|
|
||||||
mapstart:Ok(Exists),
|
|
||||||
mode_start_counts:DuplicateCheck(Ok(())),
|
|
||||||
mode_finish_counts:SetDifferenceCheck(Ok(())),
|
|
||||||
mode_anticheat_counts:SetDifferenceCheck(Ok(())),
|
|
||||||
spawn1:Ok(Exists),
|
|
||||||
teleport_counts:SetDifferenceCheck(Ok(())),
|
|
||||||
spawn_counts:DuplicateCheck(Ok(())),
|
|
||||||
wormhole_in_counts:SetDifferenceCheck(Ok(())),
|
|
||||||
wormhole_out_counts:DuplicateCheck(Ok(())),
|
|
||||||
}=>{
|
|
||||||
Ok(MapInfoOwned{
|
|
||||||
display_name:display_name.to_owned(),
|
|
||||||
creator:creator.to_owned(),
|
|
||||||
game_id,
|
|
||||||
})
|
|
||||||
},
|
|
||||||
other=>Err(other.itemize()),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
struct Separated<F>{
|
|
||||||
f:F,
|
|
||||||
separator:&'static str,
|
|
||||||
}
|
|
||||||
impl<F> Separated<F>{
|
|
||||||
fn new(separator:&'static str,f:F)->Self{
|
|
||||||
Self{separator,f}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
impl<F,I,D> std::fmt::Display for Separated<F>
|
|
||||||
where
|
|
||||||
D:std::fmt::Display,
|
|
||||||
I:IntoIterator<Item=D>,
|
|
||||||
F:Fn()->I,
|
|
||||||
{
|
|
||||||
fn fmt(&self,f:&mut std::fmt::Formatter<'_>)->std::fmt::Result{
|
|
||||||
let mut it=(self.f)().into_iter();
|
|
||||||
if let Some(first)=it.next(){
|
|
||||||
write!(f,"{first}")?;
|
|
||||||
for item in it{
|
|
||||||
write!(f,"{}{item}",self.separator)?;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
struct Duplicates<D>{
|
|
||||||
display:D,
|
|
||||||
duplicates:usize,
|
|
||||||
}
|
|
||||||
impl<D> Duplicates<D>{
|
|
||||||
fn new(display:D,duplicates:usize)->Self{
|
|
||||||
Self{
|
|
||||||
display,
|
|
||||||
duplicates,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
impl<D:std::fmt::Display> std::fmt::Display for Duplicates<D>{
|
|
||||||
fn fmt(&self,f:&mut std::fmt::Formatter<'_>)->std::fmt::Result{
|
|
||||||
write!(f,"{} ({} duplicates)",self.display,self.duplicates)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
macro_rules! passed{
|
|
||||||
($name:literal)=>{
|
|
||||||
Check{
|
|
||||||
Name:$name,
|
|
||||||
Summary:String::new(),
|
|
||||||
Passed:true,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
macro_rules! summary{
|
|
||||||
($name:literal,$summary:expr)=>{
|
|
||||||
Check{
|
|
||||||
Name:$name,
|
|
||||||
Summary:$summary,
|
|
||||||
Passed:false,
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
macro_rules! summary_format{
|
|
||||||
($name:literal,$fmt:literal)=>{
|
|
||||||
Check{
|
|
||||||
Name:$name,
|
|
||||||
Summary:format!($fmt),
|
|
||||||
Passed:false,
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
// Generate an error message for each observed issue separated by newlines.
|
|
||||||
// This defines MapCheck.to_string() which is used in MapCheck.result()
|
|
||||||
impl MapCheck<'_>{
|
|
||||||
fn itemize(&self)->Result<MapCheckList,serde_json::Error>{
|
|
||||||
let model_class=match &self.model_class{
|
|
||||||
StringCheck(Ok(()))=>passed!("ModelClass"),
|
|
||||||
StringCheck(Err(context))=>summary_format!("ModelClass","Invalid model class: {context}"),
|
|
||||||
};
|
|
||||||
let model_name=match &self.model_name{
|
|
||||||
StringCheck(Ok(()))=>passed!("ModelName"),
|
|
||||||
StringCheck(Err(context))=>summary_format!("ModelName","Model name must have snake_case: {context}"),
|
|
||||||
};
|
|
||||||
let display_name=match &self.display_name{
|
|
||||||
Ok(Ok(StringCheck(Ok(_))))=>passed!("DisplayName"),
|
|
||||||
Ok(Ok(StringCheck(Err(context))))=>summary_format!("DisplayName","DisplayName must have Title Case: {context}"),
|
|
||||||
Ok(Err(context))=>summary_format!("DisplayName","Invalid DisplayName: {context}"),
|
|
||||||
Err(StringValueError::ObjectNotFound)=>summary!("DisplayName","Missing DisplayName StringValue".to_owned()),
|
|
||||||
Err(StringValueError::ValueNotSet)=>summary!("DisplayName","DisplayName Value not set".to_owned()),
|
|
||||||
Err(StringValueError::NonStringValue)=>summary!("DisplayName","DisplayName Value is not a String".to_owned()),
|
|
||||||
};
|
|
||||||
let creator=match &self.creator{
|
|
||||||
Ok(Ok(_))=>passed!("Creator"),
|
|
||||||
Ok(Err(context))=>summary_format!("Creator","Invalid Creator: {context}"),
|
|
||||||
Err(StringValueError::ObjectNotFound)=>summary!("Creator","Missing Creator StringValue".to_owned()),
|
|
||||||
Err(StringValueError::ValueNotSet)=>summary!("Creator","Creator Value not set".to_owned()),
|
|
||||||
Err(StringValueError::NonStringValue)=>summary!("Creator","Creator Value is not a String".to_owned()),
|
|
||||||
};
|
|
||||||
let game_id=match &self.game_id{
|
|
||||||
Ok(_)=>passed!("GameID"),
|
|
||||||
Err(ParseGameIDError)=>summary!("GameID","Model name must be prefixed with bhop_ surf_ or flytrials_".to_owned()),
|
|
||||||
};
|
|
||||||
let mapstart=match &self.mapstart{
|
|
||||||
Ok(Exists)=>passed!("MapStart"),
|
|
||||||
Err(Absent)=>summary_format!("MapStart","Model has no MapStart"),
|
|
||||||
};
|
|
||||||
let duplicate_start=match &self.mode_start_counts{
|
|
||||||
DuplicateCheck(Ok(()))=>passed!("DuplicateStart"),
|
|
||||||
DuplicateCheck(Err(DuplicateCheckContext(context)))=>{
|
|
||||||
let context=Separated::new(", ",||context.iter().map(|(&mode_id,names)|
|
|
||||||
Duplicates::new(ModeElement{zone:Zone::Start,mode_id},names.len())
|
|
||||||
));
|
|
||||||
summary_format!("DuplicateStart","Duplicate start zones: {context}")
|
|
||||||
}
|
|
||||||
};
|
|
||||||
let (extra_finish,missing_finish)=match &self.mode_finish_counts{
|
|
||||||
SetDifferenceCheck(Ok(()))=>(passed!("DanglingFinish"),passed!("MissingFinish")),
|
|
||||||
SetDifferenceCheck(Err(context))=>(
|
|
||||||
if context.extra.is_empty(){
|
|
||||||
passed!("DanglingFinish")
|
|
||||||
}else{
|
|
||||||
let plural=if context.extra.len()==1{"zone"}else{"zones"};
|
|
||||||
let context=Separated::new(", ",||context.extra.iter().map(|(&mode_id,_names)|
|
|
||||||
ModeElement{zone:Zone::Finish,mode_id}
|
|
||||||
));
|
|
||||||
summary_format!("DanglingFinish","No matching start zone for finish {plural}: {context}")
|
|
||||||
},
|
|
||||||
if context.missing.is_empty(){
|
|
||||||
passed!("MissingFinish")
|
|
||||||
}else{
|
|
||||||
let plural=if context.missing.len()==1{"zone"}else{"zones"};
|
|
||||||
let context=Separated::new(", ",||context.missing.iter().map(|&mode_id|
|
|
||||||
ModeElement{zone:Zone::Finish,mode_id}
|
|
||||||
));
|
|
||||||
summary_format!("MissingFinish","Missing finish {plural}: {context}")
|
|
||||||
}
|
|
||||||
),
|
|
||||||
};
|
|
||||||
let dangling_anticheat=match &self.mode_anticheat_counts{
|
|
||||||
SetDifferenceCheck(Ok(()))=>passed!("DanglingAnticheat"),
|
|
||||||
SetDifferenceCheck(Err(context))=>{
|
|
||||||
if context.extra.is_empty(){
|
|
||||||
passed!("DanglingAnticheat")
|
|
||||||
}else{
|
|
||||||
let plural=if context.extra.len()==1{"zone"}else{"zones"};
|
|
||||||
let context=Separated::new(", ",||context.extra.iter().map(|(&mode_id,_names)|
|
|
||||||
ModeElement{zone:Zone::Anticheat,mode_id}
|
|
||||||
));
|
|
||||||
summary_format!("DanglingAnticheat","No matching start zone for anticheat {plural}: {context}")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
let spawn1=match &self.spawn1{
|
|
||||||
Ok(Exists)=>passed!("Spawn1"),
|
|
||||||
Err(Absent)=>summary_format!("Spawn1","Model has no Spawn1"),
|
|
||||||
};
|
|
||||||
let dangling_teleport=match &self.teleport_counts{
|
|
||||||
SetDifferenceCheck(Ok(()))=>passed!("DanglingTeleport"),
|
|
||||||
SetDifferenceCheck(Err(context))=>{
|
|
||||||
let unique_names:HashSet<_>=context.extra.values().flat_map(|names|names.iter().copied()).collect();
|
|
||||||
let plural=if unique_names.len()==1{"object"}else{"objects"};
|
|
||||||
let context=Separated::new(", ",||&unique_names);
|
|
||||||
summary_format!("DanglingTeleport","No matching Spawn for {plural}: {context}")
|
|
||||||
}
|
|
||||||
};
|
|
||||||
let duplicate_spawns=match &self.spawn_counts{
|
|
||||||
DuplicateCheck(Ok(()))=>passed!("DuplicateSpawn"),
|
|
||||||
DuplicateCheck(Err(DuplicateCheckContext(context)))=>{
|
|
||||||
let context=Separated::new(", ",||context.iter().map(|(&stage_id,&names)|
|
|
||||||
Duplicates::new(StageElement{behaviour:StageElementBehaviour::Spawn,stage_id},names as usize)
|
|
||||||
));
|
|
||||||
summary_format!("DuplicateSpawn","Duplicate Spawn: {context}")
|
|
||||||
}
|
|
||||||
};
|
|
||||||
let (extra_wormhole_in,missing_wormhole_in)=match &self.wormhole_in_counts{
|
|
||||||
SetDifferenceCheck(Ok(()))=>(passed!("ExtraWormholeIn"),passed!("MissingWormholeIn")),
|
|
||||||
SetDifferenceCheck(Err(context))=>(
|
|
||||||
if context.extra.is_empty(){
|
|
||||||
passed!("ExtraWormholeIn")
|
|
||||||
}else{
|
|
||||||
let context=Separated::new(", ",||context.extra.iter().map(|(&wormhole_id,_names)|
|
|
||||||
WormholeElement{behaviour:WormholeBehaviour::In,wormhole_id}
|
|
||||||
));
|
|
||||||
summary_format!("ExtraWormholeIn","WormholeIn with no matching WormholeOut: {context}")
|
|
||||||
},
|
|
||||||
if context.missing.is_empty(){
|
|
||||||
passed!("MissingWormholeIn")
|
|
||||||
}else{
|
|
||||||
// This counts WormholeIn objects, but
|
|
||||||
// flipped logic is easier to understand
|
|
||||||
let context=Separated::new(", ",||context.missing.iter().map(|&wormhole_id|
|
|
||||||
WormholeElement{behaviour:WormholeBehaviour::Out,wormhole_id}
|
|
||||||
));
|
|
||||||
summary_format!("MissingWormholeIn","WormholeOut with no matching WormholeIn: {context}")
|
|
||||||
}
|
|
||||||
)
|
|
||||||
};
|
|
||||||
let duplicate_wormhole_out=match &self.wormhole_out_counts{
|
|
||||||
DuplicateCheck(Ok(()))=>passed!("DuplicateWormholeOut"),
|
|
||||||
DuplicateCheck(Err(DuplicateCheckContext(context)))=>{
|
|
||||||
let context=Separated::new(", ",||context.iter().map(|(&wormhole_id,&names)|
|
|
||||||
Duplicates::new(WormholeElement{behaviour:WormholeBehaviour::Out,wormhole_id},names as usize)
|
|
||||||
));
|
|
||||||
summary_format!("DuplicateWormholeOut","Duplicate WormholeOut: {context}")
|
|
||||||
}
|
|
||||||
};
|
|
||||||
Ok(MapCheckList{checks:Box::new([
|
|
||||||
model_class,
|
|
||||||
model_name,
|
|
||||||
display_name,
|
|
||||||
creator,
|
|
||||||
game_id,
|
|
||||||
mapstart,
|
|
||||||
duplicate_start,
|
|
||||||
extra_finish,
|
|
||||||
missing_finish,
|
|
||||||
dangling_anticheat,
|
|
||||||
spawn1,
|
|
||||||
dangling_teleport,
|
|
||||||
duplicate_spawns,
|
|
||||||
extra_wormhole_in,
|
|
||||||
missing_wormhole_in,
|
|
||||||
duplicate_wormhole_out,
|
|
||||||
])})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(serde::Serialize)]
|
|
||||||
pub struct MapCheckList{
|
|
||||||
pub checks:Box<[Check;16]>,
|
|
||||||
}
|
|
||||||
|
|
||||||
pub struct CheckListAndVersion{
|
|
||||||
pub status:Result<MapInfoOwned,MapCheckList>,
|
|
||||||
pub version:u64,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl crate::message_handler::MessageHandler{
|
|
||||||
pub async fn check_inner(&self,check_info:CheckRequest)->Result<CheckListAndVersion,Error>{
|
|
||||||
// discover asset creator and latest version
|
|
||||||
let info=self.cloud_context.get_asset_info(
|
|
||||||
rbx_asset::cloud::GetAssetLatestRequest{asset_id:check_info.ModelID}
|
|
||||||
).await.map_err(Error::ModelInfoDownload)?;
|
|
||||||
|
|
||||||
// reject models created by a group
|
|
||||||
let rbx_asset::cloud::Creator::userId(_user_id)=info.creationContext.creator else{
|
|
||||||
return Err(Error::CreatorTypeMustBeUser);
|
|
||||||
};
|
|
||||||
|
|
||||||
// parse model version string
|
|
||||||
let version=info.revisionId;
|
|
||||||
|
|
||||||
let maybe_gzip=download_asset_version(&self.cloud_context,rbx_asset::cloud::GetAssetVersionRequest{
|
|
||||||
asset_id:check_info.ModelID,
|
|
||||||
version,
|
|
||||||
}).await.map_err(Error::Download)?;
|
|
||||||
|
|
||||||
// decode dom (slow!)
|
|
||||||
let dom=maybe_gzip.read_with(read_dom,read_dom).map_err(Error::ModelFileDecode)?;
|
|
||||||
|
|
||||||
// extract the root instance
|
|
||||||
let model_instance=get_root_instance(&dom).map_err(Error::GetRootInstance)?;
|
|
||||||
|
|
||||||
// skip checks
|
|
||||||
if check_info.SkipChecks{
|
|
||||||
// extract required fields
|
|
||||||
let map_info=get_mapinfo(&dom,model_instance);
|
|
||||||
let map_info_owned=map_info.try_into().map_err(Error::IntoMapInfoOwned)?;
|
|
||||||
let status=Ok(map_info_owned);
|
|
||||||
|
|
||||||
// return early
|
|
||||||
return Ok(CheckListAndVersion{status,version});
|
|
||||||
}
|
|
||||||
|
|
||||||
// extract information from the model
|
|
||||||
let model_info=get_model_info(&dom,model_instance);
|
|
||||||
|
|
||||||
// convert the model information into a structured report
|
|
||||||
let map_check=model_info.check();
|
|
||||||
|
|
||||||
// check the report, generate an error message if it fails the check
|
|
||||||
let status=match map_check.result(){
|
|
||||||
Ok(map_info)=>Ok(map_info),
|
|
||||||
Err(Ok(check_list))=>Err(check_list),
|
|
||||||
Err(Err(e))=>return Err(Error::ToJsonValue(e)),
|
|
||||||
};
|
|
||||||
|
|
||||||
Ok(CheckListAndVersion{status,version})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,67 +0,0 @@
|
|||||||
use crate::check::CheckListAndVersion;
|
|
||||||
use crate::nats_types::CheckMapfixRequest;
|
|
||||||
|
|
||||||
#[allow(dead_code)]
|
|
||||||
#[derive(Debug)]
|
|
||||||
pub enum Error{
|
|
||||||
Check(crate::check::Error),
|
|
||||||
ApiActionMapfixCheck(submissions_api::Error),
|
|
||||||
}
|
|
||||||
impl std::fmt::Display for Error{
|
|
||||||
fn fmt(&self,f:&mut std::fmt::Formatter<'_>)->std::fmt::Result{
|
|
||||||
write!(f,"{self:?}")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
impl std::error::Error for Error{}
|
|
||||||
|
|
||||||
impl crate::message_handler::MessageHandler{
|
|
||||||
pub async fn check_mapfix(&self,check_info:CheckMapfixRequest)->Result<(),Error>{
|
|
||||||
let mapfix_id=check_info.MapfixID;
|
|
||||||
let check_result=self.check_inner(check_info.into()).await;
|
|
||||||
|
|
||||||
// update the mapfix depending on the result
|
|
||||||
match check_result{
|
|
||||||
Ok(CheckListAndVersion{status:Ok(map_info),version})=>{
|
|
||||||
self.api.action_mapfix_submitted(
|
|
||||||
submissions_api::types::ActionMapfixSubmittedRequest{
|
|
||||||
MapfixID:mapfix_id,
|
|
||||||
ModelVersion:version,
|
|
||||||
DisplayName:map_info.display_name,
|
|
||||||
Creator:map_info.creator,
|
|
||||||
GameID:map_info.game_id.into(),
|
|
||||||
}
|
|
||||||
).await.map_err(Error::ApiActionMapfixCheck)?;
|
|
||||||
|
|
||||||
// Do not proceed to request changes
|
|
||||||
return Ok(());
|
|
||||||
},
|
|
||||||
// update the mapfix model status to request changes
|
|
||||||
Ok(CheckListAndVersion{status:Err(check_list),..})=>self.api.create_mapfix_audit_check_list(
|
|
||||||
submissions_api::types::CreateMapfixAuditCheckListRequest{
|
|
||||||
MapfixID:mapfix_id,
|
|
||||||
CheckList:check_list.checks.as_slice(),
|
|
||||||
}
|
|
||||||
).await.map_err(Error::ApiActionMapfixCheck)?,
|
|
||||||
// update the mapfix model status to request changes
|
|
||||||
Err(e)=>{
|
|
||||||
// log error
|
|
||||||
println!("[check_mapfix] Error: {e}");
|
|
||||||
|
|
||||||
self.api.create_mapfix_audit_error(
|
|
||||||
submissions_api::types::CreateMapfixAuditErrorRequest{
|
|
||||||
MapfixID:mapfix_id,
|
|
||||||
ErrorMessage:e.to_string(),
|
|
||||||
}
|
|
||||||
).await.map_err(Error::ApiActionMapfixCheck)?;
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
self.api.action_mapfix_request_changes(
|
|
||||||
submissions_api::types::ActionMapfixRequestChangesRequest{
|
|
||||||
MapfixID:mapfix_id,
|
|
||||||
}
|
|
||||||
).await.map_err(Error::ApiActionMapfixCheck)?;
|
|
||||||
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,68 +0,0 @@
|
|||||||
use crate::check::CheckListAndVersion;
|
|
||||||
use crate::nats_types::CheckSubmissionRequest;
|
|
||||||
|
|
||||||
#[allow(dead_code)]
|
|
||||||
#[derive(Debug)]
|
|
||||||
pub enum Error{
|
|
||||||
Check(crate::check::Error),
|
|
||||||
ApiActionSubmissionCheck(submissions_api::Error),
|
|
||||||
}
|
|
||||||
impl std::fmt::Display for Error{
|
|
||||||
fn fmt(&self,f:&mut std::fmt::Formatter<'_>)->std::fmt::Result{
|
|
||||||
write!(f,"{self:?}")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
impl std::error::Error for Error{}
|
|
||||||
|
|
||||||
impl crate::message_handler::MessageHandler{
|
|
||||||
pub async fn check_submission(&self,check_info:CheckSubmissionRequest)->Result<(),Error>{
|
|
||||||
let submission_id=check_info.SubmissionID;
|
|
||||||
let check_result=self.check_inner(check_info.into()).await;
|
|
||||||
|
|
||||||
// update the submission depending on the result
|
|
||||||
match check_result{
|
|
||||||
// update the submission model status to submitted
|
|
||||||
Ok(CheckListAndVersion{status:Ok(map_info),version})=>{
|
|
||||||
self.api.action_submission_submitted(
|
|
||||||
submissions_api::types::ActionSubmissionSubmittedRequest{
|
|
||||||
SubmissionID:submission_id,
|
|
||||||
ModelVersion:version,
|
|
||||||
DisplayName:map_info.display_name,
|
|
||||||
Creator:map_info.creator,
|
|
||||||
GameID:map_info.game_id.into(),
|
|
||||||
}
|
|
||||||
).await.map_err(Error::ApiActionSubmissionCheck)?;
|
|
||||||
|
|
||||||
// Do not proceed to request changes
|
|
||||||
return Ok(());
|
|
||||||
},
|
|
||||||
// update the submission model status to request changes
|
|
||||||
Ok(CheckListAndVersion{status:Err(check_list),..})=>self.api.create_submission_audit_check_list(
|
|
||||||
submissions_api::types::CreateSubmissionAuditCheckListRequest{
|
|
||||||
SubmissionID:submission_id,
|
|
||||||
CheckList:check_list.checks.as_slice(),
|
|
||||||
}
|
|
||||||
).await.map_err(Error::ApiActionSubmissionCheck)?,
|
|
||||||
// update the submission model status to request changes
|
|
||||||
Err(e)=>{
|
|
||||||
// log error
|
|
||||||
println!("[check_submission] Error: {e}");
|
|
||||||
|
|
||||||
self.api.create_submission_audit_error(
|
|
||||||
submissions_api::types::CreateSubmissionAuditErrorRequest{
|
|
||||||
SubmissionID:submission_id,
|
|
||||||
ErrorMessage:e.to_string(),
|
|
||||||
}
|
|
||||||
).await.map_err(Error::ApiActionSubmissionCheck)?;
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
self.api.action_submission_request_changes(
|
|
||||||
submissions_api::types::ActionSubmissionRequestChangesRequest{
|
|
||||||
SubmissionID:submission_id,
|
|
||||||
}
|
|
||||||
).await.map_err(Error::ApiActionSubmissionCheck)?;
|
|
||||||
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,14 +1,18 @@
|
|||||||
use crate::download::download_asset_version;
|
use crate::rbx_util::{get_mapinfo,read_dom,MapInfo,ReadDomError,GetMapInfoError,ParseGameIDError};
|
||||||
use crate::rbx_util::{get_root_instance,get_mapinfo,read_dom,MapInfo,ReadDomError,GetRootInstanceError,GameID};
|
|
||||||
|
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub enum Error{
|
pub enum Error{
|
||||||
CreatorTypeMustBeUser,
|
ModelVersionsPage(rbx_asset::cookie::PageError),
|
||||||
ModelInfoDownload(rbx_asset::cloud::GetError),
|
EmptyVersionsPage,
|
||||||
Download(crate::download::Error),
|
CreatorTypeMustBeUser(rbx_asset::cookie::CreatorType),
|
||||||
|
ModelDetails(rbx_asset::cookie::GetError),
|
||||||
|
ModelInfoDownload(rbx_asset::cookie::GetAssetV2Error),
|
||||||
|
ModelFileDownload(rbx_asset::cookie::GetError),
|
||||||
|
NoLocations,
|
||||||
ModelFileDecode(ReadDomError),
|
ModelFileDecode(ReadDomError),
|
||||||
GetRootInstance(GetRootInstanceError),
|
GetMapInfo(GetMapInfoError),
|
||||||
|
ParseGameID(ParseGameIDError),
|
||||||
}
|
}
|
||||||
impl std::fmt::Display for Error{
|
impl std::fmt::Display for Error{
|
||||||
fn fmt(&self,f:&mut std::fmt::Formatter<'_>)->std::fmt::Result{
|
fn fmt(&self,f:&mut std::fmt::Formatter<'_>)->std::fmt::Result{
|
||||||
@@ -23,50 +27,57 @@ pub struct CreateRequest{
|
|||||||
}
|
}
|
||||||
#[allow(nonstandard_style)]
|
#[allow(nonstandard_style)]
|
||||||
pub struct CreateResult{
|
pub struct CreateResult{
|
||||||
pub AssetOwner:u64,
|
pub AssetOwner:i64,
|
||||||
pub DisplayName:Option<String>,
|
pub DisplayName:String,
|
||||||
pub Creator:Option<String>,
|
pub Creator:String,
|
||||||
pub GameID:Option<GameID>,
|
pub GameID:i32,
|
||||||
pub AssetVersion:u64,
|
pub AssetVersion:u64,
|
||||||
}
|
}
|
||||||
impl crate::message_handler::MessageHandler{
|
impl crate::message_handler::MessageHandler{
|
||||||
pub async fn create_inner(&self,create_info:CreateRequest)->Result<CreateResult,Error>{
|
pub async fn create_inner(&self,create_info:CreateRequest)->Result<CreateResult,Error>{
|
||||||
// discover asset creator and latest version
|
// discover asset creator
|
||||||
let info=self.cloud_context.get_asset_info(
|
let creator_fut=async{
|
||||||
rbx_asset::cloud::GetAssetLatestRequest{asset_id:create_info.ModelID}
|
self.cookie_context.get_asset_details(
|
||||||
).await.map_err(Error::ModelInfoDownload)?;
|
rbx_asset::cookie::GetAssetDetailsRequest{asset_id:create_info.ModelID}
|
||||||
|
).await.map_err(Error::ModelDetails)
|
||||||
// reject models created by a group
|
|
||||||
let rbx_asset::cloud::Creator::userId(user_id)=info.creationContext.creator else{
|
|
||||||
return Err(Error::CreatorTypeMustBeUser);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
let asset_version=info.revisionId;
|
|
||||||
|
|
||||||
// download the map model
|
// download the map model
|
||||||
let maybe_gzip=download_asset_version(&self.cloud_context,rbx_asset::cloud::GetAssetVersionRequest{
|
let asset_fut=async{
|
||||||
asset_id:create_info.ModelID,
|
let asset_info=self.cookie_context.get_asset_v2(rbx_asset::cookie::GetAssetRequest{
|
||||||
version:asset_version,
|
asset_id:create_info.ModelID,
|
||||||
}).await.map_err(Error::Download)?;
|
version:None,
|
||||||
|
}).await.map_err(Error::ModelInfoDownload)?;
|
||||||
|
|
||||||
|
let location=asset_info.info.locations.first().ok_or(Error::NoLocations)?;
|
||||||
|
let data=self.cookie_context.get_asset_v2_download(location).await.map_err(Error::ModelFileDownload)?;
|
||||||
|
|
||||||
|
Ok((asset_info.version,data))
|
||||||
|
};
|
||||||
|
|
||||||
|
let (details,(asset_version,model_data))=tokio::try_join!(creator_fut,asset_fut)?;
|
||||||
|
|
||||||
|
if details.Creator.CreatorType!=rbx_asset::cookie::CreatorType::User{
|
||||||
|
return Err(Error::CreatorTypeMustBeUser(details.Creator.CreatorType));
|
||||||
|
}
|
||||||
|
|
||||||
// decode dom (slow!)
|
// decode dom (slow!)
|
||||||
let dom=maybe_gzip.read_with(read_dom,read_dom).map_err(Error::ModelFileDecode)?;
|
let dom=read_dom(&mut std::io::Cursor::new(model_data)).map_err(Error::ModelFileDecode)?;
|
||||||
|
|
||||||
// extract the root instance
|
|
||||||
let model_instance=get_root_instance(&dom).map_err(Error::GetRootInstance)?;
|
|
||||||
|
|
||||||
// parse create fields out of asset
|
// parse create fields out of asset
|
||||||
let MapInfo{
|
let MapInfo{
|
||||||
display_name,
|
display_name,
|
||||||
creator,
|
creator,
|
||||||
game_id,
|
game_id,
|
||||||
}=get_mapinfo(&dom,model_instance);
|
}=get_mapinfo(&dom).map_err(Error::GetMapInfo)?;
|
||||||
|
|
||||||
|
let game_id=game_id.map_err(Error::ParseGameID)?;
|
||||||
|
|
||||||
Ok(CreateResult{
|
Ok(CreateResult{
|
||||||
AssetOwner:user_id,
|
AssetOwner:details.Creator.Id as i64,
|
||||||
DisplayName:display_name.ok().map(ToOwned::to_owned),
|
DisplayName:display_name.unwrap_or_default().to_owned(),
|
||||||
Creator:creator.ok().map(ToOwned::to_owned),
|
Creator:creator.unwrap_or_default().to_owned(),
|
||||||
GameID:game_id.ok(),
|
GameID:game_id as i32,
|
||||||
AssetVersion:asset_version,
|
AssetVersion:asset_version,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,15 +24,13 @@ impl crate::message_handler::MessageHandler{
|
|||||||
// call create on api
|
// call create on api
|
||||||
self.api.create_mapfix(submissions_api::types::CreateMapfixRequest{
|
self.api.create_mapfix(submissions_api::types::CreateMapfixRequest{
|
||||||
OperationID:create_info.OperationID,
|
OperationID:create_info.OperationID,
|
||||||
AssetOwner:create_request.AssetOwner as i64,
|
AssetOwner:create_request.AssetOwner,
|
||||||
DisplayName:create_request.DisplayName.as_deref().unwrap_or_default(),
|
DisplayName:create_request.DisplayName.as_str(),
|
||||||
Creator:create_request.Creator.as_deref().unwrap_or_default(),
|
Creator:create_request.Creator.as_str(),
|
||||||
// not great TODO: make this great
|
GameID:create_request.GameID,
|
||||||
GameID:create_request.GameID.unwrap_or(crate::rbx_util::GameID::Bhop).into(),
|
|
||||||
AssetID:create_info.ModelID,
|
AssetID:create_info.ModelID,
|
||||||
AssetVersion:create_request.AssetVersion,
|
AssetVersion:create_request.AssetVersion,
|
||||||
TargetAssetID:create_info.TargetAssetID,
|
TargetAssetID:create_info.TargetAssetID,
|
||||||
Description:create_info.Description.as_str(),
|
|
||||||
}).await.map_err(Error::ApiActionMapfixCreate)?;
|
}).await.map_err(Error::ApiActionMapfixCreate)?;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
@@ -43,12 +41,9 @@ impl crate::message_handler::MessageHandler{
|
|||||||
let create_result=self.create_mapfix_inner(create_info).await;
|
let create_result=self.create_mapfix_inner(create_info).await;
|
||||||
|
|
||||||
if let Err(e)=create_result{
|
if let Err(e)=create_result{
|
||||||
// log error
|
|
||||||
println!("[create_mapfix] Error: {e}");
|
|
||||||
|
|
||||||
self.api.action_operation_failed(submissions_api::types::ActionOperationFailedRequest{
|
self.api.action_operation_failed(submissions_api::types::ActionOperationFailedRequest{
|
||||||
OperationID:operation_id,
|
OperationID:operation_id,
|
||||||
StatusMessage:e.to_string(),
|
StatusMessage:format!("{e}"),
|
||||||
}).await?;
|
}).await?;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
use crate::nats_types::CreateSubmissionRequest;
|
use crate::nats_types::CreateSubmissionRequest;
|
||||||
use crate::create::CreateRequest;
|
use crate::create::CreateRequest;
|
||||||
use crate::rbx_util::GameID;
|
|
||||||
|
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
@@ -20,33 +19,15 @@ impl crate::message_handler::MessageHandler{
|
|||||||
let create_request=self.create_inner(CreateRequest{
|
let create_request=self.create_inner(CreateRequest{
|
||||||
ModelID:create_info.ModelID,
|
ModelID:create_info.ModelID,
|
||||||
}).await.map_err(Error::Create)?;
|
}).await.map_err(Error::Create)?;
|
||||||
|
|
||||||
// grab values from submission form, otherwise try to fill blanks from map data
|
|
||||||
let display_name=if create_info.DisplayName.is_empty(){
|
|
||||||
create_request.DisplayName.as_deref().unwrap_or_default()
|
|
||||||
}else{
|
|
||||||
create_info.DisplayName.as_str()
|
|
||||||
};
|
|
||||||
|
|
||||||
let creator=if create_info.Creator.is_empty(){
|
|
||||||
create_request.Creator.as_deref().unwrap_or_default()
|
|
||||||
}else{
|
|
||||||
create_info.Creator.as_str()
|
|
||||||
};
|
|
||||||
|
|
||||||
let game_id=create_info.GameID.try_into().ok().or(create_request.GameID).unwrap_or(GameID::Bhop);
|
|
||||||
|
|
||||||
// call create on api
|
// call create on api
|
||||||
self.api.create_submission(submissions_api::types::CreateSubmissionRequest{
|
self.api.create_submission(submissions_api::types::CreateSubmissionRequest{
|
||||||
OperationID:create_info.OperationID,
|
OperationID:create_info.OperationID,
|
||||||
AssetOwner:create_request.AssetOwner as i64,
|
AssetOwner:create_request.AssetOwner,
|
||||||
DisplayName:display_name,
|
DisplayName:create_request.DisplayName.as_str(),
|
||||||
Creator:creator,
|
Creator:create_request.Creator.as_str(),
|
||||||
GameID:game_id.into(),
|
GameID:create_request.GameID,
|
||||||
AssetID:create_info.ModelID,
|
AssetID:create_info.ModelID,
|
||||||
AssetVersion:create_request.AssetVersion,
|
AssetVersion:create_request.AssetVersion,
|
||||||
Status:create_info.Status,
|
|
||||||
Roles:create_info.Roles,
|
|
||||||
}).await.map_err(Error::ApiActionSubmissionCreate)?;
|
}).await.map_err(Error::ApiActionSubmissionCreate)?;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
@@ -57,12 +38,9 @@ impl crate::message_handler::MessageHandler{
|
|||||||
let create_result=self.create_submission_inner(create_info).await;
|
let create_result=self.create_submission_inner(create_info).await;
|
||||||
|
|
||||||
if let Err(e)=create_result{
|
if let Err(e)=create_result{
|
||||||
// log error
|
|
||||||
println!("[create_submission] Error: {e}");
|
|
||||||
|
|
||||||
self.api.action_operation_failed(submissions_api::types::ActionOperationFailedRequest{
|
self.api.action_operation_failed(submissions_api::types::ActionOperationFailedRequest{
|
||||||
OperationID:operation_id,
|
OperationID:operation_id,
|
||||||
StatusMessage:e.to_string(),
|
StatusMessage:format!("{e}"),
|
||||||
}).await?;
|
}).await?;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,26 +0,0 @@
|
|||||||
#[allow(dead_code)]
|
|
||||||
#[derive(Debug)]
|
|
||||||
pub enum Error{
|
|
||||||
ModelLocationDownload(rbx_asset::cloud::GetError),
|
|
||||||
NonFreeModel,
|
|
||||||
ModelFileDownload(rbx_asset::cloud::GetError),
|
|
||||||
}
|
|
||||||
impl std::fmt::Display for Error{
|
|
||||||
fn fmt(&self,f:&mut std::fmt::Formatter<'_>)->std::fmt::Result{
|
|
||||||
write!(f,"{self:?}")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
impl std::error::Error for Error{}
|
|
||||||
|
|
||||||
pub async fn download_asset_version(cloud_context:&rbx_asset::cloud::Context,request:rbx_asset::cloud::GetAssetVersionRequest)->Result<rbx_asset::types::MaybeGzippedBytes,Error>{
|
|
||||||
// download the location of the map model
|
|
||||||
let location=cloud_context.get_asset_version_location(request).await.map_err(Error::ModelLocationDownload)?;
|
|
||||||
|
|
||||||
// if the location does not exist, you are not allowed to download it
|
|
||||||
let location=location.location.ok_or(Error::NonFreeModel)?;
|
|
||||||
|
|
||||||
// download the map model
|
|
||||||
let maybe_gzip=cloud_context.get_asset(&location).await.map_err(Error::ModelFileDownload)?;
|
|
||||||
|
|
||||||
Ok(maybe_gzip)
|
|
||||||
}
|
|
||||||
@@ -3,10 +3,7 @@ use futures::StreamExt;
|
|||||||
mod rbx_util;
|
mod rbx_util;
|
||||||
mod message_handler;
|
mod message_handler;
|
||||||
mod nats_types;
|
mod nats_types;
|
||||||
mod download;
|
mod types;
|
||||||
mod check;
|
|
||||||
mod check_mapfix;
|
|
||||||
mod check_submission;
|
|
||||||
mod create;
|
mod create;
|
||||||
mod create_mapfix;
|
mod create_mapfix;
|
||||||
mod create_submission;
|
mod create_submission;
|
||||||
@@ -23,7 +20,6 @@ pub enum StartupError{
|
|||||||
NatsConnect(async_nats::ConnectError),
|
NatsConnect(async_nats::ConnectError),
|
||||||
NatsGetStream(async_nats::jetstream::context::GetStreamError),
|
NatsGetStream(async_nats::jetstream::context::GetStreamError),
|
||||||
NatsConsumer(async_nats::jetstream::stream::ConsumerError),
|
NatsConsumer(async_nats::jetstream::stream::ConsumerError),
|
||||||
NatsConsumerUpdate(async_nats::jetstream::stream::ConsumerUpdateError),
|
|
||||||
NatsStream(async_nats::jetstream::consumer::StreamError),
|
NatsStream(async_nats::jetstream::consumer::StreamError),
|
||||||
}
|
}
|
||||||
impl std::fmt::Display for StartupError{
|
impl std::fmt::Display for StartupError{
|
||||||
@@ -42,15 +38,12 @@ async fn main()->Result<(),StartupError>{
|
|||||||
"None"=>None,
|
"None"=>None,
|
||||||
_=>Some(s.parse().expect("ROBLOX_GROUP_ID int parse")),
|
_=>Some(s.parse().expect("ROBLOX_GROUP_ID int parse")),
|
||||||
},
|
},
|
||||||
Err(e)=>panic!("{e}: ROBLOX_GROUP_ID env required"),
|
Err(e)=>Err(e).expect("ROBLOX_GROUP_ID env required"),
|
||||||
};
|
};
|
||||||
|
|
||||||
// create / upload models through STRAFESNET_CI2 account
|
// talk to roblox through STRAFESNET_CI2 account
|
||||||
let cookie=std::env::var("RBXCOOKIE").expect("RBXCOOKIE env required");
|
let cookie=std::env::var("RBXCOOKIE").expect("RBXCOOKIE env required");
|
||||||
let cookie_context=rbx_asset::cookie::Context::new(rbx_asset::cookie::Cookie::new(cookie));
|
let cookie_context=rbx_asset::cookie::CookieContext::new(rbx_asset::cookie::Cookie::new(cookie));
|
||||||
// download models through cloud api
|
|
||||||
let api_key=std::env::var("RBX_API_KEY").expect("RBX_API_KEY env required");
|
|
||||||
let cloud_context=rbx_asset::cloud::Context::new(rbx_asset::cloud::ApiKey::new(api_key));
|
|
||||||
|
|
||||||
// maps-service api
|
// maps-service api
|
||||||
let api_host_internal=std::env::var("API_HOST_INTERNAL").expect("API_HOST_INTERNAL env required");
|
let api_host_internal=std::env::var("API_HOST_INTERNAL").expect("API_HOST_INTERNAL env required");
|
||||||
@@ -59,35 +52,20 @@ async fn main()->Result<(),StartupError>{
|
|||||||
// nats
|
// nats
|
||||||
let nats_host=std::env::var("NATS_HOST").expect("NATS_HOST env required");
|
let nats_host=std::env::var("NATS_HOST").expect("NATS_HOST env required");
|
||||||
let nats_fut=async{
|
let nats_fut=async{
|
||||||
const STREAM_NAME:&str="maptest";
|
|
||||||
const DURABLE_NAME:&str="validation";
|
|
||||||
const FILTER_SUBJECT:&str="maptest.>";
|
|
||||||
|
|
||||||
let nats_config=async_nats::jetstream::consumer::pull::Config{
|
|
||||||
name:Some(DURABLE_NAME.to_owned()),
|
|
||||||
durable_name:Some(DURABLE_NAME.to_owned()),
|
|
||||||
filter_subject:FILTER_SUBJECT.to_owned(),
|
|
||||||
..Default::default()
|
|
||||||
};
|
|
||||||
|
|
||||||
let nasty=async_nats::connect(nats_host).await.map_err(StartupError::NatsConnect)?;
|
let nasty=async_nats::connect(nats_host).await.map_err(StartupError::NatsConnect)?;
|
||||||
|
|
||||||
// use nats jetstream
|
// use nats jetstream
|
||||||
let stream=async_nats::jetstream::new(nasty)
|
async_nats::jetstream::new(nasty)
|
||||||
.get_stream(STREAM_NAME).await.map_err(StartupError::NatsGetStream)?;
|
.get_stream("maptest").await.map_err(StartupError::NatsGetStream)?
|
||||||
|
.get_or_create_consumer("validation",async_nats::jetstream::consumer::pull::Config{
|
||||||
let consumer=stream.get_or_create_consumer(DURABLE_NAME,nats_config.clone()).await.map_err(StartupError::NatsConsumer)?;
|
name:Some("validation".to_owned()),
|
||||||
|
durable_name:Some("validation".to_owned()),
|
||||||
// check if config matches expected config
|
filter_subject:"maptest.>".to_owned(),
|
||||||
if consumer.cached_info().config.filter_subject!=FILTER_SUBJECT{
|
..Default::default()
|
||||||
stream.update_consumer(nats_config).await.map_err(StartupError::NatsConsumerUpdate)?;
|
}).await.map_err(StartupError::NatsConsumer)?
|
||||||
}
|
.messages().await.map_err(StartupError::NatsStream)
|
||||||
|
|
||||||
// only need messages
|
|
||||||
consumer.messages().await.map_err(StartupError::NatsStream)
|
|
||||||
};
|
};
|
||||||
|
|
||||||
let message_handler=message_handler::MessageHandler::new(cloud_context,cookie_context,group_id,api);
|
let message_handler=message_handler::MessageHandler::new(cookie_context,group_id,api);
|
||||||
|
|
||||||
// Create a signal listener for SIGTERM
|
// Create a signal listener for SIGTERM
|
||||||
let mut sig_term=tokio::signal::unix::signal(tokio::signal::unix::SignalKind::terminate()).expect("Failed to create SIGTERM signal listener");
|
let mut sig_term=tokio::signal::unix::signal(tokio::signal::unix::SignalKind::terminate()).expect("Failed to create SIGTERM signal listener");
|
||||||
|
|||||||
@@ -7,8 +7,6 @@ pub enum HandleMessageError{
|
|||||||
UnknownSubject(String),
|
UnknownSubject(String),
|
||||||
CreateMapfix(submissions_api::Error),
|
CreateMapfix(submissions_api::Error),
|
||||||
CreateSubmission(submissions_api::Error),
|
CreateSubmission(submissions_api::Error),
|
||||||
CheckMapfix(crate::check_mapfix::Error),
|
|
||||||
CheckSubmission(crate::check_submission::Error),
|
|
||||||
UploadMapfix(crate::upload_mapfix::Error),
|
UploadMapfix(crate::upload_mapfix::Error),
|
||||||
UploadSubmission(crate::upload_submission::Error),
|
UploadSubmission(crate::upload_submission::Error),
|
||||||
ValidateMapfix(crate::validate_mapfix::Error),
|
ValidateMapfix(crate::validate_mapfix::Error),
|
||||||
@@ -28,21 +26,18 @@ fn from_slice<'a,T:serde::de::Deserialize<'a>>(slice:&'a [u8])->Result<T,HandleM
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub struct MessageHandler{
|
pub struct MessageHandler{
|
||||||
pub(crate) cloud_context:rbx_asset::cloud::Context,
|
pub(crate) cookie_context:rbx_asset::cookie::CookieContext,
|
||||||
pub(crate) cookie_context:rbx_asset::cookie::Context,
|
|
||||||
pub(crate) group_id:Option<u64>,
|
pub(crate) group_id:Option<u64>,
|
||||||
pub(crate) api:submissions_api::internal::Context,
|
pub(crate) api:submissions_api::internal::Context,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl MessageHandler{
|
impl MessageHandler{
|
||||||
pub fn new(
|
pub fn new(
|
||||||
cloud_context:rbx_asset::cloud::Context,
|
cookie_context:rbx_asset::cookie::CookieContext,
|
||||||
cookie_context:rbx_asset::cookie::Context,
|
|
||||||
group_id:Option<u64>,
|
group_id:Option<u64>,
|
||||||
api:submissions_api::internal::Context,
|
api:submissions_api::internal::Context,
|
||||||
)->Self{
|
)->Self{
|
||||||
Self{
|
Self{
|
||||||
cloud_context,
|
|
||||||
cookie_context,
|
cookie_context,
|
||||||
group_id,
|
group_id,
|
||||||
api,
|
api,
|
||||||
@@ -54,8 +49,6 @@ impl MessageHandler{
|
|||||||
match message.subject.as_str(){
|
match message.subject.as_str(){
|
||||||
"maptest.mapfixes.create"=>self.create_mapfix(from_slice(&message.payload)?).await.map_err(HandleMessageError::CreateMapfix),
|
"maptest.mapfixes.create"=>self.create_mapfix(from_slice(&message.payload)?).await.map_err(HandleMessageError::CreateMapfix),
|
||||||
"maptest.submissions.create"=>self.create_submission(from_slice(&message.payload)?).await.map_err(HandleMessageError::CreateSubmission),
|
"maptest.submissions.create"=>self.create_submission(from_slice(&message.payload)?).await.map_err(HandleMessageError::CreateSubmission),
|
||||||
"maptest.mapfixes.check"=>self.check_mapfix(from_slice(&message.payload)?).await.map_err(HandleMessageError::CheckMapfix),
|
|
||||||
"maptest.submissions.check"=>self.check_submission(from_slice(&message.payload)?).await.map_err(HandleMessageError::CheckSubmission),
|
|
||||||
"maptest.mapfixes.upload"=>self.upload_mapfix(from_slice(&message.payload)?).await.map_err(HandleMessageError::UploadMapfix),
|
"maptest.mapfixes.upload"=>self.upload_mapfix(from_slice(&message.payload)?).await.map_err(HandleMessageError::UploadMapfix),
|
||||||
"maptest.submissions.upload"=>self.upload_submission(from_slice(&message.payload)?).await.map_err(HandleMessageError::UploadSubmission),
|
"maptest.submissions.upload"=>self.upload_submission(from_slice(&message.payload)?).await.map_err(HandleMessageError::UploadSubmission),
|
||||||
"maptest.mapfixes.validate"=>self.validate_mapfix(from_slice(&message.payload)?).await.map_err(HandleMessageError::ValidateMapfix),
|
"maptest.mapfixes.validate"=>self.validate_mapfix(from_slice(&message.payload)?).await.map_err(HandleMessageError::ValidateMapfix),
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
use submissions_api::types::{SubmissionID,MapfixID,OperationID};
|
|
||||||
|
|
||||||
// These represent the information needed in the nats message
|
// These represent the information needed in the nats message
|
||||||
// to perform the operation, not necessarily the over-the-wire format
|
// to perform the operation, not necessarily the over-the-wire format
|
||||||
|
|
||||||
@@ -10,46 +8,23 @@ use submissions_api::types::{SubmissionID,MapfixID,OperationID};
|
|||||||
#[derive(serde::Deserialize)]
|
#[derive(serde::Deserialize)]
|
||||||
pub struct CreateSubmissionRequest{
|
pub struct CreateSubmissionRequest{
|
||||||
// operation_id is passed back in the response message
|
// operation_id is passed back in the response message
|
||||||
pub OperationID:OperationID,
|
pub OperationID:i32,
|
||||||
pub ModelID:u64,
|
pub ModelID:u64,
|
||||||
pub DisplayName:String,
|
|
||||||
pub Creator:String,
|
|
||||||
pub GameID:u32,
|
|
||||||
// initial status is passed back on create
|
|
||||||
pub Status:u32,
|
|
||||||
pub Roles:u32,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(nonstandard_style)]
|
#[allow(nonstandard_style)]
|
||||||
#[derive(serde::Deserialize)]
|
#[derive(serde::Deserialize)]
|
||||||
pub struct CreateMapfixRequest{
|
pub struct CreateMapfixRequest{
|
||||||
pub OperationID:OperationID,
|
pub OperationID:i32,
|
||||||
pub ModelID:u64,
|
pub ModelID:u64,
|
||||||
pub TargetAssetID:u64,
|
pub TargetAssetID:u64,
|
||||||
pub Description:String,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[allow(nonstandard_style)]
|
|
||||||
#[derive(serde::Deserialize)]
|
|
||||||
pub struct CheckSubmissionRequest{
|
|
||||||
pub SubmissionID:SubmissionID,
|
|
||||||
pub ModelID:u64,
|
|
||||||
pub SkipChecks:bool,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[allow(nonstandard_style)]
|
|
||||||
#[derive(serde::Deserialize)]
|
|
||||||
pub struct CheckMapfixRequest{
|
|
||||||
pub MapfixID:MapfixID,
|
|
||||||
pub ModelID:u64,
|
|
||||||
pub SkipChecks:bool,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(nonstandard_style)]
|
#[allow(nonstandard_style)]
|
||||||
#[derive(serde::Deserialize)]
|
#[derive(serde::Deserialize)]
|
||||||
pub struct ValidateSubmissionRequest{
|
pub struct ValidateSubmissionRequest{
|
||||||
// submission_id is passed back in the response message
|
// submission_id is passed back in the response message
|
||||||
pub SubmissionID:SubmissionID,
|
pub SubmissionID:i64,
|
||||||
pub ModelID:u64,
|
pub ModelID:u64,
|
||||||
pub ModelVersion:u64,
|
pub ModelVersion:u64,
|
||||||
pub ValidatedModelID:Option<u64>,
|
pub ValidatedModelID:Option<u64>,
|
||||||
@@ -59,7 +34,7 @@ pub struct ValidateSubmissionRequest{
|
|||||||
#[derive(serde::Deserialize)]
|
#[derive(serde::Deserialize)]
|
||||||
pub struct ValidateMapfixRequest{
|
pub struct ValidateMapfixRequest{
|
||||||
// submission_id is passed back in the response message
|
// submission_id is passed back in the response message
|
||||||
pub MapfixID:MapfixID,
|
pub MapfixID:i64,
|
||||||
pub ModelID:u64,
|
pub ModelID:u64,
|
||||||
pub ModelVersion:u64,
|
pub ModelVersion:u64,
|
||||||
pub ValidatedModelID:Option<u64>,
|
pub ValidatedModelID:Option<u64>,
|
||||||
@@ -69,7 +44,7 @@ pub struct ValidateMapfixRequest{
|
|||||||
#[allow(nonstandard_style)]
|
#[allow(nonstandard_style)]
|
||||||
#[derive(serde::Deserialize)]
|
#[derive(serde::Deserialize)]
|
||||||
pub struct UploadSubmissionRequest{
|
pub struct UploadSubmissionRequest{
|
||||||
pub SubmissionID:SubmissionID,
|
pub SubmissionID:i64,
|
||||||
pub ModelID:u64,
|
pub ModelID:u64,
|
||||||
pub ModelVersion:u64,
|
pub ModelVersion:u64,
|
||||||
pub ModelName:String,
|
pub ModelName:String,
|
||||||
@@ -78,7 +53,7 @@ pub struct UploadSubmissionRequest{
|
|||||||
#[allow(nonstandard_style)]
|
#[allow(nonstandard_style)]
|
||||||
#[derive(serde::Deserialize)]
|
#[derive(serde::Deserialize)]
|
||||||
pub struct UploadMapfixRequest{
|
pub struct UploadMapfixRequest{
|
||||||
pub MapfixID:MapfixID,
|
pub MapfixID:i64,
|
||||||
pub ModelID:u64,
|
pub ModelID:u64,
|
||||||
pub ModelVersion:u64,
|
pub ModelVersion:u64,
|
||||||
pub TargetAssetID:u64,
|
pub TargetAssetID:u64,
|
||||||
|
|||||||
@@ -5,7 +5,8 @@ pub enum ReadDomError{
|
|||||||
Binary(rbx_binary::DecodeError),
|
Binary(rbx_binary::DecodeError),
|
||||||
Xml(rbx_xml::DecodeError),
|
Xml(rbx_xml::DecodeError),
|
||||||
Read(std::io::Error),
|
Read(std::io::Error),
|
||||||
UnknownFormat(Vec<u8>),
|
Seek(std::io::Error),
|
||||||
|
UnknownFormat([u8;8]),
|
||||||
}
|
}
|
||||||
impl std::fmt::Display for ReadDomError{
|
impl std::fmt::Display for ReadDomError{
|
||||||
fn fmt(&self,f:&mut std::fmt::Formatter<'_>)->std::fmt::Result{
|
fn fmt(&self,f:&mut std::fmt::Formatter<'_>)->std::fmt::Result{
|
||||||
@@ -14,22 +15,44 @@ impl std::fmt::Display for ReadDomError{
|
|||||||
}
|
}
|
||||||
impl std::error::Error for ReadDomError{}
|
impl std::error::Error for ReadDomError{}
|
||||||
|
|
||||||
pub fn read_dom<R:std::io::Read>(input:R)->Result<rbx_dom_weak::WeakDom,ReadDomError>{
|
pub fn read_dom<R:std::io::Read+std::io::Seek>(input:&mut R)->Result<rbx_dom_weak::WeakDom,ReadDomError>{
|
||||||
let mut buf=std::io::BufReader::new(input);
|
let mut first_8=[0u8;8];
|
||||||
let peek=std::io::BufRead::fill_buf(&mut buf).map_err(ReadDomError::Read)?;
|
std::io::Read::read_exact(input,&mut first_8).map_err(ReadDomError::Read)?;
|
||||||
match peek.get(0..8){
|
std::io::Seek::rewind(input).map_err(ReadDomError::Seek)?;
|
||||||
Some(b"<roblox!")=>rbx_binary::from_reader(buf).map_err(ReadDomError::Binary),
|
match &first_8[0..4]{
|
||||||
Some(b"<roblox ")=>rbx_xml::from_reader_default(buf).map_err(ReadDomError::Xml),
|
b"<rob"=>{
|
||||||
_=>Err(ReadDomError::UnknownFormat(peek.to_owned())),
|
match &first_8[4..8]{
|
||||||
|
b"lox!"=>rbx_binary::from_reader(input).map_err(ReadDomError::Binary),
|
||||||
|
b"lox "=>rbx_xml::from_reader(input,rbx_xml::DecodeOptions::default()).map_err(ReadDomError::Xml),
|
||||||
|
_=>Err(ReadDomError::UnknownFormat(first_8)),
|
||||||
|
}
|
||||||
|
},
|
||||||
|
_=>Err(ReadDomError::UnknownFormat(first_8)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn static_ustr(s:&'static str)->rbx_dom_weak::Ustr{
|
pub fn class_is_a(class:&str,superclass:&str)->bool{
|
||||||
rbx_dom_weak::ustr(s)
|
if class==superclass{
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
let class_descriptor=rbx_reflection_database::get().classes.get(class);
|
||||||
|
if let Some(descriptor)=&class_descriptor{
|
||||||
|
if let Some(class_super)=&descriptor.superclass{
|
||||||
|
return class_is_a(&class_super,superclass)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
false
|
||||||
}
|
}
|
||||||
|
|
||||||
fn find_first_child_name_and_class<'a>(dom:&'a rbx_dom_weak::WeakDom,instance:&rbx_dom_weak::Instance,name:&str,class:&str)->Option<&'a rbx_dom_weak::Instance>{
|
pub fn find_first_child_class<'a>(dom:&'a rbx_dom_weak::WeakDom,instance:&rbx_dom_weak::Instance,name:&str,class:&str)->Option<&'a rbx_dom_weak::Instance>{
|
||||||
instance.children().iter().filter_map(|&r|dom.get_by_ref(r)).find(|inst|inst.name==name&&inst.class==class)
|
for &referent in instance.children(){
|
||||||
|
if let Some(c)=dom.get_by_ref(referent){
|
||||||
|
if c.name==name&&class_is_a(c.class.as_str(),class) {
|
||||||
|
return Some(c);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
None
|
||||||
}
|
}
|
||||||
|
|
||||||
pub enum GameID{
|
pub enum GameID{
|
||||||
@@ -37,15 +60,6 @@ pub enum GameID{
|
|||||||
Surf=2,
|
Surf=2,
|
||||||
FlyTrials=5,
|
FlyTrials=5,
|
||||||
}
|
}
|
||||||
impl From<GameID> for submissions_api::types::GameID{
|
|
||||||
fn from(value:GameID)->Self{
|
|
||||||
match value{
|
|
||||||
GameID::Bhop=>submissions_api::types::GameID::Bhop,
|
|
||||||
GameID::Surf=>submissions_api::types::GameID::Surf,
|
|
||||||
GameID::FlyTrials=>submissions_api::types::GameID::FlyTrials,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct ParseGameIDError;
|
pub struct ParseGameIDError;
|
||||||
impl std::str::FromStr for GameID{
|
impl std::str::FromStr for GameID{
|
||||||
@@ -60,19 +74,7 @@ impl std::str::FromStr for GameID{
|
|||||||
if s.starts_with("flytrials_"){
|
if s.starts_with("flytrials_"){
|
||||||
return Ok(GameID::FlyTrials);
|
return Ok(GameID::FlyTrials);
|
||||||
}
|
}
|
||||||
Err(ParseGameIDError)
|
return Err(ParseGameIDError);
|
||||||
}
|
|
||||||
}
|
|
||||||
pub struct GameIDError;
|
|
||||||
impl TryFrom<u32> for GameID{
|
|
||||||
type Error=GameIDError;
|
|
||||||
fn try_from(value:u32)->Result<Self,Self::Error>{
|
|
||||||
match value{
|
|
||||||
1=>Ok(GameID::Bhop),
|
|
||||||
2=>Ok(GameID::Surf),
|
|
||||||
5=>Ok(GameID::FlyTrials),
|
|
||||||
_=>Err(GameIDError)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -82,7 +84,6 @@ pub struct MapInfo<'a>{
|
|||||||
pub game_id:Result<GameID,ParseGameIDError>,
|
pub game_id:Result<GameID,ParseGameIDError>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
|
||||||
pub enum StringValueError{
|
pub enum StringValueError{
|
||||||
ObjectNotFound,
|
ObjectNotFound,
|
||||||
ValueNotSet,
|
ValueNotSet,
|
||||||
@@ -91,7 +92,7 @@ pub enum StringValueError{
|
|||||||
|
|
||||||
fn string_value(instance:Option<&rbx_dom_weak::Instance>)->Result<&str,StringValueError>{
|
fn string_value(instance:Option<&rbx_dom_weak::Instance>)->Result<&str,StringValueError>{
|
||||||
let instance=instance.ok_or(StringValueError::ObjectNotFound)?;
|
let instance=instance.ok_or(StringValueError::ObjectNotFound)?;
|
||||||
let value=instance.properties.get(&static_ustr("Value")).ok_or(StringValueError::ValueNotSet)?;
|
let value=instance.properties.get("Value").ok_or(StringValueError::ValueNotSet)?;
|
||||||
match value{
|
match value{
|
||||||
rbx_dom_weak::types::Variant::String(value)=>Ok(value),
|
rbx_dom_weak::types::Variant::String(value)=>Ok(value),
|
||||||
_=>Err(StringValueError::NonStringValue),
|
_=>Err(StringValueError::NonStringValue),
|
||||||
@@ -99,24 +100,20 @@ fn string_value(instance:Option<&rbx_dom_weak::Instance>)->Result<&str,StringVal
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub enum GetRootInstanceError{
|
pub enum GetMapInfoError{
|
||||||
ModelFileRootMustHaveOneChild,
|
ModelFileRootMustHaveOneChild,
|
||||||
ModelFileChildRefIsNil,
|
ModelFileChildRefIsNil,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_root_instance(dom:&rbx_dom_weak::WeakDom)->Result<&rbx_dom_weak::Instance,GetRootInstanceError>{
|
pub fn get_mapinfo(dom:&rbx_dom_weak::WeakDom)->Result<MapInfo,GetMapInfoError>{
|
||||||
let &[map_ref]=dom.root().children()else{
|
let &[map_ref]=dom.root().children()else{
|
||||||
return Err(GetRootInstanceError::ModelFileRootMustHaveOneChild);
|
return Err(GetMapInfoError::ModelFileRootMustHaveOneChild);
|
||||||
};
|
};
|
||||||
let model_instance=dom.get_by_ref(map_ref).ok_or(GetRootInstanceError::ModelFileChildRefIsNil)?;
|
let model_instance=dom.get_by_ref(map_ref).ok_or(GetMapInfoError::ModelFileChildRefIsNil)?;
|
||||||
|
|
||||||
Ok(model_instance)
|
Ok(MapInfo{
|
||||||
}
|
display_name:string_value(find_first_child_class(dom,model_instance,"DisplayName","StringValue")),
|
||||||
|
creator:string_value(find_first_child_class(dom,model_instance,"Creator","StringValue")),
|
||||||
pub fn get_mapinfo<'a>(dom:&'a rbx_dom_weak::WeakDom,model_instance:&rbx_dom_weak::Instance)->MapInfo<'a>{
|
|
||||||
MapInfo{
|
|
||||||
display_name:string_value(find_first_child_name_and_class(dom,model_instance,"DisplayName","StringValue")),
|
|
||||||
creator:string_value(find_first_child_name_and_class(dom,model_instance,"Creator","StringValue")),
|
|
||||||
game_id:model_instance.name.parse(),
|
game_id:model_instance.name.parse(),
|
||||||
}
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
4
validation/src/types.rs
Normal file
4
validation/src/types.rs
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
pub enum ResourceID{
|
||||||
|
Mapfix(i64),
|
||||||
|
Submission(i64),
|
||||||
|
}
|
||||||
@@ -1,11 +1,9 @@
|
|||||||
use crate::download::download_asset_version;
|
|
||||||
use crate::nats_types::UploadMapfixRequest;
|
use crate::nats_types::UploadMapfixRequest;
|
||||||
|
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub enum Error{
|
pub enum Error{
|
||||||
Download(crate::download::Error),
|
Get(rbx_asset::cookie::GetError),
|
||||||
IO(std::io::Error),
|
|
||||||
Json(serde_json::Error),
|
Json(serde_json::Error),
|
||||||
Upload(rbx_asset::cookie::UploadError),
|
Upload(rbx_asset::cookie::UploadError),
|
||||||
ApiActionMapfixUploaded(submissions_api::Error),
|
ApiActionMapfixUploaded(submissions_api::Error),
|
||||||
@@ -19,14 +17,11 @@ impl std::error::Error for Error{}
|
|||||||
|
|
||||||
impl crate::message_handler::MessageHandler{
|
impl crate::message_handler::MessageHandler{
|
||||||
pub async fn upload_mapfix(&self,upload_info:UploadMapfixRequest)->Result<(),Error>{
|
pub async fn upload_mapfix(&self,upload_info:UploadMapfixRequest)->Result<(),Error>{
|
||||||
// download the map model
|
// download the map model version
|
||||||
let maybe_gzip=download_asset_version(&self.cloud_context,rbx_asset::cloud::GetAssetVersionRequest{
|
let model_data=self.cookie_context.get_asset(rbx_asset::cookie::GetAssetRequest{
|
||||||
asset_id:upload_info.ModelID,
|
asset_id:upload_info.ModelID,
|
||||||
version:upload_info.ModelVersion,
|
version:Some(upload_info.ModelVersion),
|
||||||
}).await.map_err(Error::Download)?;
|
}).await.map_err(Error::Get)?;
|
||||||
|
|
||||||
// transparently handle gzipped models
|
|
||||||
let model_data=maybe_gzip.to_vec().map_err(Error::IO)?;
|
|
||||||
|
|
||||||
// upload the map to the strafesnet group
|
// upload the map to the strafesnet group
|
||||||
let _upload_response=self.cookie_context.upload(rbx_asset::cookie::UploadRequest{
|
let _upload_response=self.cookie_context.upload(rbx_asset::cookie::UploadRequest{
|
||||||
|
|||||||
@@ -1,11 +1,9 @@
|
|||||||
use crate::download::download_asset_version;
|
|
||||||
use crate::nats_types::UploadSubmissionRequest;
|
use crate::nats_types::UploadSubmissionRequest;
|
||||||
|
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub enum Error{
|
pub enum Error{
|
||||||
Download(crate::download::Error),
|
Get(rbx_asset::cookie::GetError),
|
||||||
IO(std::io::Error),
|
|
||||||
Json(serde_json::Error),
|
Json(serde_json::Error),
|
||||||
Create(rbx_asset::cookie::CreateError),
|
Create(rbx_asset::cookie::CreateError),
|
||||||
SystemTime(std::time::SystemTimeError),
|
SystemTime(std::time::SystemTimeError),
|
||||||
@@ -20,14 +18,11 @@ impl std::error::Error for Error{}
|
|||||||
|
|
||||||
impl crate::message_handler::MessageHandler{
|
impl crate::message_handler::MessageHandler{
|
||||||
pub async fn upload_submission(&self,upload_info:UploadSubmissionRequest)->Result<(),Error>{
|
pub async fn upload_submission(&self,upload_info:UploadSubmissionRequest)->Result<(),Error>{
|
||||||
// download the map model
|
// download the map model version
|
||||||
let maybe_gzip=download_asset_version(&self.cloud_context,rbx_asset::cloud::GetAssetVersionRequest{
|
let model_data=self.cookie_context.get_asset(rbx_asset::cookie::GetAssetRequest{
|
||||||
asset_id:upload_info.ModelID,
|
asset_id:upload_info.ModelID,
|
||||||
version:upload_info.ModelVersion,
|
version:Some(upload_info.ModelVersion),
|
||||||
}).await.map_err(Error::Download)?;
|
}).await.map_err(Error::Get)?;
|
||||||
|
|
||||||
// transparently handle gzipped models
|
|
||||||
let model_data=maybe_gzip.to_vec().map_err(Error::IO)?;
|
|
||||||
|
|
||||||
// upload the map to the strafesnet group
|
// upload the map to the strafesnet group
|
||||||
let upload_response=self.cookie_context.create(rbx_asset::cookie::CreateRequest{
|
let upload_response=self.cookie_context.create(rbx_asset::cookie::CreateRequest{
|
||||||
|
|||||||
@@ -22,23 +22,14 @@ impl crate::message_handler::MessageHandler{
|
|||||||
Ok(())=>{
|
Ok(())=>{
|
||||||
// update the mapfix model status to validated
|
// update the mapfix model status to validated
|
||||||
self.api.action_mapfix_validated(
|
self.api.action_mapfix_validated(
|
||||||
mapfix_id
|
submissions_api::types::MapfixID(mapfix_id)
|
||||||
).await.map_err(Error::ApiActionMapfixValidate)?;
|
).await.map_err(Error::ApiActionMapfixValidate)?;
|
||||||
},
|
},
|
||||||
Err(e)=>{
|
Err(e)=>{
|
||||||
// log error
|
|
||||||
println!("[validate_mapfix] Error: {e}");
|
|
||||||
|
|
||||||
self.api.create_mapfix_audit_error(
|
|
||||||
submissions_api::types::CreateMapfixAuditErrorRequest{
|
|
||||||
MapfixID:mapfix_id,
|
|
||||||
ErrorMessage:e.to_string(),
|
|
||||||
}
|
|
||||||
).await.map_err(Error::ApiActionMapfixValidate)?;
|
|
||||||
|
|
||||||
// update the mapfix model status to accepted
|
// update the mapfix model status to accepted
|
||||||
self.api.action_mapfix_accepted(submissions_api::types::ActionMapfixAcceptedRequest{
|
self.api.action_mapfix_accepted(submissions_api::types::ActionMapfixAcceptedRequest{
|
||||||
MapfixID:mapfix_id,
|
MapfixID:mapfix_id,
|
||||||
|
StatusMessage:format!("{e}"),
|
||||||
}).await.map_err(Error::ApiActionMapfixValidate)?;
|
}).await.map_err(Error::ApiActionMapfixValidate)?;
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,23 +22,14 @@ impl crate::message_handler::MessageHandler{
|
|||||||
Ok(())=>{
|
Ok(())=>{
|
||||||
// update the submission model status to validated
|
// update the submission model status to validated
|
||||||
self.api.action_submission_validated(
|
self.api.action_submission_validated(
|
||||||
submission_id
|
submissions_api::types::SubmissionID(submission_id)
|
||||||
).await.map_err(Error::ApiActionSubmissionValidate)?;
|
).await.map_err(Error::ApiActionSubmissionValidate)?;
|
||||||
},
|
},
|
||||||
Err(e)=>{
|
Err(e)=>{
|
||||||
// log error
|
|
||||||
println!("[validate_submission] Error: {e}");
|
|
||||||
|
|
||||||
self.api.create_submission_audit_error(
|
|
||||||
submissions_api::types::CreateSubmissionAuditErrorRequest{
|
|
||||||
SubmissionID:submission_id,
|
|
||||||
ErrorMessage:e.to_string(),
|
|
||||||
}
|
|
||||||
).await.map_err(Error::ApiActionSubmissionValidate)?;
|
|
||||||
|
|
||||||
// update the submission model status to accepted
|
// update the submission model status to accepted
|
||||||
self.api.action_submission_accepted(submissions_api::types::ActionSubmissionAcceptedRequest{
|
self.api.action_submission_accepted(submissions_api::types::ActionSubmissionAcceptedRequest{
|
||||||
SubmissionID:submission_id,
|
SubmissionID:submission_id,
|
||||||
|
StatusMessage:format!("{e}"),
|
||||||
}).await.map_err(Error::ApiActionSubmissionValidate)?;
|
}).await.map_err(Error::ApiActionSubmissionValidate)?;
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
use futures::TryStreamExt;
|
use futures::TryStreamExt;
|
||||||
use submissions_api::types::Resource;
|
use submissions_api::types::ResourceType;
|
||||||
|
|
||||||
use crate::download::download_asset_version;
|
use crate::rbx_util::{class_is_a,read_dom,ReadDomError};
|
||||||
use crate::rbx_util::{read_dom,static_ustr,ReadDomError};
|
use crate::types::ResourceID;
|
||||||
|
|
||||||
const SCRIPT_CONCURRENCY:usize=16;
|
const SCRIPT_CONCURRENCY:usize=16;
|
||||||
|
|
||||||
@@ -20,7 +20,7 @@ struct NamePolicy{
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn source_has_illegal_keywords(source:&str)->bool{
|
fn source_has_illegal_keywords(source:&str)->bool{
|
||||||
source.contains("getfenv")||source.contains("require")
|
source.find("getfenv").is_some()||source.find("require").is_some()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn hash_source(source:&str)->String{
|
fn hash_source(source:&str)->String{
|
||||||
@@ -32,23 +32,17 @@ fn hash_source(source:&str)->String{
|
|||||||
|
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub enum Error{
|
pub enum ValidateError{
|
||||||
ModelInfoDownload(rbx_asset::cloud::GetError),
|
|
||||||
CreatorTypeMustBeUser,
|
|
||||||
RevisionMismatch{
|
|
||||||
current:u64,
|
|
||||||
submitted:u64,
|
|
||||||
},
|
|
||||||
ScriptFlaggedIllegalKeyword(String),
|
ScriptFlaggedIllegalKeyword(String),
|
||||||
ScriptBlocked(Option<submissions_api::types::ScriptID>),
|
ScriptBlocked(Option<submissions_api::types::ScriptID>),
|
||||||
ScriptNotYetReviewed(Option<submissions_api::types::ScriptID>),
|
ScriptNotYetReviewed(Option<submissions_api::types::ScriptID>),
|
||||||
Download(crate::download::Error),
|
ModelFileDownload(rbx_asset::cookie::GetError),
|
||||||
ModelFileDecode(ReadDomError),
|
ModelFileDecode(ReadDomError),
|
||||||
ApiGetScriptPolicyFromHash(submissions_api::types::ScriptPolicySingleItemError),
|
ApiGetScriptPolicyFromHash(submissions_api::types::SingleItemError),
|
||||||
ApiGetScript(submissions_api::Error),
|
ApiGetScript(submissions_api::Error),
|
||||||
ApiCreateScript(submissions_api::Error),
|
ApiCreateScript(submissions_api::Error),
|
||||||
ApiCreateScriptPolicy(submissions_api::Error),
|
ApiCreateScriptPolicy(submissions_api::Error),
|
||||||
ApiGetScriptFromHash(submissions_api::types::ScriptSingleItemError),
|
ApiGetScriptFromHash(submissions_api::types::SingleItemError),
|
||||||
ApiUpdateMapfixModel(submissions_api::Error),
|
ApiUpdateMapfixModel(submissions_api::Error),
|
||||||
ApiUpdateSubmissionModel(submissions_api::Error),
|
ApiUpdateSubmissionModel(submissions_api::Error),
|
||||||
ModelFileRootMustHaveOneChild,
|
ModelFileRootMustHaveOneChild,
|
||||||
@@ -57,19 +51,19 @@ pub enum Error{
|
|||||||
AssetUpload(rbx_asset::cookie::UploadError),
|
AssetUpload(rbx_asset::cookie::UploadError),
|
||||||
AssetCreate(rbx_asset::cookie::CreateError),
|
AssetCreate(rbx_asset::cookie::CreateError),
|
||||||
}
|
}
|
||||||
impl std::fmt::Display for Error{
|
impl std::fmt::Display for ValidateError{
|
||||||
fn fmt(&self,f:&mut std::fmt::Formatter<'_>)->std::fmt::Result{
|
fn fmt(&self,f:&mut std::fmt::Formatter<'_>)->std::fmt::Result{
|
||||||
write!(f,"{self:?}")
|
write!(f,"{self:?}")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl std::error::Error for Error{}
|
impl std::error::Error for ValidateError{}
|
||||||
|
|
||||||
#[allow(nonstandard_style)]
|
#[allow(nonstandard_style)]
|
||||||
pub struct ValidateRequest{
|
pub struct ValidateRequest{
|
||||||
pub ModelID:u64,
|
pub ModelID:u64,
|
||||||
pub ModelVersion:u64,
|
pub ModelVersion:u64,
|
||||||
pub ValidatedModelID:Option<u64>,
|
pub ValidatedModelID:Option<u64>,
|
||||||
pub Resource:Resource,
|
pub ResourceID:ResourceID,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<crate::nats_types::ValidateMapfixRequest> for ValidateRequest{
|
impl From<crate::nats_types::ValidateMapfixRequest> for ValidateRequest{
|
||||||
@@ -78,7 +72,7 @@ impl From<crate::nats_types::ValidateMapfixRequest> for ValidateRequest{
|
|||||||
ModelID:value.ModelID,
|
ModelID:value.ModelID,
|
||||||
ModelVersion:value.ModelVersion,
|
ModelVersion:value.ModelVersion,
|
||||||
ValidatedModelID:value.ValidatedModelID,
|
ValidatedModelID:value.ValidatedModelID,
|
||||||
Resource:Resource::Mapfix(value.MapfixID),
|
ResourceID:ResourceID::Mapfix(value.MapfixID),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -88,57 +82,36 @@ impl From<crate::nats_types::ValidateSubmissionRequest> for ValidateRequest{
|
|||||||
ModelID:value.ModelID,
|
ModelID:value.ModelID,
|
||||||
ModelVersion:value.ModelVersion,
|
ModelVersion:value.ModelVersion,
|
||||||
ValidatedModelID:value.ValidatedModelID,
|
ValidatedModelID:value.ValidatedModelID,
|
||||||
Resource:Resource::Submission(value.SubmissionID),
|
ResourceID:ResourceID::Submission(value.SubmissionID),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl crate::message_handler::MessageHandler{
|
impl crate::message_handler::MessageHandler{
|
||||||
pub async fn validate_inner(&self,validate_info:ValidateRequest)->Result<(),Error>{
|
pub async fn validate_inner(&self,validate_info:ValidateRequest)->Result<(),ValidateError>{
|
||||||
// discover asset creator and latest version
|
// download map
|
||||||
let info=self.cloud_context.get_asset_info(
|
let data=self.cookie_context.get_asset(rbx_asset::cookie::GetAssetRequest{
|
||||||
rbx_asset::cloud::GetAssetLatestRequest{asset_id:validate_info.ModelID}
|
|
||||||
).await.map_err(Error::ModelInfoDownload)?;
|
|
||||||
|
|
||||||
// reject models created by a group
|
|
||||||
let rbx_asset::cloud::Creator::userId(_user_id)=info.creationContext.creator else{
|
|
||||||
return Err(Error::CreatorTypeMustBeUser);
|
|
||||||
};
|
|
||||||
|
|
||||||
// Has the map been updated since it was submitted?
|
|
||||||
if info.revisionId!=validate_info.ModelVersion{
|
|
||||||
return Err(Error::RevisionMismatch{
|
|
||||||
current:info.revisionId,
|
|
||||||
submitted:validate_info.ModelVersion,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
// download the map model
|
|
||||||
let maybe_gzip=download_asset_version(&self.cloud_context,rbx_asset::cloud::GetAssetVersionRequest{
|
|
||||||
asset_id:validate_info.ModelID,
|
asset_id:validate_info.ModelID,
|
||||||
version:validate_info.ModelVersion,
|
version:Some(validate_info.ModelVersion),
|
||||||
}).await.map_err(Error::Download)?;
|
}).await.map_err(ValidateError::ModelFileDownload)?;
|
||||||
|
|
||||||
// decode dom (slow!)
|
// decode dom (slow!)
|
||||||
let mut dom=maybe_gzip.read_with(read_dom,read_dom).map_err(Error::ModelFileDecode)?;
|
let mut dom=read_dom(&mut std::io::Cursor::new(data)).map_err(ValidateError::ModelFileDecode)?;
|
||||||
|
|
||||||
/* VALIDATE MAP */
|
/* VALIDATE MAP */
|
||||||
|
|
||||||
// stupid ustr thing
|
|
||||||
let source_property=static_ustr("Source");
|
|
||||||
|
|
||||||
// collect unique scripts
|
// collect unique scripts
|
||||||
let script_refs=get_script_refs(&dom);
|
let script_refs=get_script_refs(&dom);
|
||||||
let mut script_map=std::collections::HashMap::<String,NamePolicy>::new();
|
let mut script_map=std::collections::HashMap::<String,NamePolicy>::new();
|
||||||
for &script_ref in &script_refs{
|
for &script_ref in &script_refs{
|
||||||
if let Some(script)=dom.get_by_ref(script_ref){
|
if let Some(script)=dom.get_by_ref(script_ref){
|
||||||
if let Some(rbx_dom_weak::types::Variant::String(source))=script.properties.get(&source_property){
|
if let Some(rbx_dom_weak::types::Variant::String(source))=script.properties.get("Source"){
|
||||||
// check the source for illegal keywords
|
// check the source for illegal keywords
|
||||||
if source_has_illegal_keywords(source){
|
if source_has_illegal_keywords(source){
|
||||||
// immediately abort
|
// immediately abort
|
||||||
// grab path to offending script
|
// grab path to offending script
|
||||||
let path=get_partial_path(&dom,script);
|
let path=get_partial_path(&dom,script);
|
||||||
return Err(Error::ScriptFlaggedIllegalKeyword(path));
|
return Err(ValidateError::ScriptFlaggedIllegalKeyword(path));
|
||||||
}
|
}
|
||||||
// associate a name and policy with the source code
|
// associate a name and policy with the source code
|
||||||
// policy will be fetched from the database to replace the default policy
|
// policy will be fetched from the database to replace the default policy
|
||||||
@@ -159,7 +132,7 @@ impl crate::message_handler::MessageHandler{
|
|||||||
// fetch the script policy
|
// fetch the script policy
|
||||||
let script_policy=self.api.get_script_policy_from_hash(submissions_api::types::HashRequest{
|
let script_policy=self.api.get_script_policy_from_hash(submissions_api::types::HashRequest{
|
||||||
hash:hash.as_str(),
|
hash:hash.as_str(),
|
||||||
}).await.map_err(Error::ApiGetScriptPolicyFromHash)?;
|
}).await.map_err(ValidateError::ApiGetScriptPolicyFromHash)?;
|
||||||
|
|
||||||
// write the policy to the script_map, fetching the replacement code if necessary
|
// write the policy to the script_map, fetching the replacement code if necessary
|
||||||
if let Some(script_policy)=script_policy{
|
if let Some(script_policy)=script_policy{
|
||||||
@@ -171,12 +144,15 @@ impl crate::message_handler::MessageHandler{
|
|||||||
submissions_api::types::Policy::Replace=>{
|
submissions_api::types::Policy::Replace=>{
|
||||||
let script=self.api.get_script(submissions_api::types::GetScriptRequest{
|
let script=self.api.get_script(submissions_api::types::GetScriptRequest{
|
||||||
ScriptID:script_policy.ToScriptID,
|
ScriptID:script_policy.ToScriptID,
|
||||||
}).await.map_err(Error::ApiGetScript)?;
|
}).await.map_err(ValidateError::ApiGetScript)?;
|
||||||
Policy::Replace(script.Source)
|
Policy::Replace(script.Source)
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
}else{
|
}else{
|
||||||
let (resource_type,resource_id)=validate_info.Resource.split();
|
let (resource_type,resource_id)=match validate_info.ResourceID{
|
||||||
|
ResourceID::Mapfix(mapfix_id)=>(ResourceType::Mapfix,mapfix_id),
|
||||||
|
ResourceID::Submission(submission_id)=>(ResourceType::Submission,submission_id),
|
||||||
|
};
|
||||||
|
|
||||||
// upload the script
|
// upload the script
|
||||||
let script=self.api.create_script(submissions_api::types::CreateScriptRequest{
|
let script=self.api.create_script(submissions_api::types::CreateScriptRequest{
|
||||||
@@ -184,14 +160,14 @@ impl crate::message_handler::MessageHandler{
|
|||||||
Source:source.as_str(),
|
Source:source.as_str(),
|
||||||
ResourceType:resource_type,
|
ResourceType:resource_type,
|
||||||
ResourceID:Some(resource_id),
|
ResourceID:Some(resource_id),
|
||||||
}).await.map_err(Error::ApiCreateScript)?;
|
}).await.map_err(ValidateError::ApiCreateScript)?;
|
||||||
|
|
||||||
// create a None policy (pending review by yours truly)
|
// create a None policy (pending review by yours truly)
|
||||||
self.api.create_script_policy(submissions_api::types::CreateScriptPolicyRequest{
|
self.api.create_script_policy(submissions_api::types::CreateScriptPolicyRequest{
|
||||||
ToScriptID:script.ScriptID,
|
ToScriptID:script.ScriptID,
|
||||||
FromScriptID:script.ScriptID,
|
FromScriptID:script.ScriptID,
|
||||||
Policy:submissions_api::types::Policy::None,
|
Policy:submissions_api::types::Policy::None,
|
||||||
}).await.map_err(Error::ApiCreateScriptPolicy)?;
|
}).await.map_err(ValidateError::ApiCreateScriptPolicy)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
@@ -199,17 +175,17 @@ impl crate::message_handler::MessageHandler{
|
|||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
// make the replacements
|
// make the replacements
|
||||||
let mut modified=false;
|
let mut modified=true;
|
||||||
for &script_ref in &script_refs{
|
for &script_ref in &script_refs{
|
||||||
if let Some(script)=dom.get_by_ref_mut(script_ref){
|
if let Some(script)=dom.get_by_ref_mut(script_ref){
|
||||||
if let Some(rbx_dom_weak::types::Variant::String(source))=script.properties.get_mut(&source_property){
|
if let Some(rbx_dom_weak::types::Variant::String(source))=script.properties.get_mut("Source"){
|
||||||
match script_map.get(source.as_str()).map(|p|&p.policy){
|
match script_map.get(source.as_str()).map(|p|&p.policy){
|
||||||
Some(Policy::Blocked)=>{
|
Some(Policy::Blocked)=>{
|
||||||
let hash=hash_source(source.as_str());
|
let hash=hash_source(source.as_str());
|
||||||
let script=self.api.get_script_from_hash(submissions_api::types::HashRequest{
|
let script=self.api.get_script_from_hash(submissions_api::types::HashRequest{
|
||||||
hash:hash.as_str(),
|
hash:hash.as_str(),
|
||||||
}).await.map_err(Error::ApiGetScriptFromHash)?;
|
}).await.map_err(ValidateError::ApiGetScriptFromHash)?;
|
||||||
return Err(Error::ScriptBlocked(script.map(|s|s.ID)));
|
return Err(ValidateError::ScriptBlocked(script.map(|s|s.ID)));
|
||||||
},
|
},
|
||||||
None
|
None
|
||||||
|Some(Policy::None)
|
|Some(Policy::None)
|
||||||
@@ -217,8 +193,8 @@ impl crate::message_handler::MessageHandler{
|
|||||||
let hash=hash_source(source.as_str());
|
let hash=hash_source(source.as_str());
|
||||||
let script=self.api.get_script_from_hash(submissions_api::types::HashRequest{
|
let script=self.api.get_script_from_hash(submissions_api::types::HashRequest{
|
||||||
hash:hash.as_str(),
|
hash:hash.as_str(),
|
||||||
}).await.map_err(Error::ApiGetScriptFromHash)?;
|
}).await.map_err(ValidateError::ApiGetScriptFromHash)?;
|
||||||
return Err(Error::ScriptNotYetReviewed(script.map(|s|s.ID)));
|
return Err(ValidateError::ScriptNotYetReviewed(script.map(|s|s.ID)));
|
||||||
},
|
},
|
||||||
Some(Policy::Allowed)=>(),
|
Some(Policy::Allowed)=>(),
|
||||||
Some(Policy::Delete)=>{
|
Some(Policy::Delete)=>{
|
||||||
@@ -235,17 +211,19 @@ impl crate::message_handler::MessageHandler{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
println!("[Validator] Forcing model upload! modified=true");
|
||||||
|
|
||||||
// if the model was validated, the submission must be changed to use the modified model
|
// if the model was validated, the submission must be changed to use the modified model
|
||||||
let (validated_model_id,validated_model_version)=if modified{
|
if modified{
|
||||||
// serialize model (slow!)
|
// serialize model (slow!)
|
||||||
let mut data=Vec::new();
|
let mut data=Vec::new();
|
||||||
let &[map_ref]=dom.root().children()else{
|
let &[map_ref]=dom.root().children()else{
|
||||||
return Err(Error::ModelFileRootMustHaveOneChild);
|
return Err(ValidateError::ModelFileRootMustHaveOneChild);
|
||||||
};
|
};
|
||||||
rbx_binary::to_writer(&mut data,&dom,&[map_ref]).map_err(Error::ModelFileEncode)?;
|
rbx_binary::to_writer(&mut data,&dom,&[map_ref]).map_err(ValidateError::ModelFileEncode)?;
|
||||||
|
|
||||||
// upload a model lol
|
// upload a model lol
|
||||||
if let Some(model_id)=validate_info.ValidatedModelID{
|
let model_id=if let Some(model_id)=validate_info.ValidatedModelID{
|
||||||
// upload to existing id
|
// upload to existing id
|
||||||
let response=self.cookie_context.upload(rbx_asset::cookie::UploadRequest{
|
let response=self.cookie_context.upload(rbx_asset::cookie::UploadRequest{
|
||||||
assetid:model_id,
|
assetid:model_id,
|
||||||
@@ -254,13 +232,13 @@ impl crate::message_handler::MessageHandler{
|
|||||||
ispublic:None,
|
ispublic:None,
|
||||||
allowComments:None,
|
allowComments:None,
|
||||||
groupId:None,
|
groupId:None,
|
||||||
},data).await.map_err(Error::AssetUpload)?;
|
},data).await.map_err(ValidateError::AssetUpload)?;
|
||||||
|
|
||||||
(response.AssetId,response.AssetVersion)
|
response.AssetId
|
||||||
}else{
|
}else{
|
||||||
// grab the map instance from the map ref
|
// grab the map instance from the map re
|
||||||
let Some(map_instance)=dom.get_by_ref(map_ref)else{
|
let Some(map_instance)=dom.get_by_ref(map_ref)else{
|
||||||
return Err(Error::ModelFileChildRefIsNil);
|
return Err(ValidateError::ModelFileChildRefIsNil);
|
||||||
};
|
};
|
||||||
// create new model
|
// create new model
|
||||||
let response=self.cookie_context.create(rbx_asset::cookie::CreateRequest{
|
let response=self.cookie_context.create(rbx_asset::cookie::CreateRequest{
|
||||||
@@ -269,37 +247,46 @@ impl crate::message_handler::MessageHandler{
|
|||||||
ispublic:true,
|
ispublic:true,
|
||||||
allowComments:true,
|
allowComments:true,
|
||||||
groupId:None,
|
groupId:None,
|
||||||
},data).await.map_err(Error::AssetCreate)?;
|
},data).await.map_err(ValidateError::AssetCreate)?;
|
||||||
|
|
||||||
(response.AssetId,response.AssetVersion)
|
response.AssetId
|
||||||
|
};
|
||||||
|
|
||||||
|
match validate_info.ResourceID{
|
||||||
|
ResourceID::Mapfix(mapfix_id)=>{
|
||||||
|
// update the mapfix to use the validated model
|
||||||
|
self.api.update_mapfix_validated_model(submissions_api::types::UpdateMapfixModelRequest{
|
||||||
|
MapfixID:mapfix_id,
|
||||||
|
ModelID:model_id,
|
||||||
|
ModelVersion:1, //TODO
|
||||||
|
}).await.map_err(ValidateError::ApiUpdateMapfixModel)?;
|
||||||
|
},
|
||||||
|
ResourceID::Submission(submission_id)=>{
|
||||||
|
// update the submission to use the validated model
|
||||||
|
self.api.update_submission_validated_model(submissions_api::types::UpdateSubmissionModelRequest{
|
||||||
|
SubmissionID:submission_id,
|
||||||
|
ModelID:model_id,
|
||||||
|
ModelVersion:1, //TODO
|
||||||
|
}).await.map_err(ValidateError::ApiUpdateSubmissionModel)?;
|
||||||
|
},
|
||||||
}
|
}
|
||||||
}else{
|
|
||||||
(validate_info.ModelID,validate_info.ModelVersion)
|
|
||||||
};
|
|
||||||
|
|
||||||
match validate_info.Resource{
|
|
||||||
Resource::Mapfix(mapfix_id)=>{
|
|
||||||
// update the mapfix to use the validated model
|
|
||||||
self.api.update_mapfix_validated_model(submissions_api::types::UpdateMapfixModelRequest{
|
|
||||||
MapfixID:mapfix_id,
|
|
||||||
ModelID:validated_model_id,
|
|
||||||
ModelVersion:validated_model_version,
|
|
||||||
}).await.map_err(Error::ApiUpdateMapfixModel)?;
|
|
||||||
},
|
|
||||||
Resource::Submission(submission_id)=>{
|
|
||||||
// update the submission to use the validated model
|
|
||||||
self.api.update_submission_validated_model(submissions_api::types::UpdateSubmissionModelRequest{
|
|
||||||
SubmissionID:submission_id,
|
|
||||||
ModelID:validated_model_id,
|
|
||||||
ModelVersion:validated_model_version,
|
|
||||||
}).await.map_err(Error::ApiUpdateSubmissionModel)?;
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn recursive_collect_superclass(objects:&mut std::vec::Vec<rbx_dom_weak::types::Ref>,dom:&rbx_dom_weak::WeakDom,instance:&rbx_dom_weak::Instance,superclass:&str){
|
||||||
|
for &referent in instance.children(){
|
||||||
|
if let Some(c)=dom.get_by_ref(referent){
|
||||||
|
if class_is_a(c.class.as_str(),superclass){
|
||||||
|
objects.push(c.referent());//copy ref
|
||||||
|
}
|
||||||
|
recursive_collect_superclass(objects,dom,c,superclass);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fn get_partial_path(dom:&rbx_dom_weak::WeakDom,instance:&rbx_dom_weak::Instance)->String{
|
fn get_partial_path(dom:&rbx_dom_weak::WeakDom,instance:&rbx_dom_weak::Instance)->String{
|
||||||
let mut names:Vec<_>=core::iter::successors(
|
let mut names:Vec<_>=core::iter::successors(
|
||||||
Some(instance),
|
Some(instance),
|
||||||
@@ -314,11 +301,7 @@ fn get_partial_path(dom:&rbx_dom_weak::WeakDom,instance:&rbx_dom_weak::Instance)
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn get_script_refs(dom:&rbx_dom_weak::WeakDom)->Vec<rbx_dom_weak::types::Ref>{
|
fn get_script_refs(dom:&rbx_dom_weak::WeakDom)->Vec<rbx_dom_weak::types::Ref>{
|
||||||
let db=rbx_reflection_database::get();
|
let mut scripts=std::vec::Vec::new();
|
||||||
let superclass=&db.classes["LuaSourceContainer"];
|
recursive_collect_superclass(&mut scripts,dom,dom.root(),"LuaSourceContainer");
|
||||||
dom.descendants().filter_map(|inst|{
|
scripts
|
||||||
let class=db.classes.get(inst.class.as_str())?;
|
|
||||||
db.has_superclass(class,superclass)
|
|
||||||
.then_some(inst.referent())
|
|
||||||
}).collect()
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
FROM registry.itzana.me/docker-proxy/oven/bun:1.2.8
|
FROM oven/bun:latest
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
@@ -10,4 +10,4 @@ ENV NEXT_TELEMETRY_DISABLED=1
|
|||||||
|
|
||||||
RUN bun install
|
RUN bun install
|
||||||
RUN bun run build
|
RUN bun run build
|
||||||
ENTRYPOINT ["bun", "run", "start"]
|
ENTRYPOINT ["bun", "run", "start"]
|
||||||
@@ -7,7 +7,10 @@ const nextConfig: NextConfig = {
|
|||||||
remotePatterns: [
|
remotePatterns: [
|
||||||
{
|
{
|
||||||
protocol: "https",
|
protocol: "https",
|
||||||
hostname: "**.rbxcdn.com",
|
hostname: "tr.rbxcdn.com",
|
||||||
|
pathname: "/**",
|
||||||
|
port: "",
|
||||||
|
search: "",
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -13,19 +13,18 @@
|
|||||||
"@emotion/styled": "^11.14.0",
|
"@emotion/styled": "^11.14.0",
|
||||||
"@mui/icons-material": "^6.1.10",
|
"@mui/icons-material": "^6.1.10",
|
||||||
"@mui/material": "^6.1.10",
|
"@mui/material": "^6.1.10",
|
||||||
"date-fns": "^4.1.0",
|
|
||||||
"next": "^15.1.0",
|
"next": "^15.1.0",
|
||||||
"react": "^19.0.0",
|
"react": "^19.0.0",
|
||||||
"react-dom": "^19.0.0",
|
"react-dom": "^19.0.0",
|
||||||
"sass": "^1.82.0"
|
"sass": "^1.82.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@eslint/eslintrc": "^3.2.0",
|
"typescript": "^5.7.2",
|
||||||
"@types/node": "^20.17.9",
|
"@types/node": "^20.17.9",
|
||||||
"@types/react": "^19.0.1",
|
"@types/react": "^19.0.1",
|
||||||
"@types/react-dom": "^19.0.2",
|
"@types/react-dom": "^19.0.2",
|
||||||
"eslint": "^9.16.0",
|
"eslint": "^9.16.0",
|
||||||
"eslint-config-next": "15.1.0",
|
"eslint-config-next": "15.1.0",
|
||||||
"typescript": "^5.7.2"
|
"@eslint/eslintrc": "^3.2.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Binary file not shown.
|
Before Width: | Height: | Size: 30 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 35 KiB |
@@ -1,43 +0,0 @@
|
|||||||
import { Button, Container, Paper, Typography } from "@mui/material";
|
|
||||||
import Webpage from "@/app/_components/webpage";
|
|
||||||
|
|
||||||
interface ErrorDisplayProps {
|
|
||||||
title: string;
|
|
||||||
message: string;
|
|
||||||
buttonText?: string;
|
|
||||||
onButtonClick?: () => void;
|
|
||||||
}
|
|
||||||
|
|
||||||
export function ErrorDisplay({
|
|
||||||
title,
|
|
||||||
message,
|
|
||||||
buttonText,
|
|
||||||
onButtonClick
|
|
||||||
}: ErrorDisplayProps) {
|
|
||||||
return (
|
|
||||||
<Webpage>
|
|
||||||
<Container maxWidth="lg" sx={{ py: 6 }}>
|
|
||||||
<Paper
|
|
||||||
elevation={3}
|
|
||||||
sx={{
|
|
||||||
p: 4,
|
|
||||||
textAlign: 'center',
|
|
||||||
borderRadius: 2
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<Typography variant="h5" gutterBottom>{title}</Typography>
|
|
||||||
<Typography variant="body1">{message}</Typography>
|
|
||||||
{buttonText && onButtonClick && (
|
|
||||||
<Button
|
|
||||||
variant="contained"
|
|
||||||
onClick={onButtonClick}
|
|
||||||
sx={{ mt: 3 }}
|
|
||||||
>
|
|
||||||
{buttonText}
|
|
||||||
</Button>
|
|
||||||
)}
|
|
||||||
</Paper>
|
|
||||||
</Container>
|
|
||||||
</Webpage>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
@@ -1,151 +0,0 @@
|
|||||||
import {Box, IconButton, Typography} from "@mui/material";
|
|
||||||
import {useEffect, useRef, useState} from "react";
|
|
||||||
import Link from "next/link";
|
|
||||||
import ArrowBackIosNewIcon from "@mui/icons-material/ArrowBackIosNew";
|
|
||||||
import ArrowForwardIosIcon from "@mui/icons-material/ArrowForwardIos";
|
|
||||||
import {SubmissionInfo} from "@/app/ts/Submission";
|
|
||||||
import {MapfixInfo} from "@/app/ts/Mapfix";
|
|
||||||
|
|
||||||
// Type for the items in the carousel
|
|
||||||
type CarouselItem = SubmissionInfo | MapfixInfo;
|
|
||||||
|
|
||||||
// Props for the Carousel component
|
|
||||||
interface CarouselProps<T extends CarouselItem> {
|
|
||||||
title: string;
|
|
||||||
items: T[] | undefined;
|
|
||||||
renderItem: (item: T) => React.ReactNode;
|
|
||||||
viewAllLink: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
export function Carousel<T extends CarouselItem>({ title, items, renderItem, viewAllLink }: CarouselProps<T>) {
|
|
||||||
const carouselRef = useRef<HTMLDivElement | null>(null);
|
|
||||||
const [scrollPosition, setScrollPosition] = useState<number>(0);
|
|
||||||
const [maxScroll, setMaxScroll] = useState<number>(0);
|
|
||||||
|
|
||||||
const SCROLL_AMOUNT = 300;
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
if (carouselRef.current) {
|
|
||||||
const scrollWidth = carouselRef.current.scrollWidth;
|
|
||||||
const clientWidth = carouselRef.current.clientWidth;
|
|
||||||
setMaxScroll(scrollWidth - clientWidth);
|
|
||||||
}
|
|
||||||
}, [items]);
|
|
||||||
|
|
||||||
const scroll = (direction: 'left' | 'right'): void => {
|
|
||||||
if (carouselRef.current) {
|
|
||||||
const scrollAmount = direction === 'left' ? -SCROLL_AMOUNT : SCROLL_AMOUNT;
|
|
||||||
|
|
||||||
carouselRef.current.scrollBy({
|
|
||||||
left: scrollAmount,
|
|
||||||
behavior: 'smooth'
|
|
||||||
});
|
|
||||||
|
|
||||||
setTimeout(() => {
|
|
||||||
if (carouselRef.current) {
|
|
||||||
setScrollPosition(carouselRef.current.scrollLeft);
|
|
||||||
}
|
|
||||||
}, 300);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
const handleScroll = () => {
|
|
||||||
if (carouselRef.current) {
|
|
||||||
setScrollPosition(carouselRef.current.scrollLeft);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const ref = carouselRef.current;
|
|
||||||
if (ref) {
|
|
||||||
ref.addEventListener('scroll', handleScroll);
|
|
||||||
return () => ref.removeEventListener('scroll', handleScroll);
|
|
||||||
}
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
return (
|
|
||||||
<Box mb={6}>
|
|
||||||
<Box display="flex" justifyContent="space-between" alignItems="center" mb={2}>
|
|
||||||
<Typography variant="h4" component="h2" fontWeight="bold">
|
|
||||||
{title}
|
|
||||||
</Typography>
|
|
||||||
<Link href={viewAllLink} style={{textDecoration: 'none'}}>
|
|
||||||
<Typography component="span" color="primary">
|
|
||||||
View All →
|
|
||||||
</Typography>
|
|
||||||
</Link>
|
|
||||||
</Box>
|
|
||||||
|
|
||||||
<Box position="relative">
|
|
||||||
<IconButton
|
|
||||||
sx={{
|
|
||||||
position: 'absolute',
|
|
||||||
left: -20,
|
|
||||||
top: '50%',
|
|
||||||
transform: 'translateY(-50%)',
|
|
||||||
zIndex: 2,
|
|
||||||
backgroundColor: 'background.paper',
|
|
||||||
boxShadow: 2,
|
|
||||||
'&:hover': {
|
|
||||||
backgroundColor: 'action.hover',
|
|
||||||
},
|
|
||||||
visibility: scrollPosition <= 5 ? 'hidden' : 'visible',
|
|
||||||
}}
|
|
||||||
onClick={() => scroll('left')}
|
|
||||||
>
|
|
||||||
<ArrowBackIosNewIcon />
|
|
||||||
</IconButton>
|
|
||||||
|
|
||||||
<Box
|
|
||||||
ref={carouselRef}
|
|
||||||
sx={{
|
|
||||||
display: 'flex',
|
|
||||||
overflowX: 'auto',
|
|
||||||
scrollbarWidth: 'none',
|
|
||||||
msOverflowStyle: 'none',
|
|
||||||
'&::-webkit-scrollbar': {
|
|
||||||
display: 'none',
|
|
||||||
},
|
|
||||||
gap: '16px', // Fixed 16px gap - using string with px unit to ensure it's absolute
|
|
||||||
padding: '8px 4px',
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
{items?.map((item, index) => (
|
|
||||||
<Box
|
|
||||||
key={index}
|
|
||||||
sx={{
|
|
||||||
flex: '0 0 auto',
|
|
||||||
width: {
|
|
||||||
xs: '260px', // Fixed width at different breakpoints
|
|
||||||
sm: '280px',
|
|
||||||
md: '300px'
|
|
||||||
}
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
{renderItem(item)}
|
|
||||||
</Box>
|
|
||||||
))}
|
|
||||||
</Box>
|
|
||||||
|
|
||||||
<IconButton
|
|
||||||
sx={{
|
|
||||||
position: 'absolute',
|
|
||||||
right: -20,
|
|
||||||
top: '50%',
|
|
||||||
transform: 'translateY(-50%)',
|
|
||||||
zIndex: 2,
|
|
||||||
backgroundColor: 'background.paper',
|
|
||||||
boxShadow: 2,
|
|
||||||
'&:hover': {
|
|
||||||
backgroundColor: 'action.hover',
|
|
||||||
},
|
|
||||||
visibility: scrollPosition >= maxScroll - 5 ? 'hidden' : 'visible',
|
|
||||||
}}
|
|
||||||
onClick={() => scroll('right')}
|
|
||||||
>
|
|
||||||
<ArrowForwardIosIcon />
|
|
||||||
</IconButton>
|
|
||||||
</Box>
|
|
||||||
</Box>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
@@ -1,54 +0,0 @@
|
|||||||
import React from 'react';
|
|
||||||
import {
|
|
||||||
Box,
|
|
||||||
Avatar,
|
|
||||||
Typography,
|
|
||||||
Tooltip
|
|
||||||
} from "@mui/material";
|
|
||||||
import PersonIcon from '@mui/icons-material/Person';
|
|
||||||
import { formatDistanceToNow, format } from "date-fns";
|
|
||||||
import { AuditEvent, decodeAuditEvent as auditEventMessage } from "@/app/ts/AuditEvent";
|
|
||||||
|
|
||||||
interface AuditEventItemProps {
|
|
||||||
event: AuditEvent;
|
|
||||||
validatorUser: number;
|
|
||||||
userAvatarUrl?: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
export default function AuditEventItem({ event, validatorUser, userAvatarUrl }: AuditEventItemProps) {
|
|
||||||
return (
|
|
||||||
<Box sx={{ display: 'flex', gap: 2 }}>
|
|
||||||
<Avatar
|
|
||||||
src={event.User === validatorUser ? undefined : userAvatarUrl}
|
|
||||||
sx={{ border: '1px solid rgba(255, 255, 255, 0.1)', bgcolor: 'grey.900' }}
|
|
||||||
>
|
|
||||||
<PersonIcon />
|
|
||||||
</Avatar>
|
|
||||||
<Box sx={{ flexGrow: 1 }}>
|
|
||||||
<Box sx={{ display: 'flex', justifyContent: 'space-between' }}>
|
|
||||||
<Typography variant="subtitle2">
|
|
||||||
{event.User === validatorUser ? "Validator" : event.Username || "Unknown"}
|
|
||||||
</Typography>
|
|
||||||
<DateDisplay date={event.Date} />
|
|
||||||
</Box>
|
|
||||||
<Typography variant="body2">{auditEventMessage(event)}</Typography>
|
|
||||||
</Box>
|
|
||||||
</Box>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
interface DateDisplayProps {
|
|
||||||
date: number;
|
|
||||||
}
|
|
||||||
|
|
||||||
function DateDisplay({ date }: DateDisplayProps) {
|
|
||||||
return (
|
|
||||||
<Typography variant="caption" color="text.secondary">
|
|
||||||
<Tooltip title={format(new Date(date * 1000), 'PPpp')}>
|
|
||||||
<Typography variant="caption" color="text.secondary">
|
|
||||||
{formatDistanceToNow(new Date(date * 1000), { addSuffix: true })}
|
|
||||||
</Typography>
|
|
||||||
</Tooltip>
|
|
||||||
</Typography>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
@@ -1,42 +0,0 @@
|
|||||||
import React from 'react';
|
|
||||||
import {
|
|
||||||
Box,
|
|
||||||
Stack,
|
|
||||||
} from "@mui/material";
|
|
||||||
import { AuditEvent, AuditEventType } from "@/app/ts/AuditEvent";
|
|
||||||
import AuditEventItem from './AuditEventItem';
|
|
||||||
|
|
||||||
interface AuditEventsTabPanelProps {
|
|
||||||
activeTab: number;
|
|
||||||
auditEvents: AuditEvent[];
|
|
||||||
validatorUser: number;
|
|
||||||
auditEventUserAvatarUrls?: Record<number, string>;
|
|
||||||
}
|
|
||||||
|
|
||||||
export default function AuditEventsTabPanel({
|
|
||||||
activeTab,
|
|
||||||
auditEvents,
|
|
||||||
validatorUser,
|
|
||||||
auditEventUserAvatarUrls
|
|
||||||
}: AuditEventsTabPanelProps) {
|
|
||||||
const filteredEvents = auditEvents.filter(
|
|
||||||
event => event.EventType !== AuditEventType.Comment
|
|
||||||
);
|
|
||||||
|
|
||||||
return (
|
|
||||||
<Box role="tabpanel" hidden={activeTab !== 1}>
|
|
||||||
{activeTab === 1 && (
|
|
||||||
<Stack spacing={2}>
|
|
||||||
{filteredEvents.map((event, index) => (
|
|
||||||
<AuditEventItem
|
|
||||||
key={index}
|
|
||||||
event={event}
|
|
||||||
validatorUser={validatorUser}
|
|
||||||
userAvatarUrl={auditEventUserAvatarUrls?.[event.User]}
|
|
||||||
/>
|
|
||||||
))}
|
|
||||||
</Stack>
|
|
||||||
)}
|
|
||||||
</Box>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
@@ -1,54 +0,0 @@
|
|||||||
import React from 'react';
|
|
||||||
import {
|
|
||||||
Box,
|
|
||||||
Avatar,
|
|
||||||
Typography,
|
|
||||||
Tooltip
|
|
||||||
} from "@mui/material";
|
|
||||||
import PersonIcon from '@mui/icons-material/Person';
|
|
||||||
import { formatDistanceToNow, format } from "date-fns";
|
|
||||||
import { AuditEvent, decodeAuditEvent } from "@/app/ts/AuditEvent";
|
|
||||||
|
|
||||||
interface CommentItemProps {
|
|
||||||
event: AuditEvent;
|
|
||||||
validatorUser: number;
|
|
||||||
userAvatarUrl?: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
export default function CommentItem({ event, validatorUser, userAvatarUrl }: CommentItemProps) {
|
|
||||||
return (
|
|
||||||
<Box sx={{ display: 'flex', gap: 2 }}>
|
|
||||||
<Avatar
|
|
||||||
src={event.User === validatorUser ? undefined : userAvatarUrl}
|
|
||||||
sx={{ border: '1px solid rgba(255, 255, 255, 0.1)', bgcolor: 'grey.900' }}
|
|
||||||
>
|
|
||||||
<PersonIcon />
|
|
||||||
</Avatar>
|
|
||||||
<Box sx={{ flexGrow: 1 }}>
|
|
||||||
<Box sx={{ display: 'flex', justifyContent: 'space-between' }}>
|
|
||||||
<Typography variant="subtitle2">
|
|
||||||
{event.User === validatorUser ? "Validator" : event.Username || "Unknown"}
|
|
||||||
</Typography>
|
|
||||||
<DateDisplay date={event.Date} />
|
|
||||||
</Box>
|
|
||||||
<Typography variant="body2">{decodeAuditEvent(event)}</Typography>
|
|
||||||
</Box>
|
|
||||||
</Box>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
interface DateDisplayProps {
|
|
||||||
date: number;
|
|
||||||
}
|
|
||||||
|
|
||||||
function DateDisplay({ date }: DateDisplayProps) {
|
|
||||||
return (
|
|
||||||
<Typography variant="caption" color="text.secondary">
|
|
||||||
<Tooltip title={format(new Date(date * 1000), 'PPpp')}>
|
|
||||||
<Typography variant="caption" color="text.secondary">
|
|
||||||
{formatDistanceToNow(new Date(date * 1000), { addSuffix: true })}
|
|
||||||
</Typography>
|
|
||||||
</Tooltip>
|
|
||||||
</Typography>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user