Node.js based forum software built for the modern web
feat: if an incoming remote message is too long, don't create the room, but notify the local recipients instead
Julian Lam885b83e50999
diff --git a/public/language/en-GB/error.json b/public/language/en-GB/error.jsonindex d511ef8300..3880a36d47 100644--- a/public/language/en-GB/error.json+++ b/public/language/en-GB/error.json@@ -194,6 +194,7 @@"cant-add-users-to-chat-room": "Can't add users to chat room.","cant-remove-users-from-chat-room": "Can't remove users from chat room.","chat-room-name-too-long": "Chat room name too long. Names can't be longer than %1 characters.",+ "remote-chat-received-too-long": "You received a chat message from %1, but it was too long and was rejected.","already-voting-for-this-post": "You have already voted for this post.","reputation-system-disabled": "Reputation system is disabled.",diff --git a/src/activitypub/notes.js b/src/activitypub/notes.jsindex 920fe69205..52c22c34e8 100644--- a/src/activitypub/notes.js+++ b/src/activitypub/notes.js@@ -9,6 +9,7 @@ const meta = require('../meta');const privileges = require('../privileges');const categories = require('../categories');const messaging = require('../messaging');+const notifications = require('../notifications');const user = require('../user');const topics = require('../topics');const posts = require('../posts');@@ -288,6 +289,20 @@ Notes.assertPrivate = async (object) => {const payload = await activitypub.mocks.message(object);+ try {+ await messaging.checkContent(payload.content, false);+ } catch (e) {+ const { displayname, userslug } = await user.getUserFields(payload.uid, ['displayname', 'userslug']);+ const notification = await notifications.create({+ bodyShort: `[[error:remote-chat-received-too-long, ${displayname}]]`,+ path: `/user/${userslug}`,+ nid: `error:chat:uid:${payload.uid}`,+ from: payload.uid,+ });+ notifications.push(notification, Array.from(recipients).filter(uid => utils.isNumber(uid)));+ return null;+ }+if (!roomId) {roomId = await messaging.newRoom(payload.uid, { uids: [...recipients] });}