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

Function handleGetChatMessages

src/node/handler/PadMessageHandler.ts:730–749  ·  view source on GitHub ↗
(socket:any, {data: {start, end}}:any)

Source from the content-addressed store, hash-verified

728 * @param message the message from the client
729 */
730const handleGetChatMessages = async (socket:any, {data: {start, end}}:any) => {
731 if (!Number.isInteger(start)) throw new Error(`missing or invalid start: ${start}`);
732 if (!Number.isInteger(end)) throw new Error(`missing or invalid end: ${end}`);
733 const count = end - start;
734 if (count < 0 || count > 100) throw new Error(`invalid number of messages: ${count}`);
735 const {padId, author: authorId} = sessioninfos[socket.id];
736 const pad = await padManager.getPad(padId, null, authorId);
737
738 const chatMessages = await pad.getChatMessages(start, end);
739 const infoMsg = {
740 type: 'COLLABROOM',
741 data: {
742 type: 'CHAT_MESSAGES',
743 messages: chatMessages,
744 },
745 };
746
747 // send the messages back to the client
748 socket.emit('message', infoMsg);
749};
750
751/**
752 * Handles a handleSuggestUserName, that means a user have suggest a userName for a other user

Callers 1

Calls 1

getChatMessagesMethod · 0.80

Tested by

no test coverage detected