chat: Silence accidental deprecation warnings

This fixes a bug introduced in commit
363a48b6d5.
This commit is contained in:
Richard Hansen 2022-02-26 18:51:08 -05:00
parent e3e86dc0aa
commit ad45359a9d

View file

@ -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);
}