MCPcopy Index your code
hub / github.com/ether/etherpad / appendChatMessage

Method appendChatMessage

src/node/db/Pad.ts:536–547  ·  view source on GitHub ↗

* Adds a chat message to the pad, including saving it to the database. * * @param {(ChatMessage|string)} msgOrText - Either a chat message object (recommended) or a * string containing the raw text of the user's chat message (deprecated). * @param {?string} [authorId] - The user's au

(msgOrText: string| ChatMessage, authorId = null, time = null)

Source from the content-addressed store, hash-verified

534 * `msgOrText.time` instead.
535 */
536 async appendChatMessage(msgOrText: string| ChatMessage, authorId = null, time = null) {
537 const msg =
538 msgOrText instanceof ChatMessage ? msgOrText : new ChatMessage(msgOrText, authorId, time);
539 this.chatHead++;
540 await Promise.all([
541 // Don't save the display name in the database because the user can change it at any time. The
542 // `displayName` property will be populated with the current value when the message is read
543 // from the database.
544 this.db.set(`pad:${this.id}:chat:${this.chatHead}`, {...msg, displayName: undefined}),
545 this.saveToDatabase(),
546 ]);
547 }
548
549 /**
550 * @param {number} entryNum - ID of the desired chat message.

Callers 1

Calls 2

saveToDatabaseMethod · 0.95
setMethod · 0.80

Tested by

no test coverage detected