diff --git a/lib/commands.js b/lib/commands.js index 255e1708..e4927f54 100644 --- a/lib/commands.js +++ b/lib/commands.js @@ -217,14 +217,14 @@ exports.bindCommands = function bindCommands(forum) { } /** - * Get ChatRoom who posted the command + * Get PrivateMessage who posted the command * * @public * - * @returns {Promise} Resolved to retrieved ChatRoom + * @returns {Promise} Resolved to retrieved PrivateMessage */ - getRoom() { - return this.parent.getRoom(); + getPM() { + return this.parent.getPM(); } /** @@ -422,25 +422,25 @@ exports.bindCommands = function bindCommands(forum) { } /** - * Get the ChatRoom this Commands object referrs to + * Get the PrivateMessage this Commands object referrs to * * @public * * @returns {Promise} Resolves to the retrieved ChatRoom */ - getRoom() { - return this._getItem('room', this.ids.room, forum.Chat); + getPM() { + return this._getItem('pm', this.ids.pm, forum.PrivateMessage); } /** - * Set the ChatRoom this Commands object refers to + * Set the PrivateMessage this Commands object refers to * * @public * - * @param {ChatRoom} room The ChatRoom to cache + * @param {PrivateMessage} pm The pm to cache */ - setRoom(room) { - this._setItem('room', room); + setPM(pm) { + this._setItem('pm', pm); } /** diff --git a/providers/nodebb/chat.js b/providers/nodebb/chat.js index a1fcb9c6..9f467661 100644 --- a/providers/nodebb/chat.js +++ b/providers/nodebb/chat.js @@ -449,7 +449,7 @@ exports.bindChat = function bindChat(forum) { post: -1, topic: -1, user: message.from.id, - room: message.room, + pm: message.room, chat: message.id }; return forum.Commands.get(ids, message.content, (content) => message.reply(content)) diff --git a/providers/nodebb/notification.js b/providers/nodebb/notification.js index 3d7753a8..e0b16088 100644 --- a/providers/nodebb/notification.js +++ b/providers/nodebb/notification.js @@ -380,7 +380,7 @@ exports.bindNotification = function bindNotification(forum) { post: notification.postId, topic: notification.topicId, user: notification.userId, - room: -1, + pm: -1, chat: -1 }; return notification.getText() diff --git a/test/lib/commandsTest.js b/test/lib/commandsTest.js index 2716b712..2cbd1e80 100644 --- a/test/lib/commandsTest.js +++ b/test/lib/commandsTest.js @@ -715,7 +715,7 @@ describe('lib/config', () => { getPost: sinon.stub(), getTopic: sinon.stub(), getUser: sinon.stub(), - getRoom: sinon.stub() + getPM: sinon.stub() }; command = new Command({}, parent); }); @@ -739,9 +739,9 @@ describe('lib/config', () => { }); it('should proxy getRoom() to parent.getRoom()', () => { const expected = Math.random(); - parent.getRoom.returns(expected); - command.getRoom().should.equal(expected); - parent.getRoom.should.have.been.calledOnce; + parent.getPM.returns(expected); + command.getPM().should.equal(expected); + parent.getPM.should.have.been.calledOnce; }); }); describe('reply()', () => { @@ -883,7 +883,7 @@ describe('lib/config', () => { ['getPost', 'Post', 'post'], ['getTopic', 'Topic', 'topic'], ['getUser', 'User', 'user'], - ['getRoom', 'Chat', 'room'] + ['getPM', 'PrivateMessage', 'pm'] ].forEach((config) => { const method = config[0], object = config[1], @@ -932,7 +932,7 @@ describe('lib/config', () => { [ ['setPost', 'post'], ['setTopic', 'topic'], - ['setRoom', 'room'], + ['setPM', 'pm'], ['setUser', 'user'] ].forEach((config) => { const method = config[0], diff --git a/test/providers/nodebb/chatTests.js b/test/providers/nodebb/chatTests.js index 4bfbc76f..706c820b 100644 --- a/test/providers/nodebb/chatTests.js +++ b/test/providers/nodebb/chatTests.js @@ -1068,11 +1068,11 @@ describe('providers/nodebb/chat', () => { message: 1 }).then(() => { const param = forum.Commands.get.firstCall.args[0]; - param.should.have.all.keys('post', 'topic', 'user', 'room', 'chat'); + param.should.have.all.keys('post', 'topic', 'user', 'pm', 'chat'); param.post.should.equal(-1); param.topic.should.equal(-1); param.user.should.equal(userId); - param.room.should.equal(roomId); + param.pm.should.equal(roomId); param.chat.should.equal(chatId); }); }); diff --git a/test/providers/nodebb/notificationTest.js b/test/providers/nodebb/notificationTest.js index 35e15416..76bc861e 100644 --- a/test/providers/nodebb/notificationTest.js +++ b/test/providers/nodebb/notificationTest.js @@ -604,7 +604,7 @@ describe('providers/nodebb/notification', () => { post: post, topic: topic, user: user, - room: -1, + pm: -1, chat: -1 }); args[1].should.eql(text);