@ -1,4 +1,5 @@
|
||||
import $ from 'cafy';
|
||||
import * as sanitizeHtml from 'sanitize-html';
|
||||
import { ID } from '@/misc/cafy-id';
|
||||
import define from '../../define';
|
||||
import { publishAdminStream } from '@/services/stream';
|
||||
@ -6,6 +7,8 @@ import { ApiError } from '../../error';
|
||||
import { getUser } from '../../common/getters';
|
||||
import { AbuseUserReports, Users } from '@/models/index';
|
||||
import { genId } from '@/misc/gen-id';
|
||||
import { sendEmail } from '@/services/send-email';
|
||||
import { fetchMeta } from '@/misc/fetch-meta';
|
||||
|
||||
export const meta = {
|
||||
tags: ['users'],
|
||||
@ -26,23 +29,24 @@ export const meta = {
|
||||
noSuchUser: {
|
||||
message: 'No such user.',
|
||||
code: 'NO_SUCH_USER',
|
||||
id: '1acefcb5-0959-43fd-9685-b48305736cb5'
|
||||
id: '1acefcb5-0959-43fd-9685-b48305736cb5',
|
||||
},
|
||||
|
||||
cannotReportYourself: {
|
||||
message: 'Cannot report yourself.',
|
||||
code: 'CANNOT_REPORT_YOURSELF',
|
||||
id: '1e13149e-b1e8-43cf-902e-c01dbfcb202f'
|
||||
id: '1e13149e-b1e8-43cf-902e-c01dbfcb202f',
|
||||
},
|
||||
|
||||
cannotReportAdmin: {
|
||||
message: 'Cannot report the admin.',
|
||||
code: 'CANNOT_REPORT_THE_ADMIN',
|
||||
id: '35e166f5-05fb-4f87-a2d5-adb42676d48f'
|
||||
}
|
||||
}
|
||||
id: '35e166f5-05fb-4f87-a2d5-adb42676d48f',
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
// eslint-disable-next-line import/no-default-export
|
||||
export default define(meta, async (ps, me) => {
|
||||
// Lookup user
|
||||
const user = await getUser(ps.userId).catch(e => {
|
||||
@ -72,10 +76,10 @@ export default define(meta, async (ps, me) => {
|
||||
setTimeout(async () => {
|
||||
const moderators = await Users.find({
|
||||
where: [{
|
||||
isAdmin: true
|
||||
isAdmin: true,
|
||||
}, {
|
||||
isModerator: true
|
||||
}]
|
||||
isModerator: true,
|
||||
}],
|
||||
});
|
||||
|
||||
for (const moderator of moderators) {
|
||||
@ -83,8 +87,15 @@ export default define(meta, async (ps, me) => {
|
||||
id: report.id,
|
||||
targetUserId: report.targetUserId,
|
||||
reporterId: report.reporterId,
|
||||
comment: report.comment
|
||||
comment: report.comment,
|
||||
});
|
||||
}
|
||||
|
||||
const meta = await fetchMeta();
|
||||
if (meta.email) {
|
||||
sendEmail(meta.email, 'New abuse report',
|
||||
sanitizeHtml(ps.comment),
|
||||
sanitizeHtml(ps.comment));
|
||||
}
|
||||
}, 1);
|
||||
});
|
||||
|
Reference in New Issue
Block a user