mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-18 03:31:03 +01:00
refactor(socket.io): deprecate SocketModules.chats.getIP in favour of api.chats.getIpAddress
This commit is contained in:
@@ -8,6 +8,7 @@ const user = require('../user');
|
||||
const meta = require('../meta');
|
||||
const messaging = require('../messaging');
|
||||
const notifications = require('../notifications');
|
||||
const privileges = require('../privileges');
|
||||
const plugins = require('../plugins');
|
||||
|
||||
const socketHelpers = require('../socket.io/helpers');
|
||||
@@ -295,6 +296,15 @@ chatsAPI.getRawMessage = async (caller, { mid, roomId }) => {
|
||||
return { content };
|
||||
};
|
||||
|
||||
chatsAPI.getIpAddress = async (caller, { mid }) => {
|
||||
const allowed = await privileges.global.can('view:users:info', caller.uid);
|
||||
if (!allowed) {
|
||||
throw new Error('[[error:no-privileges]]');
|
||||
}
|
||||
const ip = await messaging.getMessageField(mid, 'ip');
|
||||
return { ip };
|
||||
};
|
||||
|
||||
chatsAPI.editMessage = async (caller, { mid, roomId, message }) => {
|
||||
await messaging.canEdit(mid, caller.uid);
|
||||
await messaging.editMessage(caller.uid, mid, roomId, message);
|
||||
|
||||
Reference in New Issue
Block a user