forked from FoundKeyGang/FoundKey
enhance: better rendering of reports
Passing the report object reduces the number of parameters to be passed.
This commit is contained in:
parent
fc51ac17b1
commit
6060e7d220
2 changed files with 5 additions and 6 deletions
|
@ -1,13 +1,12 @@
|
||||||
import config from '@/config/index.js';
|
import config from '@/config/index.js';
|
||||||
import { ILocalUser } from '@/models/entities/user.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
|
export const renderFlag = (user: ILocalUser, flag: AbuseUserReport) => {
|
||||||
// object has to be a uri or array of uris
|
|
||||||
export const renderFlag = (user: ILocalUser, object: [string], content: string) => {
|
|
||||||
return {
|
return {
|
||||||
type: 'Flag',
|
type: 'Flag',
|
||||||
actor: `${config.url}/users/${user.id}`,
|
actor: `${config.url}/users/${user.id}`,
|
||||||
content,
|
content: flag.comment,
|
||||||
object,
|
object: flag.urls,
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
@ -29,7 +29,7 @@ export default define(meta, paramDef, async (ps, me) => {
|
||||||
const actor = await getInstanceActor();
|
const actor = await getInstanceActor();
|
||||||
const targetUser = await Users.findOneByOrFail({ id: report.targetUserId });
|
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, {
|
await AbuseUserReports.update(report.id, {
|
||||||
|
|
Loading…
Reference in a new issue