mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-02-01 03:12:42 +01:00
ChatMessage: Log deprecation warnings for .userId
, .authorId
This commit is contained in:
parent
b4d9252bfe
commit
363a48b6d5
2 changed files with 19 additions and 5 deletions
|
@ -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
|
// 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.
|
// authorManager.getAuthorName() to resolve before saving the message to the database.
|
||||||
const promise = pad.appendChatMessage(message);
|
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({
|
socketio.sockets.in(padId).json.send({
|
||||||
type: 'COLLABROOM',
|
type: 'COLLABROOM',
|
||||||
data: {type: 'CHAT_MESSAGE', message},
|
data: {type: 'CHAT_MESSAGE', message},
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
const {padutils: {warnDeprecated}} = require('./pad_utils');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents a chat message stored in the database and transmitted among users. Plugins can extend
|
* Represents a chat message stored in the database and transmitted among users. Plugins can extend
|
||||||
* the object with additional properties.
|
* the object with additional properties.
|
||||||
|
@ -52,8 +54,14 @@ class ChatMessage {
|
||||||
* @deprecated Use `authorId` instead.
|
* @deprecated Use `authorId` instead.
|
||||||
* @type {string}
|
* @type {string}
|
||||||
*/
|
*/
|
||||||
get userId() { return this.authorId; }
|
get userId() {
|
||||||
set userId(val) { this.authorId = val; }
|
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.
|
* Alias of `displayName`, for compatibility with old plugins.
|
||||||
|
@ -61,8 +69,14 @@ class ChatMessage {
|
||||||
* @deprecated Use `displayName` instead.
|
* @deprecated Use `displayName` instead.
|
||||||
* @type {string}
|
* @type {string}
|
||||||
*/
|
*/
|
||||||
get userName() { return this.displayName; }
|
get userName() {
|
||||||
set userName(val) { this.displayName = val; }
|
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
|
// TODO: Delete this method once users are unlikely to roll back to a version of Etherpad that
|
||||||
// doesn't support authorId and displayName.
|
// doesn't support authorId and displayName.
|
||||||
|
|
Loading…
Reference in a new issue