Compare commits
173 Commits
uint
...
constraint
| Author | SHA1 | Date | |
|---|---|---|---|
|
20dab8b776
|
|||
|
9382c0e2d6
|
|||
|
abb3cf3076
|
|||
|
40b0af0063
|
|||
| 976adf2b66 | |||
| 53cc4b9e9e | |||
|
51f62f039b
|
|||
|
42cc783887
|
|||
| ed7109270f | |||
| abd233ce65 | |||
| 215c39000b | |||
| c4d97b6537 | |||
| 0834400c05 | |||
| 463d14d2b5 | |||
| 6a52166901 | |||
| d7c2ad3dde | |||
| f54bf1dc34 | |||
| 644c04c133 | |||
| 8006e3efbc | |||
| b60d2b6186 | |||
| 8f2a0b53e4 | |||
| 70dd8502f4 | |||
| 5b977289e7 | |||
| 7b3af95f3d | |||
|
4d78a9b2c5
|
|||
|
ec59a83379
|
|||
| 54bf3f55a0 | |||
| 14f404ffe3 | |||
|
0e1d2fe50a
|
|||
|
ada8c322da
|
|||
|
84d2bfef20
|
|||
| 170e7c64b6 | |||
| b443866dd6 | |||
|
ebe37ad6a2
|
|||
|
131dad7ae0
|
|||
| 127402fa77 | |||
|
40f83a4e30
|
|||
|
b6d4ce4f80
|
|||
| 07391a84cb | |||
|
|
3f848a35c8 | ||
| e5e2387502 | |||
|
90d13d28ae
|
|||
| 513b9722b1 | |||
|
3da8e414e6
|
|||
|
2acc30e18c
|
|||
|
a990ed458c
|
|||
|
4055ef550e
|
|||
|
555844e6ee
|
|||
|
80f30d20fa
|
|||
|
489a8c9c10
|
|||
|
534598ba70
|
|||
|
fdc0240698
|
|||
|
b0829bc1fc
|
|||
|
845f8e69d9
|
|||
|
0d8937e896
|
|||
| 2927afd848 | |||
| 8f6c543f81 | |||
|
7c95f8ddd0
|
|||
|
24964407bd
|
|||
|
|
8d5bd9e523 | ||
|
|
e1fc637619 | ||
|
|
762ee874a0 | ||
| a1c84ff225 | |||
|
cea6242dd7
|
|||
| fefe116611 | |||
|
0ada77421f
|
|||
|
fa2d611534
|
|||
| 81539a606c | |||
| 32095296c2 | |||
|
8ea5ee2d41
|
|||
|
954dbaeac6
|
|||
| 5b7efa2426 | |||
|
|
740e3c8932 | ||
|
4f31f8c75a
|
|||
|
d39a8c0208
|
|||
|
636282b993
|
|||
|
e3667fec0c
|
|||
|
0dff464561
|
|||
|
e30fb5f916
|
|||
|
9dd7156f38
|
|||
|
fc9aae4235
|
|||
|
a11a0d2fd5
|
|||
|
9dad1a6b4d
|
|||
|
a95e6b7a9a
|
|||
|
|
4c1aef9113 | ||
|
|
c98d170423 | ||
|
6d14047f57
|
|||
|
41663624d3
|
|||
|
49b9b41085
|
|||
|
3614018794
|
|||
|
872b98aa74
|
|||
|
d5c8477869
|
|||
|
b600ca582b
|
|||
|
adbcbed9ac
|
|||
|
8f8d685f71
|
|||
|
a669de3c0b
|
|||
|
649b941d5f
|
|||
|
1b4456f30a
|
|||
|
d34a5c7091
|
|||
|
2f36877cb6
|
|||
|
3a124b8190
|
|||
|
6cc6da4879
|
|||
|
123b0c9a81
|
|||
|
54b0abbbf3
|
|||
|
1b0384da11
|
|||
|
e0cebfd80e
|
|||
|
5ba52ecb57
|
|||
|
9e42050a65
|
|||
|
c817bfc8c8
|
|||
|
8f97ca6690
|
|||
|
f220cb62bc
|
|||
|
f090fd7d68
|
|||
|
404e1281ff
|
|||
|
e4f710c83f
|
|||
|
a942c81ea8
|
|||
|
109b24061a
|
|||
|
ddef30984f
|
|||
|
9331f37d70
|
|||
|
c4f910c1f0
|
|||
|
343a4011dd
|
|||
|
c63997d161
|
|||
|
ea58fcedc9
|
|||
|
50e3fb283c
|
|||
|
aa513a7973
|
|||
|
eff9097456
|
|||
|
668c5fef51
|
|||
|
57db5f738e
|
|||
|
3789755a19
|
|||
|
ee6c37ab9d
|
|||
|
12bfbfb0a0
|
|||
|
c57a53692d
|
|||
|
ccf07c5931
|
|||
|
6efab4f411
|
|||
|
34d1db02a5
|
|||
|
d86ed0cdf5
|
|||
|
d19763349e
|
|||
|
5846e92924
|
|||
|
34b8d7475d
|
|||
|
a5daa2df4a
|
|||
|
1b73af9fe2
|
|||
|
8433030562
|
|||
|
8372665fd3
|
|||
|
d24b342738
|
|||
|
796f31aadf
|
|||
|
44f8736838
|
|||
|
b7e5d82c13
|
|||
|
169007f16e
|
|||
|
2519c9faa1
|
|||
|
1ff6bdbd4c
|
|||
|
d1ca9bdab9
|
|||
| c76ff3b687 | |||
| a42501d254 | |||
| f915c51ba4 | |||
| ff9da333eb | |||
| 1dabd216aa | |||
| cc7e890580 | |||
| 99d1b38535 | |||
| 12ca1b7dab | |||
|
fa1b44f172
|
|||
|
03519e9337
|
|||
|
60b6d30379
|
|||
|
19b8f7b7a2
|
|||
|
4f586c6176
|
|||
|
d1a70509b7
|
|||
|
95bfb87c6e
|
|||
|
de0cf37918
|
|||
|
f1fd826c62
|
|||
|
1380a00872
|
|||
|
174a210f81
|
|||
|
67a03f394f
|
|||
|
6eebe404d5
|
|||
|
1d409218a5
|
|||
|
e2c72c90c7
|
737
Cargo.lock
generated
737
Cargo.lock
generated
File diff suppressed because it is too large
Load Diff
@@ -26,10 +26,11 @@ Prerequisite: golang installed
|
|||||||
|
|
||||||
Prerequisite: bun installed
|
Prerequisite: bun installed
|
||||||
|
|
||||||
The environment variable `API_HOST` will need to be set for the middleware.
|
The environment variables `API_HOST` and `AUTH_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/v1/"
|
API_HOST="http://localhost:8082/"
|
||||||
|
AUTH_HOST="http://localhost:8083/"
|
||||||
```
|
```
|
||||||
|
|
||||||
1. `cd web`
|
1. `cd web`
|
||||||
|
|||||||
@@ -33,6 +33,8 @@ 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
|
||||||
@@ -50,6 +52,7 @@ 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:
|
||||||
|
|||||||
@@ -47,14 +47,14 @@ paths:
|
|||||||
required: true
|
required: true
|
||||||
schema:
|
schema:
|
||||||
type: integer
|
type: integer
|
||||||
format: uint64
|
format: int64
|
||||||
minimum: 0
|
minimum: 0
|
||||||
- name: ValidatedModelVersion
|
- name: ValidatedModelVersion
|
||||||
in: query
|
in: query
|
||||||
required: true
|
required: true
|
||||||
schema:
|
schema:
|
||||||
type: integer
|
type: integer
|
||||||
format: uint64
|
format: int64
|
||||||
minimum: 0
|
minimum: 0
|
||||||
responses:
|
responses:
|
||||||
"204":
|
"204":
|
||||||
@@ -65,10 +65,100 @@ paths:
|
|||||||
application/json:
|
application/json:
|
||||||
schema:
|
schema:
|
||||||
$ref: "#/components/schemas/Error"
|
$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:
|
/mapfixes/{MapfixID}/status/validator-submitted:
|
||||||
post:
|
post:
|
||||||
summary: (Internal endpoint) Role Validator changes status from Submitting -> Submitted
|
summary: (Internal endpoint) Role Validator changes status from Submitting -> Submitted
|
||||||
operationId: actionMapfixSubmitted
|
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:
|
tags:
|
||||||
- Mapfixes
|
- Mapfixes
|
||||||
parameters:
|
parameters:
|
||||||
@@ -107,13 +197,6 @@ 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
|
||||||
@@ -202,14 +285,14 @@ paths:
|
|||||||
required: true
|
required: true
|
||||||
schema:
|
schema:
|
||||||
type: integer
|
type: integer
|
||||||
format: uint64
|
format: int64
|
||||||
minimum: 0
|
minimum: 0
|
||||||
- name: ValidatedModelVersion
|
- name: ValidatedModelVersion
|
||||||
in: query
|
in: query
|
||||||
required: true
|
required: true
|
||||||
schema:
|
schema:
|
||||||
type: integer
|
type: integer
|
||||||
format: uint64
|
format: int64
|
||||||
minimum: 0
|
minimum: 0
|
||||||
responses:
|
responses:
|
||||||
"204":
|
"204":
|
||||||
@@ -220,10 +303,100 @@ paths:
|
|||||||
application/json:
|
application/json:
|
||||||
schema:
|
schema:
|
||||||
$ref: "#/components/schemas/Error"
|
$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:
|
/submissions/{SubmissionID}/status/validator-submitted:
|
||||||
post:
|
post:
|
||||||
summary: (Internal endpoint) Role Validator changes status from Submitting -> Submitted
|
summary: (Internal endpoint) Role Validator changes status from Submitting -> Submitted
|
||||||
operationId: actionSubmissionSubmitted
|
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:
|
tags:
|
||||||
- Submissions
|
- Submissions
|
||||||
parameters:
|
parameters:
|
||||||
@@ -262,13 +435,6 @@ 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
|
||||||
@@ -291,7 +457,7 @@ paths:
|
|||||||
required: true
|
required: true
|
||||||
schema:
|
schema:
|
||||||
type: integer
|
type: integer
|
||||||
format: uint64
|
format: int64
|
||||||
minimum: 0
|
minimum: 0
|
||||||
responses:
|
responses:
|
||||||
"204":
|
"204":
|
||||||
@@ -321,13 +487,13 @@ paths:
|
|||||||
in: query
|
in: query
|
||||||
schema:
|
schema:
|
||||||
type: integer
|
type: integer
|
||||||
format: uint64
|
format: int64
|
||||||
minimum: 0
|
minimum: 0
|
||||||
- name: Policy
|
- name: Policy
|
||||||
in: query
|
in: query
|
||||||
schema:
|
schema:
|
||||||
type: integer
|
type: integer
|
||||||
format: uint32
|
format: int32
|
||||||
minimum: 0
|
minimum: 0
|
||||||
responses:
|
responses:
|
||||||
"200":
|
"200":
|
||||||
@@ -397,13 +563,13 @@ paths:
|
|||||||
in: query
|
in: query
|
||||||
schema:
|
schema:
|
||||||
type: integer
|
type: integer
|
||||||
format: uint32
|
format: int32
|
||||||
minimum: 0
|
minimum: 0
|
||||||
- name: ResourceID
|
- name: ResourceID
|
||||||
in: query
|
in: query
|
||||||
schema:
|
schema:
|
||||||
type: integer
|
type: integer
|
||||||
format: uint64
|
format: int64
|
||||||
minimum: 0
|
minimum: 0
|
||||||
responses:
|
responses:
|
||||||
"200":
|
"200":
|
||||||
@@ -474,7 +640,7 @@ components:
|
|||||||
description: The unique identifier for a submission.
|
description: The unique identifier for a submission.
|
||||||
schema:
|
schema:
|
||||||
type: integer
|
type: integer
|
||||||
format: uint64
|
format: int64
|
||||||
minimum: 0
|
minimum: 0
|
||||||
OperationID:
|
OperationID:
|
||||||
name: OperationID
|
name: OperationID
|
||||||
@@ -483,7 +649,7 @@ components:
|
|||||||
description: The unique identifier for a long-running operation.
|
description: The unique identifier for a long-running operation.
|
||||||
schema:
|
schema:
|
||||||
type: integer
|
type: integer
|
||||||
format: uint32
|
format: int32
|
||||||
minimum: 0
|
minimum: 0
|
||||||
SubmissionID:
|
SubmissionID:
|
||||||
name: SubmissionID
|
name: SubmissionID
|
||||||
@@ -492,7 +658,7 @@ components:
|
|||||||
description: The unique identifier for a submission.
|
description: The unique identifier for a submission.
|
||||||
schema:
|
schema:
|
||||||
type: integer
|
type: integer
|
||||||
format: uint64
|
format: int64
|
||||||
minimum: 0
|
minimum: 0
|
||||||
ScriptID:
|
ScriptID:
|
||||||
name: ScriptID
|
name: ScriptID
|
||||||
@@ -501,7 +667,7 @@ components:
|
|||||||
description: The unique identifier for a script.
|
description: The unique identifier for a script.
|
||||||
schema:
|
schema:
|
||||||
type: integer
|
type: integer
|
||||||
format: uint64
|
format: int64
|
||||||
minimum: 0
|
minimum: 0
|
||||||
Page:
|
Page:
|
||||||
name: Page
|
name: Page
|
||||||
@@ -509,7 +675,7 @@ components:
|
|||||||
required: true
|
required: true
|
||||||
schema:
|
schema:
|
||||||
type: integer
|
type: integer
|
||||||
format: uint32
|
format: int32
|
||||||
minimum: 1
|
minimum: 1
|
||||||
Limit:
|
Limit:
|
||||||
name: Limit
|
name: Limit
|
||||||
@@ -517,7 +683,7 @@ components:
|
|||||||
required: true
|
required: true
|
||||||
schema:
|
schema:
|
||||||
type: integer
|
type: integer
|
||||||
format: uint32
|
format: int32
|
||||||
minimum: 1
|
minimum: 1
|
||||||
maximum: 100
|
maximum: 100
|
||||||
schemas:
|
schemas:
|
||||||
@@ -528,7 +694,7 @@ components:
|
|||||||
properties:
|
properties:
|
||||||
MapfixID:
|
MapfixID:
|
||||||
type: integer
|
type: integer
|
||||||
format: uint64
|
format: int64
|
||||||
minimum: 0
|
minimum: 0
|
||||||
SubmissionID:
|
SubmissionID:
|
||||||
required:
|
required:
|
||||||
@@ -537,7 +703,7 @@ components:
|
|||||||
properties:
|
properties:
|
||||||
SubmissionID:
|
SubmissionID:
|
||||||
type: integer
|
type: integer
|
||||||
format: uint64
|
format: int64
|
||||||
minimum: 0
|
minimum: 0
|
||||||
ScriptID:
|
ScriptID:
|
||||||
required:
|
required:
|
||||||
@@ -546,7 +712,7 @@ components:
|
|||||||
properties:
|
properties:
|
||||||
ScriptID:
|
ScriptID:
|
||||||
type: integer
|
type: integer
|
||||||
format: uint64
|
format: int64
|
||||||
minimum: 0
|
minimum: 0
|
||||||
ScriptPolicyID:
|
ScriptPolicyID:
|
||||||
required:
|
required:
|
||||||
@@ -555,7 +721,7 @@ components:
|
|||||||
properties:
|
properties:
|
||||||
ScriptPolicyID:
|
ScriptPolicyID:
|
||||||
type: integer
|
type: integer
|
||||||
format: uint64
|
format: int64
|
||||||
minimum: 0
|
minimum: 0
|
||||||
MapfixCreate:
|
MapfixCreate:
|
||||||
required:
|
required:
|
||||||
@@ -567,15 +733,16 @@ components:
|
|||||||
- AssetID
|
- AssetID
|
||||||
- AssetVersion
|
- AssetVersion
|
||||||
- TargetAssetID
|
- TargetAssetID
|
||||||
|
- Description
|
||||||
type: object
|
type: object
|
||||||
properties:
|
properties:
|
||||||
OperationID:
|
OperationID:
|
||||||
type: integer
|
type: integer
|
||||||
format: uint32
|
format: int32
|
||||||
minimum: 0
|
minimum: 0
|
||||||
AssetOwner:
|
AssetOwner:
|
||||||
type: integer
|
type: integer
|
||||||
format: uint64
|
format: int64
|
||||||
minimum: 0
|
minimum: 0
|
||||||
DisplayName:
|
DisplayName:
|
||||||
type: string
|
type: string
|
||||||
@@ -585,20 +752,23 @@ components:
|
|||||||
maxLength: 128
|
maxLength: 128
|
||||||
GameID:
|
GameID:
|
||||||
type: integer
|
type: integer
|
||||||
format: uint32
|
format: int32
|
||||||
minimum: 0
|
minimum: 0
|
||||||
AssetID:
|
AssetID:
|
||||||
type: integer
|
type: integer
|
||||||
format: uint64
|
format: int64
|
||||||
minimum: 0
|
minimum: 0
|
||||||
AssetVersion:
|
AssetVersion:
|
||||||
type: integer
|
type: integer
|
||||||
format: uint64
|
format: int64
|
||||||
minimum: 0
|
minimum: 0
|
||||||
TargetAssetID:
|
TargetAssetID:
|
||||||
type: integer
|
type: integer
|
||||||
format: uint64
|
format: int64
|
||||||
minimum: 0
|
minimum: 0
|
||||||
|
Description:
|
||||||
|
type: string
|
||||||
|
maxLength: 256
|
||||||
SubmissionCreate:
|
SubmissionCreate:
|
||||||
required:
|
required:
|
||||||
- OperationID
|
- OperationID
|
||||||
@@ -608,15 +778,17 @@ components:
|
|||||||
- GameID
|
- GameID
|
||||||
- AssetID
|
- AssetID
|
||||||
- AssetVersion
|
- AssetVersion
|
||||||
|
- Status
|
||||||
|
- Roles
|
||||||
type: object
|
type: object
|
||||||
properties:
|
properties:
|
||||||
OperationID:
|
OperationID:
|
||||||
type: integer
|
type: integer
|
||||||
format: uint32
|
format: int32
|
||||||
minimum: 0
|
minimum: 0
|
||||||
AssetOwner:
|
AssetOwner:
|
||||||
type: integer
|
type: integer
|
||||||
format: uint64
|
format: int64
|
||||||
minimum: 0
|
minimum: 0
|
||||||
DisplayName:
|
DisplayName:
|
||||||
type: string
|
type: string
|
||||||
@@ -626,16 +798,24 @@ components:
|
|||||||
maxLength: 128
|
maxLength: 128
|
||||||
GameID:
|
GameID:
|
||||||
type: integer
|
type: integer
|
||||||
format: uint32
|
format: int32
|
||||||
minimum: 0
|
minimum: 0
|
||||||
AssetID:
|
AssetID:
|
||||||
type: integer
|
type: integer
|
||||||
format: uint64
|
format: int64
|
||||||
minimum: 0
|
minimum: 0
|
||||||
AssetVersion:
|
AssetVersion:
|
||||||
type: integer
|
type: integer
|
||||||
format: uint64
|
format: int64
|
||||||
minimum: 0
|
minimum: 0
|
||||||
|
Status:
|
||||||
|
type: integer
|
||||||
|
format: uint32
|
||||||
|
minimum: 0
|
||||||
|
maximum: 9
|
||||||
|
Roles:
|
||||||
|
type: integer
|
||||||
|
format: uint32
|
||||||
Script:
|
Script:
|
||||||
required:
|
required:
|
||||||
- ID
|
- ID
|
||||||
@@ -648,7 +828,7 @@ components:
|
|||||||
properties:
|
properties:
|
||||||
ID:
|
ID:
|
||||||
type: integer
|
type: integer
|
||||||
format: uint64
|
format: int64
|
||||||
minimum: 0
|
minimum: 0
|
||||||
Name:
|
Name:
|
||||||
type: string
|
type: string
|
||||||
@@ -662,11 +842,11 @@ components:
|
|||||||
maxLength: 1048576
|
maxLength: 1048576
|
||||||
ResourceType:
|
ResourceType:
|
||||||
type: integer
|
type: integer
|
||||||
format: uint32
|
format: int32
|
||||||
minimum: 0
|
minimum: 0
|
||||||
ResourceID:
|
ResourceID:
|
||||||
type: integer
|
type: integer
|
||||||
format: uint64
|
format: int64
|
||||||
minimum: 0
|
minimum: 0
|
||||||
ScriptCreate:
|
ScriptCreate:
|
||||||
required:
|
required:
|
||||||
@@ -684,11 +864,11 @@ components:
|
|||||||
maxLength: 1048576
|
maxLength: 1048576
|
||||||
ResourceType:
|
ResourceType:
|
||||||
type: integer
|
type: integer
|
||||||
format: uint32
|
format: int32
|
||||||
minimum: 0
|
minimum: 0
|
||||||
ResourceID:
|
ResourceID:
|
||||||
type: integer
|
type: integer
|
||||||
format: uint64
|
format: int64
|
||||||
minimum: 0
|
minimum: 0
|
||||||
ScriptPolicy:
|
ScriptPolicy:
|
||||||
required:
|
required:
|
||||||
@@ -700,7 +880,7 @@ components:
|
|||||||
properties:
|
properties:
|
||||||
ID:
|
ID:
|
||||||
type: integer
|
type: integer
|
||||||
format: uint64
|
format: int64
|
||||||
minimum: 0
|
minimum: 0
|
||||||
FromScriptHash:
|
FromScriptHash:
|
||||||
type: string
|
type: string
|
||||||
@@ -708,11 +888,11 @@ components:
|
|||||||
maxLength: 16
|
maxLength: 16
|
||||||
ToScriptID:
|
ToScriptID:
|
||||||
type: integer
|
type: integer
|
||||||
format: uint64
|
format: int64
|
||||||
minimum: 0
|
minimum: 0
|
||||||
Policy:
|
Policy:
|
||||||
type: integer
|
type: integer
|
||||||
format: uint32
|
format: int32
|
||||||
minimum: 0
|
minimum: 0
|
||||||
ScriptPolicyCreate:
|
ScriptPolicyCreate:
|
||||||
required:
|
required:
|
||||||
@@ -723,23 +903,42 @@ components:
|
|||||||
properties:
|
properties:
|
||||||
FromScriptID:
|
FromScriptID:
|
||||||
type: integer
|
type: integer
|
||||||
format: uint64
|
format: int64
|
||||||
minimum: 0
|
minimum: 0
|
||||||
ToScriptID:
|
ToScriptID:
|
||||||
type: integer
|
type: integer
|
||||||
format: uint64
|
format: int64
|
||||||
minimum: 0
|
minimum: 0
|
||||||
Policy:
|
Policy:
|
||||||
type: integer
|
type: integer
|
||||||
format: uint32
|
format: int32
|
||||||
minimum: 0
|
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
|
||||||
properties:
|
properties:
|
||||||
code:
|
code:
|
||||||
type: integer
|
type: integer
|
||||||
format: uint64
|
format: int64
|
||||||
minimum: 0
|
minimum: 0
|
||||||
message:
|
message:
|
||||||
type: string
|
type: string
|
||||||
|
|||||||
360
openapi.yaml
360
openapi.yaml
@@ -104,16 +104,23 @@ paths:
|
|||||||
in: query
|
in: query
|
||||||
schema:
|
schema:
|
||||||
type: integer
|
type: integer
|
||||||
format: uint32
|
format: int32
|
||||||
minimum: 1
|
minimum: 1
|
||||||
maximum: 5
|
maximum: 5
|
||||||
- name: Sort
|
- name: Sort
|
||||||
in: query
|
in: query
|
||||||
schema:
|
schema:
|
||||||
type: integer
|
type: integer
|
||||||
format: uint32
|
format: int32
|
||||||
minimum: 0
|
minimum: 0
|
||||||
maximum: 4
|
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
|
||||||
@@ -151,6 +158,34 @@ 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
|
||||||
@@ -175,41 +210,71 @@ paths:
|
|||||||
in: query
|
in: query
|
||||||
schema:
|
schema:
|
||||||
type: integer
|
type: integer
|
||||||
format: uint32
|
format: int32
|
||||||
minimum: 1
|
minimum: 1
|
||||||
maximum: 5
|
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: uint32
|
format: int32
|
||||||
minimum: 0
|
minimum: 0
|
||||||
maximum: 4
|
maximum: 4
|
||||||
|
description: >
|
||||||
|
Sort order:
|
||||||
|
* `0` - Disabled
|
||||||
|
* `1` - DisplayNameAscending
|
||||||
|
* `2` - DisplayNameDescending
|
||||||
|
* `3` - DateAscending
|
||||||
|
* `4` - DateDescending
|
||||||
- name: Submitter
|
- name: Submitter
|
||||||
in: query
|
in: query
|
||||||
schema:
|
schema:
|
||||||
type: integer
|
type: integer
|
||||||
format: uint64
|
format: int64
|
||||||
minimum: 0
|
minimum: 0
|
||||||
- name: AssetID
|
- name: AssetID
|
||||||
in: query
|
in: query
|
||||||
schema:
|
schema:
|
||||||
type: integer
|
type: integer
|
||||||
format: uint64
|
format: int64
|
||||||
minimum: 0
|
minimum: 0
|
||||||
- name: TargetAssetID
|
- name: TargetAssetID
|
||||||
in: query
|
in: query
|
||||||
schema:
|
schema:
|
||||||
type: integer
|
type: integer
|
||||||
format: uint64
|
format: int64
|
||||||
minimum: 0
|
minimum: 0
|
||||||
- name: StatusID
|
- name: StatusID
|
||||||
in: query
|
in: query
|
||||||
schema:
|
schema:
|
||||||
type: integer
|
type: integer
|
||||||
format: uint32
|
format: int32
|
||||||
minimum: 0
|
minimum: 0
|
||||||
maximum: 9
|
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
|
||||||
@@ -332,14 +397,14 @@ paths:
|
|||||||
required: true
|
required: true
|
||||||
schema:
|
schema:
|
||||||
type: integer
|
type: integer
|
||||||
format: uint64
|
format: int64
|
||||||
minimum: 0
|
minimum: 0
|
||||||
- name: ModelVersion
|
- name: ModelVersion
|
||||||
in: query
|
in: query
|
||||||
required: true
|
required: true
|
||||||
schema:
|
schema:
|
||||||
type: integer
|
type: integer
|
||||||
format: uint64
|
format: int64
|
||||||
minimum: 0
|
minimum: 0
|
||||||
responses:
|
responses:
|
||||||
"204":
|
"204":
|
||||||
@@ -384,6 +449,23 @@ paths:
|
|||||||
application/json:
|
application/json:
|
||||||
schema:
|
schema:
|
||||||
$ref: "#/components/schemas/Error"
|
$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:
|
/mapfixes/{MapfixID}/status/reset-submitting:
|
||||||
post:
|
post:
|
||||||
summary: Role Submitter manually resets submitting softlock and changes status from Submitting -> UnderConstruction
|
summary: Role Submitter manually resets submitting softlock and changes status from Submitting -> UnderConstruction
|
||||||
@@ -582,41 +664,72 @@ paths:
|
|||||||
in: query
|
in: query
|
||||||
schema:
|
schema:
|
||||||
type: integer
|
type: integer
|
||||||
format: uint32
|
format: int32
|
||||||
minimum: 1
|
minimum: 1
|
||||||
maximum: 5
|
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: uint32
|
format: int32
|
||||||
minimum: 0
|
minimum: 0
|
||||||
maximum: 4
|
maximum: 4
|
||||||
|
description: >
|
||||||
|
Sort order:
|
||||||
|
* `0` - Disabled
|
||||||
|
* `1` - DisplayNameAscending
|
||||||
|
* `2` - DisplayNameDescending
|
||||||
|
* `3` - DateAscending
|
||||||
|
* `4` - DateDescending
|
||||||
- name: Submitter
|
- name: Submitter
|
||||||
in: query
|
in: query
|
||||||
schema:
|
schema:
|
||||||
type: integer
|
type: integer
|
||||||
format: uint64
|
format: int64
|
||||||
minimum: 0
|
minimum: 0
|
||||||
- name: AssetID
|
- name: AssetID
|
||||||
in: query
|
in: query
|
||||||
schema:
|
schema:
|
||||||
type: integer
|
type: integer
|
||||||
format: uint64
|
format: int64
|
||||||
minimum: 0
|
minimum: 0
|
||||||
- name: UploadedAssetID
|
- name: UploadedAssetID
|
||||||
in: query
|
in: query
|
||||||
schema:
|
schema:
|
||||||
type: integer
|
type: integer
|
||||||
format: uint64
|
format: int64
|
||||||
minimum: 0
|
minimum: 0
|
||||||
- name: StatusID
|
- name: StatusID
|
||||||
in: query
|
in: query
|
||||||
schema:
|
schema:
|
||||||
type: integer
|
type: integer
|
||||||
format: uint32
|
format: int32
|
||||||
minimum: 0
|
minimum: 0
|
||||||
maximum: 10
|
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
|
||||||
@@ -654,6 +767,31 @@ 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
|
||||||
@@ -739,14 +877,14 @@ paths:
|
|||||||
required: true
|
required: true
|
||||||
schema:
|
schema:
|
||||||
type: integer
|
type: integer
|
||||||
format: uint64
|
format: int64
|
||||||
minimum: 0
|
minimum: 0
|
||||||
- name: ModelVersion
|
- name: ModelVersion
|
||||||
in: query
|
in: query
|
||||||
required: true
|
required: true
|
||||||
schema:
|
schema:
|
||||||
type: integer
|
type: integer
|
||||||
format: uint64
|
format: int64
|
||||||
minimum: 0
|
minimum: 0
|
||||||
responses:
|
responses:
|
||||||
"204":
|
"204":
|
||||||
@@ -791,6 +929,23 @@ paths:
|
|||||||
application/json:
|
application/json:
|
||||||
schema:
|
schema:
|
||||||
$ref: "#/components/schemas/Error"
|
$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:
|
/submissions/{SubmissionID}/status/reset-submitting:
|
||||||
post:
|
post:
|
||||||
summary: Role Submitter manually resets submitting softlock and changes status from Submitting -> UnderConstruction
|
summary: Role Submitter manually resets submitting softlock and changes status from Submitting -> UnderConstruction
|
||||||
@@ -989,13 +1144,13 @@ paths:
|
|||||||
in: query
|
in: query
|
||||||
schema:
|
schema:
|
||||||
type: integer
|
type: integer
|
||||||
format: uint64
|
format: int64
|
||||||
minimum: 0
|
minimum: 0
|
||||||
- name: Policy
|
- name: Policy
|
||||||
in: query
|
in: query
|
||||||
schema:
|
schema:
|
||||||
type: integer
|
type: integer
|
||||||
format: uint32
|
format: int32
|
||||||
minimum: 0
|
minimum: 0
|
||||||
responses:
|
responses:
|
||||||
"200":
|
"200":
|
||||||
@@ -1126,13 +1281,13 @@ paths:
|
|||||||
in: query
|
in: query
|
||||||
schema:
|
schema:
|
||||||
type: integer
|
type: integer
|
||||||
format: uint32
|
format: int32
|
||||||
minimum: 0
|
minimum: 0
|
||||||
- name: ResourceID
|
- name: ResourceID
|
||||||
in: query
|
in: query
|
||||||
schema:
|
schema:
|
||||||
type: integer
|
type: integer
|
||||||
format: uint64
|
format: int64
|
||||||
minimum: 0
|
minimum: 0
|
||||||
responses:
|
responses:
|
||||||
"200":
|
"200":
|
||||||
@@ -1247,7 +1402,7 @@ components:
|
|||||||
description: The unique identifier for a map.
|
description: The unique identifier for a map.
|
||||||
schema:
|
schema:
|
||||||
type: integer
|
type: integer
|
||||||
format: uint64
|
format: int64
|
||||||
minimum: 0
|
minimum: 0
|
||||||
MapfixID:
|
MapfixID:
|
||||||
name: MapfixID
|
name: MapfixID
|
||||||
@@ -1256,7 +1411,7 @@ components:
|
|||||||
description: The unique identifier for a mapfix.
|
description: The unique identifier for a mapfix.
|
||||||
schema:
|
schema:
|
||||||
type: integer
|
type: integer
|
||||||
format: uint64
|
format: int64
|
||||||
minimum: 0
|
minimum: 0
|
||||||
OperationID:
|
OperationID:
|
||||||
name: OperationID
|
name: OperationID
|
||||||
@@ -1265,7 +1420,7 @@ components:
|
|||||||
description: The unique identifier for a long-running operation.
|
description: The unique identifier for a long-running operation.
|
||||||
schema:
|
schema:
|
||||||
type: integer
|
type: integer
|
||||||
format: uint32
|
format: int32
|
||||||
minimum: 0
|
minimum: 0
|
||||||
SubmissionID:
|
SubmissionID:
|
||||||
name: SubmissionID
|
name: SubmissionID
|
||||||
@@ -1274,7 +1429,7 @@ components:
|
|||||||
description: The unique identifier for a submission.
|
description: The unique identifier for a submission.
|
||||||
schema:
|
schema:
|
||||||
type: integer
|
type: integer
|
||||||
format: uint64
|
format: int64
|
||||||
minimum: 0
|
minimum: 0
|
||||||
ScriptID:
|
ScriptID:
|
||||||
name: ScriptID
|
name: ScriptID
|
||||||
@@ -1283,7 +1438,7 @@ components:
|
|||||||
description: The unique identifier for a script.
|
description: The unique identifier for a script.
|
||||||
schema:
|
schema:
|
||||||
type: integer
|
type: integer
|
||||||
format: uint64
|
format: int64
|
||||||
minimum: 0
|
minimum: 0
|
||||||
ScriptPolicyID:
|
ScriptPolicyID:
|
||||||
name: ScriptPolicyID
|
name: ScriptPolicyID
|
||||||
@@ -1292,7 +1447,7 @@ components:
|
|||||||
description: The unique identifier for a script policy.
|
description: The unique identifier for a script policy.
|
||||||
schema:
|
schema:
|
||||||
type: integer
|
type: integer
|
||||||
format: uint64
|
format: int64
|
||||||
minimum: 0
|
minimum: 0
|
||||||
Page:
|
Page:
|
||||||
name: Page
|
name: Page
|
||||||
@@ -1300,7 +1455,7 @@ components:
|
|||||||
required: true
|
required: true
|
||||||
schema:
|
schema:
|
||||||
type: integer
|
type: integer
|
||||||
format: uint32
|
format: int32
|
||||||
minimum: 1
|
minimum: 1
|
||||||
Limit:
|
Limit:
|
||||||
name: Limit
|
name: Limit
|
||||||
@@ -1308,7 +1463,7 @@ components:
|
|||||||
required: true
|
required: true
|
||||||
schema:
|
schema:
|
||||||
type: integer
|
type: integer
|
||||||
format: uint32
|
format: int32
|
||||||
minimum: 0
|
minimum: 0
|
||||||
maximum: 100
|
maximum: 100
|
||||||
schemas:
|
schemas:
|
||||||
@@ -1318,6 +1473,7 @@ components:
|
|||||||
- ID
|
- ID
|
||||||
- Date
|
- Date
|
||||||
- User
|
- User
|
||||||
|
- Username
|
||||||
- ResourceType
|
- ResourceType
|
||||||
- ResourceID
|
- ResourceID
|
||||||
- EventType
|
- EventType
|
||||||
@@ -1325,23 +1481,26 @@ components:
|
|||||||
properties:
|
properties:
|
||||||
ID:
|
ID:
|
||||||
type: integer
|
type: integer
|
||||||
format: uint64
|
format: int64
|
||||||
Date:
|
Date:
|
||||||
type: integer
|
type: integer
|
||||||
format: int64
|
format: int64
|
||||||
User:
|
User:
|
||||||
type: integer
|
type: integer
|
||||||
format: uint64
|
format: int64
|
||||||
|
Username:
|
||||||
|
type: string
|
||||||
|
maxLength: 64
|
||||||
ResourceType:
|
ResourceType:
|
||||||
type: integer
|
type: integer
|
||||||
format: uint32
|
format: int32
|
||||||
description: Is this a submission or is it a mapfix
|
description: Is this a submission or is it a mapfix
|
||||||
ResourceID:
|
ResourceID:
|
||||||
type: integer
|
type: integer
|
||||||
format: uint64
|
format: int64
|
||||||
EventType:
|
EventType:
|
||||||
type: integer
|
type: integer
|
||||||
format: uint32
|
format: int32
|
||||||
EventData:
|
EventData:
|
||||||
type: object
|
type: object
|
||||||
description: Arbitrary event data
|
description: Arbitrary event data
|
||||||
@@ -1353,7 +1512,7 @@ components:
|
|||||||
properties:
|
properties:
|
||||||
OperationID:
|
OperationID:
|
||||||
type: integer
|
type: integer
|
||||||
format: uint32
|
format: int32
|
||||||
minimum: 0
|
minimum: 0
|
||||||
ScriptID:
|
ScriptID:
|
||||||
required:
|
required:
|
||||||
@@ -1362,7 +1521,7 @@ components:
|
|||||||
properties:
|
properties:
|
||||||
ScriptID:
|
ScriptID:
|
||||||
type: integer
|
type: integer
|
||||||
format: uint64
|
format: int64
|
||||||
minimum: 0
|
minimum: 0
|
||||||
ScriptPolicyID:
|
ScriptPolicyID:
|
||||||
required:
|
required:
|
||||||
@@ -1371,7 +1530,7 @@ components:
|
|||||||
properties:
|
properties:
|
||||||
ScriptPolicyID:
|
ScriptPolicyID:
|
||||||
type: integer
|
type: integer
|
||||||
format: uint64
|
format: int64
|
||||||
minimum: 0
|
minimum: 0
|
||||||
Roles:
|
Roles:
|
||||||
required:
|
required:
|
||||||
@@ -1380,7 +1539,7 @@ components:
|
|||||||
properties:
|
properties:
|
||||||
Roles:
|
Roles:
|
||||||
type: integer
|
type: integer
|
||||||
format: uint32
|
format: int32
|
||||||
minimum: 0
|
minimum: 0
|
||||||
User:
|
User:
|
||||||
required:
|
required:
|
||||||
@@ -1391,7 +1550,7 @@ components:
|
|||||||
properties:
|
properties:
|
||||||
UserID:
|
UserID:
|
||||||
type: integer
|
type: integer
|
||||||
format: uint64
|
format: int64
|
||||||
minimum: 0
|
minimum: 0
|
||||||
Username:
|
Username:
|
||||||
type: string
|
type: string
|
||||||
@@ -1410,7 +1569,7 @@ components:
|
|||||||
properties:
|
properties:
|
||||||
ID:
|
ID:
|
||||||
type: integer
|
type: integer
|
||||||
format: uint64
|
format: int64
|
||||||
minimum: 0
|
minimum: 0
|
||||||
DisplayName:
|
DisplayName:
|
||||||
type: string
|
type: string
|
||||||
@@ -1420,7 +1579,7 @@ components:
|
|||||||
maxLength: 128
|
maxLength: 128
|
||||||
GameID:
|
GameID:
|
||||||
type: integer
|
type: integer
|
||||||
format: uint32
|
format: int32
|
||||||
minimum: 0
|
minimum: 0
|
||||||
Date:
|
Date:
|
||||||
type: integer
|
type: integer
|
||||||
@@ -1440,12 +1599,12 @@ components:
|
|||||||
- Completed
|
- Completed
|
||||||
- TargetAssetID
|
- TargetAssetID
|
||||||
- StatusID
|
- StatusID
|
||||||
- StatusMessage
|
- Description
|
||||||
type: object
|
type: object
|
||||||
properties:
|
properties:
|
||||||
ID:
|
ID:
|
||||||
type: integer
|
type: integer
|
||||||
format: uint64
|
format: int64
|
||||||
minimum: 0
|
minimum: 0
|
||||||
DisplayName:
|
DisplayName:
|
||||||
type: string
|
type: string
|
||||||
@@ -1455,7 +1614,7 @@ components:
|
|||||||
maxLength: 128
|
maxLength: 128
|
||||||
GameID:
|
GameID:
|
||||||
type: integer
|
type: integer
|
||||||
format: uint32
|
format: int32
|
||||||
minimum: 0
|
minimum: 0
|
||||||
CreatedAt:
|
CreatedAt:
|
||||||
type: integer
|
type: integer
|
||||||
@@ -1467,27 +1626,27 @@ components:
|
|||||||
minimum: 0
|
minimum: 0
|
||||||
Submitter:
|
Submitter:
|
||||||
type: integer
|
type: integer
|
||||||
format: uint64
|
format: int64
|
||||||
minimum: 0
|
minimum: 0
|
||||||
AssetID:
|
AssetID:
|
||||||
type: integer
|
type: integer
|
||||||
format: uint64
|
format: int64
|
||||||
minimum: 0
|
minimum: 0
|
||||||
AssetVersion:
|
AssetVersion:
|
||||||
type: integer
|
type: integer
|
||||||
format: uint64
|
format: int64
|
||||||
minimum: 0
|
minimum: 0
|
||||||
Completed:
|
Completed:
|
||||||
type: boolean
|
type: boolean
|
||||||
TargetAssetID:
|
TargetAssetID:
|
||||||
type: integer
|
type: integer
|
||||||
format: uint64
|
format: int64
|
||||||
minimum: 0
|
minimum: 0
|
||||||
StatusID:
|
StatusID:
|
||||||
type: integer
|
type: integer
|
||||||
format: uint32
|
format: int32
|
||||||
minimum: 0
|
minimum: 0
|
||||||
StatusMessage:
|
Description:
|
||||||
type: string
|
type: string
|
||||||
maxLength: 256
|
maxLength: 256
|
||||||
Mapfixes:
|
Mapfixes:
|
||||||
@@ -1498,7 +1657,7 @@ components:
|
|||||||
properties:
|
properties:
|
||||||
Total:
|
Total:
|
||||||
type: integer
|
type: integer
|
||||||
format: uint64
|
format: int64
|
||||||
minimum: 0
|
minimum: 0
|
||||||
Mapfixes:
|
Mapfixes:
|
||||||
type: array
|
type: array
|
||||||
@@ -1508,16 +1667,20 @@ components:
|
|||||||
required:
|
required:
|
||||||
- AssetID
|
- AssetID
|
||||||
- TargetAssetID
|
- TargetAssetID
|
||||||
|
- Description
|
||||||
type: object
|
type: object
|
||||||
properties:
|
properties:
|
||||||
AssetID:
|
AssetID:
|
||||||
type: integer
|
type: integer
|
||||||
format: uint64
|
format: int64
|
||||||
minimum: 0
|
minimum: 0
|
||||||
TargetAssetID:
|
TargetAssetID:
|
||||||
type: integer
|
type: integer
|
||||||
format: uint64
|
format: int64
|
||||||
minimum: 0
|
minimum: 0
|
||||||
|
Description:
|
||||||
|
type: string
|
||||||
|
maxLength: 256
|
||||||
Operation:
|
Operation:
|
||||||
required:
|
required:
|
||||||
- OperationID
|
- OperationID
|
||||||
@@ -1530,7 +1693,7 @@ components:
|
|||||||
properties:
|
properties:
|
||||||
OperationID:
|
OperationID:
|
||||||
type: integer
|
type: integer
|
||||||
format: uint32
|
format: int32
|
||||||
minimum: 0
|
minimum: 0
|
||||||
Date:
|
Date:
|
||||||
type: integer
|
type: integer
|
||||||
@@ -1538,11 +1701,11 @@ components:
|
|||||||
minimum: 0
|
minimum: 0
|
||||||
Owner:
|
Owner:
|
||||||
type: integer
|
type: integer
|
||||||
format: uint64
|
format: int64
|
||||||
minimum: 0
|
minimum: 0
|
||||||
Status:
|
Status:
|
||||||
type: integer
|
type: integer
|
||||||
format: uint32
|
format: int32
|
||||||
minimum: 0
|
minimum: 0
|
||||||
StatusMessage:
|
StatusMessage:
|
||||||
type: string
|
type: string
|
||||||
@@ -1566,12 +1729,11 @@ components:
|
|||||||
- Completed
|
- Completed
|
||||||
# - UploadedAssetID
|
# - UploadedAssetID
|
||||||
- StatusID
|
- StatusID
|
||||||
- StatusMessage
|
|
||||||
type: object
|
type: object
|
||||||
properties:
|
properties:
|
||||||
ID:
|
ID:
|
||||||
type: integer
|
type: integer
|
||||||
format: uint64
|
format: int64
|
||||||
minimum: 0
|
minimum: 0
|
||||||
DisplayName:
|
DisplayName:
|
||||||
type: string
|
type: string
|
||||||
@@ -1581,49 +1743,46 @@ components:
|
|||||||
maxLength: 128
|
maxLength: 128
|
||||||
GameID:
|
GameID:
|
||||||
type: integer
|
type: integer
|
||||||
format: uint32
|
format: int32
|
||||||
minimum: 0
|
minimum: 0
|
||||||
CreatedAt:
|
CreatedAt:
|
||||||
type: integer
|
type: integer
|
||||||
format: uint64
|
format: int64
|
||||||
minimum: 0
|
minimum: 0
|
||||||
UpdatedAt:
|
UpdatedAt:
|
||||||
type: integer
|
type: integer
|
||||||
format: uint64
|
format: int64
|
||||||
minimum: 0
|
minimum: 0
|
||||||
Submitter:
|
Submitter:
|
||||||
type: integer
|
type: integer
|
||||||
format: uint64
|
format: int64
|
||||||
minimum: 0
|
minimum: 0
|
||||||
AssetID:
|
AssetID:
|
||||||
type: integer
|
type: integer
|
||||||
format: uint64
|
format: int64
|
||||||
minimum: 0
|
minimum: 0
|
||||||
AssetVersion:
|
AssetVersion:
|
||||||
type: integer
|
type: integer
|
||||||
format: uint64
|
format: int64
|
||||||
minimum: 0
|
minimum: 0
|
||||||
ValidatedAssetID:
|
ValidatedAssetID:
|
||||||
type: integer
|
type: integer
|
||||||
format: uint64
|
format: int64
|
||||||
minimum: 0
|
minimum: 0
|
||||||
ValidatedAssetVersion:
|
ValidatedAssetVersion:
|
||||||
type: integer
|
type: integer
|
||||||
format: uint64
|
format: int64
|
||||||
minimum: 0
|
minimum: 0
|
||||||
Completed:
|
Completed:
|
||||||
type: boolean
|
type: boolean
|
||||||
UploadedAssetID:
|
UploadedAssetID:
|
||||||
type: integer
|
type: integer
|
||||||
format: uint64
|
format: int64
|
||||||
minimum: 0
|
minimum: 0
|
||||||
StatusID:
|
StatusID:
|
||||||
type: integer
|
type: integer
|
||||||
format: uint32
|
format: int32
|
||||||
minimum: 0
|
minimum: 0
|
||||||
StatusMessage:
|
|
||||||
type: string
|
|
||||||
maxLength: 256
|
|
||||||
Submissions:
|
Submissions:
|
||||||
required:
|
required:
|
||||||
- Total
|
- Total
|
||||||
@@ -1632,7 +1791,7 @@ components:
|
|||||||
properties:
|
properties:
|
||||||
Total:
|
Total:
|
||||||
type: integer
|
type: integer
|
||||||
format: uint64
|
format: int64
|
||||||
minimum: 0
|
minimum: 0
|
||||||
Submissions:
|
Submissions:
|
||||||
type: array
|
type: array
|
||||||
@@ -1641,11 +1800,24 @@ components:
|
|||||||
SubmissionTriggerCreate:
|
SubmissionTriggerCreate:
|
||||||
required:
|
required:
|
||||||
- AssetID
|
- AssetID
|
||||||
|
- DisplayName
|
||||||
|
- Creator
|
||||||
|
- GameID
|
||||||
type: object
|
type: object
|
||||||
properties:
|
properties:
|
||||||
AssetID:
|
AssetID:
|
||||||
type: integer
|
type: integer
|
||||||
format: uint64
|
format: int64
|
||||||
|
minimum: 0
|
||||||
|
DisplayName:
|
||||||
|
type: string
|
||||||
|
maxLength: 128
|
||||||
|
Creator:
|
||||||
|
type: string
|
||||||
|
maxLength: 128
|
||||||
|
GameID:
|
||||||
|
type: integer
|
||||||
|
format: int32
|
||||||
minimum: 0
|
minimum: 0
|
||||||
ReleaseInfo:
|
ReleaseInfo:
|
||||||
required:
|
required:
|
||||||
@@ -1655,7 +1827,7 @@ components:
|
|||||||
properties:
|
properties:
|
||||||
SubmissionID:
|
SubmissionID:
|
||||||
type: integer
|
type: integer
|
||||||
format: uint64
|
format: int64
|
||||||
minimum: 0
|
minimum: 0
|
||||||
Date:
|
Date:
|
||||||
type: string
|
type: string
|
||||||
@@ -1672,7 +1844,7 @@ components:
|
|||||||
properties:
|
properties:
|
||||||
ID:
|
ID:
|
||||||
type: integer
|
type: integer
|
||||||
format: uint64
|
format: int64
|
||||||
minimum: 0
|
minimum: 0
|
||||||
Name:
|
Name:
|
||||||
type: string
|
type: string
|
||||||
@@ -1686,11 +1858,11 @@ components:
|
|||||||
maxLength: 1048576
|
maxLength: 1048576
|
||||||
ResourceType:
|
ResourceType:
|
||||||
type: integer
|
type: integer
|
||||||
format: uint32
|
format: int32
|
||||||
minimum: 0
|
minimum: 0
|
||||||
ResourceID:
|
ResourceID:
|
||||||
type: integer
|
type: integer
|
||||||
format: uint64
|
format: int64
|
||||||
minimum: 0
|
minimum: 0
|
||||||
ScriptCreate:
|
ScriptCreate:
|
||||||
required:
|
required:
|
||||||
@@ -1708,11 +1880,11 @@ components:
|
|||||||
maxLength: 1048576
|
maxLength: 1048576
|
||||||
ResourceType:
|
ResourceType:
|
||||||
type: integer
|
type: integer
|
||||||
format: uint32
|
format: int32
|
||||||
minimum: 0
|
minimum: 0
|
||||||
ResourceID:
|
ResourceID:
|
||||||
type: integer
|
type: integer
|
||||||
format: uint64
|
format: int64
|
||||||
minimum: 0
|
minimum: 0
|
||||||
ScriptUpdate:
|
ScriptUpdate:
|
||||||
required:
|
required:
|
||||||
@@ -1721,7 +1893,7 @@ components:
|
|||||||
properties:
|
properties:
|
||||||
ID:
|
ID:
|
||||||
type: integer
|
type: integer
|
||||||
format: uint64
|
format: int64
|
||||||
minimum: 0
|
minimum: 0
|
||||||
Name:
|
Name:
|
||||||
type: string
|
type: string
|
||||||
@@ -1731,11 +1903,11 @@ components:
|
|||||||
maxLength: 1048576
|
maxLength: 1048576
|
||||||
ResourceType:
|
ResourceType:
|
||||||
type: integer
|
type: integer
|
||||||
format: uint32
|
format: int32
|
||||||
minimum: 0
|
minimum: 0
|
||||||
ResourceID:
|
ResourceID:
|
||||||
type: integer
|
type: integer
|
||||||
format: uint64
|
format: int64
|
||||||
minimum: 0
|
minimum: 0
|
||||||
ScriptPolicy:
|
ScriptPolicy:
|
||||||
required:
|
required:
|
||||||
@@ -1747,7 +1919,7 @@ components:
|
|||||||
properties:
|
properties:
|
||||||
ID:
|
ID:
|
||||||
type: integer
|
type: integer
|
||||||
format: uint64
|
format: int64
|
||||||
minimum: 0
|
minimum: 0
|
||||||
FromScriptHash:
|
FromScriptHash:
|
||||||
type: string
|
type: string
|
||||||
@@ -1755,11 +1927,11 @@ components:
|
|||||||
maxLength: 16
|
maxLength: 16
|
||||||
ToScriptID:
|
ToScriptID:
|
||||||
type: integer
|
type: integer
|
||||||
format: uint64
|
format: int64
|
||||||
minimum: 0
|
minimum: 0
|
||||||
Policy:
|
Policy:
|
||||||
type: integer
|
type: integer
|
||||||
format: uint32
|
format: int32
|
||||||
minimum: 0
|
minimum: 0
|
||||||
ScriptPolicyCreate:
|
ScriptPolicyCreate:
|
||||||
required:
|
required:
|
||||||
@@ -1770,15 +1942,15 @@ components:
|
|||||||
properties:
|
properties:
|
||||||
FromScriptID:
|
FromScriptID:
|
||||||
type: integer
|
type: integer
|
||||||
format: uint64
|
format: int64
|
||||||
minimum: 0
|
minimum: 0
|
||||||
ToScriptID:
|
ToScriptID:
|
||||||
type: integer
|
type: integer
|
||||||
format: uint64
|
format: int64
|
||||||
minimum: 0
|
minimum: 0
|
||||||
Policy:
|
Policy:
|
||||||
type: integer
|
type: integer
|
||||||
format: uint32
|
format: int32
|
||||||
minimum: 0
|
minimum: 0
|
||||||
ScriptPolicyUpdate:
|
ScriptPolicyUpdate:
|
||||||
required:
|
required:
|
||||||
@@ -1787,19 +1959,19 @@ components:
|
|||||||
properties:
|
properties:
|
||||||
ID:
|
ID:
|
||||||
type: integer
|
type: integer
|
||||||
format: uint64
|
format: int64
|
||||||
minimum: 0
|
minimum: 0
|
||||||
FromScriptID:
|
FromScriptID:
|
||||||
type: integer
|
type: integer
|
||||||
format: uint64
|
format: int64
|
||||||
minimum: 0
|
minimum: 0
|
||||||
ToScriptID:
|
ToScriptID:
|
||||||
type: integer
|
type: integer
|
||||||
format: uint64
|
format: int64
|
||||||
minimum: 0
|
minimum: 0
|
||||||
Policy:
|
Policy:
|
||||||
type: integer
|
type: integer
|
||||||
format: uint32
|
format: int32
|
||||||
minimum: 0
|
minimum: 0
|
||||||
Error:
|
Error:
|
||||||
description: Represents error object
|
description: Represents error object
|
||||||
@@ -1807,7 +1979,7 @@ components:
|
|||||||
properties:
|
properties:
|
||||||
code:
|
code:
|
||||||
type: integer
|
type: integer
|
||||||
format: uint64
|
format: int64
|
||||||
minimum: 0
|
minimum: 0
|
||||||
message:
|
message:
|
||||||
type: string
|
type: string
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -1396,6 +1396,201 @@ func (s *Server) handleActionMapfixTriggerSubmitRequest(args [1]string, argsEsca
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// handleActionMapfixTriggerSubmitUncheckedRequest handles actionMapfixTriggerSubmitUnchecked operation.
|
||||||
|
//
|
||||||
|
// Role Reviewer changes status from ChangesRequested -> Submitting.
|
||||||
|
//
|
||||||
|
// POST /mapfixes/{MapfixID}/status/trigger-submit-unchecked
|
||||||
|
func (s *Server) handleActionMapfixTriggerSubmitUncheckedRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) {
|
||||||
|
statusWriter := &codeRecorder{ResponseWriter: w}
|
||||||
|
w = statusWriter
|
||||||
|
otelAttrs := []attribute.KeyValue{
|
||||||
|
otelogen.OperationID("actionMapfixTriggerSubmitUnchecked"),
|
||||||
|
semconv.HTTPRequestMethodKey.String("POST"),
|
||||||
|
semconv.HTTPRouteKey.String("/mapfixes/{MapfixID}/status/trigger-submit-unchecked"),
|
||||||
|
}
|
||||||
|
|
||||||
|
// Start a span for this request.
|
||||||
|
ctx, span := s.cfg.Tracer.Start(r.Context(), ActionMapfixTriggerSubmitUncheckedOperation,
|
||||||
|
trace.WithAttributes(otelAttrs...),
|
||||||
|
serverSpanKind,
|
||||||
|
)
|
||||||
|
defer span.End()
|
||||||
|
|
||||||
|
// Add Labeler to context.
|
||||||
|
labeler := &Labeler{attrs: otelAttrs}
|
||||||
|
ctx = contextWithLabeler(ctx, labeler)
|
||||||
|
|
||||||
|
// Run stopwatch.
|
||||||
|
startTime := time.Now()
|
||||||
|
defer func() {
|
||||||
|
elapsedDuration := time.Since(startTime)
|
||||||
|
|
||||||
|
attrSet := labeler.AttributeSet()
|
||||||
|
attrs := attrSet.ToSlice()
|
||||||
|
code := statusWriter.status
|
||||||
|
if code != 0 {
|
||||||
|
codeAttr := semconv.HTTPResponseStatusCode(code)
|
||||||
|
attrs = append(attrs, codeAttr)
|
||||||
|
span.SetAttributes(codeAttr)
|
||||||
|
}
|
||||||
|
attrOpt := metric.WithAttributes(attrs...)
|
||||||
|
|
||||||
|
// Increment request counter.
|
||||||
|
s.requests.Add(ctx, 1, attrOpt)
|
||||||
|
|
||||||
|
// Use floating point division here for higher precision (instead of Millisecond method).
|
||||||
|
s.duration.Record(ctx, float64(elapsedDuration)/float64(time.Millisecond), attrOpt)
|
||||||
|
}()
|
||||||
|
|
||||||
|
var (
|
||||||
|
recordError = func(stage string, err error) {
|
||||||
|
span.RecordError(err)
|
||||||
|
|
||||||
|
// https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status
|
||||||
|
// Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges,
|
||||||
|
// unless there was another error (e.g., network error receiving the response body; or 3xx codes with
|
||||||
|
// max redirects exceeded), in which case status MUST be set to Error.
|
||||||
|
code := statusWriter.status
|
||||||
|
if code >= 100 && code < 500 {
|
||||||
|
span.SetStatus(codes.Error, stage)
|
||||||
|
}
|
||||||
|
|
||||||
|
attrSet := labeler.AttributeSet()
|
||||||
|
attrs := attrSet.ToSlice()
|
||||||
|
if code != 0 {
|
||||||
|
attrs = append(attrs, semconv.HTTPResponseStatusCode(code))
|
||||||
|
}
|
||||||
|
|
||||||
|
s.errors.Add(ctx, 1, metric.WithAttributes(attrs...))
|
||||||
|
}
|
||||||
|
err error
|
||||||
|
opErrContext = ogenerrors.OperationContext{
|
||||||
|
Name: ActionMapfixTriggerSubmitUncheckedOperation,
|
||||||
|
ID: "actionMapfixTriggerSubmitUnchecked",
|
||||||
|
}
|
||||||
|
)
|
||||||
|
{
|
||||||
|
type bitset = [1]uint8
|
||||||
|
var satisfied bitset
|
||||||
|
{
|
||||||
|
sctx, ok, err := s.securityCookieAuth(ctx, ActionMapfixTriggerSubmitUncheckedOperation, r)
|
||||||
|
if err != nil {
|
||||||
|
err = &ogenerrors.SecurityError{
|
||||||
|
OperationContext: opErrContext,
|
||||||
|
Security: "CookieAuth",
|
||||||
|
Err: err,
|
||||||
|
}
|
||||||
|
if encodeErr := encodeErrorResponse(s.h.NewError(ctx, err), w, span); encodeErr != nil {
|
||||||
|
defer recordError("Security:CookieAuth", err)
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if ok {
|
||||||
|
satisfied[0] |= 1 << 0
|
||||||
|
ctx = sctx
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ok := func() bool {
|
||||||
|
nextRequirement:
|
||||||
|
for _, requirement := range []bitset{
|
||||||
|
{0b00000001},
|
||||||
|
} {
|
||||||
|
for i, mask := range requirement {
|
||||||
|
if satisfied[i]&mask != mask {
|
||||||
|
continue nextRequirement
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}(); !ok {
|
||||||
|
err = &ogenerrors.SecurityError{
|
||||||
|
OperationContext: opErrContext,
|
||||||
|
Err: ogenerrors.ErrSecurityRequirementIsNotSatisfied,
|
||||||
|
}
|
||||||
|
if encodeErr := encodeErrorResponse(s.h.NewError(ctx, err), w, span); encodeErr != nil {
|
||||||
|
defer recordError("Security", err)
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
params, err := decodeActionMapfixTriggerSubmitUncheckedParams(args, argsEscaped, r)
|
||||||
|
if err != nil {
|
||||||
|
err = &ogenerrors.DecodeParamsError{
|
||||||
|
OperationContext: opErrContext,
|
||||||
|
Err: err,
|
||||||
|
}
|
||||||
|
defer recordError("DecodeParams", err)
|
||||||
|
s.cfg.ErrorHandler(ctx, w, r, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
var response *ActionMapfixTriggerSubmitUncheckedNoContent
|
||||||
|
if m := s.cfg.Middleware; m != nil {
|
||||||
|
mreq := middleware.Request{
|
||||||
|
Context: ctx,
|
||||||
|
OperationName: ActionMapfixTriggerSubmitUncheckedOperation,
|
||||||
|
OperationSummary: "Role Reviewer changes status from ChangesRequested -> Submitting",
|
||||||
|
OperationID: "actionMapfixTriggerSubmitUnchecked",
|
||||||
|
Body: nil,
|
||||||
|
Params: middleware.Parameters{
|
||||||
|
{
|
||||||
|
Name: "MapfixID",
|
||||||
|
In: "path",
|
||||||
|
}: params.MapfixID,
|
||||||
|
},
|
||||||
|
Raw: r,
|
||||||
|
}
|
||||||
|
|
||||||
|
type (
|
||||||
|
Request = struct{}
|
||||||
|
Params = ActionMapfixTriggerSubmitUncheckedParams
|
||||||
|
Response = *ActionMapfixTriggerSubmitUncheckedNoContent
|
||||||
|
)
|
||||||
|
response, err = middleware.HookMiddleware[
|
||||||
|
Request,
|
||||||
|
Params,
|
||||||
|
Response,
|
||||||
|
](
|
||||||
|
m,
|
||||||
|
mreq,
|
||||||
|
unpackActionMapfixTriggerSubmitUncheckedParams,
|
||||||
|
func(ctx context.Context, request Request, params Params) (response Response, err error) {
|
||||||
|
err = s.h.ActionMapfixTriggerSubmitUnchecked(ctx, params)
|
||||||
|
return response, err
|
||||||
|
},
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
err = s.h.ActionMapfixTriggerSubmitUnchecked(ctx, params)
|
||||||
|
}
|
||||||
|
if err != nil {
|
||||||
|
if errRes, ok := errors.Into[*ErrorStatusCode](err); ok {
|
||||||
|
if err := encodeErrorResponse(errRes, w, span); err != nil {
|
||||||
|
defer recordError("Internal", err)
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if errors.Is(err, ht.ErrNotImplemented) {
|
||||||
|
s.cfg.ErrorHandler(ctx, w, r, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if err := encodeErrorResponse(s.h.NewError(ctx, err), w, span); err != nil {
|
||||||
|
defer recordError("Internal", err)
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := encodeActionMapfixTriggerSubmitUncheckedResponse(response, w, span); err != nil {
|
||||||
|
defer recordError("EncodeResponse", err)
|
||||||
|
if !errors.Is(err, ht.ErrInternalServerErrorResponse) {
|
||||||
|
s.cfg.ErrorHandler(ctx, w, r, err)
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// handleActionMapfixTriggerUploadRequest handles actionMapfixTriggerUpload operation.
|
// handleActionMapfixTriggerUploadRequest handles actionMapfixTriggerUpload operation.
|
||||||
//
|
//
|
||||||
// Role Admin changes status from Validated -> Uploading.
|
// Role Admin changes status from Validated -> Uploading.
|
||||||
@@ -3347,6 +3542,201 @@ func (s *Server) handleActionSubmissionTriggerSubmitRequest(args [1]string, args
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// handleActionSubmissionTriggerSubmitUncheckedRequest handles actionSubmissionTriggerSubmitUnchecked operation.
|
||||||
|
//
|
||||||
|
// Role Reviewer changes status from ChangesRequested -> Submitting.
|
||||||
|
//
|
||||||
|
// POST /submissions/{SubmissionID}/status/trigger-submit-unchecked
|
||||||
|
func (s *Server) handleActionSubmissionTriggerSubmitUncheckedRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) {
|
||||||
|
statusWriter := &codeRecorder{ResponseWriter: w}
|
||||||
|
w = statusWriter
|
||||||
|
otelAttrs := []attribute.KeyValue{
|
||||||
|
otelogen.OperationID("actionSubmissionTriggerSubmitUnchecked"),
|
||||||
|
semconv.HTTPRequestMethodKey.String("POST"),
|
||||||
|
semconv.HTTPRouteKey.String("/submissions/{SubmissionID}/status/trigger-submit-unchecked"),
|
||||||
|
}
|
||||||
|
|
||||||
|
// Start a span for this request.
|
||||||
|
ctx, span := s.cfg.Tracer.Start(r.Context(), ActionSubmissionTriggerSubmitUncheckedOperation,
|
||||||
|
trace.WithAttributes(otelAttrs...),
|
||||||
|
serverSpanKind,
|
||||||
|
)
|
||||||
|
defer span.End()
|
||||||
|
|
||||||
|
// Add Labeler to context.
|
||||||
|
labeler := &Labeler{attrs: otelAttrs}
|
||||||
|
ctx = contextWithLabeler(ctx, labeler)
|
||||||
|
|
||||||
|
// Run stopwatch.
|
||||||
|
startTime := time.Now()
|
||||||
|
defer func() {
|
||||||
|
elapsedDuration := time.Since(startTime)
|
||||||
|
|
||||||
|
attrSet := labeler.AttributeSet()
|
||||||
|
attrs := attrSet.ToSlice()
|
||||||
|
code := statusWriter.status
|
||||||
|
if code != 0 {
|
||||||
|
codeAttr := semconv.HTTPResponseStatusCode(code)
|
||||||
|
attrs = append(attrs, codeAttr)
|
||||||
|
span.SetAttributes(codeAttr)
|
||||||
|
}
|
||||||
|
attrOpt := metric.WithAttributes(attrs...)
|
||||||
|
|
||||||
|
// Increment request counter.
|
||||||
|
s.requests.Add(ctx, 1, attrOpt)
|
||||||
|
|
||||||
|
// Use floating point division here for higher precision (instead of Millisecond method).
|
||||||
|
s.duration.Record(ctx, float64(elapsedDuration)/float64(time.Millisecond), attrOpt)
|
||||||
|
}()
|
||||||
|
|
||||||
|
var (
|
||||||
|
recordError = func(stage string, err error) {
|
||||||
|
span.RecordError(err)
|
||||||
|
|
||||||
|
// https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status
|
||||||
|
// Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges,
|
||||||
|
// unless there was another error (e.g., network error receiving the response body; or 3xx codes with
|
||||||
|
// max redirects exceeded), in which case status MUST be set to Error.
|
||||||
|
code := statusWriter.status
|
||||||
|
if code >= 100 && code < 500 {
|
||||||
|
span.SetStatus(codes.Error, stage)
|
||||||
|
}
|
||||||
|
|
||||||
|
attrSet := labeler.AttributeSet()
|
||||||
|
attrs := attrSet.ToSlice()
|
||||||
|
if code != 0 {
|
||||||
|
attrs = append(attrs, semconv.HTTPResponseStatusCode(code))
|
||||||
|
}
|
||||||
|
|
||||||
|
s.errors.Add(ctx, 1, metric.WithAttributes(attrs...))
|
||||||
|
}
|
||||||
|
err error
|
||||||
|
opErrContext = ogenerrors.OperationContext{
|
||||||
|
Name: ActionSubmissionTriggerSubmitUncheckedOperation,
|
||||||
|
ID: "actionSubmissionTriggerSubmitUnchecked",
|
||||||
|
}
|
||||||
|
)
|
||||||
|
{
|
||||||
|
type bitset = [1]uint8
|
||||||
|
var satisfied bitset
|
||||||
|
{
|
||||||
|
sctx, ok, err := s.securityCookieAuth(ctx, ActionSubmissionTriggerSubmitUncheckedOperation, r)
|
||||||
|
if err != nil {
|
||||||
|
err = &ogenerrors.SecurityError{
|
||||||
|
OperationContext: opErrContext,
|
||||||
|
Security: "CookieAuth",
|
||||||
|
Err: err,
|
||||||
|
}
|
||||||
|
if encodeErr := encodeErrorResponse(s.h.NewError(ctx, err), w, span); encodeErr != nil {
|
||||||
|
defer recordError("Security:CookieAuth", err)
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if ok {
|
||||||
|
satisfied[0] |= 1 << 0
|
||||||
|
ctx = sctx
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ok := func() bool {
|
||||||
|
nextRequirement:
|
||||||
|
for _, requirement := range []bitset{
|
||||||
|
{0b00000001},
|
||||||
|
} {
|
||||||
|
for i, mask := range requirement {
|
||||||
|
if satisfied[i]&mask != mask {
|
||||||
|
continue nextRequirement
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}(); !ok {
|
||||||
|
err = &ogenerrors.SecurityError{
|
||||||
|
OperationContext: opErrContext,
|
||||||
|
Err: ogenerrors.ErrSecurityRequirementIsNotSatisfied,
|
||||||
|
}
|
||||||
|
if encodeErr := encodeErrorResponse(s.h.NewError(ctx, err), w, span); encodeErr != nil {
|
||||||
|
defer recordError("Security", err)
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
params, err := decodeActionSubmissionTriggerSubmitUncheckedParams(args, argsEscaped, r)
|
||||||
|
if err != nil {
|
||||||
|
err = &ogenerrors.DecodeParamsError{
|
||||||
|
OperationContext: opErrContext,
|
||||||
|
Err: err,
|
||||||
|
}
|
||||||
|
defer recordError("DecodeParams", err)
|
||||||
|
s.cfg.ErrorHandler(ctx, w, r, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
var response *ActionSubmissionTriggerSubmitUncheckedNoContent
|
||||||
|
if m := s.cfg.Middleware; m != nil {
|
||||||
|
mreq := middleware.Request{
|
||||||
|
Context: ctx,
|
||||||
|
OperationName: ActionSubmissionTriggerSubmitUncheckedOperation,
|
||||||
|
OperationSummary: "Role Reviewer changes status from ChangesRequested -> Submitting",
|
||||||
|
OperationID: "actionSubmissionTriggerSubmitUnchecked",
|
||||||
|
Body: nil,
|
||||||
|
Params: middleware.Parameters{
|
||||||
|
{
|
||||||
|
Name: "SubmissionID",
|
||||||
|
In: "path",
|
||||||
|
}: params.SubmissionID,
|
||||||
|
},
|
||||||
|
Raw: r,
|
||||||
|
}
|
||||||
|
|
||||||
|
type (
|
||||||
|
Request = struct{}
|
||||||
|
Params = ActionSubmissionTriggerSubmitUncheckedParams
|
||||||
|
Response = *ActionSubmissionTriggerSubmitUncheckedNoContent
|
||||||
|
)
|
||||||
|
response, err = middleware.HookMiddleware[
|
||||||
|
Request,
|
||||||
|
Params,
|
||||||
|
Response,
|
||||||
|
](
|
||||||
|
m,
|
||||||
|
mreq,
|
||||||
|
unpackActionSubmissionTriggerSubmitUncheckedParams,
|
||||||
|
func(ctx context.Context, request Request, params Params) (response Response, err error) {
|
||||||
|
err = s.h.ActionSubmissionTriggerSubmitUnchecked(ctx, params)
|
||||||
|
return response, err
|
||||||
|
},
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
err = s.h.ActionSubmissionTriggerSubmitUnchecked(ctx, params)
|
||||||
|
}
|
||||||
|
if err != nil {
|
||||||
|
if errRes, ok := errors.Into[*ErrorStatusCode](err); ok {
|
||||||
|
if err := encodeErrorResponse(errRes, w, span); err != nil {
|
||||||
|
defer recordError("Internal", err)
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if errors.Is(err, ht.ErrNotImplemented) {
|
||||||
|
s.cfg.ErrorHandler(ctx, w, r, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if err := encodeErrorResponse(s.h.NewError(ctx, err), w, span); err != nil {
|
||||||
|
defer recordError("Internal", err)
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := encodeActionSubmissionTriggerSubmitUncheckedResponse(response, w, span); err != nil {
|
||||||
|
defer recordError("EncodeResponse", err)
|
||||||
|
if !errors.Is(err, ht.ErrInternalServerErrorResponse) {
|
||||||
|
s.cfg.ErrorHandler(ctx, w, r, err)
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// handleActionSubmissionTriggerUploadRequest handles actionSubmissionTriggerUpload operation.
|
// handleActionSubmissionTriggerUploadRequest handles actionSubmissionTriggerUpload operation.
|
||||||
//
|
//
|
||||||
// Role Admin changes status from Validated -> Uploading.
|
// Role Admin changes status from Validated -> Uploading.
|
||||||
@@ -4922,6 +5312,201 @@ func (s *Server) handleCreateSubmissionRequest(args [0]string, argsEscaped bool,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// handleCreateSubmissionAdminRequest handles createSubmissionAdmin operation.
|
||||||
|
//
|
||||||
|
// Trigger the validator to create a new submission.
|
||||||
|
//
|
||||||
|
// POST /submissions-admin
|
||||||
|
func (s *Server) handleCreateSubmissionAdminRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) {
|
||||||
|
statusWriter := &codeRecorder{ResponseWriter: w}
|
||||||
|
w = statusWriter
|
||||||
|
otelAttrs := []attribute.KeyValue{
|
||||||
|
otelogen.OperationID("createSubmissionAdmin"),
|
||||||
|
semconv.HTTPRequestMethodKey.String("POST"),
|
||||||
|
semconv.HTTPRouteKey.String("/submissions-admin"),
|
||||||
|
}
|
||||||
|
|
||||||
|
// Start a span for this request.
|
||||||
|
ctx, span := s.cfg.Tracer.Start(r.Context(), CreateSubmissionAdminOperation,
|
||||||
|
trace.WithAttributes(otelAttrs...),
|
||||||
|
serverSpanKind,
|
||||||
|
)
|
||||||
|
defer span.End()
|
||||||
|
|
||||||
|
// Add Labeler to context.
|
||||||
|
labeler := &Labeler{attrs: otelAttrs}
|
||||||
|
ctx = contextWithLabeler(ctx, labeler)
|
||||||
|
|
||||||
|
// Run stopwatch.
|
||||||
|
startTime := time.Now()
|
||||||
|
defer func() {
|
||||||
|
elapsedDuration := time.Since(startTime)
|
||||||
|
|
||||||
|
attrSet := labeler.AttributeSet()
|
||||||
|
attrs := attrSet.ToSlice()
|
||||||
|
code := statusWriter.status
|
||||||
|
if code != 0 {
|
||||||
|
codeAttr := semconv.HTTPResponseStatusCode(code)
|
||||||
|
attrs = append(attrs, codeAttr)
|
||||||
|
span.SetAttributes(codeAttr)
|
||||||
|
}
|
||||||
|
attrOpt := metric.WithAttributes(attrs...)
|
||||||
|
|
||||||
|
// Increment request counter.
|
||||||
|
s.requests.Add(ctx, 1, attrOpt)
|
||||||
|
|
||||||
|
// Use floating point division here for higher precision (instead of Millisecond method).
|
||||||
|
s.duration.Record(ctx, float64(elapsedDuration)/float64(time.Millisecond), attrOpt)
|
||||||
|
}()
|
||||||
|
|
||||||
|
var (
|
||||||
|
recordError = func(stage string, err error) {
|
||||||
|
span.RecordError(err)
|
||||||
|
|
||||||
|
// https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status
|
||||||
|
// Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges,
|
||||||
|
// unless there was another error (e.g., network error receiving the response body; or 3xx codes with
|
||||||
|
// max redirects exceeded), in which case status MUST be set to Error.
|
||||||
|
code := statusWriter.status
|
||||||
|
if code >= 100 && code < 500 {
|
||||||
|
span.SetStatus(codes.Error, stage)
|
||||||
|
}
|
||||||
|
|
||||||
|
attrSet := labeler.AttributeSet()
|
||||||
|
attrs := attrSet.ToSlice()
|
||||||
|
if code != 0 {
|
||||||
|
attrs = append(attrs, semconv.HTTPResponseStatusCode(code))
|
||||||
|
}
|
||||||
|
|
||||||
|
s.errors.Add(ctx, 1, metric.WithAttributes(attrs...))
|
||||||
|
}
|
||||||
|
err error
|
||||||
|
opErrContext = ogenerrors.OperationContext{
|
||||||
|
Name: CreateSubmissionAdminOperation,
|
||||||
|
ID: "createSubmissionAdmin",
|
||||||
|
}
|
||||||
|
)
|
||||||
|
{
|
||||||
|
type bitset = [1]uint8
|
||||||
|
var satisfied bitset
|
||||||
|
{
|
||||||
|
sctx, ok, err := s.securityCookieAuth(ctx, CreateSubmissionAdminOperation, r)
|
||||||
|
if err != nil {
|
||||||
|
err = &ogenerrors.SecurityError{
|
||||||
|
OperationContext: opErrContext,
|
||||||
|
Security: "CookieAuth",
|
||||||
|
Err: err,
|
||||||
|
}
|
||||||
|
if encodeErr := encodeErrorResponse(s.h.NewError(ctx, err), w, span); encodeErr != nil {
|
||||||
|
defer recordError("Security:CookieAuth", err)
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if ok {
|
||||||
|
satisfied[0] |= 1 << 0
|
||||||
|
ctx = sctx
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ok := func() bool {
|
||||||
|
nextRequirement:
|
||||||
|
for _, requirement := range []bitset{
|
||||||
|
{0b00000001},
|
||||||
|
} {
|
||||||
|
for i, mask := range requirement {
|
||||||
|
if satisfied[i]&mask != mask {
|
||||||
|
continue nextRequirement
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}(); !ok {
|
||||||
|
err = &ogenerrors.SecurityError{
|
||||||
|
OperationContext: opErrContext,
|
||||||
|
Err: ogenerrors.ErrSecurityRequirementIsNotSatisfied,
|
||||||
|
}
|
||||||
|
if encodeErr := encodeErrorResponse(s.h.NewError(ctx, err), w, span); encodeErr != nil {
|
||||||
|
defer recordError("Security", err)
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
request, close, err := s.decodeCreateSubmissionAdminRequest(r)
|
||||||
|
if err != nil {
|
||||||
|
err = &ogenerrors.DecodeRequestError{
|
||||||
|
OperationContext: opErrContext,
|
||||||
|
Err: err,
|
||||||
|
}
|
||||||
|
defer recordError("DecodeRequest", err)
|
||||||
|
s.cfg.ErrorHandler(ctx, w, r, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
defer func() {
|
||||||
|
if err := close(); err != nil {
|
||||||
|
recordError("CloseRequest", err)
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
|
var response *OperationID
|
||||||
|
if m := s.cfg.Middleware; m != nil {
|
||||||
|
mreq := middleware.Request{
|
||||||
|
Context: ctx,
|
||||||
|
OperationName: CreateSubmissionAdminOperation,
|
||||||
|
OperationSummary: "Trigger the validator to create a new submission",
|
||||||
|
OperationID: "createSubmissionAdmin",
|
||||||
|
Body: request,
|
||||||
|
Params: middleware.Parameters{},
|
||||||
|
Raw: r,
|
||||||
|
}
|
||||||
|
|
||||||
|
type (
|
||||||
|
Request = *SubmissionTriggerCreate
|
||||||
|
Params = struct{}
|
||||||
|
Response = *OperationID
|
||||||
|
)
|
||||||
|
response, err = middleware.HookMiddleware[
|
||||||
|
Request,
|
||||||
|
Params,
|
||||||
|
Response,
|
||||||
|
](
|
||||||
|
m,
|
||||||
|
mreq,
|
||||||
|
nil,
|
||||||
|
func(ctx context.Context, request Request, params Params) (response Response, err error) {
|
||||||
|
response, err = s.h.CreateSubmissionAdmin(ctx, request)
|
||||||
|
return response, err
|
||||||
|
},
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
response, err = s.h.CreateSubmissionAdmin(ctx, request)
|
||||||
|
}
|
||||||
|
if err != nil {
|
||||||
|
if errRes, ok := errors.Into[*ErrorStatusCode](err); ok {
|
||||||
|
if err := encodeErrorResponse(errRes, w, span); err != nil {
|
||||||
|
defer recordError("Internal", err)
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if errors.Is(err, ht.ErrNotImplemented) {
|
||||||
|
s.cfg.ErrorHandler(ctx, w, r, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if err := encodeErrorResponse(s.h.NewError(ctx, err), w, span); err != nil {
|
||||||
|
defer recordError("Internal", err)
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := encodeCreateSubmissionAdminResponse(response, w, span); err != nil {
|
||||||
|
defer recordError("EncodeResponse", err)
|
||||||
|
if !errors.Is(err, ht.ErrInternalServerErrorResponse) {
|
||||||
|
s.cfg.ErrorHandler(ctx, w, r, err)
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// handleCreateSubmissionAuditCommentRequest handles createSubmissionAuditComment operation.
|
// handleCreateSubmissionAuditCommentRequest handles createSubmissionAuditComment operation.
|
||||||
//
|
//
|
||||||
// Post a comment to the audit log.
|
// Post a comment to the audit log.
|
||||||
@@ -5671,6 +6256,201 @@ func (s *Server) handleGetMapRequest(args [1]string, argsEscaped bool, w http.Re
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// handleGetMapAssetLocationRequest handles getMapAssetLocation operation.
|
||||||
|
//
|
||||||
|
// Get location of asset.
|
||||||
|
//
|
||||||
|
// GET /maps/{MapID}/location
|
||||||
|
func (s *Server) handleGetMapAssetLocationRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) {
|
||||||
|
statusWriter := &codeRecorder{ResponseWriter: w}
|
||||||
|
w = statusWriter
|
||||||
|
otelAttrs := []attribute.KeyValue{
|
||||||
|
otelogen.OperationID("getMapAssetLocation"),
|
||||||
|
semconv.HTTPRequestMethodKey.String("GET"),
|
||||||
|
semconv.HTTPRouteKey.String("/maps/{MapID}/location"),
|
||||||
|
}
|
||||||
|
|
||||||
|
// Start a span for this request.
|
||||||
|
ctx, span := s.cfg.Tracer.Start(r.Context(), GetMapAssetLocationOperation,
|
||||||
|
trace.WithAttributes(otelAttrs...),
|
||||||
|
serverSpanKind,
|
||||||
|
)
|
||||||
|
defer span.End()
|
||||||
|
|
||||||
|
// Add Labeler to context.
|
||||||
|
labeler := &Labeler{attrs: otelAttrs}
|
||||||
|
ctx = contextWithLabeler(ctx, labeler)
|
||||||
|
|
||||||
|
// Run stopwatch.
|
||||||
|
startTime := time.Now()
|
||||||
|
defer func() {
|
||||||
|
elapsedDuration := time.Since(startTime)
|
||||||
|
|
||||||
|
attrSet := labeler.AttributeSet()
|
||||||
|
attrs := attrSet.ToSlice()
|
||||||
|
code := statusWriter.status
|
||||||
|
if code != 0 {
|
||||||
|
codeAttr := semconv.HTTPResponseStatusCode(code)
|
||||||
|
attrs = append(attrs, codeAttr)
|
||||||
|
span.SetAttributes(codeAttr)
|
||||||
|
}
|
||||||
|
attrOpt := metric.WithAttributes(attrs...)
|
||||||
|
|
||||||
|
// Increment request counter.
|
||||||
|
s.requests.Add(ctx, 1, attrOpt)
|
||||||
|
|
||||||
|
// Use floating point division here for higher precision (instead of Millisecond method).
|
||||||
|
s.duration.Record(ctx, float64(elapsedDuration)/float64(time.Millisecond), attrOpt)
|
||||||
|
}()
|
||||||
|
|
||||||
|
var (
|
||||||
|
recordError = func(stage string, err error) {
|
||||||
|
span.RecordError(err)
|
||||||
|
|
||||||
|
// https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status
|
||||||
|
// Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges,
|
||||||
|
// unless there was another error (e.g., network error receiving the response body; or 3xx codes with
|
||||||
|
// max redirects exceeded), in which case status MUST be set to Error.
|
||||||
|
code := statusWriter.status
|
||||||
|
if code >= 100 && code < 500 {
|
||||||
|
span.SetStatus(codes.Error, stage)
|
||||||
|
}
|
||||||
|
|
||||||
|
attrSet := labeler.AttributeSet()
|
||||||
|
attrs := attrSet.ToSlice()
|
||||||
|
if code != 0 {
|
||||||
|
attrs = append(attrs, semconv.HTTPResponseStatusCode(code))
|
||||||
|
}
|
||||||
|
|
||||||
|
s.errors.Add(ctx, 1, metric.WithAttributes(attrs...))
|
||||||
|
}
|
||||||
|
err error
|
||||||
|
opErrContext = ogenerrors.OperationContext{
|
||||||
|
Name: GetMapAssetLocationOperation,
|
||||||
|
ID: "getMapAssetLocation",
|
||||||
|
}
|
||||||
|
)
|
||||||
|
{
|
||||||
|
type bitset = [1]uint8
|
||||||
|
var satisfied bitset
|
||||||
|
{
|
||||||
|
sctx, ok, err := s.securityCookieAuth(ctx, GetMapAssetLocationOperation, r)
|
||||||
|
if err != nil {
|
||||||
|
err = &ogenerrors.SecurityError{
|
||||||
|
OperationContext: opErrContext,
|
||||||
|
Security: "CookieAuth",
|
||||||
|
Err: err,
|
||||||
|
}
|
||||||
|
if encodeErr := encodeErrorResponse(s.h.NewError(ctx, err), w, span); encodeErr != nil {
|
||||||
|
defer recordError("Security:CookieAuth", err)
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if ok {
|
||||||
|
satisfied[0] |= 1 << 0
|
||||||
|
ctx = sctx
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ok := func() bool {
|
||||||
|
nextRequirement:
|
||||||
|
for _, requirement := range []bitset{
|
||||||
|
{0b00000001},
|
||||||
|
} {
|
||||||
|
for i, mask := range requirement {
|
||||||
|
if satisfied[i]&mask != mask {
|
||||||
|
continue nextRequirement
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}(); !ok {
|
||||||
|
err = &ogenerrors.SecurityError{
|
||||||
|
OperationContext: opErrContext,
|
||||||
|
Err: ogenerrors.ErrSecurityRequirementIsNotSatisfied,
|
||||||
|
}
|
||||||
|
if encodeErr := encodeErrorResponse(s.h.NewError(ctx, err), w, span); encodeErr != nil {
|
||||||
|
defer recordError("Security", err)
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
params, err := decodeGetMapAssetLocationParams(args, argsEscaped, r)
|
||||||
|
if err != nil {
|
||||||
|
err = &ogenerrors.DecodeParamsError{
|
||||||
|
OperationContext: opErrContext,
|
||||||
|
Err: err,
|
||||||
|
}
|
||||||
|
defer recordError("DecodeParams", err)
|
||||||
|
s.cfg.ErrorHandler(ctx, w, r, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
var response GetMapAssetLocationOK
|
||||||
|
if m := s.cfg.Middleware; m != nil {
|
||||||
|
mreq := middleware.Request{
|
||||||
|
Context: ctx,
|
||||||
|
OperationName: GetMapAssetLocationOperation,
|
||||||
|
OperationSummary: "Get location of asset",
|
||||||
|
OperationID: "getMapAssetLocation",
|
||||||
|
Body: nil,
|
||||||
|
Params: middleware.Parameters{
|
||||||
|
{
|
||||||
|
Name: "MapID",
|
||||||
|
In: "path",
|
||||||
|
}: params.MapID,
|
||||||
|
},
|
||||||
|
Raw: r,
|
||||||
|
}
|
||||||
|
|
||||||
|
type (
|
||||||
|
Request = struct{}
|
||||||
|
Params = GetMapAssetLocationParams
|
||||||
|
Response = GetMapAssetLocationOK
|
||||||
|
)
|
||||||
|
response, err = middleware.HookMiddleware[
|
||||||
|
Request,
|
||||||
|
Params,
|
||||||
|
Response,
|
||||||
|
](
|
||||||
|
m,
|
||||||
|
mreq,
|
||||||
|
unpackGetMapAssetLocationParams,
|
||||||
|
func(ctx context.Context, request Request, params Params) (response Response, err error) {
|
||||||
|
response, err = s.h.GetMapAssetLocation(ctx, params)
|
||||||
|
return response, err
|
||||||
|
},
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
response, err = s.h.GetMapAssetLocation(ctx, params)
|
||||||
|
}
|
||||||
|
if err != nil {
|
||||||
|
if errRes, ok := errors.Into[*ErrorStatusCode](err); ok {
|
||||||
|
if err := encodeErrorResponse(errRes, w, span); err != nil {
|
||||||
|
defer recordError("Internal", err)
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if errors.Is(err, ht.ErrNotImplemented) {
|
||||||
|
s.cfg.ErrorHandler(ctx, w, r, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if err := encodeErrorResponse(s.h.NewError(ctx, err), w, span); err != nil {
|
||||||
|
defer recordError("Internal", err)
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := encodeGetMapAssetLocationResponse(response, w, span); err != nil {
|
||||||
|
defer recordError("EncodeResponse", err)
|
||||||
|
if !errors.Is(err, ht.ErrInternalServerErrorResponse) {
|
||||||
|
s.cfg.ErrorHandler(ctx, w, r, err)
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// handleGetMapfixRequest handles getMapfix operation.
|
// handleGetMapfixRequest handles getMapfix operation.
|
||||||
//
|
//
|
||||||
// Retrieve map with ID.
|
// Retrieve map with ID.
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -6,55 +6,59 @@ 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"
|
ActionMapfixResetSubmittingOperation OperationName = "ActionMapfixResetSubmitting"
|
||||||
ActionMapfixRetryValidateOperation OperationName = "ActionMapfixRetryValidate"
|
ActionMapfixRetryValidateOperation OperationName = "ActionMapfixRetryValidate"
|
||||||
ActionMapfixRevokeOperation OperationName = "ActionMapfixRevoke"
|
ActionMapfixRevokeOperation OperationName = "ActionMapfixRevoke"
|
||||||
ActionMapfixTriggerSubmitOperation OperationName = "ActionMapfixTriggerSubmit"
|
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"
|
||||||
ActionSubmissionResetSubmittingOperation OperationName = "ActionSubmissionResetSubmitting"
|
ActionSubmissionRequestChangesOperation OperationName = "ActionSubmissionRequestChanges"
|
||||||
ActionSubmissionRetryValidateOperation OperationName = "ActionSubmissionRetryValidate"
|
ActionSubmissionResetSubmittingOperation OperationName = "ActionSubmissionResetSubmitting"
|
||||||
ActionSubmissionRevokeOperation OperationName = "ActionSubmissionRevoke"
|
ActionSubmissionRetryValidateOperation OperationName = "ActionSubmissionRetryValidate"
|
||||||
ActionSubmissionTriggerSubmitOperation OperationName = "ActionSubmissionTriggerSubmit"
|
ActionSubmissionRevokeOperation OperationName = "ActionSubmissionRevoke"
|
||||||
ActionSubmissionTriggerUploadOperation OperationName = "ActionSubmissionTriggerUpload"
|
ActionSubmissionTriggerSubmitOperation OperationName = "ActionSubmissionTriggerSubmit"
|
||||||
ActionSubmissionTriggerValidateOperation OperationName = "ActionSubmissionTriggerValidate"
|
ActionSubmissionTriggerSubmitUncheckedOperation OperationName = "ActionSubmissionTriggerSubmitUnchecked"
|
||||||
ActionSubmissionValidatedOperation OperationName = "ActionSubmissionValidated"
|
ActionSubmissionTriggerUploadOperation OperationName = "ActionSubmissionTriggerUpload"
|
||||||
CreateMapfixOperation OperationName = "CreateMapfix"
|
ActionSubmissionTriggerValidateOperation OperationName = "ActionSubmissionTriggerValidate"
|
||||||
CreateMapfixAuditCommentOperation OperationName = "CreateMapfixAuditComment"
|
ActionSubmissionValidatedOperation OperationName = "ActionSubmissionValidated"
|
||||||
CreateScriptOperation OperationName = "CreateScript"
|
CreateMapfixOperation OperationName = "CreateMapfix"
|
||||||
CreateScriptPolicyOperation OperationName = "CreateScriptPolicy"
|
CreateMapfixAuditCommentOperation OperationName = "CreateMapfixAuditComment"
|
||||||
CreateSubmissionOperation OperationName = "CreateSubmission"
|
CreateScriptOperation OperationName = "CreateScript"
|
||||||
CreateSubmissionAuditCommentOperation OperationName = "CreateSubmissionAuditComment"
|
CreateScriptPolicyOperation OperationName = "CreateScriptPolicy"
|
||||||
DeleteScriptOperation OperationName = "DeleteScript"
|
CreateSubmissionOperation OperationName = "CreateSubmission"
|
||||||
DeleteScriptPolicyOperation OperationName = "DeleteScriptPolicy"
|
CreateSubmissionAdminOperation OperationName = "CreateSubmissionAdmin"
|
||||||
GetMapOperation OperationName = "GetMap"
|
CreateSubmissionAuditCommentOperation OperationName = "CreateSubmissionAuditComment"
|
||||||
GetMapfixOperation OperationName = "GetMapfix"
|
DeleteScriptOperation OperationName = "DeleteScript"
|
||||||
GetOperationOperation OperationName = "GetOperation"
|
DeleteScriptPolicyOperation OperationName = "DeleteScriptPolicy"
|
||||||
GetScriptOperation OperationName = "GetScript"
|
GetMapOperation OperationName = "GetMap"
|
||||||
GetScriptPolicyOperation OperationName = "GetScriptPolicy"
|
GetMapAssetLocationOperation OperationName = "GetMapAssetLocation"
|
||||||
GetSubmissionOperation OperationName = "GetSubmission"
|
GetMapfixOperation OperationName = "GetMapfix"
|
||||||
ListMapfixAuditEventsOperation OperationName = "ListMapfixAuditEvents"
|
GetOperationOperation OperationName = "GetOperation"
|
||||||
ListMapfixesOperation OperationName = "ListMapfixes"
|
GetScriptOperation OperationName = "GetScript"
|
||||||
ListMapsOperation OperationName = "ListMaps"
|
GetScriptPolicyOperation OperationName = "GetScriptPolicy"
|
||||||
ListScriptPolicyOperation OperationName = "ListScriptPolicy"
|
GetSubmissionOperation OperationName = "GetSubmission"
|
||||||
ListScriptsOperation OperationName = "ListScripts"
|
ListMapfixAuditEventsOperation OperationName = "ListMapfixAuditEvents"
|
||||||
ListSubmissionAuditEventsOperation OperationName = "ListSubmissionAuditEvents"
|
ListMapfixesOperation OperationName = "ListMapfixes"
|
||||||
ListSubmissionsOperation OperationName = "ListSubmissions"
|
ListMapsOperation OperationName = "ListMaps"
|
||||||
ReleaseSubmissionsOperation OperationName = "ReleaseSubmissions"
|
ListScriptPolicyOperation OperationName = "ListScriptPolicy"
|
||||||
SessionRolesOperation OperationName = "SessionRoles"
|
ListScriptsOperation OperationName = "ListScripts"
|
||||||
SessionUserOperation OperationName = "SessionUser"
|
ListSubmissionAuditEventsOperation OperationName = "ListSubmissionAuditEvents"
|
||||||
SessionValidateOperation OperationName = "SessionValidate"
|
ListSubmissionsOperation OperationName = "ListSubmissions"
|
||||||
SetMapfixCompletedOperation OperationName = "SetMapfixCompleted"
|
ReleaseSubmissionsOperation OperationName = "ReleaseSubmissions"
|
||||||
SetSubmissionCompletedOperation OperationName = "SetSubmissionCompleted"
|
SessionRolesOperation OperationName = "SessionRoles"
|
||||||
UpdateMapfixModelOperation OperationName = "UpdateMapfixModel"
|
SessionUserOperation OperationName = "SessionUser"
|
||||||
UpdateScriptOperation OperationName = "UpdateScript"
|
SessionValidateOperation OperationName = "SessionValidate"
|
||||||
UpdateScriptPolicyOperation OperationName = "UpdateScriptPolicy"
|
SetMapfixCompletedOperation OperationName = "SetMapfixCompleted"
|
||||||
UpdateSubmissionModelOperation OperationName = "UpdateSubmissionModel"
|
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
@@ -10,7 +10,6 @@ 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"
|
||||||
@@ -27,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 = multierr.Append(merr, c())
|
merr = errors.Join(merr, c())
|
||||||
}
|
}
|
||||||
return merr
|
return merr
|
||||||
}
|
}
|
||||||
defer func() {
|
defer func() {
|
||||||
if rerr != nil {
|
if rerr != nil {
|
||||||
rerr = multierr.Append(rerr, close())
|
rerr = errors.Join(rerr, close())
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
ct, _, err := mime.ParseMediaType(r.Header.Get("Content-Type"))
|
ct, _, err := mime.ParseMediaType(r.Header.Get("Content-Type"))
|
||||||
@@ -98,13 +97,13 @@ func (s *Server) decodeCreateMapfixAuditCommentRequest(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 = multierr.Append(merr, c())
|
merr = errors.Join(merr, c())
|
||||||
}
|
}
|
||||||
return merr
|
return merr
|
||||||
}
|
}
|
||||||
defer func() {
|
defer func() {
|
||||||
if rerr != nil {
|
if rerr != nil {
|
||||||
rerr = multierr.Append(rerr, close())
|
rerr = errors.Join(rerr, close())
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
ct, _, err := mime.ParseMediaType(r.Header.Get("Content-Type"))
|
ct, _, err := mime.ParseMediaType(r.Header.Get("Content-Type"))
|
||||||
@@ -132,13 +131,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 = multierr.Append(merr, c())
|
merr = errors.Join(merr, c())
|
||||||
}
|
}
|
||||||
return merr
|
return merr
|
||||||
}
|
}
|
||||||
defer func() {
|
defer func() {
|
||||||
if rerr != nil {
|
if rerr != nil {
|
||||||
rerr = multierr.Append(rerr, close())
|
rerr = errors.Join(rerr, close())
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
ct, _, err := mime.ParseMediaType(r.Header.Get("Content-Type"))
|
ct, _, err := mime.ParseMediaType(r.Header.Get("Content-Type"))
|
||||||
@@ -203,13 +202,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 = multierr.Append(merr, c())
|
merr = errors.Join(merr, c())
|
||||||
}
|
}
|
||||||
return merr
|
return merr
|
||||||
}
|
}
|
||||||
defer func() {
|
defer func() {
|
||||||
if rerr != nil {
|
if rerr != nil {
|
||||||
rerr = multierr.Append(rerr, close())
|
rerr = errors.Join(rerr, close())
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
ct, _, err := mime.ParseMediaType(r.Header.Get("Content-Type"))
|
ct, _, err := mime.ParseMediaType(r.Header.Get("Content-Type"))
|
||||||
@@ -274,13 +273,84 @@ 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 = multierr.Append(merr, c())
|
merr = errors.Join(merr, c())
|
||||||
}
|
}
|
||||||
return merr
|
return merr
|
||||||
}
|
}
|
||||||
defer func() {
|
defer func() {
|
||||||
if rerr != nil {
|
if rerr != nil {
|
||||||
rerr = multierr.Append(rerr, close())
|
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) 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"))
|
ct, _, err := mime.ParseMediaType(r.Header.Get("Content-Type"))
|
||||||
@@ -345,13 +415,13 @@ func (s *Server) decodeCreateSubmissionAuditCommentRequest(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 = multierr.Append(merr, c())
|
merr = errors.Join(merr, c())
|
||||||
}
|
}
|
||||||
return merr
|
return merr
|
||||||
}
|
}
|
||||||
defer func() {
|
defer func() {
|
||||||
if rerr != nil {
|
if rerr != nil {
|
||||||
rerr = multierr.Append(rerr, close())
|
rerr = errors.Join(rerr, close())
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
ct, _, err := mime.ParseMediaType(r.Header.Get("Content-Type"))
|
ct, _, err := mime.ParseMediaType(r.Header.Get("Content-Type"))
|
||||||
@@ -379,13 +449,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 = multierr.Append(merr, c())
|
merr = errors.Join(merr, c())
|
||||||
}
|
}
|
||||||
return merr
|
return merr
|
||||||
}
|
}
|
||||||
defer func() {
|
defer func() {
|
||||||
if rerr != nil {
|
if rerr != nil {
|
||||||
rerr = multierr.Append(rerr, close())
|
rerr = errors.Join(rerr, close())
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
ct, _, err := mime.ParseMediaType(r.Header.Get("Content-Type"))
|
ct, _, err := mime.ParseMediaType(r.Header.Get("Content-Type"))
|
||||||
@@ -483,13 +553,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 = multierr.Append(merr, c())
|
merr = errors.Join(merr, c())
|
||||||
}
|
}
|
||||||
return merr
|
return merr
|
||||||
}
|
}
|
||||||
defer func() {
|
defer func() {
|
||||||
if rerr != nil {
|
if rerr != nil {
|
||||||
rerr = multierr.Append(rerr, close())
|
rerr = errors.Join(rerr, close())
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
ct, _, err := mime.ParseMediaType(r.Header.Get("Content-Type"))
|
ct, _, err := mime.ParseMediaType(r.Header.Get("Content-Type"))
|
||||||
@@ -554,13 +624,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 = multierr.Append(merr, c())
|
merr = errors.Join(merr, c())
|
||||||
}
|
}
|
||||||
return merr
|
return merr
|
||||||
}
|
}
|
||||||
defer func() {
|
defer func() {
|
||||||
if rerr != nil {
|
if rerr != nil {
|
||||||
rerr = multierr.Append(rerr, close())
|
rerr = errors.Join(rerr, close())
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
ct, _, err := mime.ParseMediaType(r.Header.Get("Content-Type"))
|
ct, _, err := mime.ParseMediaType(r.Header.Get("Content-Type"))
|
||||||
|
|||||||
@@ -77,6 +77,20 @@ 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(
|
func encodeCreateSubmissionAuditCommentRequest(
|
||||||
req CreateSubmissionAuditCommentReq,
|
req CreateSubmissionAuditCommentReq,
|
||||||
r *http.Request,
|
r *http.Request,
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
package api
|
package api
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"bytes"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"mime"
|
"mime"
|
||||||
@@ -435,6 +436,66 @@ func decodeActionMapfixTriggerSubmitResponse(resp *http.Response) (res *ActionMa
|
|||||||
return res, errors.Wrap(defRes, "error")
|
return res, errors.Wrap(defRes, "error")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func decodeActionMapfixTriggerSubmitUncheckedResponse(resp *http.Response) (res *ActionMapfixTriggerSubmitUncheckedNoContent, _ error) {
|
||||||
|
switch resp.StatusCode {
|
||||||
|
case 204:
|
||||||
|
// Code 204.
|
||||||
|
return &ActionMapfixTriggerSubmitUncheckedNoContent{}, 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 decodeActionMapfixTriggerUploadResponse(resp *http.Response) (res *ActionMapfixTriggerUploadNoContent, _ error) {
|
func decodeActionMapfixTriggerUploadResponse(resp *http.Response) (res *ActionMapfixTriggerUploadNoContent, _ error) {
|
||||||
switch resp.StatusCode {
|
switch resp.StatusCode {
|
||||||
case 204:
|
case 204:
|
||||||
@@ -1035,6 +1096,66 @@ func decodeActionSubmissionTriggerSubmitResponse(resp *http.Response) (res *Acti
|
|||||||
return res, errors.Wrap(defRes, "error")
|
return res, errors.Wrap(defRes, "error")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func decodeActionSubmissionTriggerSubmitUncheckedResponse(resp *http.Response) (res *ActionSubmissionTriggerSubmitUncheckedNoContent, _ error) {
|
||||||
|
switch resp.StatusCode {
|
||||||
|
case 204:
|
||||||
|
// Code 204.
|
||||||
|
return &ActionSubmissionTriggerSubmitUncheckedNoContent{}, 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 decodeActionSubmissionTriggerUploadResponse(resp *http.Response) (res *ActionSubmissionTriggerUploadNoContent, _ error) {
|
func decodeActionSubmissionTriggerUploadResponse(resp *http.Response) (res *ActionSubmissionTriggerUploadNoContent, _ error) {
|
||||||
switch resp.StatusCode {
|
switch resp.StatusCode {
|
||||||
case 204:
|
case 204:
|
||||||
@@ -1679,6 +1800,107 @@ func decodeCreateSubmissionResponse(resp *http.Response) (res *OperationID, _ er
|
|||||||
return res, errors.Wrap(defRes, "error")
|
return res, errors.Wrap(defRes, "error")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func decodeCreateSubmissionAdminResponse(resp *http.Response) (res *OperationID, _ error) {
|
||||||
|
switch resp.StatusCode {
|
||||||
|
case 201:
|
||||||
|
// Code 201.
|
||||||
|
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 OperationID
|
||||||
|
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 &response, nil
|
||||||
|
default:
|
||||||
|
return res, validate.InvalidContentType(ct)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 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 decodeCreateSubmissionAuditCommentResponse(resp *http.Response) (res *CreateSubmissionAuditCommentNoContent, _ error) {
|
func decodeCreateSubmissionAuditCommentResponse(resp *http.Response) (res *CreateSubmissionAuditCommentNoContent, _ error) {
|
||||||
switch resp.StatusCode {
|
switch resp.StatusCode {
|
||||||
case 204:
|
case 204:
|
||||||
@@ -1960,6 +2182,82 @@ func decodeGetMapResponse(resp *http.Response) (res *Map, _ error) {
|
|||||||
return res, errors.Wrap(defRes, "error")
|
return res, errors.Wrap(defRes, "error")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func decodeGetMapAssetLocationResponse(resp *http.Response) (res GetMapAssetLocationOK, _ error) {
|
||||||
|
switch resp.StatusCode {
|
||||||
|
case 200:
|
||||||
|
// Code 200.
|
||||||
|
ct, _, err := mime.ParseMediaType(resp.Header.Get("Content-Type"))
|
||||||
|
if err != nil {
|
||||||
|
return res, errors.Wrap(err, "parse media type")
|
||||||
|
}
|
||||||
|
switch {
|
||||||
|
case ct == "text/plain":
|
||||||
|
reader := resp.Body
|
||||||
|
b, err := io.ReadAll(reader)
|
||||||
|
if err != nil {
|
||||||
|
return res, err
|
||||||
|
}
|
||||||
|
|
||||||
|
response := GetMapAssetLocationOK{Data: bytes.NewReader(b)}
|
||||||
|
return response, nil
|
||||||
|
default:
|
||||||
|
return res, validate.InvalidContentType(ct)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 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 decodeGetMapfixResponse(resp *http.Response) (res *Mapfix, _ error) {
|
func decodeGetMapfixResponse(resp *http.Response) (res *Mapfix, _ error) {
|
||||||
switch resp.StatusCode {
|
switch resp.StatusCode {
|
||||||
case 200:
|
case 200:
|
||||||
@@ -2511,6 +2809,23 @@ func decodeListMapfixAuditEventsResponse(resp *http.Response) (res []AuditEvent,
|
|||||||
if response == nil {
|
if response == nil {
|
||||||
return errors.New("nil is invalid value")
|
return errors.New("nil is invalid value")
|
||||||
}
|
}
|
||||||
|
var failures []validate.FieldError
|
||||||
|
for i, elem := range response {
|
||||||
|
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 res, errors.Wrap(err, "validate")
|
return res, errors.Wrap(err, "validate")
|
||||||
@@ -3099,6 +3414,23 @@ func decodeListSubmissionAuditEventsResponse(resp *http.Response) (res []AuditEv
|
|||||||
if response == nil {
|
if response == nil {
|
||||||
return errors.New("nil is invalid value")
|
return errors.New("nil is invalid value")
|
||||||
}
|
}
|
||||||
|
var failures []validate.FieldError
|
||||||
|
for i, elem := range response {
|
||||||
|
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 res, errors.Wrap(err, "validate")
|
return res, errors.Wrap(err, "validate")
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
package api
|
package api
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
"github.com/go-faster/errors"
|
"github.com/go-faster/errors"
|
||||||
@@ -62,6 +63,13 @@ func encodeActionMapfixTriggerSubmitResponse(response *ActionMapfixTriggerSubmit
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func encodeActionMapfixTriggerSubmitUncheckedResponse(response *ActionMapfixTriggerSubmitUncheckedNoContent, w http.ResponseWriter, span trace.Span) error {
|
||||||
|
w.WriteHeader(204)
|
||||||
|
span.SetStatus(codes.Ok, http.StatusText(204))
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
func encodeActionMapfixTriggerUploadResponse(response *ActionMapfixTriggerUploadNoContent, w http.ResponseWriter, span trace.Span) error {
|
func encodeActionMapfixTriggerUploadResponse(response *ActionMapfixTriggerUploadNoContent, 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))
|
||||||
@@ -132,6 +140,13 @@ func encodeActionSubmissionTriggerSubmitResponse(response *ActionSubmissionTrigg
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func encodeActionSubmissionTriggerSubmitUncheckedResponse(response *ActionSubmissionTriggerSubmitUncheckedNoContent, w http.ResponseWriter, span trace.Span) error {
|
||||||
|
w.WriteHeader(204)
|
||||||
|
span.SetStatus(codes.Ok, http.StatusText(204))
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
func encodeActionSubmissionTriggerUploadResponse(response *ActionSubmissionTriggerUploadNoContent, w http.ResponseWriter, span trace.Span) error {
|
func encodeActionSubmissionTriggerUploadResponse(response *ActionSubmissionTriggerUploadNoContent, 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))
|
||||||
@@ -216,6 +231,20 @@ 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 {
|
func encodeCreateSubmissionAuditCommentResponse(response *CreateSubmissionAuditCommentNoContent, 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))
|
||||||
@@ -251,6 +280,22 @@ 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)
|
||||||
|
|||||||
@@ -453,7 +453,6 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if len(elem) == 0 {
|
if len(elem) == 0 {
|
||||||
// Leaf node.
|
|
||||||
switch r.Method {
|
switch r.Method {
|
||||||
case "POST":
|
case "POST":
|
||||||
s.handleActionMapfixTriggerSubmitRequest([1]string{
|
s.handleActionMapfixTriggerSubmitRequest([1]string{
|
||||||
@@ -465,6 +464,30 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
|||||||
|
|
||||||
return
|
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"
|
||||||
|
|
||||||
@@ -548,16 +571,15 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Param: "MapID"
|
// Param: "MapID"
|
||||||
// Leaf parameter, slashes are prohibited
|
// Match until "/"
|
||||||
idx := strings.IndexByte(elem, '/')
|
idx := strings.IndexByte(elem, '/')
|
||||||
if idx >= 0 {
|
if idx < 0 {
|
||||||
break
|
idx = len(elem)
|
||||||
}
|
}
|
||||||
args[0] = elem
|
args[0] = elem[:idx]
|
||||||
elem = ""
|
elem = elem[idx:]
|
||||||
|
|
||||||
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{
|
||||||
@@ -569,6 +591,30 @@ 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
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -870,6 +916,26 @@ 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] == "/" {
|
||||||
@@ -1229,7 +1295,6 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if len(elem) == 0 {
|
if len(elem) == 0 {
|
||||||
// Leaf node.
|
|
||||||
switch r.Method {
|
switch r.Method {
|
||||||
case "POST":
|
case "POST":
|
||||||
s.handleActionSubmissionTriggerSubmitRequest([1]string{
|
s.handleActionSubmissionTriggerSubmitRequest([1]string{
|
||||||
@@ -1241,6 +1306,30 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
|||||||
|
|
||||||
return
|
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"
|
||||||
|
|
||||||
@@ -1818,7 +1907,6 @@ func (s *Server) FindPath(method string, u *url.URL) (r Route, _ bool) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if len(elem) == 0 {
|
if len(elem) == 0 {
|
||||||
// Leaf node.
|
|
||||||
switch method {
|
switch method {
|
||||||
case "POST":
|
case "POST":
|
||||||
r.name = ActionMapfixTriggerSubmitOperation
|
r.name = ActionMapfixTriggerSubmitOperation
|
||||||
@@ -1832,6 +1920,32 @@ func (s *Server) FindPath(method string, u *url.URL) (r Route, _ bool) {
|
|||||||
return
|
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"
|
||||||
|
|
||||||
@@ -1923,16 +2037,15 @@ func (s *Server) FindPath(method string, u *url.URL) (r Route, _ bool) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Param: "MapID"
|
// Param: "MapID"
|
||||||
// Leaf parameter, slashes are prohibited
|
// Match until "/"
|
||||||
idx := strings.IndexByte(elem, '/')
|
idx := strings.IndexByte(elem, '/')
|
||||||
if idx >= 0 {
|
if idx < 0 {
|
||||||
break
|
idx = len(elem)
|
||||||
}
|
}
|
||||||
args[0] = elem
|
args[0] = elem[:idx]
|
||||||
elem = ""
|
elem = elem[idx:]
|
||||||
|
|
||||||
if len(elem) == 0 {
|
if len(elem) == 0 {
|
||||||
// Leaf node.
|
|
||||||
switch method {
|
switch method {
|
||||||
case "GET":
|
case "GET":
|
||||||
r.name = GetMapOperation
|
r.name = GetMapOperation
|
||||||
@@ -1946,6 +2059,32 @@ 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
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2315,6 +2454,30 @@ 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] == "/" {
|
||||||
@@ -2698,7 +2861,6 @@ func (s *Server) FindPath(method string, u *url.URL) (r Route, _ bool) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if len(elem) == 0 {
|
if len(elem) == 0 {
|
||||||
// Leaf node.
|
|
||||||
switch method {
|
switch method {
|
||||||
case "POST":
|
case "POST":
|
||||||
r.name = ActionSubmissionTriggerSubmitOperation
|
r.name = ActionSubmissionTriggerSubmitOperation
|
||||||
@@ -2712,6 +2874,32 @@ func (s *Server) FindPath(method string, u *url.URL) (r Route, _ bool) {
|
|||||||
return
|
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"
|
||||||
|
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -33,6 +33,52 @@ 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"
|
||||||
@@ -46,6 +92,7 @@ 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
|
||||||
|
|||||||
@@ -51,6 +51,12 @@ type Handler interface {
|
|||||||
//
|
//
|
||||||
// POST /mapfixes/{MapfixID}/status/trigger-submit
|
// POST /mapfixes/{MapfixID}/status/trigger-submit
|
||||||
ActionMapfixTriggerSubmit(ctx context.Context, params ActionMapfixTriggerSubmitParams) error
|
ActionMapfixTriggerSubmit(ctx context.Context, params ActionMapfixTriggerSubmitParams) 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.
|
||||||
@@ -112,6 +118,12 @@ type Handler interface {
|
|||||||
//
|
//
|
||||||
// POST /submissions/{SubmissionID}/status/trigger-submit
|
// POST /submissions/{SubmissionID}/status/trigger-submit
|
||||||
ActionSubmissionTriggerSubmit(ctx context.Context, params ActionSubmissionTriggerSubmitParams) error
|
ActionSubmissionTriggerSubmit(ctx context.Context, params ActionSubmissionTriggerSubmitParams) 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.
|
||||||
@@ -160,6 +172,12 @@ 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.
|
// CreateSubmissionAuditComment implements createSubmissionAuditComment operation.
|
||||||
//
|
//
|
||||||
// Post a comment to the audit log.
|
// Post a comment to the audit log.
|
||||||
@@ -184,6 +202,12 @@ 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.
|
||||||
|
|||||||
@@ -77,6 +77,15 @@ func (UnimplementedHandler) ActionMapfixTriggerSubmit(ctx context.Context, param
|
|||||||
return ht.ErrNotImplemented
|
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
|
||||||
|
}
|
||||||
|
|
||||||
// ActionMapfixTriggerUpload implements actionMapfixTriggerUpload operation.
|
// ActionMapfixTriggerUpload implements actionMapfixTriggerUpload operation.
|
||||||
//
|
//
|
||||||
// Role Admin changes status from Validated -> Uploading.
|
// Role Admin changes status from Validated -> Uploading.
|
||||||
@@ -168,6 +177,15 @@ func (UnimplementedHandler) ActionSubmissionTriggerSubmit(ctx context.Context, p
|
|||||||
return ht.ErrNotImplemented
|
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
|
||||||
|
}
|
||||||
|
|
||||||
// ActionSubmissionTriggerUpload implements actionSubmissionTriggerUpload operation.
|
// ActionSubmissionTriggerUpload implements actionSubmissionTriggerUpload operation.
|
||||||
//
|
//
|
||||||
// Role Admin changes status from Validated -> Uploading.
|
// Role Admin changes status from Validated -> Uploading.
|
||||||
@@ -240,6 +258,15 @@ 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.
|
// CreateSubmissionAuditComment implements createSubmissionAuditComment operation.
|
||||||
//
|
//
|
||||||
// Post a comment to the audit log.
|
// Post a comment to the audit log.
|
||||||
@@ -276,6 +303,15 @@ 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.
|
||||||
|
|||||||
@@ -10,6 +10,37 @@ import (
|
|||||||
"github.com/ogen-go/ogen/validate"
|
"github.com/ogen-go/ogen/validate"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func (s *AuditEvent) 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: 64,
|
||||||
|
MaxLengthSet: true,
|
||||||
|
Email: false,
|
||||||
|
Hostname: false,
|
||||||
|
Regex: nil,
|
||||||
|
}).Validate(string(s.Username)); err != nil {
|
||||||
|
return errors.Wrap(err, "string")
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}(); err != nil {
|
||||||
|
failures = append(failures, validate.FieldError{
|
||||||
|
Name: "Username",
|
||||||
|
Error: err,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
if len(failures) > 0 {
|
||||||
|
return &validate.Error{Fields: failures}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
func (s *Error) Validate() error {
|
func (s *Error) Validate() error {
|
||||||
if s == nil {
|
if s == nil {
|
||||||
return validate.ErrNilPointer
|
return validate.ErrNilPointer
|
||||||
@@ -408,13 +439,13 @@ func (s *Mapfix) Validate() error {
|
|||||||
Email: false,
|
Email: false,
|
||||||
Hostname: false,
|
Hostname: false,
|
||||||
Regex: nil,
|
Regex: nil,
|
||||||
}).Validate(string(s.StatusMessage)); err != nil {
|
}).Validate(string(s.Description)); err != nil {
|
||||||
return errors.Wrap(err, "string")
|
return errors.Wrap(err, "string")
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}(); err != nil {
|
}(); err != nil {
|
||||||
failures = append(failures, validate.FieldError{
|
failures = append(failures, validate.FieldError{
|
||||||
Name: "StatusMessage",
|
Name: "Description",
|
||||||
Error: err,
|
Error: err,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -470,6 +501,25 @@ func (s *MapfixTriggerCreate) Validate() error {
|
|||||||
Error: err,
|
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 {
|
if len(failures) > 0 {
|
||||||
return &validate.Error{Fields: failures}
|
return &validate.Error{Fields: failures}
|
||||||
}
|
}
|
||||||
@@ -1751,25 +1801,6 @@ func (s *Submission) Validate() error {
|
|||||||
Error: err,
|
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.StatusMessage)); err != nil {
|
|
||||||
return errors.Wrap(err, "string")
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}(); err != nil {
|
|
||||||
failures = append(failures, validate.FieldError{
|
|
||||||
Name: "StatusMessage",
|
|
||||||
Error: err,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
if len(failures) > 0 {
|
if len(failures) > 0 {
|
||||||
return &validate.Error{Fields: failures}
|
return &validate.Error{Fields: failures}
|
||||||
}
|
}
|
||||||
@@ -1802,6 +1833,64 @@ func (s *SubmissionTriggerCreate) Validate() error {
|
|||||||
Error: err,
|
Error: err,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
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.DisplayName)); err != nil {
|
||||||
|
return errors.Wrap(err, "string")
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}(); err != nil {
|
||||||
|
failures = append(failures, validate.FieldError{
|
||||||
|
Name: "DisplayName",
|
||||||
|
Error: err,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
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.Creator)); err != nil {
|
||||||
|
return errors.Wrap(err, "string")
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}(); err != nil {
|
||||||
|
failures = append(failures, validate.FieldError{
|
||||||
|
Name: "Creator",
|
||||||
|
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 len(failures) > 0 {
|
if len(failures) > 0 {
|
||||||
return &validate.Error{Fields: failures}
|
return &validate.Error{Fields: failures}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,9 +6,11 @@ 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"
|
||||||
@@ -90,6 +92,12 @@ 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,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -125,7 +133,12 @@ func serve(ctx *cli.Context) error {
|
|||||||
svc := &service.Service{
|
svc := &service.Service{
|
||||||
DB: db,
|
DB: db,
|
||||||
Nats: js,
|
Nats: js,
|
||||||
Client: maps.NewMapsServiceClient(conn),
|
Maps: 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()))
|
||||||
|
|||||||
@@ -49,7 +49,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) (uint64, []model.Mapfix, error)
|
ListWithTotal(ctx context.Context, filters OptionalMap, page model.Page, sort ListSort) (int64, []model.Mapfix, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
type Operations interface {
|
type Operations interface {
|
||||||
|
|||||||
@@ -10,17 +10,7 @@ func Optional() OptionalMap {
|
|||||||
return OptionalMap{filter: map[string]interface{}{}}
|
return OptionalMap{filter: map[string]interface{}{}}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (q OptionalMap) Add2(column string, value interface{}) OptionalMap {
|
func (q OptionalMap) Add(column string, value interface{}) OptionalMap {
|
||||||
q.filter[column] = value
|
|
||||||
return q
|
|
||||||
}
|
|
||||||
|
|
||||||
func (q OptionalMap) AddPostgresInt32(column string, value uint32) OptionalMap {
|
|
||||||
q.filter[column] = value
|
|
||||||
return q
|
|
||||||
}
|
|
||||||
|
|
||||||
func (q OptionalMap) AddPostgresInt64(column string, value uint64) OptionalMap {
|
|
||||||
q.filter[column] = value
|
q.filter[column] = value
|
||||||
return q
|
return q
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -131,7 +131,7 @@ 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) (uint64, []model.Mapfix, error) {
|
func (env *Mapfixes) ListWithTotal(ctx context.Context, filters datastore.OptionalMap, page model.Page, sort datastore.ListSort) (int64, []model.Mapfix, error) {
|
||||||
// grab page items
|
// grab page items
|
||||||
maps, err := env.List(ctx, filters, page, sort)
|
maps, err := env.List(ctx, filters, page, sort)
|
||||||
if err != nil{
|
if err != nil{
|
||||||
@@ -144,5 +144,5 @@ func (env *Mapfixes) ListWithTotal(ctx context.Context, filters datastore.Option
|
|||||||
return 0, nil, err
|
return 0, nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return uint64(total), maps, nil
|
return total, maps, nil
|
||||||
}
|
}
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -12,6 +12,186 @@ 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()
|
||||||
@@ -23,7 +203,7 @@ func (s *Error) Encode(e *jx.Encoder) {
|
|||||||
func (s *Error) encodeFields(e *jx.Encoder) {
|
func (s *Error) encodeFields(e *jx.Encoder) {
|
||||||
{
|
{
|
||||||
e.FieldStart("code")
|
e.FieldStart("code")
|
||||||
e.UInt64(s.Code)
|
e.Int64(s.Code)
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
e.FieldStart("message")
|
e.FieldStart("message")
|
||||||
@@ -48,8 +228,8 @@ func (s *Error) Decode(d *jx.Decoder) error {
|
|||||||
case "code":
|
case "code":
|
||||||
requiredBitSet[0] |= 1 << 0
|
requiredBitSet[0] |= 1 << 0
|
||||||
if err := func() error {
|
if err := func() error {
|
||||||
v, err := d.UInt64()
|
v, err := d.Int64()
|
||||||
s.Code = uint64(v)
|
s.Code = int64(v)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -136,11 +316,11 @@ func (s *MapfixCreate) Encode(e *jx.Encoder) {
|
|||||||
func (s *MapfixCreate) encodeFields(e *jx.Encoder) {
|
func (s *MapfixCreate) encodeFields(e *jx.Encoder) {
|
||||||
{
|
{
|
||||||
e.FieldStart("OperationID")
|
e.FieldStart("OperationID")
|
||||||
e.UInt32(s.OperationID)
|
e.Int32(s.OperationID)
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
e.FieldStart("AssetOwner")
|
e.FieldStart("AssetOwner")
|
||||||
e.UInt64(s.AssetOwner)
|
e.Int64(s.AssetOwner)
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
e.FieldStart("DisplayName")
|
e.FieldStart("DisplayName")
|
||||||
@@ -152,23 +332,27 @@ func (s *MapfixCreate) encodeFields(e *jx.Encoder) {
|
|||||||
}
|
}
|
||||||
{
|
{
|
||||||
e.FieldStart("GameID")
|
e.FieldStart("GameID")
|
||||||
e.UInt32(s.GameID)
|
e.Int32(s.GameID)
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
e.FieldStart("AssetID")
|
e.FieldStart("AssetID")
|
||||||
e.UInt64(s.AssetID)
|
e.Int64(s.AssetID)
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
e.FieldStart("AssetVersion")
|
e.FieldStart("AssetVersion")
|
||||||
e.UInt64(s.AssetVersion)
|
e.Int64(s.AssetVersion)
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
e.FieldStart("TargetAssetID")
|
e.FieldStart("TargetAssetID")
|
||||||
e.UInt64(s.TargetAssetID)
|
e.Int64(s.TargetAssetID)
|
||||||
|
}
|
||||||
|
{
|
||||||
|
e.FieldStart("Description")
|
||||||
|
e.Str(s.Description)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var jsonFieldsNameOfMapfixCreate = [8]string{
|
var jsonFieldsNameOfMapfixCreate = [9]string{
|
||||||
0: "OperationID",
|
0: "OperationID",
|
||||||
1: "AssetOwner",
|
1: "AssetOwner",
|
||||||
2: "DisplayName",
|
2: "DisplayName",
|
||||||
@@ -177,6 +361,7 @@ var jsonFieldsNameOfMapfixCreate = [8]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.
|
||||||
@@ -184,15 +369,15 @@ 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 [1]uint8
|
var requiredBitSet [2]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) {
|
||||||
case "OperationID":
|
case "OperationID":
|
||||||
requiredBitSet[0] |= 1 << 0
|
requiredBitSet[0] |= 1 << 0
|
||||||
if err := func() error {
|
if err := func() error {
|
||||||
v, err := d.UInt32()
|
v, err := d.Int32()
|
||||||
s.OperationID = uint32(v)
|
s.OperationID = int32(v)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -203,8 +388,8 @@ func (s *MapfixCreate) Decode(d *jx.Decoder) error {
|
|||||||
case "AssetOwner":
|
case "AssetOwner":
|
||||||
requiredBitSet[0] |= 1 << 1
|
requiredBitSet[0] |= 1 << 1
|
||||||
if err := func() error {
|
if err := func() error {
|
||||||
v, err := d.UInt64()
|
v, err := d.Int64()
|
||||||
s.AssetOwner = uint64(v)
|
s.AssetOwner = int64(v)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -239,8 +424,8 @@ func (s *MapfixCreate) Decode(d *jx.Decoder) error {
|
|||||||
case "GameID":
|
case "GameID":
|
||||||
requiredBitSet[0] |= 1 << 4
|
requiredBitSet[0] |= 1 << 4
|
||||||
if err := func() error {
|
if err := func() error {
|
||||||
v, err := d.UInt32()
|
v, err := d.Int32()
|
||||||
s.GameID = uint32(v)
|
s.GameID = int32(v)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -251,8 +436,8 @@ func (s *MapfixCreate) Decode(d *jx.Decoder) error {
|
|||||||
case "AssetID":
|
case "AssetID":
|
||||||
requiredBitSet[0] |= 1 << 5
|
requiredBitSet[0] |= 1 << 5
|
||||||
if err := func() error {
|
if err := func() error {
|
||||||
v, err := d.UInt64()
|
v, err := d.Int64()
|
||||||
s.AssetID = uint64(v)
|
s.AssetID = int64(v)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -263,8 +448,8 @@ func (s *MapfixCreate) Decode(d *jx.Decoder) error {
|
|||||||
case "AssetVersion":
|
case "AssetVersion":
|
||||||
requiredBitSet[0] |= 1 << 6
|
requiredBitSet[0] |= 1 << 6
|
||||||
if err := func() error {
|
if err := func() error {
|
||||||
v, err := d.UInt64()
|
v, err := d.Int64()
|
||||||
s.AssetVersion = uint64(v)
|
s.AssetVersion = int64(v)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -275,8 +460,8 @@ func (s *MapfixCreate) Decode(d *jx.Decoder) error {
|
|||||||
case "TargetAssetID":
|
case "TargetAssetID":
|
||||||
requiredBitSet[0] |= 1 << 7
|
requiredBitSet[0] |= 1 << 7
|
||||||
if err := func() error {
|
if err := func() error {
|
||||||
v, err := d.UInt64()
|
v, err := d.Int64()
|
||||||
s.TargetAssetID = uint64(v)
|
s.TargetAssetID = int64(v)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -284,6 +469,18 @@ 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()
|
||||||
}
|
}
|
||||||
@@ -293,8 +490,9 @@ 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 [1]uint8{
|
for i, mask := range [2]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.
|
||||||
@@ -351,7 +549,7 @@ func (s *MapfixID) Encode(e *jx.Encoder) {
|
|||||||
func (s *MapfixID) encodeFields(e *jx.Encoder) {
|
func (s *MapfixID) encodeFields(e *jx.Encoder) {
|
||||||
{
|
{
|
||||||
e.FieldStart("MapfixID")
|
e.FieldStart("MapfixID")
|
||||||
e.UInt64(s.MapfixID)
|
e.Int64(s.MapfixID)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -371,8 +569,8 @@ func (s *MapfixID) Decode(d *jx.Decoder) error {
|
|||||||
case "MapfixID":
|
case "MapfixID":
|
||||||
requiredBitSet[0] |= 1 << 0
|
requiredBitSet[0] |= 1 << 0
|
||||||
if err := func() error {
|
if err := func() error {
|
||||||
v, err := d.UInt64()
|
v, err := d.Int64()
|
||||||
s.MapfixID = uint64(v)
|
s.MapfixID = int64(v)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -436,37 +634,37 @@ func (s *MapfixID) UnmarshalJSON(data []byte) error {
|
|||||||
return s.Decode(d)
|
return s.Decode(d)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Encode encodes uint64 as json.
|
// Encode encodes int64 as json.
|
||||||
func (o OptUint64) Encode(e *jx.Encoder) {
|
func (o OptInt64) Encode(e *jx.Encoder) {
|
||||||
if !o.Set {
|
if !o.Set {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
e.UInt64(uint64(o.Value))
|
e.Int64(int64(o.Value))
|
||||||
}
|
}
|
||||||
|
|
||||||
// Decode decodes uint64 from json.
|
// Decode decodes int64 from json.
|
||||||
func (o *OptUint64) Decode(d *jx.Decoder) error {
|
func (o *OptInt64) Decode(d *jx.Decoder) error {
|
||||||
if o == nil {
|
if o == nil {
|
||||||
return errors.New("invalid: unable to decode OptUint64 to nil")
|
return errors.New("invalid: unable to decode OptInt64 to nil")
|
||||||
}
|
}
|
||||||
o.Set = true
|
o.Set = true
|
||||||
v, err := d.UInt64()
|
v, err := d.Int64()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
o.Value = uint64(v)
|
o.Value = int64(v)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// MarshalJSON implements stdjson.Marshaler.
|
// MarshalJSON implements stdjson.Marshaler.
|
||||||
func (s OptUint64) MarshalJSON() ([]byte, error) {
|
func (s OptInt64) MarshalJSON() ([]byte, error) {
|
||||||
e := jx.Encoder{}
|
e := jx.Encoder{}
|
||||||
s.Encode(&e)
|
s.Encode(&e)
|
||||||
return e.Bytes(), nil
|
return e.Bytes(), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// UnmarshalJSON implements stdjson.Unmarshaler.
|
// UnmarshalJSON implements stdjson.Unmarshaler.
|
||||||
func (s *OptUint64) UnmarshalJSON(data []byte) error {
|
func (s *OptInt64) UnmarshalJSON(data []byte) error {
|
||||||
d := jx.DecodeBytes(data)
|
d := jx.DecodeBytes(data)
|
||||||
return s.Decode(d)
|
return s.Decode(d)
|
||||||
}
|
}
|
||||||
@@ -482,7 +680,7 @@ func (s *Script) Encode(e *jx.Encoder) {
|
|||||||
func (s *Script) encodeFields(e *jx.Encoder) {
|
func (s *Script) encodeFields(e *jx.Encoder) {
|
||||||
{
|
{
|
||||||
e.FieldStart("ID")
|
e.FieldStart("ID")
|
||||||
e.UInt64(s.ID)
|
e.Int64(s.ID)
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
e.FieldStart("Name")
|
e.FieldStart("Name")
|
||||||
@@ -498,11 +696,11 @@ func (s *Script) encodeFields(e *jx.Encoder) {
|
|||||||
}
|
}
|
||||||
{
|
{
|
||||||
e.FieldStart("ResourceType")
|
e.FieldStart("ResourceType")
|
||||||
e.UInt32(s.ResourceType)
|
e.Int32(s.ResourceType)
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
e.FieldStart("ResourceID")
|
e.FieldStart("ResourceID")
|
||||||
e.UInt64(s.ResourceID)
|
e.Int64(s.ResourceID)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -527,8 +725,8 @@ func (s *Script) Decode(d *jx.Decoder) error {
|
|||||||
case "ID":
|
case "ID":
|
||||||
requiredBitSet[0] |= 1 << 0
|
requiredBitSet[0] |= 1 << 0
|
||||||
if err := func() error {
|
if err := func() error {
|
||||||
v, err := d.UInt64()
|
v, err := d.Int64()
|
||||||
s.ID = uint64(v)
|
s.ID = int64(v)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -575,8 +773,8 @@ func (s *Script) Decode(d *jx.Decoder) error {
|
|||||||
case "ResourceType":
|
case "ResourceType":
|
||||||
requiredBitSet[0] |= 1 << 4
|
requiredBitSet[0] |= 1 << 4
|
||||||
if err := func() error {
|
if err := func() error {
|
||||||
v, err := d.UInt32()
|
v, err := d.Int32()
|
||||||
s.ResourceType = uint32(v)
|
s.ResourceType = int32(v)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -587,8 +785,8 @@ func (s *Script) Decode(d *jx.Decoder) error {
|
|||||||
case "ResourceID":
|
case "ResourceID":
|
||||||
requiredBitSet[0] |= 1 << 5
|
requiredBitSet[0] |= 1 << 5
|
||||||
if err := func() error {
|
if err := func() error {
|
||||||
v, err := d.UInt64()
|
v, err := d.Int64()
|
||||||
s.ResourceID = uint64(v)
|
s.ResourceID = int64(v)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -671,7 +869,7 @@ func (s *ScriptCreate) encodeFields(e *jx.Encoder) {
|
|||||||
}
|
}
|
||||||
{
|
{
|
||||||
e.FieldStart("ResourceType")
|
e.FieldStart("ResourceType")
|
||||||
e.UInt32(s.ResourceType)
|
e.Int32(s.ResourceType)
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
if s.ResourceID.Set {
|
if s.ResourceID.Set {
|
||||||
@@ -724,8 +922,8 @@ func (s *ScriptCreate) Decode(d *jx.Decoder) error {
|
|||||||
case "ResourceType":
|
case "ResourceType":
|
||||||
requiredBitSet[0] |= 1 << 2
|
requiredBitSet[0] |= 1 << 2
|
||||||
if err := func() error {
|
if err := func() error {
|
||||||
v, err := d.UInt32()
|
v, err := d.Int32()
|
||||||
s.ResourceType = uint32(v)
|
s.ResourceType = int32(v)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -810,7 +1008,7 @@ func (s *ScriptID) Encode(e *jx.Encoder) {
|
|||||||
func (s *ScriptID) encodeFields(e *jx.Encoder) {
|
func (s *ScriptID) encodeFields(e *jx.Encoder) {
|
||||||
{
|
{
|
||||||
e.FieldStart("ScriptID")
|
e.FieldStart("ScriptID")
|
||||||
e.UInt64(s.ScriptID)
|
e.Int64(s.ScriptID)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -830,8 +1028,8 @@ func (s *ScriptID) Decode(d *jx.Decoder) error {
|
|||||||
case "ScriptID":
|
case "ScriptID":
|
||||||
requiredBitSet[0] |= 1 << 0
|
requiredBitSet[0] |= 1 << 0
|
||||||
if err := func() error {
|
if err := func() error {
|
||||||
v, err := d.UInt64()
|
v, err := d.Int64()
|
||||||
s.ScriptID = uint64(v)
|
s.ScriptID = int64(v)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -906,7 +1104,7 @@ func (s *ScriptPolicy) Encode(e *jx.Encoder) {
|
|||||||
func (s *ScriptPolicy) encodeFields(e *jx.Encoder) {
|
func (s *ScriptPolicy) encodeFields(e *jx.Encoder) {
|
||||||
{
|
{
|
||||||
e.FieldStart("ID")
|
e.FieldStart("ID")
|
||||||
e.UInt64(s.ID)
|
e.Int64(s.ID)
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
e.FieldStart("FromScriptHash")
|
e.FieldStart("FromScriptHash")
|
||||||
@@ -914,11 +1112,11 @@ func (s *ScriptPolicy) encodeFields(e *jx.Encoder) {
|
|||||||
}
|
}
|
||||||
{
|
{
|
||||||
e.FieldStart("ToScriptID")
|
e.FieldStart("ToScriptID")
|
||||||
e.UInt64(s.ToScriptID)
|
e.Int64(s.ToScriptID)
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
e.FieldStart("Policy")
|
e.FieldStart("Policy")
|
||||||
e.UInt32(s.Policy)
|
e.Int32(s.Policy)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -941,8 +1139,8 @@ func (s *ScriptPolicy) Decode(d *jx.Decoder) error {
|
|||||||
case "ID":
|
case "ID":
|
||||||
requiredBitSet[0] |= 1 << 0
|
requiredBitSet[0] |= 1 << 0
|
||||||
if err := func() error {
|
if err := func() error {
|
||||||
v, err := d.UInt64()
|
v, err := d.Int64()
|
||||||
s.ID = uint64(v)
|
s.ID = int64(v)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -965,8 +1163,8 @@ func (s *ScriptPolicy) Decode(d *jx.Decoder) error {
|
|||||||
case "ToScriptID":
|
case "ToScriptID":
|
||||||
requiredBitSet[0] |= 1 << 2
|
requiredBitSet[0] |= 1 << 2
|
||||||
if err := func() error {
|
if err := func() error {
|
||||||
v, err := d.UInt64()
|
v, err := d.Int64()
|
||||||
s.ToScriptID = uint64(v)
|
s.ToScriptID = int64(v)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -977,8 +1175,8 @@ func (s *ScriptPolicy) Decode(d *jx.Decoder) error {
|
|||||||
case "Policy":
|
case "Policy":
|
||||||
requiredBitSet[0] |= 1 << 3
|
requiredBitSet[0] |= 1 << 3
|
||||||
if err := func() error {
|
if err := func() error {
|
||||||
v, err := d.UInt32()
|
v, err := d.Int32()
|
||||||
s.Policy = uint32(v)
|
s.Policy = int32(v)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -1053,15 +1251,15 @@ func (s *ScriptPolicyCreate) Encode(e *jx.Encoder) {
|
|||||||
func (s *ScriptPolicyCreate) encodeFields(e *jx.Encoder) {
|
func (s *ScriptPolicyCreate) encodeFields(e *jx.Encoder) {
|
||||||
{
|
{
|
||||||
e.FieldStart("FromScriptID")
|
e.FieldStart("FromScriptID")
|
||||||
e.UInt64(s.FromScriptID)
|
e.Int64(s.FromScriptID)
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
e.FieldStart("ToScriptID")
|
e.FieldStart("ToScriptID")
|
||||||
e.UInt64(s.ToScriptID)
|
e.Int64(s.ToScriptID)
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
e.FieldStart("Policy")
|
e.FieldStart("Policy")
|
||||||
e.UInt32(s.Policy)
|
e.Int32(s.Policy)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1083,8 +1281,8 @@ func (s *ScriptPolicyCreate) Decode(d *jx.Decoder) error {
|
|||||||
case "FromScriptID":
|
case "FromScriptID":
|
||||||
requiredBitSet[0] |= 1 << 0
|
requiredBitSet[0] |= 1 << 0
|
||||||
if err := func() error {
|
if err := func() error {
|
||||||
v, err := d.UInt64()
|
v, err := d.Int64()
|
||||||
s.FromScriptID = uint64(v)
|
s.FromScriptID = int64(v)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -1095,8 +1293,8 @@ func (s *ScriptPolicyCreate) Decode(d *jx.Decoder) error {
|
|||||||
case "ToScriptID":
|
case "ToScriptID":
|
||||||
requiredBitSet[0] |= 1 << 1
|
requiredBitSet[0] |= 1 << 1
|
||||||
if err := func() error {
|
if err := func() error {
|
||||||
v, err := d.UInt64()
|
v, err := d.Int64()
|
||||||
s.ToScriptID = uint64(v)
|
s.ToScriptID = int64(v)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -1107,8 +1305,8 @@ func (s *ScriptPolicyCreate) Decode(d *jx.Decoder) error {
|
|||||||
case "Policy":
|
case "Policy":
|
||||||
requiredBitSet[0] |= 1 << 2
|
requiredBitSet[0] |= 1 << 2
|
||||||
if err := func() error {
|
if err := func() error {
|
||||||
v, err := d.UInt32()
|
v, err := d.Int32()
|
||||||
s.Policy = uint32(v)
|
s.Policy = int32(v)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -1183,7 +1381,7 @@ func (s *ScriptPolicyID) Encode(e *jx.Encoder) {
|
|||||||
func (s *ScriptPolicyID) encodeFields(e *jx.Encoder) {
|
func (s *ScriptPolicyID) encodeFields(e *jx.Encoder) {
|
||||||
{
|
{
|
||||||
e.FieldStart("ScriptPolicyID")
|
e.FieldStart("ScriptPolicyID")
|
||||||
e.UInt64(s.ScriptPolicyID)
|
e.Int64(s.ScriptPolicyID)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1203,8 +1401,8 @@ func (s *ScriptPolicyID) Decode(d *jx.Decoder) error {
|
|||||||
case "ScriptPolicyID":
|
case "ScriptPolicyID":
|
||||||
requiredBitSet[0] |= 1 << 0
|
requiredBitSet[0] |= 1 << 0
|
||||||
if err := func() error {
|
if err := func() error {
|
||||||
v, err := d.UInt64()
|
v, err := d.Int64()
|
||||||
s.ScriptPolicyID = uint64(v)
|
s.ScriptPolicyID = int64(v)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -1279,11 +1477,11 @@ func (s *SubmissionCreate) Encode(e *jx.Encoder) {
|
|||||||
func (s *SubmissionCreate) encodeFields(e *jx.Encoder) {
|
func (s *SubmissionCreate) encodeFields(e *jx.Encoder) {
|
||||||
{
|
{
|
||||||
e.FieldStart("OperationID")
|
e.FieldStart("OperationID")
|
||||||
e.UInt32(s.OperationID)
|
e.Int32(s.OperationID)
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
e.FieldStart("AssetOwner")
|
e.FieldStart("AssetOwner")
|
||||||
e.UInt64(s.AssetOwner)
|
e.Int64(s.AssetOwner)
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
e.FieldStart("DisplayName")
|
e.FieldStart("DisplayName")
|
||||||
@@ -1295,19 +1493,27 @@ func (s *SubmissionCreate) encodeFields(e *jx.Encoder) {
|
|||||||
}
|
}
|
||||||
{
|
{
|
||||||
e.FieldStart("GameID")
|
e.FieldStart("GameID")
|
||||||
e.UInt32(s.GameID)
|
e.Int32(s.GameID)
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
e.FieldStart("AssetID")
|
e.FieldStart("AssetID")
|
||||||
e.UInt64(s.AssetID)
|
e.Int64(s.AssetID)
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
e.FieldStart("AssetVersion")
|
e.FieldStart("AssetVersion")
|
||||||
e.UInt64(s.AssetVersion)
|
e.Int64(s.AssetVersion)
|
||||||
|
}
|
||||||
|
{
|
||||||
|
e.FieldStart("Status")
|
||||||
|
e.UInt32(s.Status)
|
||||||
|
}
|
||||||
|
{
|
||||||
|
e.FieldStart("Roles")
|
||||||
|
e.UInt32(s.Roles)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var jsonFieldsNameOfSubmissionCreate = [7]string{
|
var jsonFieldsNameOfSubmissionCreate = [9]string{
|
||||||
0: "OperationID",
|
0: "OperationID",
|
||||||
1: "AssetOwner",
|
1: "AssetOwner",
|
||||||
2: "DisplayName",
|
2: "DisplayName",
|
||||||
@@ -1315,6 +1521,8 @@ var jsonFieldsNameOfSubmissionCreate = [7]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.
|
||||||
@@ -1322,15 +1530,15 @@ 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 [1]uint8
|
var requiredBitSet [2]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) {
|
||||||
case "OperationID":
|
case "OperationID":
|
||||||
requiredBitSet[0] |= 1 << 0
|
requiredBitSet[0] |= 1 << 0
|
||||||
if err := func() error {
|
if err := func() error {
|
||||||
v, err := d.UInt32()
|
v, err := d.Int32()
|
||||||
s.OperationID = uint32(v)
|
s.OperationID = int32(v)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -1341,8 +1549,8 @@ func (s *SubmissionCreate) Decode(d *jx.Decoder) error {
|
|||||||
case "AssetOwner":
|
case "AssetOwner":
|
||||||
requiredBitSet[0] |= 1 << 1
|
requiredBitSet[0] |= 1 << 1
|
||||||
if err := func() error {
|
if err := func() error {
|
||||||
v, err := d.UInt64()
|
v, err := d.Int64()
|
||||||
s.AssetOwner = uint64(v)
|
s.AssetOwner = int64(v)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -1377,8 +1585,8 @@ func (s *SubmissionCreate) Decode(d *jx.Decoder) error {
|
|||||||
case "GameID":
|
case "GameID":
|
||||||
requiredBitSet[0] |= 1 << 4
|
requiredBitSet[0] |= 1 << 4
|
||||||
if err := func() error {
|
if err := func() error {
|
||||||
v, err := d.UInt32()
|
v, err := d.Int32()
|
||||||
s.GameID = uint32(v)
|
s.GameID = int32(v)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -1389,8 +1597,8 @@ func (s *SubmissionCreate) Decode(d *jx.Decoder) error {
|
|||||||
case "AssetID":
|
case "AssetID":
|
||||||
requiredBitSet[0] |= 1 << 5
|
requiredBitSet[0] |= 1 << 5
|
||||||
if err := func() error {
|
if err := func() error {
|
||||||
v, err := d.UInt64()
|
v, err := d.Int64()
|
||||||
s.AssetID = uint64(v)
|
s.AssetID = int64(v)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -1401,8 +1609,8 @@ func (s *SubmissionCreate) Decode(d *jx.Decoder) error {
|
|||||||
case "AssetVersion":
|
case "AssetVersion":
|
||||||
requiredBitSet[0] |= 1 << 6
|
requiredBitSet[0] |= 1 << 6
|
||||||
if err := func() error {
|
if err := func() error {
|
||||||
v, err := d.UInt64()
|
v, err := d.Int64()
|
||||||
s.AssetVersion = uint64(v)
|
s.AssetVersion = int64(v)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -1410,6 +1618,30 @@ 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()
|
||||||
}
|
}
|
||||||
@@ -1419,8 +1651,9 @@ 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 [1]uint8{
|
for i, mask := range [2]uint8{
|
||||||
0b01111111,
|
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.
|
||||||
@@ -1477,7 +1710,7 @@ func (s *SubmissionID) Encode(e *jx.Encoder) {
|
|||||||
func (s *SubmissionID) encodeFields(e *jx.Encoder) {
|
func (s *SubmissionID) encodeFields(e *jx.Encoder) {
|
||||||
{
|
{
|
||||||
e.FieldStart("SubmissionID")
|
e.FieldStart("SubmissionID")
|
||||||
e.UInt64(s.SubmissionID)
|
e.Int64(s.SubmissionID)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1497,8 +1730,8 @@ func (s *SubmissionID) Decode(d *jx.Decoder) error {
|
|||||||
case "SubmissionID":
|
case "SubmissionID":
|
||||||
requiredBitSet[0] |= 1 << 0
|
requiredBitSet[0] |= 1 << 0
|
||||||
if err := func() error {
|
if err := func() error {
|
||||||
v, err := d.UInt64()
|
v, err := d.Int64()
|
||||||
s.SubmissionID = uint64(v)
|
s.SubmissionID = int64(v)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,18 +7,24 @@ type OperationName = string
|
|||||||
|
|
||||||
const (
|
const (
|
||||||
ActionMapfixAcceptedOperation OperationName = "ActionMapfixAccepted"
|
ActionMapfixAcceptedOperation OperationName = "ActionMapfixAccepted"
|
||||||
|
ActionMapfixRequestChangesOperation OperationName = "ActionMapfixRequestChanges"
|
||||||
ActionMapfixSubmittedOperation OperationName = "ActionMapfixSubmitted"
|
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"
|
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,7 +9,6 @@ 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"
|
||||||
@@ -26,13 +25,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 = multierr.Append(merr, c())
|
merr = errors.Join(merr, c())
|
||||||
}
|
}
|
||||||
return merr
|
return merr
|
||||||
}
|
}
|
||||||
defer func() {
|
defer func() {
|
||||||
if rerr != nil {
|
if rerr != nil {
|
||||||
rerr = multierr.Append(rerr, close())
|
rerr = errors.Join(rerr, close())
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
ct, _, err := mime.ParseMediaType(r.Header.Get("Content-Type"))
|
ct, _, err := mime.ParseMediaType(r.Header.Get("Content-Type"))
|
||||||
@@ -86,6 +85,77 @@ 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,
|
||||||
@@ -97,13 +167,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 = multierr.Append(merr, c())
|
merr = errors.Join(merr, c())
|
||||||
}
|
}
|
||||||
return merr
|
return merr
|
||||||
}
|
}
|
||||||
defer func() {
|
defer func() {
|
||||||
if rerr != nil {
|
if rerr != nil {
|
||||||
rerr = multierr.Append(rerr, close())
|
rerr = errors.Join(rerr, close())
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
ct, _, err := mime.ParseMediaType(r.Header.Get("Content-Type"))
|
ct, _, err := mime.ParseMediaType(r.Header.Get("Content-Type"))
|
||||||
@@ -168,13 +238,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 = multierr.Append(merr, c())
|
merr = errors.Join(merr, c())
|
||||||
}
|
}
|
||||||
return merr
|
return merr
|
||||||
}
|
}
|
||||||
defer func() {
|
defer func() {
|
||||||
if rerr != nil {
|
if rerr != nil {
|
||||||
rerr = multierr.Append(rerr, close())
|
rerr = errors.Join(rerr, close())
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
ct, _, err := mime.ParseMediaType(r.Header.Get("Content-Type"))
|
ct, _, err := mime.ParseMediaType(r.Header.Get("Content-Type"))
|
||||||
@@ -239,13 +309,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 = multierr.Append(merr, c())
|
merr = errors.Join(merr, c())
|
||||||
}
|
}
|
||||||
return merr
|
return merr
|
||||||
}
|
}
|
||||||
defer func() {
|
defer func() {
|
||||||
if rerr != nil {
|
if rerr != nil {
|
||||||
rerr = multierr.Append(rerr, close())
|
rerr = errors.Join(rerr, close())
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
ct, _, err := mime.ParseMediaType(r.Header.Get("Content-Type"))
|
ct, _, err := mime.ParseMediaType(r.Header.Get("Content-Type"))
|
||||||
@@ -298,3 +368,74 @@ 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,6 +25,20 @@ 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,
|
||||||
@@ -66,3 +80,17 @@ 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
|
||||||
|
}
|
||||||
|
|||||||
@@ -75,6 +75,66 @@ func decodeActionMapfixAcceptedResponse(resp *http.Response) (res *ActionMapfixA
|
|||||||
return res, errors.Wrap(defRes, "error")
|
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) {
|
func decodeActionMapfixSubmittedResponse(resp *http.Response) (res *ActionMapfixSubmittedNoContent, _ error) {
|
||||||
switch resp.StatusCode {
|
switch resp.StatusCode {
|
||||||
case 204:
|
case 204:
|
||||||
@@ -375,6 +435,66 @@ func decodeActionSubmissionAcceptedResponse(resp *http.Response) (res *ActionSub
|
|||||||
return res, errors.Wrap(defRes, "error")
|
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) {
|
func decodeActionSubmissionSubmittedResponse(resp *http.Response) (res *ActionSubmissionSubmittedNoContent, _ error) {
|
||||||
switch resp.StatusCode {
|
switch resp.StatusCode {
|
||||||
case 204:
|
case 204:
|
||||||
@@ -656,6 +776,126 @@ func decodeCreateMapfixResponse(resp *http.Response) (res *MapfixID, _ error) {
|
|||||||
return res, errors.Wrap(defRes, "error")
|
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{
|
||||||
|
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 decodeCreateScriptResponse(resp *http.Response) (res *ScriptID, _ error) {
|
func decodeCreateScriptResponse(resp *http.Response) (res *ScriptID, _ error) {
|
||||||
switch resp.StatusCode {
|
switch resp.StatusCode {
|
||||||
case 201:
|
case 201:
|
||||||
@@ -959,6 +1199,126 @@ func decodeCreateSubmissionResponse(resp *http.Response) (res *SubmissionID, _ e
|
|||||||
return res, errors.Wrap(defRes, "error")
|
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{
|
||||||
|
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 decodeGetScriptResponse(resp *http.Response) (res *Script, _ error) {
|
func decodeGetScriptResponse(resp *http.Response) (res *Script, _ error) {
|
||||||
switch resp.StatusCode {
|
switch resp.StatusCode {
|
||||||
case 200:
|
case 200:
|
||||||
|
|||||||
@@ -20,6 +20,13 @@ 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 {
|
func encodeActionMapfixSubmittedResponse(response *ActionMapfixSubmittedNoContent, 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))
|
||||||
@@ -55,6 +62,13 @@ 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 {
|
func encodeActionSubmissionSubmittedResponse(response *ActionSubmissionSubmittedNoContent, 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))
|
||||||
@@ -90,6 +104,20 @@ 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)
|
||||||
@@ -132,6 +160,20 @@ 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,6 +113,50 @@ 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-" {
|
||||||
@@ -147,6 +191,28 @@ 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"
|
case 's': // Prefix: "submitted"
|
||||||
|
|
||||||
if l := len("submitted"); len(elem) >= l && elem[0:l] == "submitted" {
|
if l := len("submitted"); len(elem) >= l && elem[0:l] == "submitted" {
|
||||||
@@ -442,6 +508,50 @@ 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-" {
|
||||||
@@ -476,6 +586,28 @@ 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"
|
case 's': // Prefix: "submitted"
|
||||||
|
|
||||||
if l := len("submitted"); len(elem) >= l && elem[0:l] == "submitted" {
|
if l := len("submitted"); len(elem) >= l && elem[0:l] == "submitted" {
|
||||||
@@ -724,6 +856,54 @@ 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-" {
|
||||||
@@ -760,6 +940,30 @@ 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"
|
case 's': // Prefix: "submitted"
|
||||||
|
|
||||||
if l := len("submitted"); len(elem) >= l && elem[0:l] == "submitted" {
|
if l := len("submitted"); len(elem) >= l && elem[0:l] == "submitted" {
|
||||||
@@ -1091,6 +1295,54 @@ 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-" {
|
||||||
@@ -1127,6 +1379,30 @@ 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"
|
case 's': // Prefix: "submitted"
|
||||||
|
|
||||||
if l := len("submitted"); len(elem) >= l && elem[0:l] == "submitted" {
|
if l := len("submitted"); len(elem) >= l && elem[0:l] == "submitted" {
|
||||||
|
|||||||
@@ -13,6 +13,9 @@ 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.
|
// ActionMapfixSubmittedNoContent is response for ActionMapfixSubmitted operation.
|
||||||
type ActionMapfixSubmittedNoContent struct{}
|
type ActionMapfixSubmittedNoContent struct{}
|
||||||
|
|
||||||
@@ -28,6 +31,9 @@ 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.
|
// ActionSubmissionSubmittedNoContent is response for ActionSubmissionSubmitted operation.
|
||||||
type ActionSubmissionSubmittedNoContent struct{}
|
type ActionSubmissionSubmittedNoContent struct{}
|
||||||
|
|
||||||
@@ -37,15 +43,66 @@ 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 {
|
||||||
Code uint64 `json:"code"`
|
Code int64 `json:"code"`
|
||||||
Message string `json:"message"`
|
Message string `json:"message"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetCode returns the value of Code.
|
// GetCode returns the value of Code.
|
||||||
func (s *Error) GetCode() uint64 {
|
func (s *Error) GetCode() int64 {
|
||||||
return s.Code
|
return s.Code
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -55,7 +112,7 @@ func (s *Error) GetMessage() string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// SetCode sets the value of Code.
|
// SetCode sets the value of Code.
|
||||||
func (s *Error) SetCode(val uint64) {
|
func (s *Error) SetCode(val int64) {
|
||||||
s.Code = val
|
s.Code = val
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -92,23 +149,24 @@ func (s *ErrorStatusCode) SetResponse(val Error) {
|
|||||||
|
|
||||||
// Ref: #/components/schemas/MapfixCreate
|
// Ref: #/components/schemas/MapfixCreate
|
||||||
type MapfixCreate struct {
|
type MapfixCreate struct {
|
||||||
OperationID uint32 `json:"OperationID"`
|
OperationID int32 `json:"OperationID"`
|
||||||
AssetOwner uint64 `json:"AssetOwner"`
|
AssetOwner int64 `json:"AssetOwner"`
|
||||||
DisplayName string `json:"DisplayName"`
|
DisplayName string `json:"DisplayName"`
|
||||||
Creator string `json:"Creator"`
|
Creator string `json:"Creator"`
|
||||||
GameID uint32 `json:"GameID"`
|
GameID int32 `json:"GameID"`
|
||||||
AssetID uint64 `json:"AssetID"`
|
AssetID int64 `json:"AssetID"`
|
||||||
AssetVersion uint64 `json:"AssetVersion"`
|
AssetVersion int64 `json:"AssetVersion"`
|
||||||
TargetAssetID uint64 `json:"TargetAssetID"`
|
TargetAssetID int64 `json:"TargetAssetID"`
|
||||||
|
Description string `json:"Description"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetOperationID returns the value of OperationID.
|
// GetOperationID returns the value of OperationID.
|
||||||
func (s *MapfixCreate) GetOperationID() uint32 {
|
func (s *MapfixCreate) GetOperationID() int32 {
|
||||||
return s.OperationID
|
return s.OperationID
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetAssetOwner returns the value of AssetOwner.
|
// GetAssetOwner returns the value of AssetOwner.
|
||||||
func (s *MapfixCreate) GetAssetOwner() uint64 {
|
func (s *MapfixCreate) GetAssetOwner() int64 {
|
||||||
return s.AssetOwner
|
return s.AssetOwner
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -123,32 +181,37 @@ func (s *MapfixCreate) GetCreator() string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// GetGameID returns the value of GameID.
|
// GetGameID returns the value of GameID.
|
||||||
func (s *MapfixCreate) GetGameID() uint32 {
|
func (s *MapfixCreate) GetGameID() int32 {
|
||||||
return s.GameID
|
return s.GameID
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetAssetID returns the value of AssetID.
|
// GetAssetID returns the value of AssetID.
|
||||||
func (s *MapfixCreate) GetAssetID() uint64 {
|
func (s *MapfixCreate) GetAssetID() int64 {
|
||||||
return s.AssetID
|
return s.AssetID
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetAssetVersion returns the value of AssetVersion.
|
// GetAssetVersion returns the value of AssetVersion.
|
||||||
func (s *MapfixCreate) GetAssetVersion() uint64 {
|
func (s *MapfixCreate) GetAssetVersion() int64 {
|
||||||
return s.AssetVersion
|
return s.AssetVersion
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetTargetAssetID returns the value of TargetAssetID.
|
// GetTargetAssetID returns the value of TargetAssetID.
|
||||||
func (s *MapfixCreate) GetTargetAssetID() uint64 {
|
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 uint32) {
|
func (s *MapfixCreate) SetOperationID(val int32) {
|
||||||
s.OperationID = val
|
s.OperationID = val
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetAssetOwner sets the value of AssetOwner.
|
// SetAssetOwner sets the value of AssetOwner.
|
||||||
func (s *MapfixCreate) SetAssetOwner(val uint64) {
|
func (s *MapfixCreate) SetAssetOwner(val int64) {
|
||||||
s.AssetOwner = val
|
s.AssetOwner = val
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -163,40 +226,137 @@ func (s *MapfixCreate) SetCreator(val string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// SetGameID sets the value of GameID.
|
// SetGameID sets the value of GameID.
|
||||||
func (s *MapfixCreate) SetGameID(val uint32) {
|
func (s *MapfixCreate) SetGameID(val int32) {
|
||||||
s.GameID = val
|
s.GameID = val
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetAssetID sets the value of AssetID.
|
// SetAssetID sets the value of AssetID.
|
||||||
func (s *MapfixCreate) SetAssetID(val uint64) {
|
func (s *MapfixCreate) SetAssetID(val int64) {
|
||||||
s.AssetID = val
|
s.AssetID = val
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetAssetVersion sets the value of AssetVersion.
|
// SetAssetVersion sets the value of AssetVersion.
|
||||||
func (s *MapfixCreate) SetAssetVersion(val uint64) {
|
func (s *MapfixCreate) SetAssetVersion(val int64) {
|
||||||
s.AssetVersion = val
|
s.AssetVersion = val
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetTargetAssetID sets the value of TargetAssetID.
|
// SetTargetAssetID sets the value of TargetAssetID.
|
||||||
func (s *MapfixCreate) SetTargetAssetID(val uint64) {
|
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 uint64 `json:"MapfixID"`
|
MapfixID int64 `json:"MapfixID"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetMapfixID returns the value of MapfixID.
|
// GetMapfixID returns the value of MapfixID.
|
||||||
func (s *MapfixID) GetMapfixID() uint64 {
|
func (s *MapfixID) GetMapfixID() int64 {
|
||||||
return s.MapfixID
|
return s.MapfixID
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetMapfixID sets the value of MapfixID.
|
// SetMapfixID sets the value of MapfixID.
|
||||||
func (s *MapfixID) SetMapfixID(val uint64) {
|
func (s *MapfixID) SetMapfixID(val int64) {
|
||||||
s.MapfixID = val
|
s.MapfixID = val
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NewOptInt32 returns new OptInt32 with value set to v.
|
||||||
|
func NewOptInt32(v int32) OptInt32 {
|
||||||
|
return OptInt32{
|
||||||
|
Value: v,
|
||||||
|
Set: true,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// OptInt32 is optional int32.
|
||||||
|
type OptInt32 struct {
|
||||||
|
Value int32
|
||||||
|
Set bool
|
||||||
|
}
|
||||||
|
|
||||||
|
// IsSet returns true if OptInt32 was set.
|
||||||
|
func (o OptInt32) IsSet() bool { return o.Set }
|
||||||
|
|
||||||
|
// Reset unsets value.
|
||||||
|
func (o *OptInt32) Reset() {
|
||||||
|
var v int32
|
||||||
|
o.Value = v
|
||||||
|
o.Set = false
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetTo sets value to v.
|
||||||
|
func (o *OptInt32) SetTo(v int32) {
|
||||||
|
o.Set = true
|
||||||
|
o.Value = v
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get returns value and boolean that denotes whether value was set.
|
||||||
|
func (o OptInt32) Get() (v int32, ok bool) {
|
||||||
|
if !o.Set {
|
||||||
|
return v, false
|
||||||
|
}
|
||||||
|
return o.Value, true
|
||||||
|
}
|
||||||
|
|
||||||
|
// Or returns value if set, or given parameter if does not.
|
||||||
|
func (o OptInt32) Or(d int32) int32 {
|
||||||
|
if v, ok := o.Get(); ok {
|
||||||
|
return v
|
||||||
|
}
|
||||||
|
return d
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewOptInt64 returns new OptInt64 with value set to v.
|
||||||
|
func NewOptInt64(v int64) OptInt64 {
|
||||||
|
return OptInt64{
|
||||||
|
Value: v,
|
||||||
|
Set: true,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// OptInt64 is optional int64.
|
||||||
|
type OptInt64 struct {
|
||||||
|
Value int64
|
||||||
|
Set bool
|
||||||
|
}
|
||||||
|
|
||||||
|
// IsSet returns true if OptInt64 was set.
|
||||||
|
func (o OptInt64) IsSet() bool { return o.Set }
|
||||||
|
|
||||||
|
// Reset unsets value.
|
||||||
|
func (o *OptInt64) Reset() {
|
||||||
|
var v int64
|
||||||
|
o.Value = v
|
||||||
|
o.Set = false
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetTo sets value to v.
|
||||||
|
func (o *OptInt64) SetTo(v int64) {
|
||||||
|
o.Set = true
|
||||||
|
o.Value = v
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get returns value and boolean that denotes whether value was set.
|
||||||
|
func (o OptInt64) Get() (v int64, ok bool) {
|
||||||
|
if !o.Set {
|
||||||
|
return v, false
|
||||||
|
}
|
||||||
|
return o.Value, true
|
||||||
|
}
|
||||||
|
|
||||||
|
// Or returns value if set, or given parameter if does not.
|
||||||
|
func (o OptInt64) Or(d int64) int64 {
|
||||||
|
if v, ok := o.Get(); ok {
|
||||||
|
return v
|
||||||
|
}
|
||||||
|
return d
|
||||||
|
}
|
||||||
|
|
||||||
// NewOptString returns new OptString with value set to v.
|
// NewOptString returns new OptString with value set to v.
|
||||||
func NewOptString(v string) OptString {
|
func NewOptString(v string) OptString {
|
||||||
return OptString{
|
return OptString{
|
||||||
@@ -243,110 +403,18 @@ func (o OptString) Or(d string) string {
|
|||||||
return d
|
return d
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewOptUint32 returns new OptUint32 with value set to v.
|
|
||||||
func NewOptUint32(v uint32) OptUint32 {
|
|
||||||
return OptUint32{
|
|
||||||
Value: v,
|
|
||||||
Set: true,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// OptUint32 is optional uint32.
|
|
||||||
type OptUint32 struct {
|
|
||||||
Value uint32
|
|
||||||
Set bool
|
|
||||||
}
|
|
||||||
|
|
||||||
// IsSet returns true if OptUint32 was set.
|
|
||||||
func (o OptUint32) IsSet() bool { return o.Set }
|
|
||||||
|
|
||||||
// Reset unsets value.
|
|
||||||
func (o *OptUint32) Reset() {
|
|
||||||
var v uint32
|
|
||||||
o.Value = v
|
|
||||||
o.Set = false
|
|
||||||
}
|
|
||||||
|
|
||||||
// SetTo sets value to v.
|
|
||||||
func (o *OptUint32) SetTo(v uint32) {
|
|
||||||
o.Set = true
|
|
||||||
o.Value = v
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get returns value and boolean that denotes whether value was set.
|
|
||||||
func (o OptUint32) Get() (v uint32, ok bool) {
|
|
||||||
if !o.Set {
|
|
||||||
return v, false
|
|
||||||
}
|
|
||||||
return o.Value, true
|
|
||||||
}
|
|
||||||
|
|
||||||
// Or returns value if set, or given parameter if does not.
|
|
||||||
func (o OptUint32) Or(d uint32) uint32 {
|
|
||||||
if v, ok := o.Get(); ok {
|
|
||||||
return v
|
|
||||||
}
|
|
||||||
return d
|
|
||||||
}
|
|
||||||
|
|
||||||
// NewOptUint64 returns new OptUint64 with value set to v.
|
|
||||||
func NewOptUint64(v uint64) OptUint64 {
|
|
||||||
return OptUint64{
|
|
||||||
Value: v,
|
|
||||||
Set: true,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// OptUint64 is optional uint64.
|
|
||||||
type OptUint64 struct {
|
|
||||||
Value uint64
|
|
||||||
Set bool
|
|
||||||
}
|
|
||||||
|
|
||||||
// IsSet returns true if OptUint64 was set.
|
|
||||||
func (o OptUint64) IsSet() bool { return o.Set }
|
|
||||||
|
|
||||||
// Reset unsets value.
|
|
||||||
func (o *OptUint64) Reset() {
|
|
||||||
var v uint64
|
|
||||||
o.Value = v
|
|
||||||
o.Set = false
|
|
||||||
}
|
|
||||||
|
|
||||||
// SetTo sets value to v.
|
|
||||||
func (o *OptUint64) SetTo(v uint64) {
|
|
||||||
o.Set = true
|
|
||||||
o.Value = v
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get returns value and boolean that denotes whether value was set.
|
|
||||||
func (o OptUint64) Get() (v uint64, ok bool) {
|
|
||||||
if !o.Set {
|
|
||||||
return v, false
|
|
||||||
}
|
|
||||||
return o.Value, true
|
|
||||||
}
|
|
||||||
|
|
||||||
// Or returns value if set, or given parameter if does not.
|
|
||||||
func (o OptUint64) Or(d uint64) uint64 {
|
|
||||||
if v, ok := o.Get(); ok {
|
|
||||||
return v
|
|
||||||
}
|
|
||||||
return d
|
|
||||||
}
|
|
||||||
|
|
||||||
// Ref: #/components/schemas/Script
|
// Ref: #/components/schemas/Script
|
||||||
type Script struct {
|
type Script struct {
|
||||||
ID uint64 `json:"ID"`
|
ID int64 `json:"ID"`
|
||||||
Name string `json:"Name"`
|
Name string `json:"Name"`
|
||||||
Hash string `json:"Hash"`
|
Hash string `json:"Hash"`
|
||||||
Source string `json:"Source"`
|
Source string `json:"Source"`
|
||||||
ResourceType uint32 `json:"ResourceType"`
|
ResourceType int32 `json:"ResourceType"`
|
||||||
ResourceID uint64 `json:"ResourceID"`
|
ResourceID int64 `json:"ResourceID"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetID returns the value of ID.
|
// GetID returns the value of ID.
|
||||||
func (s *Script) GetID() uint64 {
|
func (s *Script) GetID() int64 {
|
||||||
return s.ID
|
return s.ID
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -366,17 +434,17 @@ func (s *Script) GetSource() string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// GetResourceType returns the value of ResourceType.
|
// GetResourceType returns the value of ResourceType.
|
||||||
func (s *Script) GetResourceType() uint32 {
|
func (s *Script) GetResourceType() int32 {
|
||||||
return s.ResourceType
|
return s.ResourceType
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetResourceID returns the value of ResourceID.
|
// GetResourceID returns the value of ResourceID.
|
||||||
func (s *Script) GetResourceID() uint64 {
|
func (s *Script) GetResourceID() int64 {
|
||||||
return s.ResourceID
|
return s.ResourceID
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetID sets the value of ID.
|
// SetID sets the value of ID.
|
||||||
func (s *Script) SetID(val uint64) {
|
func (s *Script) SetID(val int64) {
|
||||||
s.ID = val
|
s.ID = val
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -396,21 +464,21 @@ func (s *Script) SetSource(val string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// SetResourceType sets the value of ResourceType.
|
// SetResourceType sets the value of ResourceType.
|
||||||
func (s *Script) SetResourceType(val uint32) {
|
func (s *Script) SetResourceType(val int32) {
|
||||||
s.ResourceType = val
|
s.ResourceType = val
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetResourceID sets the value of ResourceID.
|
// SetResourceID sets the value of ResourceID.
|
||||||
func (s *Script) SetResourceID(val uint64) {
|
func (s *Script) SetResourceID(val int64) {
|
||||||
s.ResourceID = val
|
s.ResourceID = val
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ref: #/components/schemas/ScriptCreate
|
// Ref: #/components/schemas/ScriptCreate
|
||||||
type ScriptCreate struct {
|
type ScriptCreate struct {
|
||||||
Name string `json:"Name"`
|
Name string `json:"Name"`
|
||||||
Source string `json:"Source"`
|
Source string `json:"Source"`
|
||||||
ResourceType uint32 `json:"ResourceType"`
|
ResourceType int32 `json:"ResourceType"`
|
||||||
ResourceID OptUint64 `json:"ResourceID"`
|
ResourceID OptInt64 `json:"ResourceID"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetName returns the value of Name.
|
// GetName returns the value of Name.
|
||||||
@@ -424,12 +492,12 @@ func (s *ScriptCreate) GetSource() string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// GetResourceType returns the value of ResourceType.
|
// GetResourceType returns the value of ResourceType.
|
||||||
func (s *ScriptCreate) GetResourceType() uint32 {
|
func (s *ScriptCreate) GetResourceType() int32 {
|
||||||
return s.ResourceType
|
return s.ResourceType
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetResourceID returns the value of ResourceID.
|
// GetResourceID returns the value of ResourceID.
|
||||||
func (s *ScriptCreate) GetResourceID() OptUint64 {
|
func (s *ScriptCreate) GetResourceID() OptInt64 {
|
||||||
return s.ResourceID
|
return s.ResourceID
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -444,40 +512,40 @@ func (s *ScriptCreate) SetSource(val string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// SetResourceType sets the value of ResourceType.
|
// SetResourceType sets the value of ResourceType.
|
||||||
func (s *ScriptCreate) SetResourceType(val uint32) {
|
func (s *ScriptCreate) SetResourceType(val int32) {
|
||||||
s.ResourceType = val
|
s.ResourceType = val
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetResourceID sets the value of ResourceID.
|
// SetResourceID sets the value of ResourceID.
|
||||||
func (s *ScriptCreate) SetResourceID(val OptUint64) {
|
func (s *ScriptCreate) SetResourceID(val OptInt64) {
|
||||||
s.ResourceID = val
|
s.ResourceID = val
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ref: #/components/schemas/ScriptID
|
// Ref: #/components/schemas/ScriptID
|
||||||
type ScriptID struct {
|
type ScriptID struct {
|
||||||
ScriptID uint64 `json:"ScriptID"`
|
ScriptID int64 `json:"ScriptID"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetScriptID returns the value of ScriptID.
|
// GetScriptID returns the value of ScriptID.
|
||||||
func (s *ScriptID) GetScriptID() uint64 {
|
func (s *ScriptID) GetScriptID() int64 {
|
||||||
return s.ScriptID
|
return s.ScriptID
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetScriptID sets the value of ScriptID.
|
// SetScriptID sets the value of ScriptID.
|
||||||
func (s *ScriptID) SetScriptID(val uint64) {
|
func (s *ScriptID) SetScriptID(val int64) {
|
||||||
s.ScriptID = val
|
s.ScriptID = val
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ref: #/components/schemas/ScriptPolicy
|
// Ref: #/components/schemas/ScriptPolicy
|
||||||
type ScriptPolicy struct {
|
type ScriptPolicy struct {
|
||||||
ID uint64 `json:"ID"`
|
ID int64 `json:"ID"`
|
||||||
FromScriptHash string `json:"FromScriptHash"`
|
FromScriptHash string `json:"FromScriptHash"`
|
||||||
ToScriptID uint64 `json:"ToScriptID"`
|
ToScriptID int64 `json:"ToScriptID"`
|
||||||
Policy uint32 `json:"Policy"`
|
Policy int32 `json:"Policy"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetID returns the value of ID.
|
// GetID returns the value of ID.
|
||||||
func (s *ScriptPolicy) GetID() uint64 {
|
func (s *ScriptPolicy) GetID() int64 {
|
||||||
return s.ID
|
return s.ID
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -487,17 +555,17 @@ func (s *ScriptPolicy) GetFromScriptHash() string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// GetToScriptID returns the value of ToScriptID.
|
// GetToScriptID returns the value of ToScriptID.
|
||||||
func (s *ScriptPolicy) GetToScriptID() uint64 {
|
func (s *ScriptPolicy) GetToScriptID() int64 {
|
||||||
return s.ToScriptID
|
return s.ToScriptID
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetPolicy returns the value of Policy.
|
// GetPolicy returns the value of Policy.
|
||||||
func (s *ScriptPolicy) GetPolicy() uint32 {
|
func (s *ScriptPolicy) GetPolicy() int32 {
|
||||||
return s.Policy
|
return s.Policy
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetID sets the value of ID.
|
// SetID sets the value of ID.
|
||||||
func (s *ScriptPolicy) SetID(val uint64) {
|
func (s *ScriptPolicy) SetID(val int64) {
|
||||||
s.ID = val
|
s.ID = val
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -507,85 +575,87 @@ func (s *ScriptPolicy) SetFromScriptHash(val string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// SetToScriptID sets the value of ToScriptID.
|
// SetToScriptID sets the value of ToScriptID.
|
||||||
func (s *ScriptPolicy) SetToScriptID(val uint64) {
|
func (s *ScriptPolicy) SetToScriptID(val int64) {
|
||||||
s.ToScriptID = val
|
s.ToScriptID = val
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetPolicy sets the value of Policy.
|
// SetPolicy sets the value of Policy.
|
||||||
func (s *ScriptPolicy) SetPolicy(val uint32) {
|
func (s *ScriptPolicy) SetPolicy(val int32) {
|
||||||
s.Policy = val
|
s.Policy = val
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ref: #/components/schemas/ScriptPolicyCreate
|
// Ref: #/components/schemas/ScriptPolicyCreate
|
||||||
type ScriptPolicyCreate struct {
|
type ScriptPolicyCreate struct {
|
||||||
FromScriptID uint64 `json:"FromScriptID"`
|
FromScriptID int64 `json:"FromScriptID"`
|
||||||
ToScriptID uint64 `json:"ToScriptID"`
|
ToScriptID int64 `json:"ToScriptID"`
|
||||||
Policy uint32 `json:"Policy"`
|
Policy int32 `json:"Policy"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetFromScriptID returns the value of FromScriptID.
|
// GetFromScriptID returns the value of FromScriptID.
|
||||||
func (s *ScriptPolicyCreate) GetFromScriptID() uint64 {
|
func (s *ScriptPolicyCreate) GetFromScriptID() int64 {
|
||||||
return s.FromScriptID
|
return s.FromScriptID
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetToScriptID returns the value of ToScriptID.
|
// GetToScriptID returns the value of ToScriptID.
|
||||||
func (s *ScriptPolicyCreate) GetToScriptID() uint64 {
|
func (s *ScriptPolicyCreate) GetToScriptID() int64 {
|
||||||
return s.ToScriptID
|
return s.ToScriptID
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetPolicy returns the value of Policy.
|
// GetPolicy returns the value of Policy.
|
||||||
func (s *ScriptPolicyCreate) GetPolicy() uint32 {
|
func (s *ScriptPolicyCreate) GetPolicy() int32 {
|
||||||
return s.Policy
|
return s.Policy
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetFromScriptID sets the value of FromScriptID.
|
// SetFromScriptID sets the value of FromScriptID.
|
||||||
func (s *ScriptPolicyCreate) SetFromScriptID(val uint64) {
|
func (s *ScriptPolicyCreate) SetFromScriptID(val int64) {
|
||||||
s.FromScriptID = val
|
s.FromScriptID = val
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetToScriptID sets the value of ToScriptID.
|
// SetToScriptID sets the value of ToScriptID.
|
||||||
func (s *ScriptPolicyCreate) SetToScriptID(val uint64) {
|
func (s *ScriptPolicyCreate) SetToScriptID(val int64) {
|
||||||
s.ToScriptID = val
|
s.ToScriptID = val
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetPolicy sets the value of Policy.
|
// SetPolicy sets the value of Policy.
|
||||||
func (s *ScriptPolicyCreate) SetPolicy(val uint32) {
|
func (s *ScriptPolicyCreate) SetPolicy(val int32) {
|
||||||
s.Policy = val
|
s.Policy = val
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ref: #/components/schemas/ScriptPolicyID
|
// Ref: #/components/schemas/ScriptPolicyID
|
||||||
type ScriptPolicyID struct {
|
type ScriptPolicyID struct {
|
||||||
ScriptPolicyID uint64 `json:"ScriptPolicyID"`
|
ScriptPolicyID int64 `json:"ScriptPolicyID"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetScriptPolicyID returns the value of ScriptPolicyID.
|
// GetScriptPolicyID returns the value of ScriptPolicyID.
|
||||||
func (s *ScriptPolicyID) GetScriptPolicyID() uint64 {
|
func (s *ScriptPolicyID) GetScriptPolicyID() int64 {
|
||||||
return s.ScriptPolicyID
|
return s.ScriptPolicyID
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetScriptPolicyID sets the value of ScriptPolicyID.
|
// SetScriptPolicyID sets the value of ScriptPolicyID.
|
||||||
func (s *ScriptPolicyID) SetScriptPolicyID(val uint64) {
|
func (s *ScriptPolicyID) SetScriptPolicyID(val int64) {
|
||||||
s.ScriptPolicyID = val
|
s.ScriptPolicyID = val
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ref: #/components/schemas/SubmissionCreate
|
// Ref: #/components/schemas/SubmissionCreate
|
||||||
type SubmissionCreate struct {
|
type SubmissionCreate struct {
|
||||||
OperationID uint32 `json:"OperationID"`
|
OperationID int32 `json:"OperationID"`
|
||||||
AssetOwner uint64 `json:"AssetOwner"`
|
AssetOwner int64 `json:"AssetOwner"`
|
||||||
DisplayName string `json:"DisplayName"`
|
DisplayName string `json:"DisplayName"`
|
||||||
Creator string `json:"Creator"`
|
Creator string `json:"Creator"`
|
||||||
GameID uint32 `json:"GameID"`
|
GameID int32 `json:"GameID"`
|
||||||
AssetID uint64 `json:"AssetID"`
|
AssetID int64 `json:"AssetID"`
|
||||||
AssetVersion uint64 `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.
|
||||||
func (s *SubmissionCreate) GetOperationID() uint32 {
|
func (s *SubmissionCreate) GetOperationID() int32 {
|
||||||
return s.OperationID
|
return s.OperationID
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetAssetOwner returns the value of AssetOwner.
|
// GetAssetOwner returns the value of AssetOwner.
|
||||||
func (s *SubmissionCreate) GetAssetOwner() uint64 {
|
func (s *SubmissionCreate) GetAssetOwner() int64 {
|
||||||
return s.AssetOwner
|
return s.AssetOwner
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -600,27 +670,37 @@ func (s *SubmissionCreate) GetCreator() string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// GetGameID returns the value of GameID.
|
// GetGameID returns the value of GameID.
|
||||||
func (s *SubmissionCreate) GetGameID() uint32 {
|
func (s *SubmissionCreate) GetGameID() int32 {
|
||||||
return s.GameID
|
return s.GameID
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetAssetID returns the value of AssetID.
|
// GetAssetID returns the value of AssetID.
|
||||||
func (s *SubmissionCreate) GetAssetID() uint64 {
|
func (s *SubmissionCreate) GetAssetID() int64 {
|
||||||
return s.AssetID
|
return s.AssetID
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetAssetVersion returns the value of AssetVersion.
|
// GetAssetVersion returns the value of AssetVersion.
|
||||||
func (s *SubmissionCreate) GetAssetVersion() uint64 {
|
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 uint32) {
|
func (s *SubmissionCreate) SetOperationID(val int32) {
|
||||||
s.OperationID = val
|
s.OperationID = val
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetAssetOwner sets the value of AssetOwner.
|
// SetAssetOwner sets the value of AssetOwner.
|
||||||
func (s *SubmissionCreate) SetAssetOwner(val uint64) {
|
func (s *SubmissionCreate) SetAssetOwner(val int64) {
|
||||||
s.AssetOwner = val
|
s.AssetOwner = val
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -635,32 +715,42 @@ func (s *SubmissionCreate) SetCreator(val string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// SetGameID sets the value of GameID.
|
// SetGameID sets the value of GameID.
|
||||||
func (s *SubmissionCreate) SetGameID(val uint32) {
|
func (s *SubmissionCreate) SetGameID(val int32) {
|
||||||
s.GameID = val
|
s.GameID = val
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetAssetID sets the value of AssetID.
|
// SetAssetID sets the value of AssetID.
|
||||||
func (s *SubmissionCreate) SetAssetID(val uint64) {
|
func (s *SubmissionCreate) SetAssetID(val int64) {
|
||||||
s.AssetID = val
|
s.AssetID = val
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetAssetVersion sets the value of AssetVersion.
|
// SetAssetVersion sets the value of AssetVersion.
|
||||||
func (s *SubmissionCreate) SetAssetVersion(val uint64) {
|
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 uint64 `json:"SubmissionID"`
|
SubmissionID int64 `json:"SubmissionID"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetSubmissionID returns the value of SubmissionID.
|
// GetSubmissionID returns the value of SubmissionID.
|
||||||
func (s *SubmissionID) GetSubmissionID() uint64 {
|
func (s *SubmissionID) GetSubmissionID() int64 {
|
||||||
return s.SubmissionID
|
return s.SubmissionID
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetSubmissionID sets the value of SubmissionID.
|
// SetSubmissionID sets the value of SubmissionID.
|
||||||
func (s *SubmissionID) SetSubmissionID(val uint64) {
|
func (s *SubmissionID) SetSubmissionID(val int64) {
|
||||||
s.SubmissionID = val
|
s.SubmissionID = val
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -14,6 +14,12 @@ 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.
|
// ActionMapfixSubmitted implements actionMapfixSubmitted operation.
|
||||||
//
|
//
|
||||||
// (Internal endpoint) Role Validator changes status from Submitting -> Submitted.
|
// (Internal endpoint) Role Validator changes status from Submitting -> Submitted.
|
||||||
@@ -44,6 +50,12 @@ 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.
|
// ActionSubmissionSubmitted implements actionSubmissionSubmitted operation.
|
||||||
//
|
//
|
||||||
// (Internal endpoint) Role Validator changes status from Submitting -> Submitted.
|
// (Internal endpoint) Role Validator changes status from Submitting -> Submitted.
|
||||||
@@ -68,6 +80,18 @@ 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.
|
||||||
@@ -86,6 +110,18 @@ 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,6 +22,15 @@ 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.
|
// ActionMapfixSubmitted implements actionMapfixSubmitted operation.
|
||||||
//
|
//
|
||||||
// (Internal endpoint) Role Validator changes status from Submitting -> Submitted.
|
// (Internal endpoint) Role Validator changes status from Submitting -> Submitted.
|
||||||
@@ -67,6 +76,15 @@ 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.
|
// ActionSubmissionSubmitted implements actionSubmissionSubmitted operation.
|
||||||
//
|
//
|
||||||
// (Internal endpoint) Role Validator changes status from Submitting -> Submitted.
|
// (Internal endpoint) Role Validator changes status from Submitting -> Submitted.
|
||||||
@@ -103,6 +121,24 @@ 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.
|
||||||
@@ -130,6 +166,24 @@ 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,11 +3,88 @@
|
|||||||
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 {
|
func (s *Error) Validate() error {
|
||||||
if s == nil {
|
if s == nil {
|
||||||
return validate.ErrNilPointer
|
return validate.ErrNilPointer
|
||||||
@@ -227,6 +304,25 @@ func (s *MapfixCreate) Validate() error {
|
|||||||
Error: err,
|
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 {
|
if len(failures) > 0 {
|
||||||
return &validate.Error{Fields: failures}
|
return &validate.Error{Fields: failures}
|
||||||
}
|
}
|
||||||
@@ -862,6 +958,26 @@ func (s *SubmissionCreate) Validate() error {
|
|||||||
Error: err,
|
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 {
|
if len(failures) > 0 {
|
||||||
return &validate.Error{Fields: failures}
|
return &validate.Error{Fields: failures}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
type AuditEventType uint32
|
type AuditEventType int32
|
||||||
|
|
||||||
// User clicked "Submit", "Accept" etc
|
// User clicked "Submit", "Accept" etc
|
||||||
const AuditEventTypeAction AuditEventType = 0
|
const AuditEventTypeAction AuditEventType = 0
|
||||||
@@ -42,12 +42,31 @@ type AuditEventDataChangeName struct {
|
|||||||
NewName string `json:"new_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 {
|
type AuditEvent struct {
|
||||||
ID uint64 `gorm:"primaryKey"`
|
ID int64 `gorm:"primaryKey"`
|
||||||
CreatedAt time.Time
|
CreatedAt time.Time
|
||||||
User uint64
|
User uint64
|
||||||
ResourceType ResourceType // is this a submission or is it a mapfix
|
ResourceType ResourceType // is this a submission or is it a mapfix
|
||||||
ResourceID uint64 // submission / mapfix / map ID
|
ResourceID int64 // submission / mapfix / map ID
|
||||||
EventType AuditEventType
|
EventType AuditEventType
|
||||||
EventData json.RawMessage `gorm:"type:jsonb"`
|
EventData json.RawMessage `gorm:"type:jsonb"`
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ package model
|
|||||||
|
|
||||||
import "time"
|
import "time"
|
||||||
|
|
||||||
type MapfixStatus uint32
|
type MapfixStatus int32
|
||||||
|
|
||||||
const (
|
const (
|
||||||
// Phase: Creation
|
// Phase: Creation
|
||||||
@@ -25,7 +25,7 @@ const (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type Mapfix struct {
|
type Mapfix struct {
|
||||||
ID uint64 `gorm:"primaryKey"`
|
ID int64 `gorm:"primaryKey"`
|
||||||
DisplayName string
|
DisplayName string
|
||||||
Creator string
|
Creator string
|
||||||
GameID uint32
|
GameID uint32
|
||||||
@@ -39,5 +39,5 @@ type Mapfix struct {
|
|||||||
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 uint64 // where to upload map fix. if the TargetAssetID is 0, it's a new map.
|
||||||
StatusID MapfixStatus
|
StatusID MapfixStatus
|
||||||
StatusMessage string
|
Description string // mapfix description
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,26 +7,45 @@ 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 uint32
|
OperationID int32
|
||||||
ModelID uint64
|
ModelID uint64
|
||||||
|
DisplayName string
|
||||||
|
Creator string
|
||||||
|
GameID uint32
|
||||||
|
Status uint32
|
||||||
|
Roles uint32
|
||||||
}
|
}
|
||||||
|
|
||||||
type CreateMapfixRequest struct {
|
type CreateMapfixRequest struct {
|
||||||
OperationID uint32
|
OperationID int32
|
||||||
ModelID uint64
|
ModelID uint64
|
||||||
TargetAssetID uint64
|
TargetAssetID uint64
|
||||||
|
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 uint64
|
SubmissionID int64
|
||||||
ModelID uint64
|
ModelID uint64
|
||||||
ModelVersion uint64
|
ModelVersion uint64
|
||||||
ValidatedModelID *uint64 // optional value
|
ValidatedModelID *uint64 // optional value
|
||||||
}
|
}
|
||||||
|
|
||||||
type ValidateMapfixRequest struct {
|
type ValidateMapfixRequest struct {
|
||||||
MapfixID uint64
|
MapfixID int64
|
||||||
ModelID uint64
|
ModelID uint64
|
||||||
ModelVersion uint64
|
ModelVersion uint64
|
||||||
ValidatedModelID *uint64 // optional value
|
ValidatedModelID *uint64 // optional value
|
||||||
@@ -34,14 +53,14 @@ type ValidateMapfixRequest struct {
|
|||||||
|
|
||||||
// Create a new map
|
// Create a new map
|
||||||
type UploadSubmissionRequest struct {
|
type UploadSubmissionRequest struct {
|
||||||
SubmissionID uint64
|
SubmissionID int64
|
||||||
ModelID uint64
|
ModelID uint64
|
||||||
ModelVersion uint64
|
ModelVersion uint64
|
||||||
ModelName string
|
ModelName string
|
||||||
}
|
}
|
||||||
|
|
||||||
type UploadMapfixRequest struct {
|
type UploadMapfixRequest struct {
|
||||||
MapfixID uint64
|
MapfixID int64
|
||||||
ModelID uint64
|
ModelID uint64
|
||||||
ModelVersion uint64
|
ModelVersion uint64
|
||||||
TargetAssetID uint64
|
TargetAssetID uint64
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ package model
|
|||||||
|
|
||||||
import "time"
|
import "time"
|
||||||
|
|
||||||
type OperationStatus uint32
|
type OperationStatus int32
|
||||||
const (
|
const (
|
||||||
OperationStatusCreated OperationStatus = 0
|
OperationStatusCreated OperationStatus = 0
|
||||||
OperationStatusCompleted OperationStatus = 1
|
OperationStatusCompleted OperationStatus = 1
|
||||||
@@ -10,7 +10,7 @@ const (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type Operation struct {
|
type Operation struct {
|
||||||
ID uint32 `gorm:"primaryKey"`
|
ID int32 `gorm:"primaryKey"`
|
||||||
CreatedAt time.Time
|
CreatedAt time.Time
|
||||||
Owner uint64 // UserID
|
Owner uint64 // UserID
|
||||||
StatusID OperationStatus
|
StatusID OperationStatus
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
package model
|
package model
|
||||||
|
|
||||||
type Page struct {
|
type Page struct {
|
||||||
Number uint32
|
Number int32
|
||||||
Size uint32
|
Size int32
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ package model
|
|||||||
|
|
||||||
import "time"
|
import "time"
|
||||||
|
|
||||||
type Policy uint32
|
type Policy int32
|
||||||
|
|
||||||
const (
|
const (
|
||||||
ScriptPolicyNone Policy = 0 // not yet reviewed
|
ScriptPolicyNone Policy = 0 // not yet reviewed
|
||||||
@@ -13,15 +13,16 @@ const (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type ScriptPolicy struct {
|
type ScriptPolicy struct {
|
||||||
ID uint64 `gorm:"primaryKey"`
|
ID int64 `gorm:"primaryKey"`
|
||||||
// Hash of the source code that leads to this policy.
|
// Hash of the source code that leads to this policy.
|
||||||
// If this is a replacement mapping, the original source may not be pointed to by any policy.
|
// If this is a replacement mapping, the original source may not be pointed to by any policy.
|
||||||
// The original source should still exist in the scripts table, which can be located by the same hash.
|
// The original source should still exist in the scripts table, which can be located by the same hash.
|
||||||
FromScriptHash int64 // postgres does not support unsigned integers, so we have to pretend
|
// postgres does not support unsigned integers, so we have to manually pretend this is an unsigned integer
|
||||||
|
FromScriptHash int64 `gorm:"uniqueIndex;constraint:fk_script_policies_from_script_hash,onUpdate:NO ACTION,onDelete:NO ACTION;foreignKey:FromScriptHash;references:Hash"`
|
||||||
// The ID of the replacement source (ScriptPolicyReplace)
|
// The ID of the replacement source (ScriptPolicyReplace)
|
||||||
// or verbatim source (ScriptPolicyAllowed)
|
// or verbatim source (ScriptPolicyAllowed)
|
||||||
// or 0 (other)
|
// or 0 (other)
|
||||||
ToScriptID uint64
|
ToScriptID int64 `gorm:"constraint:fk_script_policies_to_script_id,onUpdate:NO ACTION,onDelete:NO ACTION;foreignKey:ToScriptID;references:ID"`
|
||||||
Policy Policy
|
Policy Policy
|
||||||
CreatedAt time.Time
|
CreatedAt time.Time
|
||||||
UpdatedAt time.Time
|
UpdatedAt time.Time
|
||||||
|
|||||||
13
pkg/model/resource.go
Normal file
13
pkg/model/resource.go
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
package model
|
||||||
|
|
||||||
|
type ResourceType int32
|
||||||
|
const (
|
||||||
|
ResourceUnknown ResourceType = 0
|
||||||
|
ResourceMapfix ResourceType = 1
|
||||||
|
ResourceSubmission ResourceType = 2
|
||||||
|
)
|
||||||
|
|
||||||
|
type Resource struct{
|
||||||
|
ID int64
|
||||||
|
Type ResourceType
|
||||||
|
}
|
||||||
@@ -23,25 +23,14 @@ func HashParse(hash string) (uint64, error){
|
|||||||
return strconv.ParseUint(hash, 16, 64)
|
return strconv.ParseUint(hash, 16, 64)
|
||||||
}
|
}
|
||||||
|
|
||||||
type ResourceType uint32
|
|
||||||
const (
|
|
||||||
ResourceUnknown ResourceType = 0
|
|
||||||
ResourceMapfix ResourceType = 1
|
|
||||||
ResourceSubmission ResourceType = 2
|
|
||||||
)
|
|
||||||
|
|
||||||
type Script struct {
|
type Script struct {
|
||||||
ID uint64 `gorm:"primaryKey"`
|
ID int64 `gorm:"primaryKey"`
|
||||||
Name string
|
Name string
|
||||||
hash uint64
|
// postgres does not support unsigned integers, so we have to pretend
|
||||||
|
Hash int64 `gorm:"uniqueIndex;constraint:fk_script_hash,onUpdate:CASCADE,onDelete:CASCADE;foreignKey:Hash;references:FromScriptHash"`
|
||||||
Source string
|
Source string
|
||||||
ResourceType ResourceType // is this a submission or is it a mapfix
|
ResourceType ResourceType // is this a submission or is it a mapfix
|
||||||
ResourceID uint64 // which submission / mapfix did this script first appear in
|
ResourceID int64 // which submission / mapfix did this script first appear in
|
||||||
CreatedAt time.Time
|
CreatedAt time.Time
|
||||||
UpdatedAt time.Time
|
UpdatedAt time.Time
|
||||||
}
|
}
|
||||||
|
|
||||||
// postgres does not support unsigned integers, so we have to pretend
|
|
||||||
func (script *Script) GetPostgresInt64() (int64) {
|
|
||||||
return int64(script.hash)
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ package model
|
|||||||
|
|
||||||
import "time"
|
import "time"
|
||||||
|
|
||||||
type SubmissionStatus uint32
|
type SubmissionStatus int32
|
||||||
|
|
||||||
const (
|
const (
|
||||||
// Phase: Creation
|
// Phase: Creation
|
||||||
@@ -26,7 +26,7 @@ const (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type Submission struct {
|
type Submission struct {
|
||||||
ID uint64 `gorm:"primaryKey"`
|
ID int64 `gorm:"primaryKey"`
|
||||||
DisplayName string
|
DisplayName string
|
||||||
Creator string
|
Creator string
|
||||||
GameID uint32
|
GameID uint32
|
||||||
@@ -40,5 +40,4 @@ type Submission struct {
|
|||||||
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 uint64 // where to upload map fix. if the TargetAssetID is 0, it's a new map.
|
||||||
StatusID SubmissionStatus
|
StatusID SubmissionStatus
|
||||||
StatusMessage string
|
|
||||||
}
|
}
|
||||||
|
|||||||
72
pkg/roblox/asset_location.go
Normal file
72
pkg/roblox/asset_location.go
Normal file
@@ -0,0 +1,72 @@
|
|||||||
|
package roblox
|
||||||
|
|
||||||
|
import (
|
||||||
|
"encoding/json"
|
||||||
|
"fmt"
|
||||||
|
"net/http"
|
||||||
|
"net/url"
|
||||||
|
"io"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Struct equivalent to Rust's AssetLocationInfo
|
||||||
|
type AssetLocationInfo struct {
|
||||||
|
Location string `json:"location"`
|
||||||
|
RequestId string `json:"requestId"`
|
||||||
|
IsHashDynamic bool `json:"IsHashDynamic"`
|
||||||
|
IsCopyrightProtected bool `json:"IsCopyrightProtected"`
|
||||||
|
IsArchived bool `json:"isArchived"`
|
||||||
|
AssetTypeId uint32 `json:"assetTypeId"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// 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
|
||||||
|
}
|
||||||
@@ -4,46 +4,71 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
|
||||||
|
"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/model"
|
"git.itzana.me/strafesnet/maps-service/pkg/model"
|
||||||
)
|
)
|
||||||
|
|
||||||
// CreateMapfixAuditComment implements createMapfixAuditComment operation.
|
func (svc *Service) ListAuditEvents(ctx context.Context, resource model.Resource, page model.Page) ([]api.AuditEvent, error){
|
||||||
//
|
filter := datastore.Optional()
|
||||||
// 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()
|
filter.Add("resource_type", resource.Type)
|
||||||
|
filter.Add("resource_id", resource.ID)
|
||||||
|
|
||||||
|
items, err := svc.DB.AuditEvents().List(ctx, filter, page)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return nil, err
|
||||||
}
|
|
||||||
if !has_role {
|
|
||||||
return ErrPermissionDeniedNeedRoleMapfixReview
|
|
||||||
}
|
}
|
||||||
|
|
||||||
userId, err := userInfo.GetUserID()
|
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 {
|
if err != nil {
|
||||||
return err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
data := []byte{}
|
userMap := make(map[int64]*users.UserResponse)
|
||||||
_, err = req.Read(data)
|
for _,user := range userList.Users {
|
||||||
if err != nil {
|
userMap[user.ID] = user
|
||||||
return err
|
|
||||||
}
|
|
||||||
Comment := string(data)
|
|
||||||
|
|
||||||
event_data := model.AuditEventDataComment{
|
|
||||||
Comment: Comment,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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)
|
EventData, err := json.Marshal(event_data)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@@ -52,8 +77,29 @@ func (svc *Service) CreateMapfixAuditComment(ctx context.Context, req api.Create
|
|||||||
_, err = svc.DB.AuditEvents().Create(ctx, model.AuditEvent{
|
_, err = svc.DB.AuditEvents().Create(ctx, model.AuditEvent{
|
||||||
ID: 0,
|
ID: 0,
|
||||||
User: userId,
|
User: userId,
|
||||||
ResourceType: model.ResourceMapfix,
|
ResourceType: resource.Type,
|
||||||
ResourceID: params.MapfixID,
|
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,
|
EventType: model.AuditEventTypeComment,
|
||||||
EventData: EventData,
|
EventData: EventData,
|
||||||
})
|
})
|
||||||
@@ -64,81 +110,7 @@ func (svc *Service) CreateMapfixAuditComment(ctx context.Context, req api.Create
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// ListMapfixAuditEvents invokes listMapfixAuditEvents operation.
|
func (svc *Service) CreateAuditEventChangeModel(ctx context.Context, userId uint64, resource model.Resource, event_data model.AuditEventDataChangeModel) error {
|
||||||
//
|
|
||||||
// Retrieve a list of audit events.
|
|
||||||
//
|
|
||||||
// GET /mapfixes/{MapfixID}/audit-events
|
|
||||||
func (svc *Service) ListMapfixAuditEvents(ctx context.Context, params api.ListMapfixAuditEventsParams) ([]api.AuditEvent, error) {
|
|
||||||
filter := datastore.Optional()
|
|
||||||
|
|
||||||
filter.AddPostgresInt32("resource_type", uint32(model.ResourceMapfix))
|
|
||||||
filter.AddPostgresInt64("resource_id", params.MapfixID)
|
|
||||||
|
|
||||||
items, err := svc.DB.AuditEvents().List(ctx, filter, model.Page{
|
|
||||||
Number: params.Page,
|
|
||||||
Size: params.Limit,
|
|
||||||
})
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
var resp []api.AuditEvent
|
|
||||||
for _, item := range items {
|
|
||||||
EventData := api.AuditEventEventData{}
|
|
||||||
err = EventData.UnmarshalJSON(item.EventData)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
resp = append(resp, api.AuditEvent{
|
|
||||||
ID: item.ID,
|
|
||||||
Date: item.CreatedAt.Unix(),
|
|
||||||
User: item.User,
|
|
||||||
ResourceType: uint32(item.ResourceType),
|
|
||||||
ResourceID: item.ResourceID,
|
|
||||||
EventType: uint32(item.EventType),
|
|
||||||
EventData: EventData,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
return resp, 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
|
|
||||||
}
|
|
||||||
if !has_role {
|
|
||||||
return ErrPermissionDeniedNeedRoleSubmissionReview
|
|
||||||
}
|
|
||||||
|
|
||||||
userId, err := userInfo.GetUserID()
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
data := []byte{}
|
|
||||||
_, err = req.Read(data)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
Comment := string(data)
|
|
||||||
|
|
||||||
event_data := model.AuditEventDataComment{
|
|
||||||
Comment: Comment,
|
|
||||||
}
|
|
||||||
|
|
||||||
EventData, err := json.Marshal(event_data)
|
EventData, err := json.Marshal(event_data)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@@ -147,9 +119,9 @@ func (svc *Service) CreateSubmissionAuditComment(ctx context.Context, req api.Cr
|
|||||||
_, err = svc.DB.AuditEvents().Create(ctx, model.AuditEvent{
|
_, err = svc.DB.AuditEvents().Create(ctx, model.AuditEvent{
|
||||||
ID: 0,
|
ID: 0,
|
||||||
User: userId,
|
User: userId,
|
||||||
ResourceType: model.ResourceSubmission,
|
ResourceType: resource.Type,
|
||||||
ResourceID: params.SubmissionID,
|
ResourceID: resource.ID,
|
||||||
EventType: model.AuditEventTypeComment,
|
EventType: model.AuditEventTypeChangeModel,
|
||||||
EventData: EventData,
|
EventData: EventData,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -158,43 +130,3 @@ func (svc *Service) CreateSubmissionAuditComment(ctx context.Context, req api.Cr
|
|||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// 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) {
|
|
||||||
filter := datastore.Optional()
|
|
||||||
|
|
||||||
filter.AddPostgresInt32("resource_type", uint32(model.ResourceSubmission))
|
|
||||||
filter.AddPostgresInt64("resource_id", params.SubmissionID)
|
|
||||||
|
|
||||||
items, err := svc.DB.AuditEvents().List(ctx, filter, model.Page{
|
|
||||||
Number: params.Page,
|
|
||||||
Size: params.Limit,
|
|
||||||
})
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
var resp []api.AuditEvent
|
|
||||||
for _, item := range items {
|
|
||||||
EventData := api.AuditEventEventData{}
|
|
||||||
err = EventData.UnmarshalJSON(item.EventData)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
resp = append(resp, api.AuditEvent{
|
|
||||||
ID: item.ID,
|
|
||||||
Date: item.CreatedAt.Unix(),
|
|
||||||
User: item.User,
|
|
||||||
ResourceType: uint32(item.ResourceType),
|
|
||||||
ResourceID: item.ResourceID,
|
|
||||||
EventType: uint32(item.EventType),
|
|
||||||
EventData: EventData,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
return resp, nil
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ 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"
|
||||||
@@ -65,7 +66,7 @@ func (svc *Service) CreateMapfix(ctx context.Context, request *api.MapfixTrigger
|
|||||||
filter.Add("status_id", CreationPhaseMapfixStatuses)
|
filter.Add("status_id", CreationPhaseMapfixStatuses)
|
||||||
creation_mapfixes, err := svc.DB.Mapfixes().List(ctx, filter, model.Page{
|
creation_mapfixes, err := svc.DB.Mapfixes().List(ctx, filter, model.Page{
|
||||||
Number: 1,
|
Number: 1,
|
||||||
Size: uint32(CreationPhaseMapfixesLimit),
|
Size: int32(CreationPhaseMapfixesLimit),
|
||||||
},datastore.ListSortDisabled)
|
},datastore.ListSortDisabled)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@@ -78,7 +79,7 @@ func (svc *Service) CreateMapfix(ctx context.Context, request *api.MapfixTrigger
|
|||||||
|
|
||||||
// Check if TargetAssetID actually exists
|
// Check if TargetAssetID actually exists
|
||||||
{
|
{
|
||||||
_, err := svc.Client.Get(ctx, &maps.IdMessage{
|
_, err := svc.Maps.Get(ctx, &maps.IdMessage{
|
||||||
ID: request.TargetAssetID,
|
ID: request.TargetAssetID,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -114,6 +115,7 @@ func (svc *Service) CreateMapfix(ctx context.Context, request *api.MapfixTrigger
|
|||||||
OperationID: operation.ID,
|
OperationID: operation.ID,
|
||||||
ModelID: ModelID,
|
ModelID: ModelID,
|
||||||
TargetAssetID: TargetAssetID,
|
TargetAssetID: TargetAssetID,
|
||||||
|
Description: request.Description,
|
||||||
}
|
}
|
||||||
|
|
||||||
j, err := json.Marshal(create_request)
|
j, err := json.Marshal(create_request)
|
||||||
@@ -137,7 +139,7 @@ func (svc *Service) CreateMapfix(ctx context.Context, request *api.MapfixTrigger
|
|||||||
//
|
//
|
||||||
// GET /mapfixes/{MapfixID}
|
// GET /mapfixes/{MapfixID}
|
||||||
func (svc *Service) GetMapfix(ctx context.Context, params api.GetMapfixParams) (*api.Mapfix, error) {
|
func (svc *Service) GetMapfix(ctx context.Context, params api.GetMapfixParams) (*api.Mapfix, error) {
|
||||||
mapfix, err := svc.DB.Mapfixes().Get(ctx, int64(params.MapfixID))
|
mapfix, err := svc.DB.Mapfixes().Get(ctx, params.MapfixID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -145,16 +147,16 @@ 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: uint32(mapfix.GameID),
|
GameID: int32(mapfix.GameID),
|
||||||
CreatedAt: mapfix.CreatedAt.Unix(),
|
CreatedAt: mapfix.CreatedAt.Unix(),
|
||||||
UpdatedAt: mapfix.UpdatedAt.Unix(),
|
UpdatedAt: mapfix.UpdatedAt.Unix(),
|
||||||
Submitter: mapfix.Submitter,
|
Submitter: int64(mapfix.Submitter),
|
||||||
AssetID: mapfix.AssetID,
|
AssetID: int64(mapfix.AssetID),
|
||||||
AssetVersion: mapfix.AssetVersion,
|
AssetVersion: int64(mapfix.AssetVersion),
|
||||||
Completed: mapfix.Completed,
|
Completed: mapfix.Completed,
|
||||||
TargetAssetID: mapfix.TargetAssetID,
|
TargetAssetID: int64(mapfix.TargetAssetID),
|
||||||
StatusID: uint32(mapfix.StatusID),
|
StatusID: int32(mapfix.StatusID),
|
||||||
StatusMessage: mapfix.StatusMessage,
|
Description: mapfix.Description,
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -167,28 +169,28 @@ func (svc *Service) ListMapfixes(ctx context.Context, params api.ListMapfixesPar
|
|||||||
filter := datastore.Optional()
|
filter := datastore.Optional()
|
||||||
|
|
||||||
if params.DisplayName.IsSet(){
|
if params.DisplayName.IsSet(){
|
||||||
filter.Add2("display_name", params.DisplayName.Value)
|
filter.Add("display_name", params.DisplayName.Value)
|
||||||
}
|
}
|
||||||
if params.Creator.IsSet(){
|
if params.Creator.IsSet(){
|
||||||
filter.Add2("creator", params.Creator.Value)
|
filter.Add("creator", params.Creator.Value)
|
||||||
}
|
}
|
||||||
if params.GameID.IsSet(){
|
if params.GameID.IsSet(){
|
||||||
filter.AddPostgresInt32("game_id", params.GameID.Value)
|
filter.Add("game_id", params.GameID.Value)
|
||||||
}
|
}
|
||||||
if params.Submitter.IsSet(){
|
if params.Submitter.IsSet(){
|
||||||
filter.AddPostgresInt64("submitter", params.Submitter.Value)
|
filter.Add("submitter", params.Submitter.Value)
|
||||||
}
|
}
|
||||||
if params.AssetID.IsSet(){
|
if params.AssetID.IsSet(){
|
||||||
filter.AddPostgresInt64("asset_id", params.AssetID.Value)
|
filter.Add("asset_id", params.AssetID.Value)
|
||||||
}
|
}
|
||||||
if params.TargetAssetID.IsSet(){
|
if params.TargetAssetID.IsSet(){
|
||||||
filter.AddPostgresInt64("target_asset_id", params.TargetAssetID.Value)
|
filter.Add("target_asset_id", params.TargetAssetID.Value)
|
||||||
}
|
}
|
||||||
if params.StatusID.IsSet(){
|
if params.StatusID.IsSet(){
|
||||||
filter.AddPostgresInt32("status_id", params.StatusID.Value)
|
filter.Add("status_id", params.StatusID.Value)
|
||||||
}
|
}
|
||||||
|
|
||||||
sort := datastore.ListSort(params.Sort.Or(uint32(datastore.ListSortDisabled)))
|
sort := datastore.ListSort(params.Sort.Or(int32(datastore.ListSortDisabled)))
|
||||||
|
|
||||||
total, items, err := svc.DB.Mapfixes().ListWithTotal(ctx, filter, model.Page{
|
total, items, err := svc.DB.Mapfixes().ListWithTotal(ctx, filter, model.Page{
|
||||||
Number: params.Page,
|
Number: params.Page,
|
||||||
@@ -205,15 +207,16 @@ func (svc *Service) ListMapfixes(ctx context.Context, params api.ListMapfixesPar
|
|||||||
ID: item.ID,
|
ID: item.ID,
|
||||||
DisplayName: item.DisplayName,
|
DisplayName: item.DisplayName,
|
||||||
Creator: item.Creator,
|
Creator: item.Creator,
|
||||||
GameID: item.GameID,
|
GameID: int32(item.GameID),
|
||||||
CreatedAt: item.CreatedAt.Unix(),
|
CreatedAt: item.CreatedAt.Unix(),
|
||||||
UpdatedAt: item.UpdatedAt.Unix(),
|
UpdatedAt: item.UpdatedAt.Unix(),
|
||||||
Submitter: item.Submitter,
|
Submitter: int64(item.Submitter),
|
||||||
AssetID: item.AssetID,
|
AssetID: int64(item.AssetID),
|
||||||
AssetVersion: item.AssetVersion,
|
AssetVersion: int64(item.AssetVersion),
|
||||||
Completed: item.Completed,
|
Completed: item.Completed,
|
||||||
TargetAssetID: item.TargetAssetID,
|
TargetAssetID: int64(item.TargetAssetID),
|
||||||
StatusID: uint32(item.StatusID),
|
StatusID: int32(item.StatusID),
|
||||||
|
Description: item.Description,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -296,24 +299,15 @@ func (svc *Service) UpdateMapfixModel(ctx context.Context, params api.UpdateMapf
|
|||||||
NewModelVersion: NewModelVersion,
|
NewModelVersion: NewModelVersion,
|
||||||
}
|
}
|
||||||
|
|
||||||
EventData, err := json.Marshal(event_data)
|
return svc.CreateAuditEventChangeModel(
|
||||||
if err != nil {
|
ctx,
|
||||||
return err
|
userId,
|
||||||
}
|
model.Resource{
|
||||||
|
ID: params.MapfixID,
|
||||||
_, err = svc.DB.AuditEvents().Create(ctx, model.AuditEvent{
|
Type: model.ResourceMapfix,
|
||||||
ID: 0,
|
},
|
||||||
User: userId,
|
event_data,
|
||||||
ResourceType: model.ResourceMapfix,
|
)
|
||||||
ResourceID: params.MapfixID,
|
|
||||||
EventType: model.AuditEventTypeChangeModel,
|
|
||||||
EventData: EventData,
|
|
||||||
})
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ActionMapfixReject invokes actionMapfixReject operation.
|
// ActionMapfixReject invokes actionMapfixReject operation.
|
||||||
@@ -354,24 +348,15 @@ func (svc *Service) ActionMapfixReject(ctx context.Context, params api.ActionMap
|
|||||||
TargetStatus: uint32(target_status),
|
TargetStatus: uint32(target_status),
|
||||||
}
|
}
|
||||||
|
|
||||||
EventData, err := json.Marshal(event_data)
|
return svc.CreateAuditEventAction(
|
||||||
if err != nil {
|
ctx,
|
||||||
return err
|
userId,
|
||||||
}
|
model.Resource{
|
||||||
|
ID: params.MapfixID,
|
||||||
_, err = svc.DB.AuditEvents().Create(ctx, model.AuditEvent{
|
Type: model.ResourceMapfix,
|
||||||
ID: 0,
|
},
|
||||||
User: userId,
|
event_data,
|
||||||
ResourceType: model.ResourceMapfix,
|
)
|
||||||
ResourceID: params.MapfixID,
|
|
||||||
EventType: model.AuditEventTypeAction,
|
|
||||||
EventData: EventData,
|
|
||||||
})
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ActionMapfixRequestChanges invokes actionMapfixRequestChanges operation.
|
// ActionMapfixRequestChanges invokes actionMapfixRequestChanges operation.
|
||||||
@@ -394,10 +379,33 @@ func (svc *Service) ActionMapfixRequestChanges(ctx context.Context, params api.A
|
|||||||
return ErrPermissionDeniedNeedRoleMapfixReview
|
return ErrPermissionDeniedNeedRoleMapfixReview
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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", model.MapfixStatusChangesRequested)
|
smap.Add("status_id", target_status)
|
||||||
return svc.DB.Mapfixes().IfStatusThenUpdate(ctx, params.MapfixID, []model.MapfixStatus{model.MapfixStatusValidated, model.MapfixStatusAcceptedUnvalidated, model.MapfixStatusSubmitted}, smap)
|
err = svc.DB.Mapfixes().IfStatusThenUpdate(ctx, params.MapfixID, []model.MapfixStatus{model.MapfixStatusValidated, model.MapfixStatusAcceptedUnvalidated, 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.
|
||||||
@@ -441,24 +449,15 @@ func (svc *Service) ActionMapfixRevoke(ctx context.Context, params api.ActionMap
|
|||||||
TargetStatus: uint32(target_status),
|
TargetStatus: uint32(target_status),
|
||||||
}
|
}
|
||||||
|
|
||||||
EventData, err := json.Marshal(event_data)
|
return svc.CreateAuditEventAction(
|
||||||
if err != nil {
|
ctx,
|
||||||
return err
|
userId,
|
||||||
}
|
model.Resource{
|
||||||
|
ID: params.MapfixID,
|
||||||
_, err = svc.DB.AuditEvents().Create(ctx, model.AuditEvent{
|
Type: model.ResourceMapfix,
|
||||||
ID: 0,
|
},
|
||||||
User: userId,
|
event_data,
|
||||||
ResourceType: model.ResourceMapfix,
|
)
|
||||||
ResourceID: params.MapfixID,
|
|
||||||
EventType: model.AuditEventTypeAction,
|
|
||||||
EventData: EventData,
|
|
||||||
})
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ActionMapfixTriggerSubmit invokes actionMapfixTriggerSubmit operation.
|
// ActionMapfixTriggerSubmit invokes actionMapfixTriggerSubmit operation.
|
||||||
@@ -490,7 +489,7 @@ func (svc *Service) ActionMapfixTriggerSubmit(ctx context.Context, params api.Ac
|
|||||||
}
|
}
|
||||||
|
|
||||||
// transaction
|
// transaction
|
||||||
target_status := model.MapfixStatusSubmitted
|
target_status := model.MapfixStatusSubmitting
|
||||||
smap := datastore.Optional()
|
smap := datastore.Optional()
|
||||||
smap.Add("status_id", target_status)
|
smap.Add("status_id", target_status)
|
||||||
err = svc.DB.Mapfixes().IfStatusThenUpdate(ctx, params.MapfixID, []model.MapfixStatus{model.MapfixStatusUnderConstruction, model.MapfixStatusChangesRequested}, smap)
|
err = svc.DB.Mapfixes().IfStatusThenUpdate(ctx, params.MapfixID, []model.MapfixStatus{model.MapfixStatusUnderConstruction, model.MapfixStatusChangesRequested}, smap)
|
||||||
@@ -498,28 +497,112 @@ func (svc *Service) ActionMapfixTriggerSubmit(ctx context.Context, params api.Ac
|
|||||||
return err
|
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{
|
event_data := model.AuditEventDataAction{
|
||||||
TargetStatus: uint32(target_status),
|
TargetStatus: uint32(target_status),
|
||||||
}
|
}
|
||||||
|
|
||||||
EventData, err := json.Marshal(event_data)
|
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 {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err = svc.DB.AuditEvents().Create(ctx, model.AuditEvent{
|
userId, err := userInfo.GetUserID()
|
||||||
ID: 0,
|
|
||||||
User: userId,
|
|
||||||
ResourceType: model.ResourceMapfix,
|
|
||||||
ResourceID: params.MapfixID,
|
|
||||||
EventType: model.AuditEventTypeAction,
|
|
||||||
EventData: EventData,
|
|
||||||
})
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
// 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.
|
// ActionMapfixResetSubmitting implements actionMapfixResetSubmitting operation.
|
||||||
@@ -558,7 +641,6 @@ func (svc *Service) ActionMapfixResetSubmitting(ctx context.Context, params api.
|
|||||||
target_status := model.MapfixStatusUnderConstruction
|
target_status := model.MapfixStatusUnderConstruction
|
||||||
smap := datastore.Optional()
|
smap := datastore.Optional()
|
||||||
smap.Add("status_id", target_status)
|
smap.Add("status_id", target_status)
|
||||||
smap.Add("status_message", "Manually forced reset")
|
|
||||||
err = svc.DB.Mapfixes().IfStatusThenUpdate(ctx, params.MapfixID, []model.MapfixStatus{model.MapfixStatusSubmitting}, smap)
|
err = svc.DB.Mapfixes().IfStatusThenUpdate(ctx, params.MapfixID, []model.MapfixStatus{model.MapfixStatusSubmitting}, smap)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@@ -568,24 +650,15 @@ func (svc *Service) ActionMapfixResetSubmitting(ctx context.Context, params api.
|
|||||||
TargetStatus: uint32(target_status),
|
TargetStatus: uint32(target_status),
|
||||||
}
|
}
|
||||||
|
|
||||||
EventData, err := json.Marshal(event_data)
|
return svc.CreateAuditEventAction(
|
||||||
if err != nil {
|
ctx,
|
||||||
return err
|
userId,
|
||||||
}
|
model.Resource{
|
||||||
|
ID: params.MapfixID,
|
||||||
_, err = svc.DB.AuditEvents().Create(ctx, model.AuditEvent{
|
Type: model.ResourceMapfix,
|
||||||
ID: 0,
|
},
|
||||||
User: userId,
|
event_data,
|
||||||
ResourceType: model.ResourceMapfix,
|
)
|
||||||
ResourceID: params.MapfixID,
|
|
||||||
EventType: model.AuditEventTypeAction,
|
|
||||||
EventData: EventData,
|
|
||||||
})
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ActionMapfixTriggerUpload invokes actionMapfixTriggerUpload operation.
|
// ActionMapfixTriggerUpload invokes actionMapfixTriggerUpload operation.
|
||||||
@@ -644,24 +717,15 @@ func (svc *Service) ActionMapfixTriggerUpload(ctx context.Context, params api.Ac
|
|||||||
TargetStatus: uint32(target_status),
|
TargetStatus: uint32(target_status),
|
||||||
}
|
}
|
||||||
|
|
||||||
EventData, err := json.Marshal(event_data)
|
return svc.CreateAuditEventAction(
|
||||||
if err != nil {
|
ctx,
|
||||||
return err
|
userId,
|
||||||
}
|
model.Resource{
|
||||||
|
ID: params.MapfixID,
|
||||||
_, err = svc.DB.AuditEvents().Create(ctx, model.AuditEvent{
|
Type: model.ResourceMapfix,
|
||||||
ID: 0,
|
},
|
||||||
User: userId,
|
event_data,
|
||||||
ResourceType: model.ResourceMapfix,
|
)
|
||||||
ResourceID: params.MapfixID,
|
|
||||||
EventType: model.AuditEventTypeAction,
|
|
||||||
EventData: EventData,
|
|
||||||
})
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ActionMapfixValidate invokes actionMapfixValidate operation.
|
// ActionMapfixValidate invokes actionMapfixValidate operation.
|
||||||
@@ -712,24 +776,15 @@ func (svc *Service) ActionMapfixValidated(ctx context.Context, params api.Action
|
|||||||
TargetStatus: uint32(target_status),
|
TargetStatus: uint32(target_status),
|
||||||
}
|
}
|
||||||
|
|
||||||
EventData, err := json.Marshal(event_data)
|
return svc.CreateAuditEventAction(
|
||||||
if err != nil {
|
ctx,
|
||||||
return err
|
userId,
|
||||||
}
|
model.Resource{
|
||||||
|
ID: params.MapfixID,
|
||||||
_, err = svc.DB.AuditEvents().Create(ctx, model.AuditEvent{
|
Type: model.ResourceMapfix,
|
||||||
ID: 0,
|
},
|
||||||
User: userId,
|
event_data,
|
||||||
ResourceType: model.ResourceMapfix,
|
)
|
||||||
ResourceID: params.MapfixID,
|
|
||||||
EventType: model.AuditEventTypeAction,
|
|
||||||
EventData: EventData,
|
|
||||||
})
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ActionMapfixTriggerValidate invokes actionMapfixTriggerValidate operation.
|
// ActionMapfixTriggerValidate invokes actionMapfixTriggerValidate operation.
|
||||||
@@ -821,24 +876,15 @@ func (svc *Service) ActionMapfixTriggerValidate(ctx context.Context, params api.
|
|||||||
TargetStatus: uint32(target_status),
|
TargetStatus: uint32(target_status),
|
||||||
}
|
}
|
||||||
|
|
||||||
EventData, err := json.Marshal(event_data)
|
return svc.CreateAuditEventAction(
|
||||||
if err != nil {
|
ctx,
|
||||||
return err
|
userId,
|
||||||
}
|
model.Resource{
|
||||||
|
ID: params.MapfixID,
|
||||||
_, err = svc.DB.AuditEvents().Create(ctx, model.AuditEvent{
|
Type: model.ResourceMapfix,
|
||||||
ID: 0,
|
},
|
||||||
User: userId,
|
event_data,
|
||||||
ResourceType: model.ResourceMapfix,
|
)
|
||||||
ResourceID: params.MapfixID,
|
|
||||||
EventType: model.AuditEventTypeAction,
|
|
||||||
EventData: EventData,
|
|
||||||
})
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ActionMapfixRetryValidate invokes actionMapfixRetryValidate operation.
|
// ActionMapfixRetryValidate invokes actionMapfixRetryValidate operation.
|
||||||
@@ -901,24 +947,15 @@ func (svc *Service) ActionMapfixRetryValidate(ctx context.Context, params api.Ac
|
|||||||
TargetStatus: uint32(target_status),
|
TargetStatus: uint32(target_status),
|
||||||
}
|
}
|
||||||
|
|
||||||
EventData, err := json.Marshal(event_data)
|
return svc.CreateAuditEventAction(
|
||||||
if err != nil {
|
ctx,
|
||||||
return err
|
userId,
|
||||||
}
|
model.Resource{
|
||||||
|
ID: params.MapfixID,
|
||||||
_, err = svc.DB.AuditEvents().Create(ctx, model.AuditEvent{
|
Type: model.ResourceMapfix,
|
||||||
ID: 0,
|
},
|
||||||
User: userId,
|
event_data,
|
||||||
ResourceType: model.ResourceMapfix,
|
)
|
||||||
ResourceID: params.MapfixID,
|
|
||||||
EventType: model.AuditEventTypeAction,
|
|
||||||
EventData: EventData,
|
|
||||||
})
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ActionMapfixAccepted implements actionMapfixAccepted operation.
|
// ActionMapfixAccepted implements actionMapfixAccepted operation.
|
||||||
@@ -960,7 +997,6 @@ func (svc *Service) ActionMapfixAccepted(ctx context.Context, params api.ActionM
|
|||||||
target_status := model.MapfixStatusAcceptedUnvalidated
|
target_status := model.MapfixStatusAcceptedUnvalidated
|
||||||
smap := datastore.Optional()
|
smap := datastore.Optional()
|
||||||
smap.Add("status_id", target_status)
|
smap.Add("status_id", target_status)
|
||||||
smap.Add("status_message", "Manually forced reset")
|
|
||||||
err = svc.DB.Mapfixes().IfStatusThenUpdate(ctx, params.MapfixID, []model.MapfixStatus{model.MapfixStatusValidating}, smap)
|
err = svc.DB.Mapfixes().IfStatusThenUpdate(ctx, params.MapfixID, []model.MapfixStatus{model.MapfixStatusValidating}, smap)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@@ -970,22 +1006,85 @@ func (svc *Service) ActionMapfixAccepted(ctx context.Context, params api.ActionM
|
|||||||
TargetStatus: uint32(target_status),
|
TargetStatus: uint32(target_status),
|
||||||
}
|
}
|
||||||
|
|
||||||
EventData, err := json.Marshal(event_data)
|
return svc.CreateAuditEventAction(
|
||||||
if err != nil {
|
ctx,
|
||||||
return err
|
userId,
|
||||||
}
|
model.Resource{
|
||||||
|
ID: params.MapfixID,
|
||||||
_, err = svc.DB.AuditEvents().Create(ctx, model.AuditEvent{
|
Type: model.ResourceMapfix,
|
||||||
ID: 0,
|
},
|
||||||
User: userId,
|
event_data,
|
||||||
ResourceType: model.ResourceMapfix,
|
)
|
||||||
ResourceID: params.MapfixID,
|
}
|
||||||
EventType: model.AuditEventTypeAction,
|
|
||||||
EventData: EventData,
|
// CreateMapfixAuditComment implements createMapfixAuditComment operation.
|
||||||
})
|
//
|
||||||
if err != nil {
|
// Post a comment to the audit log
|
||||||
return err
|
//
|
||||||
}
|
// POST /mapfixes/{MapfixID}/comment
|
||||||
|
func (svc *Service) CreateMapfixAuditComment(ctx context.Context, req api.CreateMapfixAuditCommentReq, params api.CreateMapfixAuditCommentParams) (error) {
|
||||||
return nil
|
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,9 +2,11 @@ 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.
|
||||||
@@ -25,7 +27,7 @@ func (svc *Service) ListMaps(ctx context.Context, params api.ListMapsParams) ([]
|
|||||||
filter.GameID = ¶ms.GameID.Value
|
filter.GameID = ¶ms.GameID.Value
|
||||||
}
|
}
|
||||||
|
|
||||||
mapList, err := svc.Client.List(ctx, &maps.ListRequest{
|
mapList, err := svc.Maps.List(ctx, &maps.ListRequest{
|
||||||
Filter: &filter,
|
Filter: &filter,
|
||||||
Page: &maps.Pagination{
|
Page: &maps.Pagination{
|
||||||
Size: params.Limit,
|
Size: params.Limit,
|
||||||
@@ -56,7 +58,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.Client.Get(ctx, &maps.IdMessage{
|
mapResponse, err := svc.Maps.Get(ctx, &maps.IdMessage{
|
||||||
ID: params.MapID,
|
ID: params.MapID,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -71,3 +73,29 @@ 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) {
|
||||||
|
// 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
|
||||||
|
}
|
||||||
|
|||||||
@@ -84,6 +84,7 @@ 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),
|
||||||
|
|||||||
@@ -6,8 +6,10 @@ 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"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -32,7 +34,9 @@ var (
|
|||||||
type Service struct {
|
type Service struct {
|
||||||
DB datastore.Datastore
|
DB datastore.Datastore
|
||||||
Nats nats.JetStreamContext
|
Nats nats.JetStreamContext
|
||||||
Client maps.MapsServiceClient
|
Maps 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,6 +5,7 @@ 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"
|
||||||
@@ -20,7 +21,7 @@ var(
|
|||||||
model.SubmissionStatusSubmitted,
|
model.SubmissionStatusSubmitted,
|
||||||
model.SubmissionStatusUnderConstruction,
|
model.SubmissionStatusUnderConstruction,
|
||||||
}
|
}
|
||||||
// limit mapfixes in the pipeline to one per target map
|
// limit submissions in the pipeline to one per target map
|
||||||
ActiveAcceptedSubmissionStatuses = []model.SubmissionStatus{
|
ActiveAcceptedSubmissionStatuses = []model.SubmissionStatus{
|
||||||
model.SubmissionStatusUploading,
|
model.SubmissionStatusUploading,
|
||||||
model.SubmissionStatusValidated,
|
model.SubmissionStatusValidated,
|
||||||
@@ -101,8 +102,89 @@ 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: ModelID,
|
||||||
|
DisplayName: request.DisplayName,
|
||||||
|
Creator: request.Creator,
|
||||||
|
GameID: uint32(request.GameID),
|
||||||
|
Status: uint32(model.SubmissionStatusUnderConstruction),
|
||||||
|
Roles: uint32(RolesEmpty),
|
||||||
|
}
|
||||||
|
|
||||||
|
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{
|
||||||
|
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)
|
j, err := json.Marshal(create_request)
|
||||||
@@ -143,7 +225,6 @@ 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
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -285,24 +366,15 @@ func (svc *Service) UpdateSubmissionModel(ctx context.Context, params api.Update
|
|||||||
NewModelVersion: NewModelVersion,
|
NewModelVersion: NewModelVersion,
|
||||||
}
|
}
|
||||||
|
|
||||||
EventData, err := json.Marshal(event_data)
|
return svc.CreateAuditEventChangeModel(
|
||||||
if err != nil {
|
ctx,
|
||||||
return err
|
userId,
|
||||||
}
|
model.Resource{
|
||||||
|
ID: params.SubmissionID,
|
||||||
_, err = svc.DB.AuditEvents().Create(ctx, model.AuditEvent{
|
Type: model.ResourceSubmission,
|
||||||
ID: 0,
|
},
|
||||||
User: userId,
|
event_data,
|
||||||
ResourceType: model.ResourceSubmission,
|
)
|
||||||
ResourceID: submission.ID,
|
|
||||||
EventType: model.AuditEventTypeChangeModel,
|
|
||||||
EventData: EventData,
|
|
||||||
})
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ActionSubmissionReject invokes actionSubmissionReject operation.
|
// ActionSubmissionReject invokes actionSubmissionReject operation.
|
||||||
@@ -343,24 +415,15 @@ func (svc *Service) ActionSubmissionReject(ctx context.Context, params api.Actio
|
|||||||
TargetStatus: uint32(target_status),
|
TargetStatus: uint32(target_status),
|
||||||
}
|
}
|
||||||
|
|
||||||
EventData, err := json.Marshal(event_data)
|
return svc.CreateAuditEventAction(
|
||||||
if err != nil {
|
ctx,
|
||||||
return err
|
userId,
|
||||||
}
|
model.Resource{
|
||||||
|
ID: params.SubmissionID,
|
||||||
_, err = svc.DB.AuditEvents().Create(ctx, model.AuditEvent{
|
Type: model.ResourceSubmission,
|
||||||
ID: 0,
|
},
|
||||||
User: userId,
|
event_data,
|
||||||
ResourceType: model.ResourceSubmission,
|
)
|
||||||
ResourceID: params.SubmissionID,
|
|
||||||
EventType: model.AuditEventTypeAction,
|
|
||||||
EventData: EventData,
|
|
||||||
})
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ActionSubmissionRequestChanges invokes actionSubmissionRequestChanges operation.
|
// ActionSubmissionRequestChanges invokes actionSubmissionRequestChanges operation.
|
||||||
@@ -401,24 +464,15 @@ func (svc *Service) ActionSubmissionRequestChanges(ctx context.Context, params a
|
|||||||
TargetStatus: uint32(target_status),
|
TargetStatus: uint32(target_status),
|
||||||
}
|
}
|
||||||
|
|
||||||
EventData, err := json.Marshal(event_data)
|
return svc.CreateAuditEventAction(
|
||||||
if err != nil {
|
ctx,
|
||||||
return err
|
userId,
|
||||||
}
|
model.Resource{
|
||||||
|
ID: params.SubmissionID,
|
||||||
_, err = svc.DB.AuditEvents().Create(ctx, model.AuditEvent{
|
Type: model.ResourceSubmission,
|
||||||
ID: 0,
|
},
|
||||||
User: userId,
|
event_data,
|
||||||
ResourceType: model.ResourceSubmission,
|
)
|
||||||
ResourceID: params.SubmissionID,
|
|
||||||
EventType: model.AuditEventTypeAction,
|
|
||||||
EventData: EventData,
|
|
||||||
})
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ActionSubmissionRevoke invokes actionSubmissionRevoke operation.
|
// ActionSubmissionRevoke invokes actionSubmissionRevoke operation.
|
||||||
@@ -462,24 +516,15 @@ func (svc *Service) ActionSubmissionRevoke(ctx context.Context, params api.Actio
|
|||||||
TargetStatus: uint32(target_status),
|
TargetStatus: uint32(target_status),
|
||||||
}
|
}
|
||||||
|
|
||||||
EventData, err := json.Marshal(event_data)
|
return svc.CreateAuditEventAction(
|
||||||
if err != nil {
|
ctx,
|
||||||
return err
|
userId,
|
||||||
}
|
model.Resource{
|
||||||
|
ID: params.SubmissionID,
|
||||||
_, err = svc.DB.AuditEvents().Create(ctx, model.AuditEvent{
|
Type: model.ResourceSubmission,
|
||||||
ID: 0,
|
},
|
||||||
User: userId,
|
event_data,
|
||||||
ResourceType: model.ResourceSubmission,
|
)
|
||||||
ResourceID: params.SubmissionID,
|
|
||||||
EventType: model.AuditEventTypeAction,
|
|
||||||
EventData: EventData,
|
|
||||||
})
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ActionSubmissionTriggerSubmit invokes actionSubmissionTriggerSubmit operation.
|
// ActionSubmissionTriggerSubmit invokes actionSubmissionTriggerSubmit operation.
|
||||||
@@ -505,13 +550,21 @@ func (svc *Service) ActionSubmissionTriggerSubmit(ctx context.Context, params ap
|
|||||||
}
|
}
|
||||||
|
|
||||||
// check if caller is the submitter
|
// check if caller is the submitter
|
||||||
has_role := userId == submission.Submitter
|
is_submitter := userId == submission.Submitter
|
||||||
if !has_role {
|
// neither = deny
|
||||||
return ErrPermissionDeniedNotSubmitter
|
if !is_submitter {
|
||||||
|
has_submission_review, err := userInfo.HasRoleSubmissionReview()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
if !has_submission_review {
|
||||||
|
return ErrPermissionDeniedNotSubmitter
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// transaction
|
// transaction
|
||||||
target_status := model.SubmissionStatusSubmitted
|
target_status := model.SubmissionStatusSubmitting
|
||||||
smap := datastore.Optional()
|
smap := datastore.Optional()
|
||||||
smap.Add("status_id", target_status)
|
smap.Add("status_id", target_status)
|
||||||
err = svc.DB.Submissions().IfStatusThenUpdate(ctx, params.SubmissionID, []model.SubmissionStatus{model.SubmissionStatusUnderConstruction, model.SubmissionStatusChangesRequested}, smap)
|
err = svc.DB.Submissions().IfStatusThenUpdate(ctx, params.SubmissionID, []model.SubmissionStatus{model.SubmissionStatusUnderConstruction, model.SubmissionStatusChangesRequested}, smap)
|
||||||
@@ -519,28 +572,112 @@ func (svc *Service) ActionSubmissionTriggerSubmit(ctx context.Context, params ap
|
|||||||
return err
|
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{
|
event_data := model.AuditEventDataAction{
|
||||||
TargetStatus: uint32(target_status),
|
TargetStatus: uint32(target_status),
|
||||||
}
|
}
|
||||||
|
|
||||||
EventData, err := json.Marshal(event_data)
|
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 {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err = svc.DB.AuditEvents().Create(ctx, model.AuditEvent{
|
userId, err := userInfo.GetUserID()
|
||||||
ID: 0,
|
|
||||||
User: userId,
|
|
||||||
ResourceType: model.ResourceSubmission,
|
|
||||||
ResourceID: params.SubmissionID,
|
|
||||||
EventType: model.AuditEventTypeAction,
|
|
||||||
EventData: EventData,
|
|
||||||
})
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
// 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.
|
// ActionSubmissionResetSubmitting implements actionSubmissionResetSubmitting operation.
|
||||||
@@ -579,7 +716,6 @@ func (svc *Service) ActionSubmissionResetSubmitting(ctx context.Context, params
|
|||||||
target_status := model.SubmissionStatusUnderConstruction
|
target_status := model.SubmissionStatusUnderConstruction
|
||||||
smap := datastore.Optional()
|
smap := datastore.Optional()
|
||||||
smap.Add("status_id", target_status)
|
smap.Add("status_id", target_status)
|
||||||
smap.Add("status_message", "Manually forced reset")
|
|
||||||
err = svc.DB.Submissions().IfStatusThenUpdate(ctx, params.SubmissionID, []model.SubmissionStatus{model.SubmissionStatusSubmitting}, smap)
|
err = svc.DB.Submissions().IfStatusThenUpdate(ctx, params.SubmissionID, []model.SubmissionStatus{model.SubmissionStatusSubmitting}, smap)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@@ -589,24 +725,15 @@ func (svc *Service) ActionSubmissionResetSubmitting(ctx context.Context, params
|
|||||||
TargetStatus: uint32(target_status),
|
TargetStatus: uint32(target_status),
|
||||||
}
|
}
|
||||||
|
|
||||||
EventData, err := json.Marshal(event_data)
|
return svc.CreateAuditEventAction(
|
||||||
if err != nil {
|
ctx,
|
||||||
return err
|
userId,
|
||||||
}
|
model.Resource{
|
||||||
|
ID: params.SubmissionID,
|
||||||
_, err = svc.DB.AuditEvents().Create(ctx, model.AuditEvent{
|
Type: model.ResourceSubmission,
|
||||||
ID: 0,
|
},
|
||||||
User: userId,
|
event_data,
|
||||||
ResourceType: model.ResourceSubmission,
|
)
|
||||||
ResourceID: params.SubmissionID,
|
|
||||||
EventType: model.AuditEventTypeAction,
|
|
||||||
EventData: EventData,
|
|
||||||
})
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ActionSubmissionTriggerUpload invokes actionSubmissionTriggerUpload operation.
|
// ActionSubmissionTriggerUpload invokes actionSubmissionTriggerUpload operation.
|
||||||
@@ -672,24 +799,15 @@ func (svc *Service) ActionSubmissionTriggerUpload(ctx context.Context, params ap
|
|||||||
TargetStatus: uint32(target_status),
|
TargetStatus: uint32(target_status),
|
||||||
}
|
}
|
||||||
|
|
||||||
EventData, err := json.Marshal(event_data)
|
return svc.CreateAuditEventAction(
|
||||||
if err != nil {
|
ctx,
|
||||||
return err
|
userId,
|
||||||
}
|
model.Resource{
|
||||||
|
ID: params.SubmissionID,
|
||||||
_, err = svc.DB.AuditEvents().Create(ctx, model.AuditEvent{
|
Type: model.ResourceSubmission,
|
||||||
ID: 0,
|
},
|
||||||
User: userId,
|
event_data,
|
||||||
ResourceType: model.ResourceSubmission,
|
)
|
||||||
ResourceID: params.SubmissionID,
|
|
||||||
EventType: model.AuditEventTypeAction,
|
|
||||||
EventData: EventData,
|
|
||||||
})
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ActionSubmissionValidate invokes actionSubmissionValidate operation.
|
// ActionSubmissionValidate invokes actionSubmissionValidate operation.
|
||||||
@@ -740,24 +858,15 @@ func (svc *Service) ActionSubmissionValidated(ctx context.Context, params api.Ac
|
|||||||
TargetStatus: uint32(target_status),
|
TargetStatus: uint32(target_status),
|
||||||
}
|
}
|
||||||
|
|
||||||
EventData, err := json.Marshal(event_data)
|
return svc.CreateAuditEventAction(
|
||||||
if err != nil {
|
ctx,
|
||||||
return err
|
userId,
|
||||||
}
|
model.Resource{
|
||||||
|
ID: params.SubmissionID,
|
||||||
_, err = svc.DB.AuditEvents().Create(ctx, model.AuditEvent{
|
Type: model.ResourceSubmission,
|
||||||
ID: 0,
|
},
|
||||||
User: userId,
|
event_data,
|
||||||
ResourceType: model.ResourceSubmission,
|
)
|
||||||
ResourceID: params.SubmissionID,
|
|
||||||
EventType: model.AuditEventTypeAction,
|
|
||||||
EventData: EventData,
|
|
||||||
})
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ActionSubmissionTriggerValidate invokes actionSubmissionTriggerValidate operation.
|
// ActionSubmissionTriggerValidate invokes actionSubmissionTriggerValidate operation.
|
||||||
@@ -832,24 +941,15 @@ func (svc *Service) ActionSubmissionTriggerValidate(ctx context.Context, params
|
|||||||
TargetStatus: uint32(target_status),
|
TargetStatus: uint32(target_status),
|
||||||
}
|
}
|
||||||
|
|
||||||
EventData, err := json.Marshal(event_data)
|
return svc.CreateAuditEventAction(
|
||||||
if err != nil {
|
ctx,
|
||||||
return err
|
userId,
|
||||||
}
|
model.Resource{
|
||||||
|
ID: params.SubmissionID,
|
||||||
_, err = svc.DB.AuditEvents().Create(ctx, model.AuditEvent{
|
Type: model.ResourceSubmission,
|
||||||
ID: 0,
|
},
|
||||||
User: userId,
|
event_data,
|
||||||
ResourceType: model.ResourceSubmission,
|
)
|
||||||
ResourceID: params.SubmissionID,
|
|
||||||
EventType: model.AuditEventTypeAction,
|
|
||||||
EventData: EventData,
|
|
||||||
})
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ActionSubmissionRetryValidate invokes actionSubmissionRetryValidate operation.
|
// ActionSubmissionRetryValidate invokes actionSubmissionRetryValidate operation.
|
||||||
@@ -912,24 +1012,15 @@ func (svc *Service) ActionSubmissionRetryValidate(ctx context.Context, params ap
|
|||||||
TargetStatus: uint32(target_status),
|
TargetStatus: uint32(target_status),
|
||||||
}
|
}
|
||||||
|
|
||||||
EventData, err := json.Marshal(event_data)
|
return svc.CreateAuditEventAction(
|
||||||
if err != nil {
|
ctx,
|
||||||
return err
|
userId,
|
||||||
}
|
model.Resource{
|
||||||
|
ID: params.SubmissionID,
|
||||||
_, err = svc.DB.AuditEvents().Create(ctx, model.AuditEvent{
|
Type: model.ResourceSubmission,
|
||||||
ID: 0,
|
},
|
||||||
User: userId,
|
event_data,
|
||||||
ResourceType: model.ResourceSubmission,
|
)
|
||||||
ResourceID: params.SubmissionID,
|
|
||||||
EventType: model.AuditEventTypeAction,
|
|
||||||
EventData: EventData,
|
|
||||||
})
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ActionSubmissionAccepted implements actionSubmissionAccepted operation.
|
// ActionSubmissionAccepted implements actionSubmissionAccepted operation.
|
||||||
@@ -971,7 +1062,6 @@ func (svc *Service) ActionSubmissionAccepted(ctx context.Context, params api.Act
|
|||||||
target_status := model.SubmissionStatusAcceptedUnvalidated
|
target_status := model.SubmissionStatusAcceptedUnvalidated
|
||||||
smap := datastore.Optional()
|
smap := datastore.Optional()
|
||||||
smap.Add("status_id", target_status)
|
smap.Add("status_id", target_status)
|
||||||
smap.Add("status_message", "Manually forced reset")
|
|
||||||
err = svc.DB.Submissions().IfStatusThenUpdate(ctx, params.SubmissionID, []model.SubmissionStatus{model.SubmissionStatusValidating}, smap)
|
err = svc.DB.Submissions().IfStatusThenUpdate(ctx, params.SubmissionID, []model.SubmissionStatus{model.SubmissionStatusValidating}, smap)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@@ -981,24 +1071,15 @@ func (svc *Service) ActionSubmissionAccepted(ctx context.Context, params api.Act
|
|||||||
TargetStatus: uint32(target_status),
|
TargetStatus: uint32(target_status),
|
||||||
}
|
}
|
||||||
|
|
||||||
EventData, err := json.Marshal(event_data)
|
return svc.CreateAuditEventAction(
|
||||||
if err != nil {
|
ctx,
|
||||||
return err
|
userId,
|
||||||
}
|
model.Resource{
|
||||||
|
ID: params.SubmissionID,
|
||||||
_, err = svc.DB.AuditEvents().Create(ctx, model.AuditEvent{
|
Type: model.ResourceSubmission,
|
||||||
ID: 0,
|
},
|
||||||
User: userId,
|
event_data,
|
||||||
ResourceType: model.ResourceSubmission,
|
)
|
||||||
ResourceID: params.SubmissionID,
|
|
||||||
EventType: model.AuditEventTypeAction,
|
|
||||||
EventData: EventData,
|
|
||||||
})
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ReleaseSubmissions invokes releaseSubmissions operation.
|
// ReleaseSubmissions invokes releaseSubmissions operation.
|
||||||
@@ -1046,7 +1127,7 @@ func (svc *Service) ReleaseSubmissions(ctx context.Context, request []api.Releas
|
|||||||
date := request[i].Date.Unix()
|
date := request[i].Date.Unix()
|
||||||
var GameID = int32(submission.GameID)
|
var GameID = int32(submission.GameID)
|
||||||
// create each map with go-grpc
|
// create each map with go-grpc
|
||||||
_, err := svc.Client.Create(ctx, &maps.MapRequest{
|
_, err := svc.Maps.Create(ctx, &maps.MapRequest{
|
||||||
ID: int64(submission.UploadedAssetID),
|
ID: int64(submission.UploadedAssetID),
|
||||||
DisplayName: &submission.DisplayName,
|
DisplayName: &submission.DisplayName,
|
||||||
Creator: &submission.Creator,
|
Creator: &submission.Creator,
|
||||||
@@ -1068,3 +1149,75 @@ 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,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|||||||
92
pkg/service_internal/audit_events.go
Normal file
92
pkg/service_internal/audit_events.go
Normal file
@@ -0,0 +1,92 @@
|
|||||||
|
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
|
||||||
|
}
|
||||||
@@ -2,7 +2,6 @@ package service_internal
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
@@ -54,27 +53,18 @@ func (svc *Service) UpdateMapfixValidatedModel(ctx context.Context, params inter
|
|||||||
ValidatedModelVersion: ValidatedModelVersion,
|
ValidatedModelVersion: ValidatedModelVersion,
|
||||||
}
|
}
|
||||||
|
|
||||||
EventData, err := json.Marshal(event_data)
|
return svc.CreateAuditEventChangeValidatedModel(
|
||||||
if err != nil {
|
ctx,
|
||||||
return err
|
ValidtorUserID,
|
||||||
}
|
model.Resource{
|
||||||
|
ID: params.MapfixID,
|
||||||
_, err = svc.DB.AuditEvents().Create(ctx, model.AuditEvent{
|
Type: model.ResourceMapfix,
|
||||||
ID: 0,
|
},
|
||||||
User: ValidtorUserID,
|
event_data,
|
||||||
ResourceType: model.ResourceMapfix,
|
)
|
||||||
ResourceID: params.MapfixID,
|
|
||||||
EventType: model.AuditEventTypeChangeValidatedModel,
|
|
||||||
EventData: EventData,
|
|
||||||
})
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ActionMapfixValidate invokes actionMapfixValidate operation.
|
// ActionMapfixSubmitted invokes actionMapfixSubmitted operation.
|
||||||
//
|
//
|
||||||
// Role Validator changes status from Submitting -> Submitted.
|
// Role Validator changes status from Submitting -> Submitted.
|
||||||
//
|
//
|
||||||
@@ -84,6 +74,40 @@ func (svc *Service) ActionMapfixSubmitted(ctx context.Context, params internal.A
|
|||||||
target_status := model.MapfixStatusSubmitted
|
target_status := model.MapfixStatusSubmitted
|
||||||
smap := datastore.Optional()
|
smap := datastore.Optional()
|
||||||
smap.Add("status_id", target_status)
|
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)
|
err := svc.DB.Mapfixes().IfStatusThenUpdate(ctx, params.MapfixID, []model.MapfixStatus{model.MapfixStatusSubmitting}, smap)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@@ -93,24 +117,15 @@ func (svc *Service) ActionMapfixSubmitted(ctx context.Context, params internal.A
|
|||||||
TargetStatus: uint32(target_status),
|
TargetStatus: uint32(target_status),
|
||||||
}
|
}
|
||||||
|
|
||||||
EventData, err := json.Marshal(event_data)
|
return svc.CreateAuditEventAction(
|
||||||
if err != nil {
|
ctx,
|
||||||
return err
|
ValidtorUserID,
|
||||||
}
|
model.Resource{
|
||||||
|
ID: params.MapfixID,
|
||||||
_, err = svc.DB.AuditEvents().Create(ctx, model.AuditEvent{
|
Type: model.ResourceMapfix,
|
||||||
ID: 0,
|
},
|
||||||
User: ValidtorUserID,
|
event_data,
|
||||||
ResourceType: model.ResourceMapfix,
|
)
|
||||||
ResourceID: params.MapfixID,
|
|
||||||
EventType: model.AuditEventTypeAction,
|
|
||||||
EventData: EventData,
|
|
||||||
})
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ActionMapfixValidate invokes actionMapfixValidate operation.
|
// ActionMapfixValidate invokes actionMapfixValidate operation.
|
||||||
@@ -135,34 +150,25 @@ func (svc *Service) ActionMapfixAccepted(ctx context.Context, params internal.Ac
|
|||||||
target_status := model.MapfixStatusAcceptedUnvalidated
|
target_status := model.MapfixStatusAcceptedUnvalidated
|
||||||
smap := datastore.Optional()
|
smap := datastore.Optional()
|
||||||
smap.Add("status_id", target_status)
|
smap.Add("status_id", target_status)
|
||||||
smap.Add("status_message", params.StatusMessage)
|
|
||||||
err := svc.DB.Mapfixes().IfStatusThenUpdate(ctx, params.MapfixID, []model.MapfixStatus{model.MapfixStatusValidating}, smap)
|
err := svc.DB.Mapfixes().IfStatusThenUpdate(ctx, params.MapfixID, []model.MapfixStatus{model.MapfixStatusValidating}, smap)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// push an action audit event
|
||||||
event_data := model.AuditEventDataAction{
|
event_data := model.AuditEventDataAction{
|
||||||
TargetStatus: uint32(target_status),
|
TargetStatus: uint32(target_status),
|
||||||
}
|
}
|
||||||
|
|
||||||
EventData, err := json.Marshal(event_data)
|
return svc.CreateAuditEventAction(
|
||||||
if err != nil {
|
ctx,
|
||||||
return err
|
ValidtorUserID,
|
||||||
}
|
model.Resource{
|
||||||
|
ID: params.MapfixID,
|
||||||
_, err = svc.DB.AuditEvents().Create(ctx, model.AuditEvent{
|
Type: model.ResourceMapfix,
|
||||||
ID: 0,
|
},
|
||||||
User: ValidtorUserID,
|
event_data,
|
||||||
ResourceType: model.ResourceMapfix,
|
)
|
||||||
ResourceID: params.MapfixID,
|
|
||||||
EventType: model.AuditEventTypeAction,
|
|
||||||
EventData: EventData,
|
|
||||||
})
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ActionMapfixUploaded implements actionMapfixUploaded operation.
|
// ActionMapfixUploaded implements actionMapfixUploaded operation.
|
||||||
@@ -184,24 +190,66 @@ func (svc *Service) ActionMapfixUploaded(ctx context.Context, params internal.Ac
|
|||||||
TargetStatus: uint32(target_status),
|
TargetStatus: uint32(target_status),
|
||||||
}
|
}
|
||||||
|
|
||||||
EventData, err := json.Marshal(event_data)
|
return svc.CreateAuditEventAction(
|
||||||
if err != nil {
|
ctx,
|
||||||
return err
|
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,
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err = svc.DB.AuditEvents().Create(ctx, model.AuditEvent{
|
return svc.CreateAuditEventError(
|
||||||
ID: 0,
|
ctx,
|
||||||
User: ValidtorUserID,
|
ValidtorUserID,
|
||||||
ResourceType: model.ResourceMapfix,
|
model.Resource{
|
||||||
ResourceID: params.MapfixID,
|
ID: params.MapfixID,
|
||||||
EventType: model.AuditEventTypeAction,
|
Type: model.ResourceMapfix,
|
||||||
EventData: EventData,
|
},
|
||||||
})
|
event_data,
|
||||||
if err != nil {
|
)
|
||||||
return err
|
}
|
||||||
|
|
||||||
|
// 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,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
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
|
||||||
@@ -260,6 +308,7 @@ func (svc *Service) CreateMapfix(ctx context.Context, request *internal.MapfixCr
|
|||||||
Completed: false,
|
Completed: false,
|
||||||
TargetAssetID: TargetAssetID,
|
TargetAssetID: TargetAssetID,
|
||||||
StatusID: model.MapfixStatusUnderConstruction,
|
StatusID: model.MapfixStatusUnderConstruction,
|
||||||
|
Description: request.Description,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|||||||
@@ -71,6 +71,7 @@ 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),
|
||||||
|
|||||||
@@ -2,13 +2,13 @@ package service_internal
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"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(
|
||||||
@@ -53,27 +53,18 @@ func (svc *Service) UpdateSubmissionValidatedModel(ctx context.Context, params i
|
|||||||
ValidatedModelVersion: ValidatedModelVersion,
|
ValidatedModelVersion: ValidatedModelVersion,
|
||||||
}
|
}
|
||||||
|
|
||||||
EventData, err := json.Marshal(event_data)
|
return svc.CreateAuditEventChangeValidatedModel(
|
||||||
if err != nil {
|
ctx,
|
||||||
return err
|
ValidtorUserID,
|
||||||
}
|
model.Resource{
|
||||||
|
ID: params.SubmissionID,
|
||||||
_, err = svc.DB.AuditEvents().Create(ctx, model.AuditEvent{
|
Type: model.ResourceSubmission,
|
||||||
ID: 0,
|
},
|
||||||
User: ValidtorUserID,
|
event_data,
|
||||||
ResourceType: model.ResourceSubmission,
|
)
|
||||||
ResourceID: params.SubmissionID,
|
|
||||||
EventType: model.AuditEventTypeChangeValidatedModel,
|
|
||||||
EventData: EventData,
|
|
||||||
})
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ActionSubmissionValidate invokes actionSubmissionValidate operation.
|
// ActionSubmissionSubmitted invokes actionSubmissionSubmitted operation.
|
||||||
//
|
//
|
||||||
// Role Validator changes status from Submitting -> Submitted.
|
// Role Validator changes status from Submitting -> Submitted.
|
||||||
//
|
//
|
||||||
@@ -83,6 +74,10 @@ func (svc *Service) ActionSubmissionSubmitted(ctx context.Context, params intern
|
|||||||
target_status := model.SubmissionStatusSubmitted
|
target_status := model.SubmissionStatusSubmitted
|
||||||
smap := datastore.Optional()
|
smap := datastore.Optional()
|
||||||
smap.Add("status_id", target_status)
|
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)
|
err := svc.DB.Submissions().IfStatusThenUpdate(ctx, params.SubmissionID, []model.SubmissionStatus{model.SubmissionStatusSubmitting}, smap)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@@ -92,24 +87,46 @@ func (svc *Service) ActionSubmissionSubmitted(ctx context.Context, params intern
|
|||||||
TargetStatus: uint32(target_status),
|
TargetStatus: uint32(target_status),
|
||||||
}
|
}
|
||||||
|
|
||||||
EventData, err := json.Marshal(event_data)
|
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 {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err = svc.DB.AuditEvents().Create(ctx, model.AuditEvent{
|
// push an action audit event
|
||||||
ID: 0,
|
event_data := model.AuditEventDataAction{
|
||||||
User: ValidtorUserID,
|
TargetStatus: uint32(target_status),
|
||||||
ResourceType: model.ResourceSubmission,
|
|
||||||
ResourceID: params.SubmissionID,
|
|
||||||
EventType: model.AuditEventTypeAction,
|
|
||||||
EventData: EventData,
|
|
||||||
})
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return svc.CreateAuditEventAction(
|
||||||
|
ctx,
|
||||||
|
ValidtorUserID,
|
||||||
|
model.Resource{
|
||||||
|
ID: params.SubmissionID,
|
||||||
|
Type: model.ResourceSubmission,
|
||||||
|
},
|
||||||
|
event_data,
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ActionSubmissionValidate invokes actionSubmissionValidate operation.
|
// ActionSubmissionValidate invokes actionSubmissionValidate operation.
|
||||||
@@ -131,24 +148,15 @@ func (svc *Service) ActionSubmissionValidated(ctx context.Context, params intern
|
|||||||
TargetStatus: uint32(target_status),
|
TargetStatus: uint32(target_status),
|
||||||
}
|
}
|
||||||
|
|
||||||
EventData, err := json.Marshal(event_data)
|
return svc.CreateAuditEventAction(
|
||||||
if err != nil {
|
ctx,
|
||||||
return err
|
ValidtorUserID,
|
||||||
}
|
model.Resource{
|
||||||
|
ID: params.SubmissionID,
|
||||||
_, err = svc.DB.AuditEvents().Create(ctx, model.AuditEvent{
|
Type: model.ResourceSubmission,
|
||||||
ID: 0,
|
},
|
||||||
User: ValidtorUserID,
|
event_data,
|
||||||
ResourceType: model.ResourceSubmission,
|
)
|
||||||
ResourceID: params.SubmissionID,
|
|
||||||
EventType: model.AuditEventTypeAction,
|
|
||||||
EventData: EventData,
|
|
||||||
})
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ActionSubmissionAccepted implements actionSubmissionAccepted operation.
|
// ActionSubmissionAccepted implements actionSubmissionAccepted operation.
|
||||||
@@ -161,34 +169,25 @@ func (svc *Service) ActionSubmissionAccepted(ctx context.Context, params interna
|
|||||||
target_status := model.SubmissionStatusAcceptedUnvalidated
|
target_status := model.SubmissionStatusAcceptedUnvalidated
|
||||||
smap := datastore.Optional()
|
smap := datastore.Optional()
|
||||||
smap.Add("status_id", target_status)
|
smap.Add("status_id", target_status)
|
||||||
smap.Add("status_message", params.StatusMessage)
|
|
||||||
err := svc.DB.Submissions().IfStatusThenUpdate(ctx, params.SubmissionID, []model.SubmissionStatus{model.SubmissionStatusValidating}, smap)
|
err := svc.DB.Submissions().IfStatusThenUpdate(ctx, params.SubmissionID, []model.SubmissionStatus{model.SubmissionStatusValidating}, smap)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// push an action audit event
|
||||||
event_data := model.AuditEventDataAction{
|
event_data := model.AuditEventDataAction{
|
||||||
TargetStatus: uint32(target_status),
|
TargetStatus: uint32(target_status),
|
||||||
}
|
}
|
||||||
|
|
||||||
EventData, err := json.Marshal(event_data)
|
return svc.CreateAuditEventAction(
|
||||||
if err != nil {
|
ctx,
|
||||||
return err
|
ValidtorUserID,
|
||||||
}
|
model.Resource{
|
||||||
|
ID: params.SubmissionID,
|
||||||
_, err = svc.DB.AuditEvents().Create(ctx, model.AuditEvent{
|
Type: model.ResourceSubmission,
|
||||||
ID: 0,
|
},
|
||||||
User: ValidtorUserID,
|
event_data,
|
||||||
ResourceType: model.ResourceSubmission,
|
)
|
||||||
ResourceID: params.SubmissionID,
|
|
||||||
EventType: model.AuditEventTypeAction,
|
|
||||||
EventData: EventData,
|
|
||||||
})
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ActionSubmissionUploaded implements actionSubmissionUploaded operation.
|
// ActionSubmissionUploaded implements actionSubmissionUploaded operation.
|
||||||
@@ -211,24 +210,66 @@ func (svc *Service) ActionSubmissionUploaded(ctx context.Context, params interna
|
|||||||
TargetStatus: uint32(target_status),
|
TargetStatus: uint32(target_status),
|
||||||
}
|
}
|
||||||
|
|
||||||
EventData, err := json.Marshal(event_data)
|
return svc.CreateAuditEventAction(
|
||||||
if err != nil {
|
ctx,
|
||||||
return err
|
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,
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err = svc.DB.AuditEvents().Create(ctx, model.AuditEvent{
|
return svc.CreateAuditEventError(
|
||||||
ID: 0,
|
ctx,
|
||||||
User: ValidtorUserID,
|
ValidtorUserID,
|
||||||
ResourceType: model.ResourceSubmission,
|
model.Resource{
|
||||||
ResourceID: params.SubmissionID,
|
ID: params.SubmissionID,
|
||||||
EventType: model.AuditEventTypeAction,
|
Type: model.ResourceSubmission,
|
||||||
EventData: EventData,
|
},
|
||||||
})
|
event_data,
|
||||||
if err != nil {
|
)
|
||||||
return err
|
}
|
||||||
|
|
||||||
|
// 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,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
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
|
||||||
@@ -244,6 +285,8 @@ func (svc *Service) CreateSubmission(ctx context.Context, request *internal.Subm
|
|||||||
var Submitter=uint64(request.AssetOwner);
|
var Submitter=uint64(request.AssetOwner);
|
||||||
var AssetID=uint64(request.AssetID);
|
var AssetID=uint64(request.AssetID);
|
||||||
var AssetVersion=uint64(request.AssetVersion);
|
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
|
||||||
{
|
{
|
||||||
@@ -269,8 +312,11 @@ func (svc *Service) CreateSubmission(ctx context.Context, request *internal.Subm
|
|||||||
}
|
}
|
||||||
|
|
||||||
// check if user owns asset
|
// check if user owns asset
|
||||||
// TODO: allow bypass by admin
|
is_submitter := operation.Owner == Submitter
|
||||||
if operation.Owner != Submitter {
|
// check if user is map admin
|
||||||
|
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
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -283,7 +329,7 @@ func (svc *Service) CreateSubmission(ctx context.Context, request *internal.Subm
|
|||||||
AssetID: AssetID,
|
AssetID: AssetID,
|
||||||
AssetVersion: AssetVersion,
|
AssetVersion: AssetVersion,
|
||||||
Completed: false,
|
Completed: false,
|
||||||
StatusID: model.SubmissionStatusUnderConstruction,
|
StatusID: Status,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|||||||
@@ -5,14 +5,16 @@ 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.40.0"
|
async-nats = "0.41.0"
|
||||||
futures = "0.3.31"
|
futures = "0.3.31"
|
||||||
rbx_asset = { version = "0.4.3", registry = "strafesnet" }
|
rbx_asset = { version = "0.4.5", registry = "strafesnet" }
|
||||||
rbx_binary = { version = "0.7.4", registry = "strafesnet"}
|
rbx_binary = "1.0.0"
|
||||||
rbx_dom_weak = { version = "2.9.0", registry = "strafesnet"}
|
rbx_dom_weak = "3.0.0"
|
||||||
rbx_reflection_database = { version = "0.2.12", registry = "strafesnet"}
|
rbx_reflection_database = "1.0.3"
|
||||||
rbx_xml = { version = "0.13.3", registry = "strafesnet"}
|
rbx_xml = "1.0.0"
|
||||||
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 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "submissions-api"
|
name = "submissions-api"
|
||||||
version = "0.7.0"
|
version = "0.8.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,6 +11,7 @@ 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,4 +44,8 @@ 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<'a>(&self,config:GetScriptsRequest<'a>)->Result<Vec<ScriptResponse>,Error>{
|
pub async fn get_scripts(&self,config:GetScriptsRequest<'_>)->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(resource_id)=config.ResourceID{
|
if let Some(ResourceID(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<'a>(&self,config:HashRequest<'a>)->Result<Option<ScriptResponse>,SingleItemError>{
|
pub async fn get_script_from_hash(&self,config:HashRequest<'_>)->Result<Option<ScriptResponse>,ScriptSingleItemError>{
|
||||||
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);
|
return Err(SingleItemError::DuplicateItems(scripts.into_iter().map(|item|item.ID).collect()));
|
||||||
}
|
}
|
||||||
Ok(scripts.into_iter().next())
|
Ok(scripts.into_iter().next())
|
||||||
}
|
}
|
||||||
pub async fn create_script<'a>(&self,config:CreateScriptRequest<'a>)->Result<ScriptIDResponse,Error>{
|
pub async fn create_script(&self,config:CreateScriptRequest<'_>)->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,7 +72,17 @@ 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<'a>(&self,config:GetScriptPoliciesRequest<'a>)->Result<Vec<ScriptPolicyResponse>,Error>{
|
pub async fn delete_script(&self,config:GetScriptRequest)->Result<(),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)?;
|
||||||
|
|
||||||
@@ -96,7 +106,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<'a>(&self,config:HashRequest<'a>)->Result<Option<ScriptPolicyResponse>,SingleItemError>{
|
pub async fn get_script_policy_from_hash(&self,config:HashRequest<'_>)->Result<Option<ScriptPolicyResponse>,ScriptPolicySingleItemError>{
|
||||||
let policies=self.get_script_policies(GetScriptPoliciesRequest{
|
let policies=self.get_script_policies(GetScriptPoliciesRequest{
|
||||||
Page:1,
|
Page:1,
|
||||||
Limit:2,
|
Limit:2,
|
||||||
@@ -105,7 +115,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);
|
return Err(SingleItemError::DuplicateItems(policies.into_iter().map(|item|item.ID).collect()));
|
||||||
}
|
}
|
||||||
Ok(policies.into_iter().next())
|
Ok(policies.into_iter().next())
|
||||||
}
|
}
|
||||||
@@ -130,6 +140,94 @@ 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(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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<'a>(&self,config:GetScriptsRequest<'a>)->Result<Vec<ScriptResponse>,Error>{
|
pub async fn get_scripts(&self,config:GetScriptsRequest<'_>)->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(resource_id)=config.ResourceID{
|
if let Some(ResourceID(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<'a>(&self,config:HashRequest<'a>)->Result<Option<ScriptResponse>,SingleItemError>{
|
pub async fn get_script_from_hash(&self,config:HashRequest<'_>)->Result<Option<ScriptResponse>,ScriptSingleItemError>{
|
||||||
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);
|
return Err(SingleItemError::DuplicateItems(scripts.into_iter().map(|item|item.ID).collect()));
|
||||||
}
|
}
|
||||||
Ok(scripts.into_iter().next())
|
Ok(scripts.into_iter().next())
|
||||||
}
|
}
|
||||||
pub async fn create_script<'a>(&self,config:CreateScriptRequest<'a>)->Result<ScriptIDResponse,Error>{
|
pub async fn create_script(&self,config:CreateScriptRequest<'_>)->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<'a>(&self,config:GetScriptPoliciesRequest<'a>)->Result<Vec<ScriptPolicyResponse>,Error>{
|
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)?;
|
||||||
|
|
||||||
@@ -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<'a>(&self,config:HashRequest<'a>)->Result<Option<ScriptPolicyResponse>,SingleItemError>{
|
pub async fn get_script_policy_from_hash(&self,config:HashRequest<'_>)->Result<Option<ScriptPolicyResponse>,ScriptPolicySingleItemError>{
|
||||||
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);
|
return Err(SingleItemError::DuplicateItems(policies.into_iter().map(|item|item.ID).collect()));
|
||||||
}
|
}
|
||||||
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<'a>(&self,config:CreateSubmissionRequest<'a>)->Result<SubmissionIDResponse,Error>{
|
pub async fn create_submission(&self,config:CreateSubmissionRequest<'_>)->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,19 +161,39 @@ 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_submitted,config,ActionSubmissionSubmittedRequest,"status/validator-submitted",config.SubmissionID.0,
|
||||||
|
("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",action_submission_validated,config,SubmissionID,"status/validator-validated",config.0,);
|
||||||
action!("submissions",update_submission_validated_model,config,UpdateSubmissionModelRequest,"validated-model",config.SubmissionID,
|
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,
|
action!("submissions",action_submission_uploaded,config,ActionSubmissionUploadedRequest,"status/validator-uploaded",config.SubmissionID.0,
|
||||||
("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,
|
action!("submissions",action_submission_accepted,config,ActionSubmissionAcceptedRequest,"status/validator-failed",config.SubmissionID.0,);
|
||||||
("StatusMessage",config.StatusMessage.as_str())
|
action!("submissions",create_submission_audit_error,config,CreateSubmissionAuditErrorRequest,"error",config.SubmissionID.0,
|
||||||
|
("ErrorMessage",config.ErrorMessage.as_str())
|
||||||
);
|
);
|
||||||
pub async fn create_mapfix<'a>(&self,config:CreateMapfixRequest<'a>)->Result<MapfixIDResponse,Error>{
|
pub async fn create_mapfix(&self,config:CreateMapfixRequest<'_>)->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)?;
|
||||||
|
|
||||||
@@ -184,18 +204,38 @@ 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_submitted,config,ActionMapfixSubmittedRequest,"status/validator-submitted",config.MapfixID.0,
|
||||||
|
("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",action_mapfix_validated,config,MapfixID,"status/validator-validated",config.0,);
|
||||||
action!("mapfixes",update_mapfix_validated_model,config,UpdateMapfixModelRequest,"validated-model",config.MapfixID,
|
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,);
|
action!("mapfixes",action_mapfix_uploaded,config,ActionMapfixUploadedRequest,"status/validator-uploaded",config.MapfixID.0,);
|
||||||
action!("mapfixes",action_mapfix_accepted,config,ActionMapfixAcceptedRequest,"status/validator-failed",config.MapfixID,
|
action!("mapfixes",action_mapfix_accepted,config,ActionMapfixAcceptedRequest,"status/validator-failed",config.MapfixID.0,);
|
||||||
|
// 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())
|
||||||
);
|
);
|
||||||
// simple operation endpoint
|
action!("mapfixes",create_mapfix_audit_error,config,CreateMapfixAuditErrorRequest,"error",config.MapfixID.0,
|
||||||
action!("operations",action_operation_failed,config,ActionOperationFailedRequest,"status/operation-failed",config.OperationID,
|
("ErrorMessage",config.ErrorMessage.as_str())
|
||||||
("StatusMessage",config.StatusMessage.as_str())
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,21 +14,25 @@ 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{
|
pub enum SingleItemError<Items>{
|
||||||
DuplicateItems,
|
DuplicateItems(Items),
|
||||||
Other(Error),
|
Other(Error),
|
||||||
}
|
}
|
||||||
impl std::fmt::Display for SingleItemError{
|
impl<Items> std::fmt::Display for SingleItemError<Items>
|
||||||
|
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 std::error::Error for SingleItemError{}
|
impl<Items> std::error::Error for SingleItemError<Items> where Items:std::fmt::Debug{}
|
||||||
|
pub type ScriptSingleItemError=SingleItemError<Vec<ScriptID>>;
|
||||||
|
pub type ScriptPolicySingleItemError=SingleItemError<Vec<ScriptPolicyID>>;
|
||||||
|
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct StatusCodeWithUrlAndBody{
|
pub struct UrlAndBody{
|
||||||
pub status_code:reqwest::StatusCode,
|
|
||||||
pub url:url::Url,
|
pub url:url::Url,
|
||||||
pub body:String,
|
pub body:String,
|
||||||
}
|
}
|
||||||
@@ -36,7 +40,10 @@ pub struct StatusCodeWithUrlAndBody{
|
|||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub enum ResponseError{
|
pub enum ResponseError{
|
||||||
Reqwest(reqwest::Error),
|
Reqwest(reqwest::Error),
|
||||||
StatusCodeWithUrlAndBody(StatusCodeWithUrlAndBody),
|
Details{
|
||||||
|
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 {
|
||||||
@@ -53,26 +60,34 @@ 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::StatusCodeWithUrlAndBody(StatusCodeWithUrlAndBody{
|
Err(ResponseError::Details{
|
||||||
status_code,
|
status_code,
|
||||||
url,
|
url_and_body:Box::new(UrlAndBody{url,body})
|
||||||
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:i32,
|
pub OperationID:OperationID,
|
||||||
pub AssetOwner:i64,
|
pub AssetOwner:i64,
|
||||||
pub DisplayName:&'a str,
|
pub DisplayName:&'a str,
|
||||||
pub Creator:&'a str,
|
pub Creator:&'a str,
|
||||||
pub GameID:i32,
|
pub GameID:GameID,
|
||||||
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)]
|
||||||
@@ -83,13 +98,15 @@ 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:i32,
|
pub OperationID:OperationID,
|
||||||
pub AssetOwner:i64,
|
pub AssetOwner:i64,
|
||||||
pub DisplayName:&'a str,
|
pub DisplayName:&'a str,
|
||||||
pub Creator:&'a str,
|
pub Creator:&'a str,
|
||||||
pub GameID:i32,
|
pub GameID:GameID,
|
||||||
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)]
|
||||||
@@ -128,7 +145,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<i64>,
|
pub ResourceID:Option<ResourceID>,
|
||||||
}
|
}
|
||||||
#[derive(Clone,Copy,Debug)]
|
#[derive(Clone,Copy,Debug)]
|
||||||
pub struct HashRequest<'a>{
|
pub struct HashRequest<'a>{
|
||||||
@@ -142,7 +159,7 @@ pub struct ScriptResponse{
|
|||||||
pub Hash:String,
|
pub Hash:String,
|
||||||
pub Source:String,
|
pub Source:String,
|
||||||
pub ResourceType:ResourceType,
|
pub ResourceType:ResourceType,
|
||||||
pub ResourceID:i64,
|
pub ResourceID:ResourceID,
|
||||||
}
|
}
|
||||||
#[allow(nonstandard_style)]
|
#[allow(nonstandard_style)]
|
||||||
#[derive(Clone,Debug,serde::Serialize)]
|
#[derive(Clone,Debug,serde::Serialize)]
|
||||||
@@ -151,7 +168,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<i64>,
|
pub ResourceID:Option<ResourceID>,
|
||||||
}
|
}
|
||||||
#[allow(nonstandard_style)]
|
#[allow(nonstandard_style)]
|
||||||
#[derive(Clone,Debug,serde::Deserialize)]
|
#[derive(Clone,Debug,serde::Deserialize)]
|
||||||
@@ -169,6 +186,10 @@ 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>{
|
||||||
@@ -217,55 +238,243 @@ pub struct UpdateScriptPolicyRequest{
|
|||||||
#[allow(nonstandard_style)]
|
#[allow(nonstandard_style)]
|
||||||
#[derive(Clone,Debug)]
|
#[derive(Clone,Debug)]
|
||||||
pub struct UpdateSubmissionModelRequest{
|
pub struct UpdateSubmissionModelRequest{
|
||||||
pub SubmissionID:i64,
|
pub SubmissionID:SubmissionID,
|
||||||
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:i64,
|
pub SubmissionID:SubmissionID,
|
||||||
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:i64,
|
pub SubmissionID:SubmissionID,
|
||||||
pub StatusMessage:String,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone,Copy,Debug,serde::Deserialize)]
|
#[allow(nonstandard_style)]
|
||||||
pub struct SubmissionID(pub i64);
|
#[derive(Clone,Debug)]
|
||||||
|
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:i64,
|
pub MapfixID:MapfixID,
|
||||||
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:i64,
|
pub MapfixID:MapfixID,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(nonstandard_style)]
|
#[allow(nonstandard_style)]
|
||||||
#[derive(Clone,Debug)]
|
#[derive(Clone,Debug)]
|
||||||
pub struct ActionMapfixAcceptedRequest{
|
pub struct ActionMapfixAcceptedRequest{
|
||||||
pub MapfixID:i64,
|
pub MapfixID:MapfixID,
|
||||||
pub StatusMessage:String,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone,Copy,Debug,serde::Deserialize)]
|
#[allow(nonstandard_style)]
|
||||||
pub struct MapfixID(pub i64);
|
#[derive(Clone,Debug)]
|
||||||
|
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:i32,
|
pub OperationID:OperationID,
|
||||||
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],
|
||||||
|
}
|
||||||
|
|||||||
863
validation/src/check.rs
Normal file
863
validation/src/check.rs
Normal file
@@ -0,0 +1,863 @@
|
|||||||
|
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})
|
||||||
|
}
|
||||||
|
}
|
||||||
67
validation/src/check_mapfix.rs
Normal file
67
validation/src/check_mapfix.rs
Normal file
@@ -0,0 +1,67 @@
|
|||||||
|
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(())
|
||||||
|
}
|
||||||
|
}
|
||||||
68
validation/src/check_submission.rs
Normal file
68
validation/src/check_submission.rs
Normal file
@@ -0,0 +1,68 @@
|
|||||||
|
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,18 +1,14 @@
|
|||||||
use crate::rbx_util::{get_mapinfo,read_dom,MapInfo,ReadDomError,GetMapInfoError,ParseGameIDError};
|
use crate::download::download_asset_version;
|
||||||
|
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,
|
CreatorTypeMustBeUser,
|
||||||
ModelInfoDownload(rbx_asset::cloud::GetError),
|
ModelInfoDownload(rbx_asset::cloud::GetError),
|
||||||
ModelLocationDownload(rbx_asset::cloud::GetError),
|
Download(crate::download::Error),
|
||||||
NonFreeModel,
|
|
||||||
ModelFileDownload(rbx_asset::cloud::GetError),
|
|
||||||
ParseUserID(core::num::ParseIntError),
|
|
||||||
ParseModelVersion(core::num::ParseIntError),
|
|
||||||
ModelFileDecode(ReadDomError),
|
ModelFileDecode(ReadDomError),
|
||||||
GetMapInfo(GetMapInfoError),
|
GetRootInstance(GetRootInstanceError),
|
||||||
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{
|
||||||
@@ -27,10 +23,10 @@ pub struct CreateRequest{
|
|||||||
}
|
}
|
||||||
#[allow(nonstandard_style)]
|
#[allow(nonstandard_style)]
|
||||||
pub struct CreateResult{
|
pub struct CreateResult{
|
||||||
pub AssetOwner:i64,
|
pub AssetOwner:u64,
|
||||||
pub DisplayName:String,
|
pub DisplayName:Option<String>,
|
||||||
pub Creator:String,
|
pub Creator:Option<String>,
|
||||||
pub GameID:i32,
|
pub GameID:Option<GameID>,
|
||||||
pub AssetVersion:u64,
|
pub AssetVersion:u64,
|
||||||
}
|
}
|
||||||
impl crate::message_handler::MessageHandler{
|
impl crate::message_handler::MessageHandler{
|
||||||
@@ -41,45 +37,36 @@ impl crate::message_handler::MessageHandler{
|
|||||||
).await.map_err(Error::ModelInfoDownload)?;
|
).await.map_err(Error::ModelInfoDownload)?;
|
||||||
|
|
||||||
// reject models created by a group
|
// reject models created by a group
|
||||||
let rbx_asset::cloud::Creator::userId(user_id_string)=info.creationContext.creator else{
|
let rbx_asset::cloud::Creator::userId(user_id)=info.creationContext.creator else{
|
||||||
return Err(Error::CreatorTypeMustBeUser);
|
return Err(Error::CreatorTypeMustBeUser);
|
||||||
};
|
};
|
||||||
|
|
||||||
// parse user string and model version string
|
let asset_version=info.revisionId;
|
||||||
let user_id:u64=user_id_string.parse().map_err(Error::ParseUserID)?;
|
|
||||||
let asset_version=info.revisionId.parse().map_err(Error::ParseModelVersion)?;
|
|
||||||
|
|
||||||
// download the location of the map model
|
|
||||||
let location=self.cloud_context.get_asset_version_location(rbx_asset::cloud::GetAssetVersionRequest{
|
|
||||||
asset_id:create_info.ModelID,
|
|
||||||
version:asset_version,
|
|
||||||
}).await.map_err(Error::ModelLocationDownload)?;
|
|
||||||
|
|
||||||
// if the location does not exist, you are not allowed to donwload it
|
|
||||||
let Some(location)=location.location else{
|
|
||||||
return Err(Error::NonFreeModel);
|
|
||||||
};
|
|
||||||
|
|
||||||
// download the map model
|
// download the map model
|
||||||
let model_data=self.cloud_context.get_asset(&location).await.map_err(Error::ModelFileDownload)?;
|
let maybe_gzip=download_asset_version(&self.cloud_context,rbx_asset::cloud::GetAssetVersionRequest{
|
||||||
|
asset_id:create_info.ModelID,
|
||||||
|
version:asset_version,
|
||||||
|
}).await.map_err(Error::Download)?;
|
||||||
|
|
||||||
// decode dom (slow!)
|
// decode dom (slow!)
|
||||||
let dom=read_dom(std::io::Cursor::new(model_data)).map_err(Error::ModelFileDecode)?;
|
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)?;
|
||||||
|
|
||||||
// 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).map_err(Error::GetMapInfo)?;
|
}=get_mapinfo(&dom,model_instance);
|
||||||
|
|
||||||
let game_id=game_id.map_err(Error::ParseGameID)?;
|
|
||||||
|
|
||||||
Ok(CreateResult{
|
Ok(CreateResult{
|
||||||
AssetOwner:user_id as i64,
|
AssetOwner:user_id,
|
||||||
DisplayName:display_name.unwrap_or_default().to_owned(),
|
DisplayName:display_name.ok().map(ToOwned::to_owned),
|
||||||
Creator:creator.unwrap_or_default().to_owned(),
|
Creator:creator.ok().map(ToOwned::to_owned),
|
||||||
GameID:game_id as i32,
|
GameID:game_id.ok(),
|
||||||
AssetVersion:asset_version,
|
AssetVersion:asset_version,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,13 +24,15 @@ 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,
|
AssetOwner:create_request.AssetOwner as i64,
|
||||||
DisplayName:create_request.DisplayName.as_str(),
|
DisplayName:create_request.DisplayName.as_deref().unwrap_or_default(),
|
||||||
Creator:create_request.Creator.as_str(),
|
Creator:create_request.Creator.as_deref().unwrap_or_default(),
|
||||||
GameID:create_request.GameID,
|
// not great TODO: make this great
|
||||||
|
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(())
|
||||||
@@ -41,9 +43,12 @@ 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:format!("{e}"),
|
StatusMessage:e.to_string(),
|
||||||
}).await?;
|
}).await?;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
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)]
|
||||||
@@ -19,15 +20,33 @@ 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,
|
AssetOwner:create_request.AssetOwner as i64,
|
||||||
DisplayName:create_request.DisplayName.as_str(),
|
DisplayName:display_name,
|
||||||
Creator:create_request.Creator.as_str(),
|
Creator:creator,
|
||||||
GameID:create_request.GameID,
|
GameID:game_id.into(),
|
||||||
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(())
|
||||||
@@ -38,9 +57,12 @@ 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:format!("{e}"),
|
StatusMessage:e.to_string(),
|
||||||
}).await?;
|
}).await?;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
26
validation/src/download.rs
Normal file
26
validation/src/download.rs
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
#[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,7 +3,10 @@ use futures::StreamExt;
|
|||||||
mod rbx_util;
|
mod rbx_util;
|
||||||
mod message_handler;
|
mod message_handler;
|
||||||
mod nats_types;
|
mod nats_types;
|
||||||
mod types;
|
mod download;
|
||||||
|
mod check;
|
||||||
|
mod check_mapfix;
|
||||||
|
mod check_submission;
|
||||||
mod create;
|
mod create;
|
||||||
mod create_mapfix;
|
mod create_mapfix;
|
||||||
mod create_submission;
|
mod create_submission;
|
||||||
@@ -39,7 +42,7 @@ 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)=>Err(e).expect("ROBLOX_GROUP_ID env required"),
|
Err(e)=>panic!("{e}: ROBLOX_GROUP_ID env required"),
|
||||||
};
|
};
|
||||||
|
|
||||||
// create / upload models through STRAFESNET_CI2 account
|
// create / upload models through STRAFESNET_CI2 account
|
||||||
|
|||||||
@@ -7,6 +7,8 @@ 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),
|
||||||
@@ -52,6 +54,8 @@ 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,3 +1,5 @@
|
|||||||
|
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
|
||||||
|
|
||||||
@@ -8,23 +10,46 @@
|
|||||||
#[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:i32,
|
pub OperationID:OperationID,
|
||||||
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:i32,
|
pub OperationID:OperationID,
|
||||||
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:i64,
|
pub SubmissionID:SubmissionID,
|
||||||
pub ModelID:u64,
|
pub ModelID:u64,
|
||||||
pub ModelVersion:u64,
|
pub ModelVersion:u64,
|
||||||
pub ValidatedModelID:Option<u64>,
|
pub ValidatedModelID:Option<u64>,
|
||||||
@@ -34,7 +59,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:i64,
|
pub MapfixID:MapfixID,
|
||||||
pub ModelID:u64,
|
pub ModelID:u64,
|
||||||
pub ModelVersion:u64,
|
pub ModelVersion:u64,
|
||||||
pub ValidatedModelID:Option<u64>,
|
pub ValidatedModelID:Option<u64>,
|
||||||
@@ -44,7 +69,7 @@ pub struct ValidateMapfixRequest{
|
|||||||
#[allow(nonstandard_style)]
|
#[allow(nonstandard_style)]
|
||||||
#[derive(serde::Deserialize)]
|
#[derive(serde::Deserialize)]
|
||||||
pub struct UploadSubmissionRequest{
|
pub struct UploadSubmissionRequest{
|
||||||
pub SubmissionID:i64,
|
pub SubmissionID:SubmissionID,
|
||||||
pub ModelID:u64,
|
pub ModelID:u64,
|
||||||
pub ModelVersion:u64,
|
pub ModelVersion:u64,
|
||||||
pub ModelName:String,
|
pub ModelName:String,
|
||||||
@@ -53,7 +78,7 @@ pub struct UploadSubmissionRequest{
|
|||||||
#[allow(nonstandard_style)]
|
#[allow(nonstandard_style)]
|
||||||
#[derive(serde::Deserialize)]
|
#[derive(serde::Deserialize)]
|
||||||
pub struct UploadMapfixRequest{
|
pub struct UploadMapfixRequest{
|
||||||
pub MapfixID:i64,
|
pub MapfixID:MapfixID,
|
||||||
pub ModelID:u64,
|
pub ModelID:u64,
|
||||||
pub ModelVersion:u64,
|
pub ModelVersion:u64,
|
||||||
pub TargetAssetID:u64,
|
pub TargetAssetID:u64,
|
||||||
|
|||||||
@@ -5,8 +5,7 @@ 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),
|
||||||
Seek(std::io::Error),
|
UnknownFormat(Vec<u8>),
|
||||||
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{
|
||||||
@@ -15,44 +14,22 @@ 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+std::io::Seek>(mut input:R)->Result<rbx_dom_weak::WeakDom,ReadDomError>{
|
pub fn read_dom<R:std::io::Read>(input:R)->Result<rbx_dom_weak::WeakDom,ReadDomError>{
|
||||||
let mut first_8=[0u8;8];
|
let mut buf=std::io::BufReader::new(input);
|
||||||
std::io::Read::read_exact(&mut input,&mut first_8).map_err(ReadDomError::Read)?;
|
let peek=std::io::BufRead::fill_buf(&mut buf).map_err(ReadDomError::Read)?;
|
||||||
std::io::Seek::rewind(&mut input).map_err(ReadDomError::Seek)?;
|
match peek.get(0..8){
|
||||||
match &first_8[0..4]{
|
Some(b"<roblox!")=>rbx_binary::from_reader(buf).map_err(ReadDomError::Binary),
|
||||||
b"<rob"=>{
|
Some(b"<roblox ")=>rbx_xml::from_reader_default(buf).map_err(ReadDomError::Xml),
|
||||||
match &first_8[4..8]{
|
_=>Err(ReadDomError::UnknownFormat(peek.to_owned())),
|
||||||
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 class_is_a(class:&str,superclass:&str)->bool{
|
pub fn static_ustr(s:&'static str)->rbx_dom_weak::Ustr{
|
||||||
if class==superclass{
|
rbx_dom_weak::ustr(s)
|
||||||
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
|
|
||||||
}
|
}
|
||||||
|
|
||||||
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>{
|
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>{
|
||||||
for &referent in instance.children(){
|
instance.children().iter().filter_map(|&r|dom.get_by_ref(r)).find(|inst|inst.name==name&&inst.class==class)
|
||||||
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{
|
||||||
@@ -60,6 +37,15 @@ 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{
|
||||||
@@ -74,7 +60,19 @@ impl std::str::FromStr for GameID{
|
|||||||
if s.starts_with("flytrials_"){
|
if s.starts_with("flytrials_"){
|
||||||
return Ok(GameID::FlyTrials);
|
return Ok(GameID::FlyTrials);
|
||||||
}
|
}
|
||||||
return Err(ParseGameIDError);
|
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)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -84,6 +82,7 @@ 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,
|
||||||
@@ -92,7 +91,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("Value").ok_or(StringValueError::ValueNotSet)?;
|
let value=instance.properties.get(&static_ustr("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),
|
||||||
@@ -100,20 +99,24 @@ fn string_value(instance:Option<&rbx_dom_weak::Instance>)->Result<&str,StringVal
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub enum GetMapInfoError{
|
pub enum GetRootInstanceError{
|
||||||
ModelFileRootMustHaveOneChild,
|
ModelFileRootMustHaveOneChild,
|
||||||
ModelFileChildRefIsNil,
|
ModelFileChildRefIsNil,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_mapinfo(dom:&rbx_dom_weak::WeakDom)->Result<MapInfo,GetMapInfoError>{
|
pub fn get_root_instance(dom:&rbx_dom_weak::WeakDom)->Result<&rbx_dom_weak::Instance,GetRootInstanceError>{
|
||||||
let &[map_ref]=dom.root().children()else{
|
let &[map_ref]=dom.root().children()else{
|
||||||
return Err(GetMapInfoError::ModelFileRootMustHaveOneChild);
|
return Err(GetRootInstanceError::ModelFileRootMustHaveOneChild);
|
||||||
};
|
};
|
||||||
let model_instance=dom.get_by_ref(map_ref).ok_or(GetMapInfoError::ModelFileChildRefIsNil)?;
|
let model_instance=dom.get_by_ref(map_ref).ok_or(GetRootInstanceError::ModelFileChildRefIsNil)?;
|
||||||
|
|
||||||
Ok(MapInfo{
|
Ok(model_instance)
|
||||||
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")),
|
|
||||||
game_id:model_instance.name.parse(),
|
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(),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +0,0 @@
|
|||||||
pub enum ResourceID{
|
|
||||||
Mapfix(i64),
|
|
||||||
Submission(i64),
|
|
||||||
}
|
|
||||||
@@ -1,11 +1,11 @@
|
|||||||
|
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{
|
||||||
GetLocation(rbx_asset::cloud::GetError),
|
Download(crate::download::Error),
|
||||||
NonFreeModel,
|
IO(std::io::Error),
|
||||||
Get(rbx_asset::cloud::GetError),
|
|
||||||
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,19 +19,14 @@ 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 location of the map model
|
// download the map model
|
||||||
let location=self.cloud_context.get_asset_version_location(rbx_asset::cloud::GetAssetVersionRequest{
|
let maybe_gzip=download_asset_version(&self.cloud_context,rbx_asset::cloud::GetAssetVersionRequest{
|
||||||
asset_id:upload_info.ModelID,
|
asset_id:upload_info.ModelID,
|
||||||
version:upload_info.ModelVersion,
|
version:upload_info.ModelVersion,
|
||||||
}).await.map_err(Error::GetLocation)?;
|
}).await.map_err(Error::Download)?;
|
||||||
|
|
||||||
// if the location does not exist, you are not allowed to donwload it
|
// transparently handle gzipped models
|
||||||
let Some(location)=location.location else{
|
let model_data=maybe_gzip.to_vec().map_err(Error::IO)?;
|
||||||
return Err(Error::NonFreeModel);
|
|
||||||
};
|
|
||||||
|
|
||||||
// download the map model
|
|
||||||
let model_data=self.cloud_context.get_asset(&location).await.map_err(Error::Get)?;
|
|
||||||
|
|
||||||
// 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,11 @@
|
|||||||
|
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{
|
||||||
GetLocation(rbx_asset::cloud::GetError),
|
Download(crate::download::Error),
|
||||||
NonFreeModel,
|
IO(std::io::Error),
|
||||||
Get(rbx_asset::cloud::GetError),
|
|
||||||
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,19 +20,14 @@ 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 location of the map model
|
// download the map model
|
||||||
let location=self.cloud_context.get_asset_version_location(rbx_asset::cloud::GetAssetVersionRequest{
|
let maybe_gzip=download_asset_version(&self.cloud_context,rbx_asset::cloud::GetAssetVersionRequest{
|
||||||
asset_id:upload_info.ModelID,
|
asset_id:upload_info.ModelID,
|
||||||
version:upload_info.ModelVersion,
|
version:upload_info.ModelVersion,
|
||||||
}).await.map_err(Error::GetLocation)?;
|
}).await.map_err(Error::Download)?;
|
||||||
|
|
||||||
// if the location does not exist, you are not allowed to donwload it
|
// transparently handle gzipped models
|
||||||
let Some(location)=location.location else{
|
let model_data=maybe_gzip.to_vec().map_err(Error::IO)?;
|
||||||
return Err(Error::NonFreeModel);
|
|
||||||
};
|
|
||||||
|
|
||||||
// download the map model
|
|
||||||
let model_data=self.cloud_context.get_asset(&location).await.map_err(Error::Get)?;
|
|
||||||
|
|
||||||
// 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,14 +22,23 @@ 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(
|
||||||
submissions_api::types::MapfixID(mapfix_id)
|
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,14 +22,23 @@ 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(
|
||||||
submissions_api::types::SubmissionID(submission_id)
|
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::ResourceType;
|
use submissions_api::types::Resource;
|
||||||
|
|
||||||
use crate::rbx_util::{class_is_a,read_dom,ReadDomError};
|
use crate::download::download_asset_version;
|
||||||
use crate::types::ResourceID;
|
use crate::rbx_util::{read_dom,static_ustr,ReadDomError};
|
||||||
|
|
||||||
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.find("getfenv").is_some()||source.find("require").is_some()
|
source.contains("getfenv")||source.contains("require")
|
||||||
}
|
}
|
||||||
|
|
||||||
fn hash_source(source:&str)->String{
|
fn hash_source(source:&str)->String{
|
||||||
@@ -33,18 +33,22 @@ fn hash_source(source:&str)->String{
|
|||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub enum Error{
|
pub enum Error{
|
||||||
|
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>),
|
||||||
ModelLocationDownload(rbx_asset::cloud::GetError),
|
Download(crate::download::Error),
|
||||||
NonFreeModel,
|
|
||||||
ModelFileDownload(rbx_asset::cloud::GetError),
|
|
||||||
ModelFileDecode(ReadDomError),
|
ModelFileDecode(ReadDomError),
|
||||||
ApiGetScriptPolicyFromHash(submissions_api::types::SingleItemError),
|
ApiGetScriptPolicyFromHash(submissions_api::types::ScriptPolicySingleItemError),
|
||||||
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::SingleItemError),
|
ApiGetScriptFromHash(submissions_api::types::ScriptSingleItemError),
|
||||||
ApiUpdateMapfixModel(submissions_api::Error),
|
ApiUpdateMapfixModel(submissions_api::Error),
|
||||||
ApiUpdateSubmissionModel(submissions_api::Error),
|
ApiUpdateSubmissionModel(submissions_api::Error),
|
||||||
ModelFileRootMustHaveOneChild,
|
ModelFileRootMustHaveOneChild,
|
||||||
@@ -65,7 +69,7 @@ pub struct ValidateRequest{
|
|||||||
pub ModelID:u64,
|
pub ModelID:u64,
|
||||||
pub ModelVersion:u64,
|
pub ModelVersion:u64,
|
||||||
pub ValidatedModelID:Option<u64>,
|
pub ValidatedModelID:Option<u64>,
|
||||||
pub ResourceID:ResourceID,
|
pub Resource:Resource,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<crate::nats_types::ValidateMapfixRequest> for ValidateRequest{
|
impl From<crate::nats_types::ValidateMapfixRequest> for ValidateRequest{
|
||||||
@@ -74,7 +78,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,
|
||||||
ResourceID:ResourceID::Mapfix(value.MapfixID),
|
Resource:Resource::Mapfix(value.MapfixID),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -84,38 +88,51 @@ 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,
|
||||||
ResourceID:ResourceID::Submission(value.SubmissionID),
|
Resource:Resource::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<(),Error>{
|
||||||
// download the location of the map model
|
// discover asset creator and latest version
|
||||||
let location=self.cloud_context.get_asset_version_location(rbx_asset::cloud::GetAssetVersionRequest{
|
let info=self.cloud_context.get_asset_info(
|
||||||
asset_id:validate_info.ModelID,
|
rbx_asset::cloud::GetAssetLatestRequest{asset_id:validate_info.ModelID}
|
||||||
version:validate_info.ModelVersion,
|
).await.map_err(Error::ModelInfoDownload)?;
|
||||||
}).await.map_err(Error::ModelLocationDownload)?;
|
|
||||||
|
|
||||||
// if the location does not exist, you are not allowed to donwload it
|
// reject models created by a group
|
||||||
let Some(location)=location.location else{
|
let rbx_asset::cloud::Creator::userId(_user_id)=info.creationContext.creator else{
|
||||||
return Err(Error::NonFreeModel);
|
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
|
// download the map model
|
||||||
let model_data=self.cloud_context.get_asset(&location).await.map_err(Error::ModelFileDownload)?;
|
let maybe_gzip=download_asset_version(&self.cloud_context,rbx_asset::cloud::GetAssetVersionRequest{
|
||||||
|
asset_id:validate_info.ModelID,
|
||||||
|
version:validate_info.ModelVersion,
|
||||||
|
}).await.map_err(Error::Download)?;
|
||||||
|
|
||||||
// decode dom (slow!)
|
// decode dom (slow!)
|
||||||
let mut dom=read_dom(std::io::Cursor::new(model_data)).map_err(Error::ModelFileDecode)?;
|
let mut dom=maybe_gzip.read_with(read_dom,read_dom).map_err(Error::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"){
|
if let Some(rbx_dom_weak::types::Variant::String(source))=script.properties.get(&source_property){
|
||||||
// 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
|
||||||
@@ -159,10 +176,7 @@ impl crate::message_handler::MessageHandler{
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
}else{
|
}else{
|
||||||
let (resource_type,resource_id)=match validate_info.ResourceID{
|
let (resource_type,resource_id)=validate_info.Resource.split();
|
||||||
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{
|
||||||
@@ -188,7 +202,7 @@ impl crate::message_handler::MessageHandler{
|
|||||||
let mut modified=false;
|
let mut modified=false;
|
||||||
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"){
|
if let Some(rbx_dom_weak::types::Variant::String(source))=script.properties.get_mut(&source_property){
|
||||||
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());
|
||||||
@@ -263,8 +277,8 @@ impl crate::message_handler::MessageHandler{
|
|||||||
(validate_info.ModelID,validate_info.ModelVersion)
|
(validate_info.ModelID,validate_info.ModelVersion)
|
||||||
};
|
};
|
||||||
|
|
||||||
match validate_info.ResourceID{
|
match validate_info.Resource{
|
||||||
ResourceID::Mapfix(mapfix_id)=>{
|
Resource::Mapfix(mapfix_id)=>{
|
||||||
// update the mapfix to use the validated model
|
// update the mapfix to use the validated model
|
||||||
self.api.update_mapfix_validated_model(submissions_api::types::UpdateMapfixModelRequest{
|
self.api.update_mapfix_validated_model(submissions_api::types::UpdateMapfixModelRequest{
|
||||||
MapfixID:mapfix_id,
|
MapfixID:mapfix_id,
|
||||||
@@ -272,7 +286,7 @@ impl crate::message_handler::MessageHandler{
|
|||||||
ModelVersion:validated_model_version,
|
ModelVersion:validated_model_version,
|
||||||
}).await.map_err(Error::ApiUpdateMapfixModel)?;
|
}).await.map_err(Error::ApiUpdateMapfixModel)?;
|
||||||
},
|
},
|
||||||
ResourceID::Submission(submission_id)=>{
|
Resource::Submission(submission_id)=>{
|
||||||
// update the submission to use the validated model
|
// update the submission to use the validated model
|
||||||
self.api.update_submission_validated_model(submissions_api::types::UpdateSubmissionModelRequest{
|
self.api.update_submission_validated_model(submissions_api::types::UpdateSubmissionModelRequest{
|
||||||
SubmissionID:submission_id,
|
SubmissionID:submission_id,
|
||||||
@@ -286,17 +300,6 @@ impl crate::message_handler::MessageHandler{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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),
|
||||||
@@ -311,7 +314,11 @@ 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 mut scripts=std::vec::Vec::new();
|
let db=rbx_reflection_database::get();
|
||||||
recursive_collect_superclass(&mut scripts,dom,dom.root(),"LuaSourceContainer");
|
let superclass=&db.classes["LuaSourceContainer"];
|
||||||
scripts
|
dom.descendants().filter_map(|inst|{
|
||||||
|
let class=db.classes.get(inst.class.as_str())?;
|
||||||
|
db.has_superclass(class,superclass)
|
||||||
|
.then_some(inst.referent())
|
||||||
|
}).collect()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,18 +13,19 @@
|
|||||||
"@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": {
|
||||||
"typescript": "^5.7.2",
|
"@eslint/eslintrc": "^3.2.0",
|
||||||
"@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",
|
||||||
"@eslint/eslintrc": "^3.2.0"
|
"typescript": "^5.7.2"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
BIN
web/public/errors/404.png
Normal file
BIN
web/public/errors/404.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 30 KiB |
BIN
web/public/errors/500.png
Normal file
BIN
web/public/errors/500.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 35 KiB |
43
web/src/app/_components/ErrorDisplay.tsx
Normal file
43
web/src/app/_components/ErrorDisplay.tsx
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
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>
|
||||||
|
);
|
||||||
|
}
|
||||||
151
web/src/app/_components/carousel.tsx
Normal file
151
web/src/app/_components/carousel.tsx
Normal file
@@ -0,0 +1,151 @@
|
|||||||
|
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>
|
||||||
|
);
|
||||||
|
}
|
||||||
52
web/src/app/_components/comments/AuditEventItem.tsx
Normal file
52
web/src/app/_components/comments/AuditEventItem.tsx
Normal file
@@ -0,0 +1,52 @@
|
|||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
export default function AuditEventItem({ event, validatorUser }: AuditEventItemProps) {
|
||||||
|
return (
|
||||||
|
<Box sx={{ display: 'flex', gap: 2 }}>
|
||||||
|
<Avatar
|
||||||
|
src={event.User === validatorUser ? undefined : `/thumbnails/user/${event.User}`}
|
||||||
|
>
|
||||||
|
<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>
|
||||||
|
);
|
||||||
|
}
|
||||||
39
web/src/app/_components/comments/AuditEventsTabPanel.tsx
Normal file
39
web/src/app/_components/comments/AuditEventsTabPanel.tsx
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
export default function AuditEventsTabPanel({
|
||||||
|
activeTab,
|
||||||
|
auditEvents,
|
||||||
|
validatorUser
|
||||||
|
}: 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}
|
||||||
|
/>
|
||||||
|
))}
|
||||||
|
</Stack>
|
||||||
|
)}
|
||||||
|
</Box>
|
||||||
|
);
|
||||||
|
}
|
||||||
52
web/src/app/_components/comments/CommentItem.tsx
Normal file
52
web/src/app/_components/comments/CommentItem.tsx
Normal file
@@ -0,0 +1,52 @@
|
|||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
export default function CommentItem({ event, validatorUser }: CommentItemProps) {
|
||||||
|
return (
|
||||||
|
<Box sx={{ display: 'flex', gap: 2 }}>
|
||||||
|
<Avatar
|
||||||
|
src={event.User === validatorUser ? undefined : `/thumbnails/user/${event.User}`}
|
||||||
|
>
|
||||||
|
<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>
|
||||||
|
);
|
||||||
|
}
|
||||||
65
web/src/app/_components/comments/CommentsAndAuditSection.tsx
Normal file
65
web/src/app/_components/comments/CommentsAndAuditSection.tsx
Normal file
@@ -0,0 +1,65 @@
|
|||||||
|
import React, {useState} from 'react';
|
||||||
|
import {
|
||||||
|
Paper,
|
||||||
|
Box,
|
||||||
|
Tabs,
|
||||||
|
Tab,
|
||||||
|
} from "@mui/material";
|
||||||
|
import CommentsTabPanel from './CommentsTabPanel';
|
||||||
|
import AuditEventsTabPanel from './AuditEventsTabPanel';
|
||||||
|
import { AuditEvent } from "@/app/ts/AuditEvent";
|
||||||
|
|
||||||
|
interface CommentsAndAuditSectionProps {
|
||||||
|
auditEvents: AuditEvent[];
|
||||||
|
newComment: string;
|
||||||
|
setNewComment: (comment: string) => void;
|
||||||
|
handleCommentSubmit: () => void;
|
||||||
|
validatorUser: number;
|
||||||
|
userId: number | null;
|
||||||
|
}
|
||||||
|
|
||||||
|
export default function CommentsAndAuditSection({
|
||||||
|
auditEvents,
|
||||||
|
newComment,
|
||||||
|
setNewComment,
|
||||||
|
handleCommentSubmit,
|
||||||
|
validatorUser,
|
||||||
|
userId,
|
||||||
|
}: CommentsAndAuditSectionProps) {
|
||||||
|
|
||||||
|
const [activeTab, setActiveTab] = useState(0);
|
||||||
|
const handleTabChange = (event: React.SyntheticEvent, newValue: number) => {
|
||||||
|
setActiveTab(newValue);
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Paper sx={{ p: 3, mt: 3 }}>
|
||||||
|
<Box sx={{ borderBottom: 1, borderColor: 'divider', mb: 2 }}>
|
||||||
|
<Tabs
|
||||||
|
value={activeTab}
|
||||||
|
onChange={handleTabChange}
|
||||||
|
aria-label="comments and audit tabs"
|
||||||
|
>
|
||||||
|
<Tab label="Comments" />
|
||||||
|
<Tab label="Audit Events" />
|
||||||
|
</Tabs>
|
||||||
|
</Box>
|
||||||
|
|
||||||
|
<CommentsTabPanel
|
||||||
|
activeTab={activeTab}
|
||||||
|
auditEvents={auditEvents}
|
||||||
|
validatorUser={validatorUser}
|
||||||
|
newComment={newComment}
|
||||||
|
setNewComment={setNewComment}
|
||||||
|
handleCommentSubmit={handleCommentSubmit}
|
||||||
|
userId={userId}
|
||||||
|
/>
|
||||||
|
|
||||||
|
<AuditEventsTabPanel
|
||||||
|
activeTab={activeTab}
|
||||||
|
auditEvents={auditEvents}
|
||||||
|
validatorUser={validatorUser}
|
||||||
|
/>
|
||||||
|
</Paper>
|
||||||
|
);
|
||||||
|
}
|
||||||
100
web/src/app/_components/comments/CommentsTabPanel.tsx
Normal file
100
web/src/app/_components/comments/CommentsTabPanel.tsx
Normal file
@@ -0,0 +1,100 @@
|
|||||||
|
import React from 'react';
|
||||||
|
import {
|
||||||
|
Box,
|
||||||
|
Stack,
|
||||||
|
Avatar,
|
||||||
|
TextField,
|
||||||
|
IconButton
|
||||||
|
} from "@mui/material";
|
||||||
|
import SendIcon from '@mui/icons-material/Send';
|
||||||
|
import { AuditEvent, AuditEventType } from "@/app/ts/AuditEvent";
|
||||||
|
import CommentItem from './CommentItem';
|
||||||
|
|
||||||
|
interface CommentsTabPanelProps {
|
||||||
|
activeTab: number;
|
||||||
|
auditEvents: AuditEvent[];
|
||||||
|
validatorUser: number;
|
||||||
|
newComment: string;
|
||||||
|
setNewComment: (comment: string) => void;
|
||||||
|
handleCommentSubmit: () => void;
|
||||||
|
userId: number | null;
|
||||||
|
}
|
||||||
|
|
||||||
|
export default function CommentsTabPanel({
|
||||||
|
activeTab,
|
||||||
|
auditEvents,
|
||||||
|
validatorUser,
|
||||||
|
newComment,
|
||||||
|
setNewComment,
|
||||||
|
handleCommentSubmit,
|
||||||
|
userId
|
||||||
|
}: CommentsTabPanelProps) {
|
||||||
|
const commentEvents = auditEvents.filter(
|
||||||
|
event => event.EventType === AuditEventType.Comment
|
||||||
|
);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Box role="tabpanel" hidden={activeTab !== 0}>
|
||||||
|
{activeTab === 0 && (
|
||||||
|
<>
|
||||||
|
<Stack spacing={2} sx={{ mb: 3 }}>
|
||||||
|
{commentEvents.length > 0 ? (
|
||||||
|
commentEvents.map((event, index) => (
|
||||||
|
<CommentItem
|
||||||
|
key={index}
|
||||||
|
event={event}
|
||||||
|
validatorUser={validatorUser}
|
||||||
|
/>
|
||||||
|
))
|
||||||
|
) : (
|
||||||
|
<Box sx={{ textAlign: 'center', py: 2, color: 'text.secondary' }}>
|
||||||
|
No Comments
|
||||||
|
</Box>
|
||||||
|
)}
|
||||||
|
</Stack>
|
||||||
|
|
||||||
|
{userId !== null && (
|
||||||
|
<CommentInput
|
||||||
|
newComment={newComment}
|
||||||
|
setNewComment={setNewComment}
|
||||||
|
handleCommentSubmit={handleCommentSubmit}
|
||||||
|
userId={userId}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
</Box>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
interface CommentInputProps {
|
||||||
|
newComment: string;
|
||||||
|
setNewComment: (comment: string) => void;
|
||||||
|
handleCommentSubmit: () => void;
|
||||||
|
userId: number | null;
|
||||||
|
}
|
||||||
|
|
||||||
|
function CommentInput({ newComment, setNewComment, handleCommentSubmit, userId }: CommentInputProps) {
|
||||||
|
return (
|
||||||
|
<Box sx={{ display: 'flex', gap: 2, alignItems: 'flex-start' }}>
|
||||||
|
<Avatar
|
||||||
|
src={`/thumbnails/user/${userId}`}
|
||||||
|
/>
|
||||||
|
<TextField
|
||||||
|
fullWidth
|
||||||
|
multiline
|
||||||
|
rows={2}
|
||||||
|
placeholder="Add a comment..."
|
||||||
|
value={newComment}
|
||||||
|
onChange={(e) => setNewComment(e.target.value)}
|
||||||
|
/>
|
||||||
|
<IconButton
|
||||||
|
color="primary"
|
||||||
|
onClick={handleCommentSubmit}
|
||||||
|
disabled={!newComment.trim()}
|
||||||
|
>
|
||||||
|
<SendIcon />
|
||||||
|
</IconButton>
|
||||||
|
</Box>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -1,30 +1,245 @@
|
|||||||
import Link from "next/link"
|
"use client"
|
||||||
|
|
||||||
import "./styles/header.scss"
|
import Link from "next/link"
|
||||||
|
import Image from "next/image";
|
||||||
|
import { UserInfo } from "@/app/ts/User";
|
||||||
|
import { useState, useEffect } from "react";
|
||||||
|
|
||||||
|
import AppBar from "@mui/material/AppBar";
|
||||||
|
import Toolbar from "@mui/material/Toolbar";
|
||||||
|
import Button from "@mui/material/Button";
|
||||||
|
import Typography from "@mui/material/Typography";
|
||||||
|
import Box from "@mui/material/Box";
|
||||||
|
import Menu from "@mui/material/Menu";
|
||||||
|
import MenuItem from "@mui/material/MenuItem";
|
||||||
|
import IconButton from "@mui/material/IconButton";
|
||||||
|
import MenuIcon from "@mui/icons-material/Menu";
|
||||||
|
import Drawer from "@mui/material/Drawer";
|
||||||
|
import List from "@mui/material/List";
|
||||||
|
import ListItem from "@mui/material/ListItem";
|
||||||
|
import ListItemButton from "@mui/material/ListItemButton";
|
||||||
|
import ListItemText from "@mui/material/ListItemText";
|
||||||
|
import useMediaQuery from "@mui/material/useMediaQuery";
|
||||||
|
import { useTheme } from "@mui/material/styles";
|
||||||
|
|
||||||
interface HeaderButton {
|
interface HeaderButton {
|
||||||
name: string,
|
name: string;
|
||||||
href: string
|
href: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const navItems: HeaderButton[] = [
|
||||||
|
{ name: "Submissions", href: "/submissions" },
|
||||||
|
{ name: "Mapfixes", href: "/mapfixes" },
|
||||||
|
{ name: "Maps", href: "/maps" },
|
||||||
|
];
|
||||||
|
|
||||||
function HeaderButton(header: HeaderButton) {
|
function HeaderButton(header: HeaderButton) {
|
||||||
return (
|
return (
|
||||||
<Link href={header.href}>
|
<Button color="inherit" component={Link} href={header.href}>
|
||||||
<button>{header.name}</button>
|
{header.name}
|
||||||
</Link>
|
</Button>
|
||||||
)
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function Header() {
|
export default function Header() {
|
||||||
return (
|
const theme = useTheme();
|
||||||
<header className="header-bar">
|
const isMobile = useMediaQuery(theme.breakpoints.down('md'));
|
||||||
<nav className="left">
|
const [mobileOpen, setMobileOpen] = useState(false);
|
||||||
<HeaderButton name="Submissions" href="/submissions"/>
|
|
||||||
<HeaderButton name="Mapfixes" href="/mapfixes"/>
|
const handleLoginClick = () => {
|
||||||
<HeaderButton name="Maps" href="/maps"/>
|
window.location.href =
|
||||||
</nav>
|
"/auth/oauth2/login?redirect=" + window.location.href;
|
||||||
<nav className="right">
|
};
|
||||||
<HeaderButton name="Submit" href="/submit"/>
|
|
||||||
</nav>
|
const [valid, setValid] = useState<boolean>(false);
|
||||||
</header>
|
const [user, setUser] = useState<UserInfo | null>(null);
|
||||||
)
|
const [anchorEl, setAnchorEl] = useState<null | HTMLElement>(null);
|
||||||
}
|
|
||||||
|
const handleMenuOpen = (event: React.MouseEvent<HTMLElement>) => {
|
||||||
|
setAnchorEl(event.currentTarget);
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleMenuClose = () => {
|
||||||
|
setAnchorEl(null);
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleDrawerToggle = () => {
|
||||||
|
setMobileOpen(!mobileOpen);
|
||||||
|
};
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
async function getLoginInfo() {
|
||||||
|
try {
|
||||||
|
const response = await fetch("/api/session/user");
|
||||||
|
|
||||||
|
if (!response.ok) {
|
||||||
|
setValid(false);
|
||||||
|
setUser(null);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const userData = await response.json();
|
||||||
|
const isLoggedIn = userData && 'UserID' in userData;
|
||||||
|
|
||||||
|
setValid(isLoggedIn);
|
||||||
|
setUser(isLoggedIn ? userData : null);
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Error fetching user data:", error);
|
||||||
|
setValid(false);
|
||||||
|
setUser(null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
getLoginInfo();
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
// Mobile navigation drawer content
|
||||||
|
const drawer = (
|
||||||
|
<Box onClick={handleDrawerToggle} sx={{ textAlign: 'center' }}>
|
||||||
|
<List>
|
||||||
|
{navItems.map((item) => (
|
||||||
|
<ListItem key={item.name} disablePadding>
|
||||||
|
<ListItemButton component={Link} href={item.href} sx={{ textAlign: 'center' }}>
|
||||||
|
<ListItemText primary={item.name} />
|
||||||
|
</ListItemButton>
|
||||||
|
</ListItem>
|
||||||
|
))}
|
||||||
|
{valid && user && (
|
||||||
|
<ListItem disablePadding>
|
||||||
|
<ListItemButton component={Link} href="/submit" sx={{ textAlign: 'center' }}>
|
||||||
|
<ListItemText primary="Submit Map" sx={{ color: 'success.main' }} />
|
||||||
|
</ListItemButton>
|
||||||
|
</ListItem>
|
||||||
|
)}
|
||||||
|
{!valid && (
|
||||||
|
<ListItem disablePadding>
|
||||||
|
<ListItemButton onClick={handleLoginClick} sx={{ textAlign: 'center' }}>
|
||||||
|
<ListItemText primary="Login" />
|
||||||
|
</ListItemButton>
|
||||||
|
</ListItem>
|
||||||
|
)}
|
||||||
|
{valid && user && (
|
||||||
|
<ListItem disablePadding>
|
||||||
|
<ListItemButton component={Link} href="/auth" sx={{ textAlign: 'center' }}>
|
||||||
|
<ListItemText primary="Manage Account" />
|
||||||
|
</ListItemButton>
|
||||||
|
</ListItem>
|
||||||
|
)}
|
||||||
|
</List>
|
||||||
|
</Box>
|
||||||
|
);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<AppBar position="static">
|
||||||
|
<Toolbar>
|
||||||
|
{isMobile && (
|
||||||
|
<IconButton
|
||||||
|
color="inherit"
|
||||||
|
aria-label="open drawer"
|
||||||
|
edge="start"
|
||||||
|
onClick={handleDrawerToggle}
|
||||||
|
sx={{ mr: 2 }}
|
||||||
|
>
|
||||||
|
<MenuIcon />
|
||||||
|
</IconButton>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{/* Desktop navigation */}
|
||||||
|
{!isMobile && (
|
||||||
|
<Box display="flex" flexGrow={1} gap={2}>
|
||||||
|
{navItems.map((item) => (
|
||||||
|
<HeaderButton key={item.name} name={item.name} href={item.href} />
|
||||||
|
))}
|
||||||
|
</Box>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{/* Spacer for mobile view */}
|
||||||
|
{isMobile && <Box sx={{ flexGrow: 1 }} />}
|
||||||
|
|
||||||
|
{/* Right side of nav */}
|
||||||
|
<Box display="flex" gap={2}>
|
||||||
|
{!isMobile && valid && user && (
|
||||||
|
<Button variant="outlined" color="success" component={Link} href="/submit">
|
||||||
|
Submit Map
|
||||||
|
</Button>
|
||||||
|
)}
|
||||||
|
{!isMobile && valid && user ? (
|
||||||
|
<Box display="flex" alignItems="center">
|
||||||
|
<Button
|
||||||
|
onClick={handleMenuOpen}
|
||||||
|
color="inherit"
|
||||||
|
size="small"
|
||||||
|
style={{ textTransform: "none" }}
|
||||||
|
>
|
||||||
|
<Image
|
||||||
|
className="avatar"
|
||||||
|
width={28}
|
||||||
|
height={28}
|
||||||
|
priority={true}
|
||||||
|
src={user.AvatarURL}
|
||||||
|
alt={user.Username}
|
||||||
|
style={{ marginRight: 8 }}
|
||||||
|
/>
|
||||||
|
<Typography variant="body1">{user.Username}</Typography>
|
||||||
|
</Button>
|
||||||
|
<Menu
|
||||||
|
anchorEl={anchorEl}
|
||||||
|
open={Boolean(anchorEl)}
|
||||||
|
onClose={handleMenuClose}
|
||||||
|
anchorOrigin={{
|
||||||
|
vertical: "bottom",
|
||||||
|
horizontal: "left",
|
||||||
|
}}
|
||||||
|
transformOrigin={{
|
||||||
|
vertical: "top",
|
||||||
|
horizontal: "left",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<MenuItem component={Link} href="/auth">
|
||||||
|
Manage
|
||||||
|
</MenuItem>
|
||||||
|
</Menu>
|
||||||
|
</Box>
|
||||||
|
) : !isMobile && (
|
||||||
|
<Button color="inherit" onClick={handleLoginClick}>
|
||||||
|
Login
|
||||||
|
</Button>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{/* In mobile view, display just the avatar if logged in */}
|
||||||
|
{isMobile && valid && user && (
|
||||||
|
<IconButton
|
||||||
|
onClick={handleMenuOpen}
|
||||||
|
color="inherit"
|
||||||
|
size="small"
|
||||||
|
>
|
||||||
|
<Image
|
||||||
|
className="avatar"
|
||||||
|
width={28}
|
||||||
|
height={28}
|
||||||
|
priority={true}
|
||||||
|
src={user.AvatarURL}
|
||||||
|
alt={user.Username}
|
||||||
|
/>
|
||||||
|
</IconButton>
|
||||||
|
)}
|
||||||
|
</Box>
|
||||||
|
</Toolbar>
|
||||||
|
|
||||||
|
{/* Mobile drawer */}
|
||||||
|
<Drawer
|
||||||
|
variant="temporary"
|
||||||
|
open={mobileOpen}
|
||||||
|
onClose={handleDrawerToggle}
|
||||||
|
ModalProps={{
|
||||||
|
keepMounted: true, // Better open performance on mobile
|
||||||
|
}}
|
||||||
|
sx={{
|
||||||
|
'& .MuiDrawer-paper': { boxSizing: 'border-box', width: 240 },
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{drawer}
|
||||||
|
</Drawer>
|
||||||
|
</AppBar>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -1,71 +1,186 @@
|
|||||||
import React from "react";
|
import React from "react";
|
||||||
import Image from "next/image";
|
import {Avatar, Box, Card, CardActionArea, CardContent, CardMedia, Divider, Grid, Typography} from "@mui/material";
|
||||||
import Link from "next/link";
|
import {Explore, Person2} from "@mui/icons-material";
|
||||||
import { Rating } from "@mui/material";
|
import {StatusChip} from "@/app/_components/statusChip";
|
||||||
|
|
||||||
interface SubmissionCardProps {
|
interface MapCardProps {
|
||||||
displayName: string;
|
displayName: string;
|
||||||
assetId: number;
|
assetId: number;
|
||||||
authorId: number;
|
authorId: number;
|
||||||
author: string;
|
author: string;
|
||||||
rating: number;
|
rating: number;
|
||||||
id: number;
|
id: number;
|
||||||
|
statusID: number;
|
||||||
|
gameID: number;
|
||||||
|
created: number;
|
||||||
|
type: 'mapfix' | 'submission';
|
||||||
}
|
}
|
||||||
|
|
||||||
export function SubmissionCard(props: SubmissionCardProps) {
|
const CARD_WIDTH = 270;
|
||||||
return (
|
|
||||||
<Link href={`/submissions/${props.id}`}>
|
|
||||||
<div className="submissionCard">
|
|
||||||
<div className="content">
|
|
||||||
<div className="map-image">
|
|
||||||
{/* TODO: Grab image of model */}
|
|
||||||
<Image width={230} height={230} layout="fixed" priority={true} src={`/thumbnails/asset/${props.assetId}`} alt={props.displayName} />
|
|
||||||
</div>
|
|
||||||
<div className="details">
|
|
||||||
<div className="header">
|
|
||||||
<span className="displayName">{props.displayName}</span>
|
|
||||||
<div className="rating">
|
|
||||||
<Rating value={props.rating} readOnly size="small" />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div className="footer">
|
|
||||||
<div className="author">
|
|
||||||
<Image className="avatar" width={28} height={28} priority={true} src={`/thumbnails/user/${props.authorId}`} alt={props.author}/>
|
|
||||||
<span>{props.author}</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</Link>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
export function MapfixCard(props: SubmissionCardProps) {
|
export function MapCard(props: MapCardProps) {
|
||||||
return (
|
return (
|
||||||
<Link href={`/mapfixes/${props.id}`}>
|
<Grid item xs={12} sm={6} md={3} key={props.assetId}>
|
||||||
<div className="MapfixCard">
|
<Box sx={{
|
||||||
<div className="content">
|
width: CARD_WIDTH,
|
||||||
<div className="map-image">
|
mx: 'auto', // Center the card in its grid cell
|
||||||
{/* TODO: Grab image of model */}
|
}}>
|
||||||
<Image width={230} height={230} layout="fixed" priority={true} src={`/thumbnails/asset/${props.assetId}`} alt={props.displayName} />
|
<Card sx={{
|
||||||
</div>
|
width: CARD_WIDTH,
|
||||||
<div className="details">
|
height: 340, // Fixed height for all cards
|
||||||
<div className="header">
|
display: 'flex',
|
||||||
<span className="displayName">{props.displayName}</span>
|
flexDirection: 'column',
|
||||||
<div className="rating">
|
}}>
|
||||||
<Rating value={props.rating} readOnly size="small" />
|
<CardActionArea
|
||||||
</div>
|
sx={{
|
||||||
</div>
|
height: '100%',
|
||||||
<div className="footer">
|
display: 'flex',
|
||||||
<div className="author">
|
flexDirection: 'column',
|
||||||
<Image className="avatar" width={28} height={28} priority={true} src={`/thumbnails/user/${props.authorId}`} alt={props.author}/>
|
alignItems: 'stretch'
|
||||||
<span>{props.author}</span>
|
}}
|
||||||
</div>
|
href={`/${props.type === 'submission' ? 'submissions' : 'mapfixes'}/${props.id}`}>
|
||||||
</div>
|
<Box sx={{ position: 'relative' }}>
|
||||||
</div>
|
<CardMedia
|
||||||
</div>
|
component="img"
|
||||||
</div>
|
image={`/thumbnails/asset/${props.assetId}`}
|
||||||
</Link>
|
alt={props.displayName}
|
||||||
);
|
sx={{
|
||||||
|
height: 160, // Fixed height for all images
|
||||||
|
objectFit: 'cover',
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
<Box
|
||||||
|
sx={{
|
||||||
|
position: 'absolute',
|
||||||
|
top: 12,
|
||||||
|
right: 12,
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<StatusChip status={props.statusID}/>
|
||||||
|
</Box>
|
||||||
|
</Box>
|
||||||
|
<CardContent sx={{
|
||||||
|
flex: 1,
|
||||||
|
display: 'flex',
|
||||||
|
flexDirection: 'column',
|
||||||
|
justifyContent: 'space-between',
|
||||||
|
p: 2,
|
||||||
|
width: '100%',
|
||||||
|
}}>
|
||||||
|
<Box>
|
||||||
|
<Typography
|
||||||
|
variant="subtitle1"
|
||||||
|
component="div"
|
||||||
|
sx={{
|
||||||
|
mb: 1,
|
||||||
|
fontWeight: 600,
|
||||||
|
color: '#fff',
|
||||||
|
lineHeight: '1.3',
|
||||||
|
// Allow text to wrap
|
||||||
|
overflow: 'hidden',
|
||||||
|
textOverflow: 'ellipsis',
|
||||||
|
display: '-webkit-box',
|
||||||
|
WebkitLineClamp: 2,
|
||||||
|
WebkitBoxOrient: 'vertical',
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{props.displayName}
|
||||||
|
</Typography>
|
||||||
|
<Box sx={{
|
||||||
|
display: 'flex',
|
||||||
|
mb: 1.5,
|
||||||
|
}}>
|
||||||
|
<Explore sx={{
|
||||||
|
mr: 0.75,
|
||||||
|
mt: 0.25,
|
||||||
|
color: 'text.secondary',
|
||||||
|
fontSize: '0.9rem',
|
||||||
|
flexShrink: 0,
|
||||||
|
}} />
|
||||||
|
<Typography
|
||||||
|
variant="body2"
|
||||||
|
color="text.secondary"
|
||||||
|
sx={{
|
||||||
|
fontWeight: 500,
|
||||||
|
// Allow text to wrap
|
||||||
|
overflow: 'hidden',
|
||||||
|
textOverflow: 'ellipsis',
|
||||||
|
display: '-webkit-box',
|
||||||
|
WebkitLineClamp: 2,
|
||||||
|
WebkitBoxOrient: 'vertical',
|
||||||
|
lineHeight: '1.2',
|
||||||
|
wordBreak: 'break-word',
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{props.gameID === 1 ? 'Bhop' : props.gameID === 2 ? 'Surf' : props.gameID === 5 ? 'Fly Trials' : props.gameID === 4 ? 'Deathrun' : 'Unknown'}
|
||||||
|
</Typography>
|
||||||
|
</Box>
|
||||||
|
<Box sx={{
|
||||||
|
display: 'flex',
|
||||||
|
mb: 1.5,
|
||||||
|
}}>
|
||||||
|
<Person2 sx={{
|
||||||
|
mr: 0.75,
|
||||||
|
mt: 0.25,
|
||||||
|
color: 'text.secondary',
|
||||||
|
fontSize: '0.9rem',
|
||||||
|
flexShrink: 0,
|
||||||
|
}} />
|
||||||
|
<Typography
|
||||||
|
variant="body2"
|
||||||
|
color="text.secondary"
|
||||||
|
sx={{
|
||||||
|
fontWeight: 500,
|
||||||
|
// Allow text to wrap
|
||||||
|
overflow: 'hidden',
|
||||||
|
textOverflow: 'ellipsis',
|
||||||
|
display: '-webkit-box',
|
||||||
|
WebkitLineClamp: 2,
|
||||||
|
WebkitBoxOrient: 'vertical',
|
||||||
|
lineHeight: '1.2',
|
||||||
|
wordBreak: 'break-word',
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{props.author}
|
||||||
|
</Typography>
|
||||||
|
</Box>
|
||||||
|
</Box>
|
||||||
|
<Box>
|
||||||
|
<Divider sx={{ my: 1.5 }} />
|
||||||
|
<Box sx={{ display: 'flex', alignItems: 'center' }}>
|
||||||
|
<Avatar
|
||||||
|
src={`/thumbnails/user/${props.authorId}`}
|
||||||
|
alt={props.author}
|
||||||
|
sx={{
|
||||||
|
width: 24,
|
||||||
|
height: 24,
|
||||||
|
border: '1px solid rgba(255, 255, 255, 0.1)',
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
<Typography
|
||||||
|
variant="caption"
|
||||||
|
sx={{
|
||||||
|
ml: 1,
|
||||||
|
color: 'text.secondary',
|
||||||
|
fontWeight: 500,
|
||||||
|
overflow: 'hidden',
|
||||||
|
textOverflow: 'ellipsis',
|
||||||
|
whiteSpace: 'nowrap',
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{/*In the future author should be the username of the submitter not the info from the map*/}
|
||||||
|
{props.author} - {new Date(props.created * 1000).toLocaleDateString('en-US', {
|
||||||
|
year: 'numeric',
|
||||||
|
month: 'long',
|
||||||
|
day: 'numeric'
|
||||||
|
})}
|
||||||
|
</Typography>
|
||||||
|
</Box>
|
||||||
|
</Box>
|
||||||
|
</CardContent>
|
||||||
|
</CardActionArea>
|
||||||
|
</Card>
|
||||||
|
</Box>
|
||||||
|
</Grid>
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
38
web/src/app/_components/review/CopyableField.tsx
Normal file
38
web/src/app/_components/review/CopyableField.tsx
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
import { Typography, Box, IconButton, Tooltip } from "@mui/material";
|
||||||
|
import ContentCopyIcon from '@mui/icons-material/ContentCopy';
|
||||||
|
|
||||||
|
interface CopyableFieldProps {
|
||||||
|
label: string;
|
||||||
|
value: string | number | null | undefined;
|
||||||
|
onCopy: (value: string) => void;
|
||||||
|
placeholderText?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export const CopyableField = ({
|
||||||
|
label,
|
||||||
|
value,
|
||||||
|
onCopy,
|
||||||
|
placeholderText = "Not assigned"
|
||||||
|
}: CopyableFieldProps) => {
|
||||||
|
const displayValue = value?.toString() || placeholderText;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<Typography variant="body2" color="text.secondary">{label}</Typography>
|
||||||
|
<Box sx={{ display: 'flex', alignItems: 'center' }}>
|
||||||
|
<Typography variant="body1">{displayValue}</Typography>
|
||||||
|
{value && (
|
||||||
|
<Tooltip title="Copy ID">
|
||||||
|
<IconButton
|
||||||
|
size="small"
|
||||||
|
onClick={() => onCopy(value.toString())}
|
||||||
|
sx={{ ml: 1 }}
|
||||||
|
>
|
||||||
|
<ContentCopyIcon fontSize="small" />
|
||||||
|
</IconButton>
|
||||||
|
</Tooltip>
|
||||||
|
)}
|
||||||
|
</Box>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
};
|
||||||
155
web/src/app/_components/review/ReviewButtons.tsx
Normal file
155
web/src/app/_components/review/ReviewButtons.tsx
Normal file
@@ -0,0 +1,155 @@
|
|||||||
|
import React from 'react';
|
||||||
|
import { Button, Stack } from '@mui/material';
|
||||||
|
import {MapfixInfo } from "@/app/ts/Mapfix";
|
||||||
|
import {hasRole, Roles, RolesConstants} from "@/app/ts/Roles";
|
||||||
|
import {SubmissionInfo} from "@/app/ts/Submission";
|
||||||
|
import {Status, StatusMatches} from "@/app/ts/Status";
|
||||||
|
|
||||||
|
interface ReviewAction {
|
||||||
|
name: string,
|
||||||
|
action: string,
|
||||||
|
}
|
||||||
|
|
||||||
|
interface ReviewButtonsProps {
|
||||||
|
onClick: (action: string, id: number) => void;
|
||||||
|
item: (SubmissionInfo | MapfixInfo);
|
||||||
|
userId: number | null;
|
||||||
|
roles: Roles;
|
||||||
|
type: "submission" | "mapfix";
|
||||||
|
}
|
||||||
|
|
||||||
|
const ReviewActions = {
|
||||||
|
Submit: {name:"Submit",action:"trigger-submit"} as ReviewAction,
|
||||||
|
SubmitUnchecked: {name:"Submit Unchecked", action:"trigger-submit-unchecked"} as ReviewAction,
|
||||||
|
ResetSubmitting: {name:"Reset Submitting",action:"reset-submitting"} as ReviewAction,
|
||||||
|
Revoke: {name:"Revoke",action:"revoke"} as ReviewAction,
|
||||||
|
Accept: {name:"Accept",action:"trigger-validate"} as ReviewAction,
|
||||||
|
Reject: {name:"Reject",action:"reject"} as ReviewAction,
|
||||||
|
Validate: {name:"Validate",action:"retry-validate"} as ReviewAction,
|
||||||
|
ResetValidating: {name:"Reset Validating",action:"reset-validating"} as ReviewAction,
|
||||||
|
RequestChanges: {name:"Request Changes",action:"request-changes"} as ReviewAction,
|
||||||
|
Upload: {name:"Upload",action:"trigger-upload"} as ReviewAction,
|
||||||
|
ResetUploading: {name:"Reset Uploading",action:"reset-uploading"} as ReviewAction,
|
||||||
|
}
|
||||||
|
|
||||||
|
const ReviewButtons: React.FC<ReviewButtonsProps> = ({
|
||||||
|
onClick,
|
||||||
|
item,
|
||||||
|
userId,
|
||||||
|
roles,
|
||||||
|
type,
|
||||||
|
}) => {
|
||||||
|
const getVisibleButtons = () => {
|
||||||
|
if (!item || userId === null) return [];
|
||||||
|
|
||||||
|
// Define a type for the button
|
||||||
|
type ReviewButton = {
|
||||||
|
action: ReviewAction;
|
||||||
|
color: "primary" | "error" | "success" | "info" | "warning";
|
||||||
|
};
|
||||||
|
|
||||||
|
const buttons: ReviewButton[] = [];
|
||||||
|
const is_submitter = userId === item.Submitter;
|
||||||
|
const status = item.StatusID;
|
||||||
|
|
||||||
|
const reviewRole = type === "submission" ? RolesConstants.SubmissionReview : RolesConstants.MapfixReview;
|
||||||
|
const uploadRole = type === "submission" ? RolesConstants.SubmissionUpload : RolesConstants.MapfixUpload;
|
||||||
|
|
||||||
|
if (is_submitter) {
|
||||||
|
if (StatusMatches(status, [Status.UnderConstruction, Status.ChangesRequested])) {
|
||||||
|
buttons.push({
|
||||||
|
action: ReviewActions.Submit,
|
||||||
|
color: "primary"
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (StatusMatches(status, [Status.Submitted, Status.ChangesRequested])) {
|
||||||
|
buttons.push({
|
||||||
|
action: ReviewActions.Revoke,
|
||||||
|
color: "error"
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Buttons for review role
|
||||||
|
if (hasRole(roles, reviewRole)) {
|
||||||
|
if (status === Status.Submitted && !is_submitter) {
|
||||||
|
buttons.push(
|
||||||
|
{
|
||||||
|
action: ReviewActions.Accept,
|
||||||
|
color: "success"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
action: ReviewActions.Reject,
|
||||||
|
color: "error"
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (status === Status.AcceptedUnvalidated) {
|
||||||
|
buttons.push({
|
||||||
|
action: ReviewActions.Validate,
|
||||||
|
color: "info"
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (status === Status.Validating) {
|
||||||
|
buttons.push({
|
||||||
|
action: ReviewActions.ResetValidating,
|
||||||
|
color: "warning"
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (StatusMatches(status, [Status.Validated, Status.AcceptedUnvalidated, Status.Submitted]) && !is_submitter) {
|
||||||
|
buttons.push({
|
||||||
|
action: ReviewActions.RequestChanges,
|
||||||
|
color: "warning"
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (status === Status.ChangesRequested) {
|
||||||
|
buttons.push({
|
||||||
|
action: ReviewActions.SubmitUnchecked,
|
||||||
|
color: "warning"
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Buttons for upload role
|
||||||
|
if (hasRole(roles, uploadRole)) {
|
||||||
|
if (status === Status.Validated) {
|
||||||
|
buttons.push({
|
||||||
|
action: ReviewActions.Upload,
|
||||||
|
color: "success"
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (status === Status.Uploading) {
|
||||||
|
buttons.push({
|
||||||
|
action: ReviewActions.ResetUploading,
|
||||||
|
color: "warning"
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return buttons;
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Stack spacing={2} sx={{ mb: 3 }}>
|
||||||
|
{getVisibleButtons().map((button, index) => (
|
||||||
|
<Button
|
||||||
|
key={index}
|
||||||
|
variant="contained"
|
||||||
|
color={button.color}
|
||||||
|
fullWidth
|
||||||
|
onClick={() => onClick(button.action.action, item.ID)}
|
||||||
|
>
|
||||||
|
{button.action.name}
|
||||||
|
</Button>
|
||||||
|
))}
|
||||||
|
</Stack>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default ReviewButtons;
|
||||||
86
web/src/app/_components/review/ReviewItem.tsx
Normal file
86
web/src/app/_components/review/ReviewItem.tsx
Normal file
@@ -0,0 +1,86 @@
|
|||||||
|
import { Paper, Grid, Typography } from "@mui/material";
|
||||||
|
import { ReviewItemHeader } from "./ReviewItemHeader";
|
||||||
|
import { CopyableField } from "@/app/_components/review/CopyableField";
|
||||||
|
import { SubmissionInfo } from "@/app/ts/Submission";
|
||||||
|
import { MapfixInfo } from "@/app/ts/Mapfix";
|
||||||
|
|
||||||
|
// Define a field configuration for specific types
|
||||||
|
interface FieldConfig {
|
||||||
|
key: string;
|
||||||
|
label: string;
|
||||||
|
placeholder?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
type ReviewItemType = SubmissionInfo | MapfixInfo;
|
||||||
|
|
||||||
|
interface ReviewItemProps {
|
||||||
|
item: ReviewItemType;
|
||||||
|
handleCopyValue: (value: string) => void;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function ReviewItem({
|
||||||
|
item,
|
||||||
|
handleCopyValue
|
||||||
|
}: ReviewItemProps) {
|
||||||
|
// Type guard to check if item is valid
|
||||||
|
if (!item) return null;
|
||||||
|
|
||||||
|
// Determine the type of item
|
||||||
|
const isSubmission = 'UploadedAssetID' in item;
|
||||||
|
const isMapfix = 'TargetAssetID' in item;
|
||||||
|
|
||||||
|
// Define static fields based on item type
|
||||||
|
let fields: FieldConfig[] = [];
|
||||||
|
if (isSubmission) {
|
||||||
|
// Fields for Submission
|
||||||
|
fields = [
|
||||||
|
{ key: 'Submitter', label: 'Submitter ID' },
|
||||||
|
{ key: 'AssetID', label: 'Asset ID' },
|
||||||
|
{ key: 'UploadedAssetID', label: 'Uploaded Asset ID' },
|
||||||
|
];
|
||||||
|
} else if (isMapfix) {
|
||||||
|
// Fields for Mapfix
|
||||||
|
fields = [
|
||||||
|
{ key: 'Submitter', label: 'Submitter ID' },
|
||||||
|
{ key: 'AssetID', label: 'Asset ID' },
|
||||||
|
{ key: 'TargetAssetID', label: 'Target Asset ID' },
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Paper elevation={3} sx={{ p: 3, borderRadius: 2, mb: 4 }}>
|
||||||
|
<ReviewItemHeader
|
||||||
|
displayName={item.DisplayName}
|
||||||
|
statusId={item.StatusID}
|
||||||
|
creator={item.Creator}
|
||||||
|
submitterId={item.Submitter}
|
||||||
|
/>
|
||||||
|
|
||||||
|
{/* Item Details */}
|
||||||
|
<Grid container spacing={2} sx={{ mt: 2 }}>
|
||||||
|
{fields.map((field) => (
|
||||||
|
<Grid item xs={12} sm={6} key={field.key}>
|
||||||
|
<CopyableField
|
||||||
|
label={field.label}
|
||||||
|
value={(item as never)[field.key]}
|
||||||
|
onCopy={handleCopyValue}
|
||||||
|
placeholderText={field.placeholder}
|
||||||
|
/>
|
||||||
|
</Grid>
|
||||||
|
))}
|
||||||
|
</Grid>
|
||||||
|
|
||||||
|
{/* Description Section */}
|
||||||
|
{isMapfix && item.Description && (
|
||||||
|
<div style={{ marginTop: 24 }}>
|
||||||
|
<Typography variant="subtitle1" fontWeight="bold" gutterBottom>
|
||||||
|
Description
|
||||||
|
</Typography>
|
||||||
|
<Typography variant="body1">
|
||||||
|
{item.Description}
|
||||||
|
</Typography>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</Paper>
|
||||||
|
);
|
||||||
|
}
|
||||||
69
web/src/app/_components/review/ReviewItemHeader.tsx
Normal file
69
web/src/app/_components/review/ReviewItemHeader.tsx
Normal file
@@ -0,0 +1,69 @@
|
|||||||
|
import {Typography, Box, Avatar, keyframes} from "@mui/material";
|
||||||
|
import { StatusChip } from "@/app/_components/statusChip";
|
||||||
|
import { SubmissionStatus } from "@/app/ts/Submission";
|
||||||
|
import { MapfixStatus } from "@/app/ts/Mapfix";
|
||||||
|
import {Status, StatusMatches} from "@/app/ts/Status";
|
||||||
|
|
||||||
|
type StatusIdType = SubmissionStatus | MapfixStatus;
|
||||||
|
|
||||||
|
interface ReviewItemHeaderProps {
|
||||||
|
displayName: string;
|
||||||
|
statusId: StatusIdType;
|
||||||
|
creator: string | null | undefined;
|
||||||
|
submitterId: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
export const ReviewItemHeader = ({ displayName, statusId, creator, submitterId }: ReviewItemHeaderProps) => {
|
||||||
|
const isProcessing = StatusMatches(statusId, [Status.Validating, Status.Uploading, Status.Submitting]);
|
||||||
|
|
||||||
|
const pulse = keyframes`
|
||||||
|
0%, 100% { opacity: 0.2; transform: scale(0.8); }
|
||||||
|
50% { opacity: 1; transform: scale(1); }
|
||||||
|
`;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<Box sx={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center', mb: 2 }}>
|
||||||
|
<Typography variant="h4" component="h1" gutterBottom>
|
||||||
|
{displayName}
|
||||||
|
</Typography>
|
||||||
|
<Box sx={{ display: 'flex', alignItems: 'center', gap: 1 }}>
|
||||||
|
{isProcessing && (
|
||||||
|
<Box sx={{
|
||||||
|
display: 'flex',
|
||||||
|
alignItems: 'center',
|
||||||
|
gap: 0.5,
|
||||||
|
mr: 0.5,
|
||||||
|
height: 24
|
||||||
|
}}>
|
||||||
|
{[0, 1, 2].map((i) => (
|
||||||
|
<Box
|
||||||
|
key={i}
|
||||||
|
sx={{
|
||||||
|
width: 6,
|
||||||
|
height: 6,
|
||||||
|
borderRadius: '50%',
|
||||||
|
backgroundColor: 'primary.main',
|
||||||
|
animation: `${pulse} 1.4s ease-in-out infinite`,
|
||||||
|
animationDelay: `${i * 0.2}s`,
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
))}
|
||||||
|
</Box>
|
||||||
|
)}
|
||||||
|
<StatusChip status={statusId as number} />
|
||||||
|
</Box>
|
||||||
|
</Box>
|
||||||
|
|
||||||
|
<Box sx={{ display: 'flex', alignItems: 'center', mb: 1 }}>
|
||||||
|
<Avatar
|
||||||
|
src={`/thumbnails/user/${submitterId}`}
|
||||||
|
sx={{ mr: 1, width: 24, height: 24 }}
|
||||||
|
/>
|
||||||
|
<Typography variant="body1">
|
||||||
|
by {creator || "Unknown Creator"}
|
||||||
|
</Typography>
|
||||||
|
</Box>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
};
|
||||||
87
web/src/app/_components/statusChip.tsx
Normal file
87
web/src/app/_components/statusChip.tsx
Normal file
@@ -0,0 +1,87 @@
|
|||||||
|
import React, {JSX} from "react";
|
||||||
|
import {Cancel, CheckCircle, Pending} from "@mui/icons-material";
|
||||||
|
import {Chip} from "@mui/material";
|
||||||
|
|
||||||
|
export const StatusChip = ({status}: { status: number }) => {
|
||||||
|
let color: 'default' | 'primary' | 'secondary' | 'error' | 'info' | 'success' | 'warning' = 'default';
|
||||||
|
let icon: JSX.Element = <Pending fontSize="small"/>;
|
||||||
|
let label: string = 'Unknown';
|
||||||
|
|
||||||
|
switch (status) {
|
||||||
|
case 0:
|
||||||
|
color = 'warning';
|
||||||
|
icon = <Pending fontSize="small"/>;
|
||||||
|
label = 'Under Construction';
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
color = 'warning';
|
||||||
|
icon = <Pending fontSize="small"/>;
|
||||||
|
label = 'Changes Requested';
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
color = 'info';
|
||||||
|
icon = <Pending fontSize="small"/>;
|
||||||
|
label = 'Submitting';
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
color = 'warning';
|
||||||
|
icon = <CheckCircle fontSize="small"/>;
|
||||||
|
label = 'Under Review';
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
color = 'warning';
|
||||||
|
icon = <Pending fontSize="small"/>;
|
||||||
|
label = 'Script Review';
|
||||||
|
break;
|
||||||
|
case 5:
|
||||||
|
color = 'info';
|
||||||
|
icon = <Pending fontSize="small"/>;
|
||||||
|
label = 'Validating';
|
||||||
|
break;
|
||||||
|
case 6:
|
||||||
|
color = 'success';
|
||||||
|
icon = <CheckCircle fontSize="small"/>;
|
||||||
|
label = 'Validated';
|
||||||
|
break;
|
||||||
|
case 7:
|
||||||
|
color = 'info';
|
||||||
|
icon = <Pending fontSize="small"/>;
|
||||||
|
label = 'Uploading';
|
||||||
|
break;
|
||||||
|
case 8:
|
||||||
|
color = 'success';
|
||||||
|
icon = <CheckCircle fontSize="small"/>;
|
||||||
|
label = 'Uploaded';
|
||||||
|
break;
|
||||||
|
case 9:
|
||||||
|
color = 'error';
|
||||||
|
icon = <Cancel fontSize="small"/>;
|
||||||
|
label = 'Rejected';
|
||||||
|
break;
|
||||||
|
case 10:
|
||||||
|
color = 'success';
|
||||||
|
icon = <CheckCircle fontSize="small"/>;
|
||||||
|
label = 'Released';
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
color = 'default';
|
||||||
|
icon = <Pending fontSize="small"/>;
|
||||||
|
label = 'Unknown';
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Chip
|
||||||
|
icon={icon}
|
||||||
|
label={label}
|
||||||
|
color={color}
|
||||||
|
size="small"
|
||||||
|
sx={{
|
||||||
|
height: 24,
|
||||||
|
fontSize: '0.75rem',
|
||||||
|
fontWeight: 600,
|
||||||
|
boxShadow: '0 2px 4px rgba(0,0,0,0.2)',
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
};
|
||||||
@@ -1,25 +1,8 @@
|
|||||||
"use client"
|
"use client"
|
||||||
|
|
||||||
import { redirect } from "next/navigation";
|
|
||||||
import { useEffect } from "react";
|
|
||||||
|
|
||||||
import Header from "./header";
|
import Header from "./header";
|
||||||
|
|
||||||
async function login_check() {
|
|
||||||
const response = await fetch("/api/session/validate")
|
|
||||||
if (response.ok) {
|
|
||||||
const logged_in = await response.json()
|
|
||||||
if (!logged_in) {
|
|
||||||
redirect("https://auth.staging.strafes.net/oauth2/login?redirect=" + window.location.href)
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
console.error("No response from /api/session/validate")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export default function Webpage({children}: Readonly<{children?: React.ReactNode}>) {
|
export default function Webpage({children}: Readonly<{children?: React.ReactNode}>) {
|
||||||
useEffect(() => { login_check() }, [])
|
|
||||||
|
|
||||||
return <>
|
return <>
|
||||||
<Header/>
|
<Header/>
|
||||||
{children}
|
{children}
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user