mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
core: fix problem_main status cross-domain get
This commit is contained in:
1 parent
40c90c0574
commit
92c1a41585
5 files changed
+16
-8
No files matched your search
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "hydrooj",
|
"name": "hydrooj",
|
||||||
"version": "3.2.26",
|
"version": "3.2.27",
|
||||||
"bin": "bin/hydrooj.js",
|
"bin": "bin/hydrooj.js",
|
||||||
"main": "src/loader",
|
"main": "src/loader",
|
||||||
"module": "src/loader",
|
"module": "src/loader",
|
||||||
|
|||||||
@@ -125,7 +125,7 @@ export class ProblemMainHandler extends ProblemHandler {
|
|||||||
this.response.template = 'problem_main.html';
|
this.response.template = 'problem_main.html';
|
||||||
// eslint-disable-next-line @typescript-eslint/no-shadow
|
// eslint-disable-next-line @typescript-eslint/no-shadow
|
||||||
const query: FilterQuery<ProblemDoc> = {};
|
const query: FilterQuery<ProblemDoc> = {};
|
||||||
let psdict = {};
|
const psdict = {};
|
||||||
const search = global.Hydro.lib.problemSearch;
|
const search = global.Hydro.lib.problemSearch;
|
||||||
let sort: string[];
|
let sort: string[];
|
||||||
let fail = false;
|
let fail = false;
|
||||||
@@ -168,8 +168,13 @@ export class ProblemMainHandler extends ProblemHandler {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (this.user.hasPriv(PRIV.PRIV_USER_PROFILE)) {
|
if (this.user.hasPriv(PRIV.PRIV_USER_PROFILE)) {
|
||||||
psdict = await problem.getListStatus(
|
const domainIds = Array.from(new Set(pdocs.map((i) => i.domainId)));
|
||||||
domainId, this.user._id, pdocs.map((pdoc) => pdoc.docId),
|
await Promise.all(
|
||||||
|
domainIds.map((did) =>
|
||||||
|
problem.getListStatus(
|
||||||
|
did, this.user._id,
|
||||||
|
pdocs.filter((i) => i.domainId === did).map((i) => i.docId),
|
||||||
|
).then((res) => Object.assign(psdict, res))),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
this.response.body = {
|
this.response.body = {
|
||||||
|
|||||||
@@ -316,7 +316,10 @@ export class ProblemModel {
|
|||||||
domainId, { uid, docId: { $in: Array.from(new Set(pids)) } },
|
domainId, { uid, docId: { $in: Array.from(new Set(pids)) } },
|
||||||
).toArray();
|
).toArray();
|
||||||
const r: Record<string, ProblemStatusDoc> = {};
|
const r: Record<string, ProblemStatusDoc> = {};
|
||||||
for (const psdoc of psdocs) r[psdoc.docId] = psdoc;
|
for (const psdoc of psdocs) {
|
||||||
|
r[psdoc.docId] = psdoc;
|
||||||
|
r[`${psdoc.domainId}#${psdoc.docId}`] = psdoc;
|
||||||
|
}
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@hydrooj/ui-default",
|
"name": "@hydrooj/ui-default",
|
||||||
"version": "4.27.12",
|
"version": "4.27.13",
|
||||||
"author": "undefined <i@undefined.moe>",
|
"author": "undefined <i@undefined.moe>",
|
||||||
"license": "AGPL-3.0",
|
"license": "AGPL-3.0",
|
||||||
"main": "hydro.js",
|
"main": "hydro.js",
|
||||||
|
|||||||
@@ -41,7 +41,7 @@
|
|||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
{%- for pdoc in pdocs -%}
|
{%- for pdoc in pdocs -%}
|
||||||
{% set psdoc = psdict[pdoc['docId']] %}
|
{% set psdoc = psdict[pdoc.domainId + '#' + pdoc.docId] %}
|
||||||
<tr data-pid="{{ pdoc.docId }}">
|
<tr data-pid="{{ pdoc.docId }}">
|
||||||
<td class="col--checkbox display-mode-hide">
|
<td class="col--checkbox display-mode-hide">
|
||||||
<label class="compact checkbox">
|
<label class="compact checkbox">
|
||||||
@@ -58,7 +58,7 @@
|
|||||||
{% endif %}
|
{% endif %}
|
||||||
<td class="col--name col--problem-name">
|
<td class="col--name col--problem-name">
|
||||||
{% if handler.user.hasPriv(PRIV.PRIV_USER_PROFILE) %}
|
{% if handler.user.hasPriv(PRIV.PRIV_USER_PROFILE) %}
|
||||||
<form class="form--inline" action="{{ url('problem_main') }}" method="post">
|
<form class="form--inline" action="{{ url('problem_main', domainId = pdoc.domainId) }}" method="post">
|
||||||
<input type="hidden" name="pid" value="{{ pdoc.docId }}">
|
<input type="hidden" name="pid" value="{{ pdoc.docId }}">
|
||||||
<input type="hidden" name="operation" value="{{ "star" if not psdoc.star else "unstar" }}">
|
<input type="hidden" name="operation" value="{{ "star" if not psdoc.star else "unstar" }}">
|
||||||
<button class="star{% if psdoc.star %} activated{% endif %}" type="submit">
|
<button class="star{% if psdoc.star %} activated{% endif %}" type="submit">
|
||||||
|
|||||||
Reference in new issue
Block a user