mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-26 08:36:12 +01:00
feat: if an incoming remote message is too long, don't create the room, but notify the local recipients instead
closes #13174
This commit is contained in:
@@ -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.",
|
||||
|
||||
@@ -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] });
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user