refactor(socket.io): deprecate SocketModules.sortPublicRooms in favour of api.chats.sortPublicRooms

This commit is contained in:
Julian Lam
2023-11-15 11:41:02 -05:00
parent 2de534fad8
commit 62b7dfd400
8 changed files with 65 additions and 9 deletions

View File

@@ -84,6 +84,22 @@ chatsAPI.getUnread = async (caller) => {
return { count };
};
chatsAPI.sortPublicRooms = async (caller, { roomIds, scores }) => {
[roomIds, scores].forEach((arr) => {
if (!Array.isArray(arr) || !arr.every(value => isFinite(value))) {
throw new Error('[[error:invalid-data]]');
}
});
const isAdmin = await user.isAdministrator(caller.uid);
if (!isAdmin) {
throw new Error('[[error:no-privileges]]');
}
await db.sortedSetAdd(`chat:rooms:public:order`, scores, roomIds);
require('../cache').del(`chat:rooms:public:order:all`);
};
chatsAPI.get = async (caller, { uid, roomId }) => await messaging.loadRoom(caller.uid, { uid, roomId });
chatsAPI.post = async (caller, data) => {