refactor(socket.io): deprecate SocketModules.chats.loadPinnedMessages in favour of api.chats.getPinnedMessages"

This commit is contained in:
Julian Lam
2023-11-17 11:37:51 -05:00
parent f9dc35021d
commit 401e8636bd
7 changed files with 65 additions and 12 deletions

View File

@@ -320,6 +320,16 @@ chatsAPI.listMessages = async (caller, { uid, roomId, start, direction = null })
return { messages };
};
chatsAPI.getPinnedMessages = async (caller, { start, roomId }) => {
start = parseInt(start, 10) || 0;
const isInRoom = await messaging.isUserInRoom(caller.uid, roomId);
if (!isInRoom) {
throw new Error('[[error:no-privileges]]');
}
const messages = await messaging.getPinnedMessages(roomId, caller.uid, start, start + 49);
return { messages };
};
chatsAPI.getMessage = async (caller, { mid, roomId }) => {
const messages = await messaging.getMessagesData([mid], caller.uid, roomId, false);
return messages.pop();