mirror of
https://github.com/zulip/zulip.git
synced 2025-11-01 12:33:40 +00:00
Add people.pm_lookup_key
This commit is contained in:
@@ -86,6 +86,12 @@ initialize();
|
||||
assert.equal(people.is_my_user_id(undefined), false);
|
||||
}());
|
||||
|
||||
(function test_pm_lookup_key() {
|
||||
assert.equal(people.pm_lookup_key('30'), '30');
|
||||
assert.equal(people.pm_lookup_key('32,30'), '32');
|
||||
assert.equal(people.pm_lookup_key('101,32,30'), '32,101');
|
||||
}());
|
||||
|
||||
(function test_get_recipients() {
|
||||
assert.equal(people.get_recipients('30'), 'Me Myself');
|
||||
assert.equal(people.get_recipients('30,32'), 'Isaac Newton');
|
||||
|
||||
@@ -310,6 +310,17 @@ function sorted_other_user_ids(user_ids) {
|
||||
return user_ids;
|
||||
}
|
||||
|
||||
exports.pm_lookup_key = function (user_ids_string) {
|
||||
/*
|
||||
The server will sometimes include our own user id
|
||||
in keys for PMs, but we only want our user id if
|
||||
we sent a message to ourself.
|
||||
*/
|
||||
var user_ids = user_ids_string.split(',');
|
||||
user_ids = sorted_other_user_ids(user_ids);
|
||||
return user_ids.join(',');
|
||||
};
|
||||
|
||||
exports.pm_with_user_ids = function (message) {
|
||||
if (message.type !== 'private') {
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user