mirror of
https://github.com/cnodejs/nodeclub.git
synced 2025-12-08 19:55:55 +00:00
fix #487 回复消息时,不 at 消息作者
This commit is contained in:
parent
a9eba1a2b0
commit
96faae0c28
@ -71,6 +71,11 @@ exports.sendMessageToMentionUsers = function (text, topicId, authorId, reply_id,
|
||||
}
|
||||
var ep = new EventProxy();
|
||||
ep.fail(callback);
|
||||
|
||||
users = users.filter(function (user) {
|
||||
return !user._id.equals(authorId);
|
||||
});
|
||||
|
||||
ep.after('sent', users.length, function () {
|
||||
callback();
|
||||
});
|
||||
|
||||
@ -11,12 +11,13 @@ var multiline = require('multiline');
|
||||
var pedding = require('pedding');
|
||||
|
||||
describe('test/common/at.test.js', function () {
|
||||
var testTopic, normalUser, normalUser2;
|
||||
var testTopic, normalUser, normalUser2, adminUser;
|
||||
before(function (done) {
|
||||
support.ready(function () {
|
||||
testTopic = support.testTopic;
|
||||
normalUser = support.normalUser;
|
||||
normalUser2 = support.normalUser2;
|
||||
adminUser = support.adminUser;
|
||||
done();
|
||||
});
|
||||
});
|
||||
@ -156,7 +157,7 @@ aldjf
|
||||
describe('sendMessageToMentionUsers()', function () {
|
||||
it('should send message to all mention users', function (done) {
|
||||
done = pedding(done, 2);
|
||||
var atUserIds = [String(normalUser._id), String(normalUser2._id)];
|
||||
var atUserIds = [String(adminUser._id), String(normalUser2._id)];
|
||||
|
||||
var ep = new eventproxy();
|
||||
ep.after('user_id', atUserIds.length, function (user_ids) {
|
||||
@ -170,7 +171,7 @@ aldjf
|
||||
callback();
|
||||
});
|
||||
|
||||
var text = '@' + normalUser.loginname + ' @' + normalUser2.loginname + ' @notexitstuser 你们好';
|
||||
var text = '@' + adminUser.loginname + ' @' + normalUser2.loginname + ' @notexitstuser 你们好';
|
||||
at.sendMessageToMentionUsers(text,
|
||||
testTopic._id,
|
||||
normalUser._id,
|
||||
@ -191,6 +192,19 @@ aldjf
|
||||
});
|
||||
});
|
||||
|
||||
it('should not send at msg to author', function (done) {
|
||||
mm(message, 'sendAtMessage', function () {
|
||||
throw new Error('should not call me');
|
||||
});
|
||||
|
||||
at.sendMessageToMentionUsers('@' + normalUser.loginname + ' hello',
|
||||
testTopic._id, normalUser._id,
|
||||
function (err) {
|
||||
should.not.exist(err);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
describe('mock message.sendAtMessage() error', function () {
|
||||
beforeEach(function () {
|
||||
mm(message, 'sendAtMessage', function () {
|
||||
|
||||
@ -52,6 +52,7 @@ ep.all('user', 'user2', 'admin', function (user, user2, admin) {
|
||||
|
||||
var adminObj = JSON.parse(JSON.stringify(admin));
|
||||
adminObj.is_admin = true;
|
||||
exports.adminUser = admin;
|
||||
exports.adminUserCookie = mockUser(adminObj);
|
||||
|
||||
createTopic(user._id, ep.done('topic'));
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user