fix(workshop): streamline import review
This commit is contained in:
1 parent
327e5c15ae
commit
2ba31fd37b
13 files changed
+234
-59
No files matched your search
@@ -9,7 +9,8 @@ version and digest together, then run the Workshop integration and production-im
|
||||
|
||||
The internal PocketBase field `users.isAdmin` means **Workshop moderator**. It does not grant Homarr administrator
|
||||
access. Signed-in moderators can open `/workshop/admin` from the visible **Moderation** button, review private report
|
||||
details, dismiss reports, and remove submissions or comments. Public submission cards show only the open report count.
|
||||
details, dismiss reports, and remove submissions or comments. Public submission cards show only the open report count;
|
||||
the submission author can read the report category and explanation without receiving the reporter identity.
|
||||
|
||||
## Run locally
|
||||
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
/// <reference path="../pb_data/types.d.ts" />
|
||||
|
||||
const reportReaderRule = "@request.auth.id != '' && (author = @request.auth.id || @request.auth.isAdmin = true)";
|
||||
|
||||
migrate(
|
||||
(app) => {
|
||||
const summaries = new Collection({
|
||||
type: "view",
|
||||
name: "workshop_report_summaries",
|
||||
listRule: reportReaderRule,
|
||||
viewRule: reportReaderRule,
|
||||
viewQuery: `
|
||||
SELECT r.id, r.submission, s.author, r.category, r.explanation, r.created
|
||||
FROM reports r
|
||||
INNER JOIN submissions s ON s.id = r.submission
|
||||
WHERE r.status = 'open'
|
||||
`,
|
||||
});
|
||||
app.save(summaries);
|
||||
},
|
||||
(app) => {
|
||||
app.delete(app.findCollectionByNameOrId("workshop_report_summaries"));
|
||||
},
|
||||
);
|
||||
@@ -28,7 +28,14 @@ const root = await request("/api/collections/_superusers/auth-with-password", {
|
||||
const rootHeaders = { authorization: `Bearer ${root.token}` };
|
||||
const collections = await request("/api/collections?perPage=200", { headers: rootHeaders });
|
||||
const collectionNames = new Set(collections.items.map((collection) => collection.name));
|
||||
for (const required of ["submissions", "votes", "comments", "reports", "workshop_listings"]) {
|
||||
for (const required of [
|
||||
"submissions",
|
||||
"votes",
|
||||
"comments",
|
||||
"reports",
|
||||
"workshop_listings",
|
||||
"workshop_report_summaries",
|
||||
]) {
|
||||
if (!collectionNames.has(required)) throw new Error(`Missing Workshop collection: ${required}`);
|
||||
}
|
||||
for (const removed of ["workshop_admin_actions", "workshop_admins"]) {
|
||||
@@ -278,6 +285,23 @@ await expectStatus(`/api/collections/reports/records/${report.id}`, { headers: v
|
||||
await expectStatus("/api/collections/reports/records", { headers: visitorSession.headers }, 200);
|
||||
const publicReports = await request("/api/collections/reports/records", { headers: visitorSession.headers });
|
||||
if (publicReports.items.length !== 0) throw new Error("Report details must remain private to Workshop moderators");
|
||||
const visitorReportSummaries = await request("/api/collections/workshop_report_summaries/records", {
|
||||
headers: visitorSession.headers,
|
||||
});
|
||||
if (visitorReportSummaries.items.length !== 0) {
|
||||
throw new Error("Report explanations must remain private from unrelated Workshop users");
|
||||
}
|
||||
const authorReportSummaries = await request("/api/collections/workshop_report_summaries/records", {
|
||||
headers: authorSession.headers,
|
||||
});
|
||||
if (
|
||||
authorReportSummaries.items.length !== 1 ||
|
||||
authorReportSummaries.items[0].submission !== submission.id ||
|
||||
authorReportSummaries.items[0].explanation !== "Runtime moderation test" ||
|
||||
"reporter" in authorReportSummaries.items[0]
|
||||
) {
|
||||
throw new Error("Submission authors must see report reasons without exposing reporter identities");
|
||||
}
|
||||
await expectStatus(
|
||||
`/api/collections/reports/records/${report.id}`,
|
||||
{ method: "DELETE", headers: visitorSession.headers },
|
||||
|
||||
Reference in new issue
Block a user