mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-26 16:46:12 +01:00
refactor: move async call to promise.all
This commit is contained in:
@@ -230,7 +230,7 @@ module.exports = function (Messaging) {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
const [room, canReply, users, messages, isAdminOrGlobalMod] = await Promise.all([
|
const [room, canReply, users, messages, isAdminOrGlobalMod, isOwner] = await Promise.all([
|
||||||
Messaging.getRoomData(data.roomId),
|
Messaging.getRoomData(data.roomId),
|
||||||
Messaging.canReply(data.roomId, uid),
|
Messaging.canReply(data.roomId, uid),
|
||||||
Messaging.getUsersInRoom(data.roomId, 0, -1),
|
Messaging.getUsersInRoom(data.roomId, 0, -1),
|
||||||
@@ -241,10 +241,11 @@ module.exports = function (Messaging) {
|
|||||||
isNew: false,
|
isNew: false,
|
||||||
}),
|
}),
|
||||||
user.isAdminOrGlobalMod(uid),
|
user.isAdminOrGlobalMod(uid),
|
||||||
|
Messaging.isRoomOwner(uid, data.roomId),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
room.messages = messages;
|
room.messages = messages;
|
||||||
room.isOwner = await Messaging.isRoomOwner(uid, room.roomId);
|
room.isOwner = isOwner;
|
||||||
room.users = users.filter(user => user && parseInt(user.uid, 10) && parseInt(user.uid, 10) !== parseInt(uid, 10));
|
room.users = users.filter(user => user && parseInt(user.uid, 10) && parseInt(user.uid, 10) !== parseInt(uid, 10));
|
||||||
room.canReply = canReply;
|
room.canReply = canReply;
|
||||||
room.groupChat = room.hasOwnProperty('groupChat') ? room.groupChat : users.length > 2;
|
room.groupChat = room.hasOwnProperty('groupChat') ? room.groupChat : users.length > 2;
|
||||||
|
|||||||
Reference in New Issue
Block a user