feat(活动): 37通用对接接口

This commit is contained in:
luying
2023-04-04 18:53:02 +08:00
parent 16eace7d4c
commit ad808162d7
9 changed files with 252 additions and 30 deletions

View File

@@ -31,7 +31,7 @@ module.exports = () => {
if(ctx.request.header['is-proxy'] != 'true') {
let url = getProxyUrl(ctx.request.url);
if(url) {
let sid = ctx.request.method == 'GET'? ctx.query.sid.toString(): ctx.request.body.sid.toString();
let sid = getServerId(url, ctx);
if(!ctx.app.config.sidToHost) {
await getNewHost(sid);
}
@@ -66,11 +66,30 @@ module.exports = () => {
'/cb/treatusername',
'/cb/treatguildname',
'/cb/getguildbyuser',
'/cb/refundioscallback'
'/cb/refundioscallback',
'/cb/sendgiftcode',
'/cb/getrolebyserver',
'/cb/getserverinfo'
];
for(let str of urls) {
if(url && url.startsWith(str)) {
return str;
}
}
}
function getServerId(url: string, ctx: any) {
switch(url) {
case '/cb/treatusername':
case '/cb/treatguildname':
case '/cb/getguildbyuser':
return ctx.query.sid.toString();
case '/cb/refundioscallback':
return ctx.request.body.sid.toString();
case '/cb/sendgiftcode':
return ctx.request.body.server_id.toString();
case '/cb/getrolebyserver':
case '/cb/getserverinfo':
return ctx.query.server_id.toString();
}
}