Skip to content

Node.js based forum software built for the modern web

fix: closes #14500

Barış Soner Uşaklıfc13bb51a27a
diff --git a/src/api/chats.js b/src/api/chats.js
index 8c14f902f7..0c042fe970 100644
--- a/src/api/chats.js
+++ b/src/api/chats.js
@@ -414,10 +414,17 @@ chatsAPI.getRawMessage = async (caller, { mid, roomId } = {}) => {
};
chatsAPI.getIpAddress = async (caller, { mid }) => {
- const allowed = await privileges.global.can('view:users:info', caller.uid);
+ const [allowed, roomId] = await Promise.all([
+ privileges.global.can('view:users:info', caller.uid),
+ messaging.getMessageField(mid, 'roomId'),
+ ]);
if (!allowed) {
throw new Error('[[error:no-privileges]]');
}
+ const inRoom = await messaging.isUserInRoom(caller.uid, roomId);
+ if (!inRoom) {
+ throw new Error('[[error:not-allowed]]');
+ }
const ip = await messaging.getMessageField(mid, 'ip');
return { ip };
};