mirror of https://github.com/zulip/zulip.git
compose: Use new ID-based api for sending messages.
This only happens if the realm is not a zephyr realm. Finishes part of #9474.
This commit is contained in:
parent
eed09527d5
commit
3f32ffc4eb
|
@ -607,13 +607,14 @@ run_test('send_message', () => {
|
||||||
queue_id: undefined,
|
queue_id: undefined,
|
||||||
stream: '',
|
stream: '',
|
||||||
topic: '',
|
topic: '',
|
||||||
to: '["alice@example.com"]',
|
to: `[${alice.user_id}]`,
|
||||||
reply_to: 'alice@example.com',
|
reply_to: 'alice@example.com',
|
||||||
private_message_recipient: 'alice@example.com',
|
private_message_recipient: 'alice@example.com',
|
||||||
to_user_ids: '31',
|
to_user_ids: '31',
|
||||||
local_id: 1,
|
local_id: 1,
|
||||||
locally_echoed: true,
|
locally_echoed: true,
|
||||||
};
|
};
|
||||||
|
|
||||||
assert.deepEqual(payload, single_msg);
|
assert.deepEqual(payload, single_msg);
|
||||||
payload.id = stub_state.local_id_counter;
|
payload.id = stub_state.local_id_counter;
|
||||||
success(payload);
|
success(payload);
|
||||||
|
@ -1676,10 +1677,15 @@ run_test('create_message_object', () => {
|
||||||
};
|
};
|
||||||
|
|
||||||
message = compose.create_message_object();
|
message = compose.create_message_object();
|
||||||
assert.deepEqual(message.to, ['alice@example.com', 'bob@example.com']);
|
assert.deepEqual(message.to, [alice.user_id, bob.user_id]);
|
||||||
assert.equal(message.to_user_ids, '31,32');
|
assert.equal(message.to_user_ids, '31,32');
|
||||||
assert.equal(message.content, 'burrito');
|
assert.equal(message.content, 'burrito');
|
||||||
|
|
||||||
|
var { email_list_to_user_ids_string } = people;
|
||||||
|
people.email_list_to_user_ids_string = () => undefined;
|
||||||
|
message = compose.create_message_object();
|
||||||
|
assert.deepEqual(message.to, [alice.email, bob.email]);
|
||||||
|
people.email_list_to_user_ids_string = email_list_to_user_ids_string;
|
||||||
});
|
});
|
||||||
|
|
||||||
run_test('nonexistent_stream_reply_error', () => {
|
run_test('nonexistent_stream_reply_error', () => {
|
||||||
|
|
|
@ -179,6 +179,20 @@ function create_message_object() {
|
||||||
message.reply_to = recipient;
|
message.reply_to = recipient;
|
||||||
message.private_message_recipient = recipient;
|
message.private_message_recipient = recipient;
|
||||||
message.to_user_ids = people.email_list_to_user_ids_string(emails);
|
message.to_user_ids = people.email_list_to_user_ids_string(emails);
|
||||||
|
|
||||||
|
// Note: The `undefined` case is for situations like the
|
||||||
|
// is_zephyr_mirror_realm case where users may be
|
||||||
|
// automatically created when you try to send a private
|
||||||
|
// message to their email address.
|
||||||
|
if (message.to_user_ids !== undefined) {
|
||||||
|
// to_user_ids is a string containing a comma-separated
|
||||||
|
// list of user IDs for the recipients; convert this into
|
||||||
|
// an array of integers.
|
||||||
|
message.to = _.map(message.to_user_ids.split(','), function (id) {
|
||||||
|
return Number(id);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
var stream_name = compose_state.stream_name();
|
var stream_name = compose_state.stream_name();
|
||||||
message.to = stream_name;
|
message.to = stream_name;
|
||||||
|
|
Loading…
Reference in New Issue