mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-04-21 16:06:16 -04:00
chat: Rename userId
to authorId
, userName
to displayName
This commit is contained in:
parent
0f47ca9046
commit
4c2f7f9a11
5 changed files with 50 additions and 20 deletions
|
@ -13,10 +13,10 @@ class ChatMessage {
|
|||
|
||||
/**
|
||||
* @param {?string} [text] - Initial value of the `text` property.
|
||||
* @param {?string} [userId] - Initial value of the `userId` property.
|
||||
* @param {?string} [authorId] - Initial value of the `authorId` property.
|
||||
* @param {?number} [time] - Initial value of the `time` property.
|
||||
*/
|
||||
constructor(text = null, userId = null, time = null) {
|
||||
constructor(text = null, authorId = null, time = null) {
|
||||
/**
|
||||
* The raw text of the user's chat message (before any rendering or processing).
|
||||
*
|
||||
|
@ -29,7 +29,7 @@ class ChatMessage {
|
|||
*
|
||||
* @type {?string}
|
||||
*/
|
||||
this.userId = userId;
|
||||
this.authorId = authorId;
|
||||
|
||||
/**
|
||||
* The message's timestamp, as milliseconds since epoch.
|
||||
|
@ -43,7 +43,37 @@ class ChatMessage {
|
|||
*
|
||||
* @type {?string}
|
||||
*/
|
||||
this.userName = null;
|
||||
this.displayName = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Alias of `authorId`, for compatibility with old plugins.
|
||||
*
|
||||
* @deprecated Use `authorId` instead.
|
||||
* @type {string}
|
||||
*/
|
||||
get userId() { return this.authorId; }
|
||||
set userId(val) { this.authorId = val; }
|
||||
|
||||
/**
|
||||
* Alias of `displayName`, for compatibility with old plugins.
|
||||
*
|
||||
* @deprecated Use `displayName` instead.
|
||||
* @type {string}
|
||||
*/
|
||||
get userName() { return this.displayName; }
|
||||
set userName(val) { 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.
|
||||
toJSON() {
|
||||
return {
|
||||
...this,
|
||||
authorId: undefined,
|
||||
displayName: undefined,
|
||||
userId: this.authorId,
|
||||
userName: this.displayName,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -111,15 +111,15 @@ exports.chat = (() => {
|
|||
// correct the time
|
||||
msg.time += this._pad.clientTimeOffset;
|
||||
|
||||
if (!msg.userId) {
|
||||
if (!msg.authorId) {
|
||||
/*
|
||||
* If, for a bug or a database corruption, the message coming from the
|
||||
* server does not contain the userId field (see for example #3731),
|
||||
* server does not contain the authorId field (see for example #3731),
|
||||
* let's be defensive and replace it with "unknown".
|
||||
*/
|
||||
msg.userId = 'unknown';
|
||||
msg.authorId = 'unknown';
|
||||
console.warn(
|
||||
'The "userId" field of a chat message coming from the server was not present. ' +
|
||||
'The "authorId" field of a chat message coming from the server was not present. ' +
|
||||
'Replacing with "unknown". This may be a bug or a database corruption.');
|
||||
}
|
||||
|
||||
|
@ -130,8 +130,8 @@ exports.chat = (() => {
|
|||
|
||||
// the hook args
|
||||
const ctx = {
|
||||
authorName: msg.userName != null ? msg.userName : html10n.get('pad.userlist.unnamed'),
|
||||
author: msg.userId,
|
||||
authorName: msg.displayName != null ? msg.displayName : html10n.get('pad.userlist.unnamed'),
|
||||
author: msg.authorId,
|
||||
text: padutils.escapeHtmlWithClickableLinks(msg.text, '_blank'),
|
||||
message: msg,
|
||||
rendered: null,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue