mirror of
https://github.com/PretendoNetwork/BOSS.git
synced 2026-09-08 09:06:49 -05:00
nppl: added 3DS policylist support
This commit is contained in:
@@ -2,15 +2,109 @@ import xmlbuilder from 'xmlbuilder';
|
||||
import moment from 'moment';
|
||||
import express from 'express';
|
||||
import subdomain from 'express-subdomain';
|
||||
import { PolicyList } from '@/types/common/policylist';
|
||||
|
||||
const nppl = express.Router();
|
||||
|
||||
nppl.get('/p01/policylist/1/1/:region', (_request, response) => {
|
||||
nppl.get([
|
||||
'/p01/policylist/:majorVersion/:countryCode',
|
||||
'/p01/policylist/:consoleType/:majorVersion/:countryCode'
|
||||
], (request, response) => {
|
||||
const { majorVersion, countryCode } = request.params;
|
||||
const consoleType = request.params.consoleType || '0'; // * Default to the 3DS
|
||||
|
||||
let policylist;
|
||||
|
||||
if (consoleType === '0') {
|
||||
policylist = get3DSPolicyList(countryCode, majorVersion);
|
||||
} else if (consoleType === '1') {
|
||||
policylist = getWiiUPolicyList(countryCode, majorVersion);
|
||||
} else {
|
||||
response.sendStatus(500);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!policylist) {
|
||||
response.sendStatus(404);
|
||||
return;
|
||||
}
|
||||
|
||||
// TODO - Make this more dynamic
|
||||
response.set('Content-Type', 'application/xml; charset=utf-8');
|
||||
response.send(xmlbuilder.create({
|
||||
response.send(xmlbuilder.create(policylist).end({ pretty: true }));
|
||||
});
|
||||
|
||||
function get3DSPolicyList(countryCode: string, majorVersion: string): { PolicyList: PolicyList } | null {
|
||||
if (majorVersion !== '3') {
|
||||
return null;
|
||||
}
|
||||
|
||||
// TODO - Pull this from the DB and use the country code
|
||||
return {
|
||||
PolicyList: {
|
||||
MajorVersion: 1,
|
||||
MajorVersion: Number(majorVersion),
|
||||
MinorVersion: 0,
|
||||
ListId: 1891,
|
||||
DefaultStop: false,
|
||||
ForceVersionUp: false,
|
||||
UpdateTime: moment().utc().format('YYYY-MM-DDTHH:MM:SS+0000'),
|
||||
Priority: [
|
||||
{
|
||||
TitleId: '0004003000008f02',
|
||||
TaskId: 'basho0',
|
||||
Level: 'EXPEDITE',
|
||||
Persistent: true, // TODO - What's this?
|
||||
Revive: true // TODO - What's this?
|
||||
},
|
||||
{
|
||||
TitleId: '000400300000bc00',
|
||||
TaskId: 'OlvNotf',
|
||||
Level: 'EXPEDITE',
|
||||
Persistent: true, // TODO - What's this?
|
||||
Revive: true // TODO - What's this?
|
||||
},
|
||||
{
|
||||
TitleId: '000400300000bd00',
|
||||
TaskId: 'OlvNotf',
|
||||
Level: 'EXPEDITE',
|
||||
Persistent: true, // TODO - What's this?
|
||||
Revive: true // TODO - What's this?
|
||||
},
|
||||
{
|
||||
TitleId: '000400300000be00',
|
||||
TaskId: 'OlvNotf',
|
||||
Level: 'EXPEDITE',
|
||||
Persistent: true, // TODO - What's this?
|
||||
Revive: true // TODO - What's this?
|
||||
},
|
||||
{
|
||||
TitleId: '0004003000008f02',
|
||||
TaskId: 'pl',
|
||||
Level: 'EXPEDITE',
|
||||
Persistent: true, // TODO - What's this?
|
||||
Revive: true // TODO - What's this?
|
||||
},
|
||||
{
|
||||
TitleId: '0004013000003400',
|
||||
TaskId: 'sprelay',
|
||||
Level: 'EXPEDITE',
|
||||
Persistent: true, // TODO - What's this?
|
||||
Revive: true // TODO - What's this?
|
||||
}
|
||||
]
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
function getWiiUPolicyList(countryCode: string, majorVersion: string): { PolicyList: PolicyList } | null {
|
||||
if (majorVersion !== '1') {
|
||||
return null;
|
||||
}
|
||||
|
||||
// TODO - Pull this from the DB and use the country code
|
||||
return {
|
||||
PolicyList: {
|
||||
MajorVersion: Number(majorVersion),
|
||||
MinorVersion: 0,
|
||||
ListId: 1924,
|
||||
DefaultStop: false,
|
||||
@@ -84,11 +178,12 @@ nppl.get('/p01/policylist/1/1/:region', (_request, response) => {
|
||||
}
|
||||
]
|
||||
}
|
||||
}).end({ pretty: true }));
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
const router = express.Router();
|
||||
|
||||
router.use(subdomain('nppl.app', nppl));
|
||||
router.use(subdomain('nppl.c.app', nppl)); // * 3DS
|
||||
router.use(subdomain('nppl.app', nppl)); // * WiiU
|
||||
|
||||
export default router;
|
||||
17
src/types/common/policylist.ts
Normal file
17
src/types/common/policylist.ts
Normal file
@@ -0,0 +1,17 @@
|
||||
type TaskLevel = 'STOPPED' | 'HIGH' | 'EXPEDITE'; // TODO - Find all of these and document their uses
|
||||
|
||||
export type PolicyList = {
|
||||
MajorVersion: number;
|
||||
MinorVersion: number;
|
||||
ListId: number;
|
||||
DefaultStop: boolean;
|
||||
ForceVersionUp: boolean;
|
||||
UpdateTime: string;
|
||||
Priority: {
|
||||
TitleId: string;
|
||||
TaskId: string;
|
||||
Level: TaskLevel;
|
||||
Persistent?: boolean;
|
||||
Revive?: boolean;
|
||||
}[];
|
||||
};
|
||||
Reference in New Issue
Block a user