mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-02-01 03:12:42 +01:00
chat: Silence accidental deprecation warnings
This fixes a bug introduced in commit
363a48b6d5
.
This commit is contained in:
parent
e3e86dc0aa
commit
ad45359a9d
1 changed files with 7 additions and 0 deletions
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue