mirror of
https://github.com/zulip/zulip.git
synced 2025-11-06 15:03:34 +00:00
Fix "Copy link to conversation" links.
This cleans up the code for stream links and creates nicer, more correct links for PMs. Fixes #10605
This commit is contained in:
@@ -76,12 +76,14 @@ run_test('test_by_conversation_and_time_uri', () => {
|
|||||||
|
|
||||||
message = {
|
message = {
|
||||||
type: 'private',
|
type: 'private',
|
||||||
reply_to: 'iago@example.com,hamlet@example.com',
|
display_recipient: [
|
||||||
|
{
|
||||||
|
user_id: hamlet.user_id,
|
||||||
|
},
|
||||||
|
],
|
||||||
id: 43,
|
id: 43,
|
||||||
};
|
};
|
||||||
|
|
||||||
people.my_current_email = () => 'jeff@example.com';
|
|
||||||
|
|
||||||
assert.equal(hash_util.by_conversation_and_time_uri(message),
|
assert.equal(hash_util.by_conversation_and_time_uri(message),
|
||||||
'https://example.com/#narrow/pm-with/iago.40example.2Ecom.2Chamlet.40example.2Ecom.2Cjeff.40example.2Ecom/near/43');
|
'https://example.com/#narrow/pm-with/1-pm/near/43');
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -108,23 +108,18 @@ exports.huddle_with_uri = function (user_ids_string) {
|
|||||||
|
|
||||||
exports.by_conversation_and_time_uri = function (message) {
|
exports.by_conversation_and_time_uri = function (message) {
|
||||||
var absolute_url = window.location.protocol + "//" +
|
var absolute_url = window.location.protocol + "//" +
|
||||||
window.location.host + "/" + window.location.pathname.split('/')[1];
|
window.location.host + "/" +
|
||||||
|
window.location.pathname.split('/')[1];
|
||||||
|
|
||||||
|
var suffix = "/near/" + exports.encodeHashComponent(message.id);
|
||||||
|
|
||||||
if (message.type === "stream") {
|
if (message.type === "stream") {
|
||||||
return absolute_url + "#narrow/stream/" +
|
return absolute_url +
|
||||||
exports.encode_stream_name(message.stream) +
|
exports.by_stream_subject_uri(message.stream, message.subject) +
|
||||||
"/subject/" + exports.encodeHashComponent(message.subject) +
|
suffix;
|
||||||
"/near/" + exports.encodeHashComponent(message.id);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Include your own email in this URI if it's not there already
|
return absolute_url + people.pm_perma_link(message) + suffix;
|
||||||
var all_emails = message.reply_to;
|
|
||||||
if (all_emails.indexOf(people.my_current_email()) === -1) {
|
|
||||||
all_emails += "," + people.my_current_email();
|
|
||||||
}
|
|
||||||
return absolute_url + "#narrow/pm-with/" +
|
|
||||||
exports.encodeHashComponent(all_emails) +
|
|
||||||
"/near/" + exports.encodeHashComponent(message.id);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return exports;
|
return exports;
|
||||||
|
|||||||
Reference in New Issue
Block a user