enhance: better rendering of reports

Passing the report object reduces the number of parameters to be passed.
This commit is contained in:
Johann150 2022-05-16 09:18:09 +02:00
parent fc51ac17b1
commit 6060e7d220
Signed by untrusted user: Johann150
GPG key ID: 9EE6577A2A06F8F1
2 changed files with 5 additions and 6 deletions

View file

@ -1,13 +1,12 @@
import config from '@/config/index.js';
import { ILocalUser } from '@/models/entities/user.js';
import { AbuseUserReport } from '@/models/entities/abuse-user-report.js';
// to anonymise reporters, the reporting actor must be a system user
// object has to be a uri or array of uris
export const renderFlag = (user: ILocalUser, object: [string], content: string) => {
export const renderFlag = (user: ILocalUser, flag: AbuseUserReport) => {
return {
type: 'Flag',
actor: `${config.url}/users/${user.id}`,
content,
object,
content: flag.comment,
object: flag.urls,
};
};

View file

@ -29,7 +29,7 @@ export default define(meta, paramDef, async (ps, me) => {
const actor = await getInstanceActor();
const targetUser = await Users.findOneByOrFail({ id: report.targetUserId });
deliver(actor, renderActivity(renderFlag(actor, report.urls, report.comment)), targetUser.inbox);
deliver(actor, renderActivity(renderFlag(actor, report)), targetUser.inbox);
}
await AbuseUserReports.update(report.id, {