From ad45359a9d67d8e818ac710af436d03632cf698e Mon Sep 17 00:00:00 2001 From: Richard Hansen Date: Sat, 26 Feb 2022 18:51:08 -0500 Subject: [PATCH] chat: Silence accidental deprecation warnings This fixes a bug introduced in commit 363a48b6d535c0a8501355a4d50f9885e2ee757e. --- src/static/js/ChatMessage.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/static/js/ChatMessage.js b/src/static/js/ChatMessage.js index 98c5c4c0a..d7ff680d1 100644 --- a/src/static/js/ChatMessage.js +++ b/src/static/js/ChatMessage.js @@ -10,6 +10,13 @@ const {padutils: {warnDeprecated}} = require('./pad_utils'); */ class ChatMessage { static fromObject(obj) { + // The userId property was renamed to authorId, and userName was renamed to displayName. Accept + // the old names in case the db record was written by an older version of Etherpad. + obj = Object.assign({}, obj); // Don't mutate the caller's object. + if ('userId' in obj && !('authorId' in obj)) obj.authorId = obj.userId; + delete obj.userId; + if ('userName' in obj && !('displayName' in obj)) obj.displayName = obj.userName; + delete obj.userName; return Object.assign(new ChatMessage(), obj); }