FIX: Improve message when posting a duplicate link (#19245)

If the duplicated link was posted by the user itself, it will display
a different JIT message.
This commit is contained in:
Jan Cernik 2022-11-29 16:08:27 -03:00 committed by GitHub
parent 88a0384d43
commit 93fcfa58d0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 6 deletions

View File

@ -648,12 +648,21 @@ export default Controller.extend({
const [linkWarn, linkInfo] = linkLookup.check(post, href);
if (linkWarn && !this.get("isWhispering")) {
const body = I18n.t("composer.duplicate_link", {
domain: linkInfo.domain,
username: linkInfo.username,
post_url: topic.urlForPostNumber(linkInfo.post_number),
ago: shortDate(linkInfo.posted_at),
});
let body;
if (linkInfo.username === this.currentUser.username) {
body = I18n.t("composer.duplicate_link_same_user", {
domain: linkInfo.domain,
post_url: topic.urlForPostNumber(linkInfo.post_number),
ago: shortDate(linkInfo.posted_at),
});
} else {
body = I18n.t("composer.duplicate_link", {
domain: linkInfo.domain,
username: linkInfo.username,
post_url: topic.urlForPostNumber(linkInfo.post_number),
ago: shortDate(linkInfo.posted_at),
});
}
this.appEvents.trigger("composer-messages:create", {
extraClass: "custom-body",
templateName: "education",

View File

@ -2237,6 +2237,7 @@ en:
one: "By mentioning <b>@%{here}</b>, you are about to notify %{count} user are you sure?"
other: "By mentioning <b>@%{here}</b>, you are about to notify %{count} users are you sure?"
duplicate_link: "It looks like your link to <b>%{domain}</b> was already posted in the topic by <b>@%{username}</b> in <a href='%{post_url}'>a reply on %{ago}</a> are you sure you want to post it again?"
duplicate_link_same_user: "It looks like you already posted a link to <b>%{domain}</b> in this topic in <a href='%{post_url}'>a reply on %{ago}</a> - are you sure you want to post it again?"
reference_topic_title: "RE: %{title}"
error: