enhance: Forward report (#8001)
* implement sending AP Flag object Optionally allow a user to select to forward a report about a remote user to the other instance. This is added in a backwards-compatible way. * add locale string * forward report only for moderators * add switch to moderator UI to forward report * fix report note url * return forwarded status from API apparently forgot to carry this over from my testing environment * object in Flag activity has to be an array For correct interoperability with Pleroma the "object" property of the Flag activity has to be an array. This array will in the future also hold the link to respective notes, so it makes sense to correct this on our side. * Update get-note-menu.ts Co-authored-by: syuilo <Syuilotan@yahoo.co.jp>
This commit is contained in:
@ -1,7 +1,11 @@
|
||||
import $ from 'cafy';
|
||||
import { ID } from '@/misc/cafy-id';
|
||||
import define from '../../define';
|
||||
import { AbuseUserReports } from '@/models/index';
|
||||
import { AbuseUserReports, Users } from '@/models/index';
|
||||
import { getInstanceActor } from '@/services/instance-actor';
|
||||
import { deliver } from '@/queue/index';
|
||||
import { renderActivity } from '@/remote/activitypub/renderer/index';
|
||||
import { renderFlag } from '@/remote/activitypub/renderer/flag';
|
||||
|
||||
export const meta = {
|
||||
tags: ['admin'],
|
||||
@ -13,6 +17,12 @@ export const meta = {
|
||||
reportId: {
|
||||
validator: $.type(ID),
|
||||
},
|
||||
|
||||
forward: {
|
||||
validator: $.optional.boolean,
|
||||
required: false,
|
||||
default: false,
|
||||
},
|
||||
},
|
||||
} as const;
|
||||
|
||||
@ -24,8 +34,16 @@ export default define(meta, async (ps, me) => {
|
||||
throw new Error('report not found');
|
||||
}
|
||||
|
||||
if (ps.forward && report.targetUserHost != null) {
|
||||
const actor = await getInstanceActor();
|
||||
const targetUser = await Users.findOne(report.targetUserId);
|
||||
|
||||
deliver(actor, renderActivity(renderFlag(actor, [targetUser.uri], report.comment)), targetUser.inbox);
|
||||
}
|
||||
|
||||
await AbuseUserReports.update(report.id, {
|
||||
resolved: true,
|
||||
assigneeId: me.id,
|
||||
forwarded: ps.forward && report.targetUserHost != null,
|
||||
});
|
||||
});
|
||||
|
Reference in New Issue
Block a user