Skip to content

Node.js based forum software built for the modern web

fix(activitypub): resolve toMid from remote message URIs in assertPrivate

Julian Lam4ed6d8455101
diff --git a/src/activitypub/notes.js b/src/activitypub/notes.js
index d0bf11d17a..4c69d4c809 100644
--- a/src/activitypub/notes.js
+++ b/src/activitypub/notes.js
@@ -443,12 +443,20 @@ Notes.assertPrivate = async (object) => {
}
});
- // Locate the roomId based on `inReplyTo`
+ // Locate the `roomId` and set `toMid` based on `inReplyTo`
let roomId;
+ let toMid;
const resolved = await activitypub.helpers.resolveLocalId(object.inReplyTo);
- let toMid = resolved.type === 'message' && resolved.id;
- if (object.inReplyTo && await messaging.messageExists(toMid || object.inReplyTo)) {
- roomId = await messaging.getMessageField(toMid || object.inReplyTo, 'roomId');
+ if (resolved.type === 'message' && resolved.id) {
+ toMid = resolved.id;
+ } else {
+ toMid = object.inReplyTo;
+ }
+ if (toMid && await messaging.messageExists(toMid)) {
+ roomId = await messaging.getMessageField(toMid, 'roomId');
+ } else {
+ toMid = undefined;
+ // roomId stays undefined
}
// Compare room members with object recipients; if someone in-room is omitted, start new chat