diff --git a/src/node/handler/PadMessageHandler.js b/src/node/handler/PadMessageHandler.js index 2cbe28755..00b1b5f98 100644 --- a/src/node/handler/PadMessageHandler.js +++ b/src/node/handler/PadMessageHandler.js @@ -446,7 +446,7 @@ exports.sendChatMessageToPadClients = async (mt, puId, text = null, padId = null // pad.appendChatMessage() ignores the displayName property so we don't need to wait for // authorManager.getAuthorName() to resolve before saving the message to the database. const promise = pad.appendChatMessage(message); - message.displayName = await authorManager.getAuthorName(message.userId); + message.displayName = await authorManager.getAuthorName(message.authorId); socketio.sockets.in(padId).json.send({ type: 'COLLABROOM', data: {type: 'CHAT_MESSAGE', message}, diff --git a/src/static/js/ChatMessage.js b/src/static/js/ChatMessage.js index b4658575e..98c5c4c0a 100644 --- a/src/static/js/ChatMessage.js +++ b/src/static/js/ChatMessage.js @@ -1,5 +1,7 @@ 'use strict'; +const {padutils: {warnDeprecated}} = require('./pad_utils'); + /** * Represents a chat message stored in the database and transmitted among users. Plugins can extend * the object with additional properties. @@ -52,8 +54,14 @@ class ChatMessage { * @deprecated Use `authorId` instead. * @type {string} */ - get userId() { return this.authorId; } - set userId(val) { this.authorId = val; } + get userId() { + warnDeprecated('ChatMessage.userId property is deprecated; use .authorId instead'); + return this.authorId; + } + set userId(val) { + warnDeprecated('ChatMessage.userId property is deprecated; use .authorId instead'); + this.authorId = val; + } /** * Alias of `displayName`, for compatibility with old plugins. @@ -61,8 +69,14 @@ class ChatMessage { * @deprecated Use `displayName` instead. * @type {string} */ - get userName() { return this.displayName; } - set userName(val) { this.displayName = val; } + get userName() { + warnDeprecated('ChatMessage.userName property is deprecated; use .displayName instead'); + return this.displayName; + } + set userName(val) { + warnDeprecated('ChatMessage.userName property is deprecated; use .displayName instead'); + this.displayName = val; + } // TODO: Delete this method once users are unlikely to roll back to a version of Etherpad that // doesn't support authorId and displayName.