mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-12-29 11:50:36 +01:00
feat: federate flag creation
This commit is contained in:
@@ -214,3 +214,19 @@ activitypubApi.undo.like = enabledCheck(async (caller, { pid }) => {
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
activitypubApi.flag = enabledCheck(async (caller, flag) => {
|
||||
if (!activitypub.helpers.isUri(flag.targetId)) {
|
||||
return;
|
||||
}
|
||||
const reportedIds = [flag.targetId];
|
||||
if (flag.type === 'post' && activitypub.helpers.isUri(flag.targetUid)) {
|
||||
reportedIds.push(flag.targetUid);
|
||||
}
|
||||
const reason = flag.reports.filter(report => report.reporter.uid === caller.uid).at(-1);
|
||||
await activitypub.send('uid', caller.uid, reportedIds, {
|
||||
type: 'Flag',
|
||||
object: reportedIds,
|
||||
content: reason ? reason.value : undefined,
|
||||
});
|
||||
});
|
||||
|
||||
@@ -11,7 +11,7 @@ flagsApi.create = async (caller, data) => {
|
||||
throw new Error('[[error:invalid-data]]');
|
||||
}
|
||||
|
||||
const { type, id, reason } = data;
|
||||
const { type, id, reason, notifyRemote } = data;
|
||||
|
||||
await flags.validate({
|
||||
uid: caller.uid,
|
||||
@@ -19,7 +19,7 @@ flagsApi.create = async (caller, data) => {
|
||||
id: id,
|
||||
});
|
||||
|
||||
const flagObj = await flags.create(type, id, caller.uid, reason);
|
||||
const flagObj = await flags.create(type, id, caller.uid, reason, undefined, undefined, notifyRemote);
|
||||
flags.notify(flagObj, caller.uid);
|
||||
|
||||
return flagObj;
|
||||
|
||||
Reference in New Issue
Block a user