mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-04-21 07:56:16 -04:00
51 lines
1.1 KiB
JavaScript
51 lines
1.1 KiB
JavaScript
![]() |
'use strict';
|
||
|
|
||
|
/**
|
||
|
* Represents a chat message stored in the database and transmitted among users. Plugins can extend
|
||
|
* the object with additional properties.
|
||
|
*
|
||
|
* Supports serialization to JSON.
|
||
|
*/
|
||
|
class ChatMessage {
|
||
|
static fromObject(obj) {
|
||
|
return Object.assign(new ChatMessage(), obj);
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* @param {?string} [text] - Initial value of the `text` property.
|
||
|
* @param {?string} [userId] - Initial value of the `userId` property.
|
||
|
* @param {?number} [time] - Initial value of the `time` property.
|
||
|
*/
|
||
|
constructor(text = null, userId = null, time = null) {
|
||
|
/**
|
||
|
* The raw text of the user's chat message (before any rendering or processing).
|
||
|
*
|
||
|
* @type {?string}
|
||
|
*/
|
||
|
this.text = text;
|
||
|
|
||
|
/**
|
||
|
* The user's author ID.
|
||
|
*
|
||
|
* @type {?string}
|
||
|
*/
|
||
|
this.userId = userId;
|
||
|
|
||
|
/**
|
||
|
* The message's timestamp, as milliseconds since epoch.
|
||
|
*
|
||
|
* @type {?number}
|
||
|
*/
|
||
|
this.time = time;
|
||
|
|
||
|
/**
|
||
|
* The user's display name.
|
||
|
*
|
||
|
* @type {?string}
|
||
|
*/
|
||
|
this.userName = null;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
module.exports = ChatMessage;
|