Skip to content

Commit

Permalink
Merge pull request #363 from SockDrawer/fix-chats-again
Browse files Browse the repository at this point in the history
feat(commands): Expose chat message id to commands
  • Loading branch information
yamikuronue authored Sep 21, 2016
2 parents 20684ce + 1ae0cb1 commit 9f3a614
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 4 deletions.
3 changes: 2 additions & 1 deletion providers/nodebb/chat.js
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,8 @@ exports.bindChat = function bindChat(forum) {
post: -1,
topic: -1,
user: message.from.id,
room: message.room
room: message.room,
chat: message.id
};
return forum.Commands.get(ids, message.content, (content) => message.reply(content))
.then((command) => command.execute());
Expand Down
3 changes: 2 additions & 1 deletion providers/nodebb/notification.js
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,8 @@ exports.bindNotification = function bindNotification(forum) {
post: notification.postId,
topic: notification.topicId,
user: notification.userId,
room: -1
room: -1,
chat: -1
};
return notification.getText()
.then((postData) => forum.Commands.get(ids,
Expand Down
5 changes: 4 additions & 1 deletion test/providers/nodebb/chatTests.js
Original file line number Diff line number Diff line change
Expand Up @@ -1058,6 +1058,8 @@ describe('providers/nodebb/chat', () => {
});
});
it('should provide expected ids to Commands parsing', () => {
const chatId = Math.random();
message.id = chatId;
const roomId = Math.random();
message.room = roomId;
const userId = Math.random();
Expand All @@ -1066,11 +1068,12 @@ describe('providers/nodebb/chat', () => {
message: 1
}).then(() => {
const param = forum.Commands.get.firstCall.args[0];
param.should.have.all.keys('post', 'topic', 'user', 'room');
param.should.have.all.keys('post', 'topic', 'user', 'room', 'chat');
param.post.should.equal(-1);
param.topic.should.equal(-1);
param.user.should.equal(userId);
param.room.should.equal(roomId);
param.chat.should.equal(chatId);
});
});
it('should provide message content to commands parsing', () => {
Expand Down
3 changes: 2 additions & 1 deletion test/providers/nodebb/notificationTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -598,7 +598,8 @@ describe('providers/nodebb/notification', () => {
post: post,
topic: topic,
user: user,
room: -1
room: -1,
chat: -1
});
args[1].should.eql(text);
args[2].should.be.a('function');
Expand Down

0 comments on commit 9f3a614

Please sign in to comment.