mirror of
https://github.com/thepeacockproject/Peacock
synced 2024-11-22 22:12:45 +01:00
Prevent disconnections caused by contract report requests (#99)
This commit is contained in:
parent
168aee05fe
commit
e6f72eb53d
@ -92,6 +92,7 @@ import FrankensteinScoreOverviewTemplate from "../static/FrankensteinScoreOvervi
|
|||||||
import FrankensteinPlanningTemplate from "../static/FrankensteinPlanningTemplate.json"
|
import FrankensteinPlanningTemplate from "../static/FrankensteinPlanningTemplate.json"
|
||||||
import Videos from "../static/Videos.json"
|
import Videos from "../static/Videos.json"
|
||||||
import ChallengeLocationTemplate from "../static/ChallengeLocationTemplate.json"
|
import ChallengeLocationTemplate from "../static/ChallengeLocationTemplate.json"
|
||||||
|
import ReportTemplate from "../static/ReportTemplate.json"
|
||||||
import ContractSearchPageTemplate from "../static/ContractSearchPageTemplate.json"
|
import ContractSearchPageTemplate from "../static/ContractSearchPageTemplate.json"
|
||||||
import ContractSearchPaginateTemplate from "../static/ContractSearchPaginateTemplate.json"
|
import ContractSearchPaginateTemplate from "../static/ContractSearchPaginateTemplate.json"
|
||||||
import ContractSearchResponseTemplate from "../static/ContractSearchResponseTemplate.json"
|
import ContractSearchResponseTemplate from "../static/ContractSearchResponseTemplate.json"
|
||||||
@ -189,6 +190,7 @@ const configs: Record<string, unknown> = {
|
|||||||
FrankensteinScoreOverviewTemplate,
|
FrankensteinScoreOverviewTemplate,
|
||||||
Videos,
|
Videos,
|
||||||
ChallengeLocationTemplate,
|
ChallengeLocationTemplate,
|
||||||
|
ReportTemplate,
|
||||||
ContractSearchPageTemplate,
|
ContractSearchPageTemplate,
|
||||||
ContractSearchPaginateTemplate,
|
ContractSearchPaginateTemplate,
|
||||||
ContractSearchResponseTemplate,
|
ContractSearchResponseTemplate,
|
||||||
|
34
components/contracts/reportRouting.ts
Normal file
34
components/contracts/reportRouting.ts
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
/*
|
||||||
|
* The Peacock Project - a HITMAN server replacement.
|
||||||
|
* Copyright (C) 2021-2023 The Peacock Project Team
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Affero General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Affero General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { Router } from "express"
|
||||||
|
import { json as jsonMiddleware } from "body-parser"
|
||||||
|
import type { RequestWithJwt } from "../types/types"
|
||||||
|
const reportRouter = Router()
|
||||||
|
|
||||||
|
reportRouter.post(
|
||||||
|
"/ReportContract",
|
||||||
|
jsonMiddleware(),
|
||||||
|
(
|
||||||
|
req: RequestWithJwt<never, { contractId: string; reason: number }>,
|
||||||
|
res,
|
||||||
|
) => {
|
||||||
|
res.json({})
|
||||||
|
},
|
||||||
|
)
|
||||||
|
export { reportRouter }
|
@ -81,6 +81,7 @@ import { multiplayerMenuDataRouter } from "./multiplayer/multiplayerMenuData"
|
|||||||
import { pack, unpack } from "msgpackr"
|
import { pack, unpack } from "msgpackr"
|
||||||
import { liveSplitManager } from "./livesplit/liveSplitManager"
|
import { liveSplitManager } from "./livesplit/liveSplitManager"
|
||||||
import { cheapLoadUserData } from "./databaseHandler"
|
import { cheapLoadUserData } from "./databaseHandler"
|
||||||
|
import { reportRouter } from "./contracts/reportRouting"
|
||||||
|
|
||||||
// welcome to the bleeding edge
|
// welcome to the bleeding edge
|
||||||
setFlagsFromString("--harmony")
|
setFlagsFromString("--harmony")
|
||||||
@ -435,6 +436,10 @@ primaryRouter.use(
|
|||||||
"/authentication/api/userchannel/ContractsService/",
|
"/authentication/api/userchannel/ContractsService/",
|
||||||
contractRoutingRouter,
|
contractRoutingRouter,
|
||||||
)
|
)
|
||||||
|
primaryRouter.use(
|
||||||
|
"/authentication/api/userchannel/ReportingService/",
|
||||||
|
reportRouter,
|
||||||
|
)
|
||||||
primaryRouter.use("/authentication/api/userchannel/", profileRouter)
|
primaryRouter.use("/authentication/api/userchannel/", profileRouter)
|
||||||
primaryRouter.use("/profiles/page/", preMenuDataRouter)
|
primaryRouter.use("/profiles/page/", preMenuDataRouter)
|
||||||
primaryRouter.use("/profiles/page", multiplayerMenuDataRouter)
|
primaryRouter.use("/profiles/page", multiplayerMenuDataRouter)
|
||||||
|
@ -451,6 +451,18 @@ menuDataRouter.get("/SafehouseCategory", (req: RequestWithJwt, res) => {
|
|||||||
res.json(safehouseData)
|
res.json(safehouseData)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
menuDataRouter.get("/report", (req: RequestWithJwt, res) => {
|
||||||
|
res.json({
|
||||||
|
template: getVersionedConfig("ReportTemplate", req.gameVersion, false),
|
||||||
|
data: {
|
||||||
|
Reasons: [
|
||||||
|
{ Id: 0, Title: "UI_MENU_REPORT_REASON_OFFENSIVE" },
|
||||||
|
{ Id: 1, Title: "UI_MENU_REPORT_REASON_BUGGY" },
|
||||||
|
],
|
||||||
|
},
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
menuDataRouter.get(
|
menuDataRouter.get(
|
||||||
"/stashpoint",
|
"/stashpoint",
|
||||||
(req: RequestWithJwt<StashpointQuery>, res) => {
|
(req: RequestWithJwt<StashpointQuery>, res) => {
|
||||||
|
128
static/ReportTemplate.json
Normal file
128
static/ReportTemplate.json
Normal file
@ -0,0 +1,128 @@
|
|||||||
|
{
|
||||||
|
"buttons": [
|
||||||
|
{
|
||||||
|
"actiontype": "accept",
|
||||||
|
"actionlabel": "$loc UI_BUTTON_PROMPTS_ACTION_SELECT"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"actiontype": "cancel",
|
||||||
|
"actionlabel": "$loc UI_BUTTON_PROMPTS_ACTION_BACK"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"onpageopened": {
|
||||||
|
"show-background-layers": {
|
||||||
|
"show-background": {
|
||||||
|
"$if $arg _isingame": { "$then": false, "$else": true }
|
||||||
|
},
|
||||||
|
"show-world-map": false,
|
||||||
|
"show-overlay": false
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"body": {
|
||||||
|
"controller": "list",
|
||||||
|
"children": [
|
||||||
|
{
|
||||||
|
"controller": "list",
|
||||||
|
"id": "category_container",
|
||||||
|
"_comment": "the container that will be dynamically updated with the contents of the selected category"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"view": "menu3.containers.ScrollingTabsContainer",
|
||||||
|
"direction": "horizontal",
|
||||||
|
"data": {
|
||||||
|
"direction": "horizontal",
|
||||||
|
"topnavigation": {
|
||||||
|
"title": "$arg contracttitle",
|
||||||
|
"icon": "usercreated"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"ncols": 10,
|
||||||
|
"_comment": "note the below two fields, the container tells the category controller which container is to be used",
|
||||||
|
"controller": "category",
|
||||||
|
"container": "category_container",
|
||||||
|
"children": [
|
||||||
|
{
|
||||||
|
"view": "menu3.basic.CategoryElement",
|
||||||
|
"id": "category_background",
|
||||||
|
"data": {
|
||||||
|
"title": "$loc UI_MENU_PAGE_TITLE_REPORTING",
|
||||||
|
"icon": "background"
|
||||||
|
},
|
||||||
|
"children": [
|
||||||
|
{
|
||||||
|
"view": "menu3.TextboxElement",
|
||||||
|
"selectable": false,
|
||||||
|
"_col": 1.25,
|
||||||
|
"row": 1,
|
||||||
|
"ncols": 4,
|
||||||
|
"data": {
|
||||||
|
"text": "$loc UI_MENU_REPORT_HEADLINE_REASON",
|
||||||
|
"size": 40,
|
||||||
|
"color": "FFFFFF"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"controller": "list",
|
||||||
|
"view": "menu3.containers.ScrollingListContainer",
|
||||||
|
"row": 1.5,
|
||||||
|
"nrows": 2.5,
|
||||||
|
"ncols": 10,
|
||||||
|
"direction": "vertical",
|
||||||
|
"data": { "direction": "vertical" },
|
||||||
|
"children": {
|
||||||
|
"$each $.Reasons": {
|
||||||
|
"view": "menu3.basic.OptionsListElement",
|
||||||
|
"data": {
|
||||||
|
"showningame": {
|
||||||
|
"$if $arg _isingame": {
|
||||||
|
"$then": true,
|
||||||
|
"$else": false
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"title": "$loc $.Title",
|
||||||
|
"icon": "arrowright"
|
||||||
|
},
|
||||||
|
"actions": {
|
||||||
|
"accept": {
|
||||||
|
"show-modal": {
|
||||||
|
"config": {
|
||||||
|
"view": "menu3.modal.ModalDialogGeneric",
|
||||||
|
"buttons": [
|
||||||
|
"$loc UI_DIALOG_CONFIRM",
|
||||||
|
{
|
||||||
|
"label": "$loc UI_DIALOG_CANCEL",
|
||||||
|
"type": "cancel"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"data": {
|
||||||
|
"title": "$loc UI_DIALOG_REPORT_CONTRACT_TITLE",
|
||||||
|
"description": "$loc UI_DIALOG_CONFIRM_REPORT_TEXT"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"onbutton": [
|
||||||
|
{
|
||||||
|
"report-pressed": {
|
||||||
|
"contractid": "$arg contractid",
|
||||||
|
"reason": "$.Id"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"set-selected": {}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"on-report-saved": {
|
||||||
|
"request-back": {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user