core: problem_receive提供来源显示

This commit is contained in:
undefined committed 2021-03-07 21:41:01 +08:00
1 parent 006f969de6
commit 0babd5b821
2 files changed
+13 -2

No files matched your search

+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "hydrooj",
"version": "2.20.6",
"version": "2.20.7",
"bin": "bin/hydrooj.js",
"main": "dist/loader.js",
"typings": "dist/loader.d.ts",
+12 -1
View File
@@ -86,9 +86,20 @@ export class ProblemSendHandler extends Handler {
export class ProblemReceiveHandler extends Handler {
async get({ domainId }) {
this.checkPerm(PERM.PERM_CREATE_PROBLEM);
const requests = await token.getMulti(token.TYPE_IMPORT, { domainId }).toArray();
let requests = await token.getMulti(token.TYPE_IMPORT, { domainId }).toArray();
requests = requests.map((request) => {
const url = new URL(request.source);
request.display = `${url.host}/${url.pathname.split('/')[2]}/`;
request.url = `${url.origin}/d/${url.pathname.split('/')[2]}/p/`;
return request;
});
this.response.template = 'problem_receive.html';
this.response.body = { requests };
this.response.body.path = [
['Hydro', 'homepage'],
['problem_main', 'problem_main'],
['problem_receive', null],
];
}
@post('url', Types.String)