Skip to content

Node.js based forum software built for the modern web

fix: limited visibility remote posts with greater scope than asserted roomId should add those users to the chat room, #12834

Julian Lam22931be1ccff
diff --git a/src/activitypub/notes.js b/src/activitypub/notes.js
index cb1468b1be..92537c036f 100644
--- a/src/activitypub/notes.js
+++ b/src/activitypub/notes.js
@@ -225,9 +225,11 @@ Notes.assertPrivate = async (object) => {
}
// Compare room members with object recipients; if someone in-room is omitted, start new chat
+ const participants = await messaging.getUsersInRoom(roomId, 0, -1);
+ const participantUids = participants.map(user => user.uid);
if (roomId) {
- const participants = await messaging.getUsersInRoom(roomId, 0, -1);
const omitted = participants.filter((user) => {
+ // todo: this could use recipientsResolved
let { uid } = user;
uid = utils.isNumber(uid) ? `${nconf.get('url')}/uid/${uid}` : uid;
return !recipients.has(uid) && uid !== object.attributedTo;
@@ -250,6 +252,13 @@ Notes.assertPrivate = async (object) => {
timestamp = Date.now(); // otherwise message can't be seen in room as it pre-dates participants joining
}
+ // Add any new members to the chat
+ const added = Array.from(recipientsResolved).filter(uid => !participantUids.includes(uid));
+ const assertion = await activitypub.actors.assert(added);
+ if (assertion) {
+ await messaging.addUsersToRoom(object.attributedTo, added, roomId);
+ }
+
// Add message to room
await messaging.sendMessage({
mid: object.id,