Fix report emails and modmail sanitization
This commit is contained in:
parent
2c3d222d3b
commit
4174e3d070
@ -1,4 +1,4 @@
|
|||||||
import * as sanitizeHtml from "sanitize-html";
|
import sanitizeHtml from "sanitize-html";
|
||||||
import define from "../../define.js";
|
import define from "../../define.js";
|
||||||
import { Users, UserProfiles } from "@/models/index.js";
|
import { Users, UserProfiles } from "@/models/index.js";
|
||||||
import { ApiError } from "../../error.js";
|
import { ApiError } from "../../error.js";
|
||||||
|
@ -1,12 +1,14 @@
|
|||||||
import * as sanitizeHtml from "sanitize-html";
|
import * as mfm from "mfm-js";
|
||||||
|
import sanitizeHtml from "sanitize-html";
|
||||||
import { publishAdminStream } from "@/services/stream.js";
|
import { publishAdminStream } from "@/services/stream.js";
|
||||||
import { AbuseUserReports, Users } from "@/models/index.js";
|
import { AbuseUserReports, UserProfiles, Users } from "@/models/index.js";
|
||||||
import { genId } from "@/misc/gen-id.js";
|
import { genId } from "@/misc/gen-id.js";
|
||||||
import { sendEmail } from "@/services/send-email.js";
|
import { sendEmail } from "@/services/send-email.js";
|
||||||
import { fetchMeta } from "@/misc/fetch-meta.js";
|
import { fetchMeta } from "@/misc/fetch-meta.js";
|
||||||
import { getUser } from "../../common/getters.js";
|
import { getUser } from "../../common/getters.js";
|
||||||
import { ApiError } from "../../error.js";
|
import { ApiError } from "../../error.js";
|
||||||
import define from "../../define.js";
|
import define from "../../define.js";
|
||||||
|
import { toHtml } from "@/mfm/to-html.js";
|
||||||
|
|
||||||
export const meta = {
|
export const meta = {
|
||||||
tags: ["users"],
|
tags: ["users"],
|
||||||
@ -84,6 +86,7 @@ export default define(meta, paramDef, async (ps, me) => {
|
|||||||
],
|
],
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const meta = await fetchMeta();
|
||||||
for (const moderator of moderators) {
|
for (const moderator of moderators) {
|
||||||
publishAdminStream(moderator.id, "newAbuseUserReport", {
|
publishAdminStream(moderator.id, "newAbuseUserReport", {
|
||||||
id: report.id,
|
id: report.id,
|
||||||
@ -91,16 +94,16 @@ export default define(meta, paramDef, async (ps, me) => {
|
|||||||
reporterId: report.reporterId,
|
reporterId: report.reporterId,
|
||||||
comment: report.comment,
|
comment: report.comment,
|
||||||
});
|
});
|
||||||
}
|
|
||||||
|
|
||||||
const meta = await fetchMeta();
|
const profile = await UserProfiles.findOneBy({ userId: moderator.id });
|
||||||
if (meta.email) {
|
if (profile?.email) {
|
||||||
sendEmail(
|
sendEmail(
|
||||||
meta.email,
|
profile.email,
|
||||||
"New abuse report",
|
"New abuse report",
|
||||||
sanitizeHtml(ps.comment),
|
sanitizeHtml(toHtml(mfm.parse(ps.comment))!),
|
||||||
sanitizeHtml(ps.comment),
|
sanitizeHtml(toHtml(mfm.parse(ps.comment))!),
|
||||||
);
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user