mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-19 17: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",
|
||||
"version": "3.2.26",
|
||||
"version": "3.2.27",
|
||||
"bin": "bin/hydrooj.js",
|
||||
"main": "src/loader",
|
||||
"module": "src/loader",
|
||||
|
||||
@@ -125,7 +125,7 @@ export class ProblemMainHandler extends ProblemHandler {
|
||||
this.response.template = 'problem_main.html';
|
||||
// eslint-disable-next-line @typescript-eslint/no-shadow
|
||||
const query: FilterQuery<ProblemDoc> = {};
|
||||
let psdict = {};
|
||||
const psdict = {};
|
||||
const search = global.Hydro.lib.problemSearch;
|
||||
let sort: string[];
|
||||
let fail = false;
|
||||
@@ -168,8 +168,13 @@ export class ProblemMainHandler extends ProblemHandler {
|
||||
}
|
||||
}
|
||||
if (this.user.hasPriv(PRIV.PRIV_USER_PROFILE)) {
|
||||
psdict = await problem.getListStatus(
|
||||
domainId, this.user._id, pdocs.map((pdoc) => pdoc.docId),
|
||||
const domainIds = Array.from(new Set(pdocs.map((i) => i.domainId)));
|
||||
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 = {
|
||||
|
||||
@@ -316,7 +316,10 @@ export class ProblemModel {
|
||||
domainId, { uid, docId: { $in: Array.from(new Set(pids)) } },
|
||||
).toArray();
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@hydrooj/ui-default",
|
||||
"version": "4.27.12",
|
||||
"version": "4.27.13",
|
||||
"author": "undefined <i@undefined.moe>",
|
||||
"license": "AGPL-3.0",
|
||||
"main": "hydro.js",
|
||||
|
||||
@@ -41,7 +41,7 @@
|
||||
</thead>
|
||||
<tbody>
|
||||
{%- for pdoc in pdocs -%}
|
||||
{% set psdoc = psdict[pdoc['docId']] %}
|
||||
{% set psdoc = psdict[pdoc.domainId + '#' + pdoc.docId] %}
|
||||
<tr data-pid="{{ pdoc.docId }}">
|
||||
<td class="col--checkbox display-mode-hide">
|
||||
<label class="compact checkbox">
|
||||
@@ -58,7 +58,7 @@
|
||||
{% endif %}
|
||||
<td class="col--name col--problem-name">
|
||||
{% 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="operation" value="{{ "star" if not psdoc.star else "unstar" }}">
|
||||
<button class="star{% if psdoc.star %} activated{% endif %}" type="submit">
|
||||
|
||||
Reference in new issue
Block a user