FIX: Allow oneboxes with no description (#31518)

This behaviour was allowed in
cb82dce86a
but then inexplicably removed a few months later in
https://github.com/discourse/onebox/pull/448, but showing
title-only oneboxes is valid. The original Meta topic that
this was discussed in was
https://meta.discourse.org/t/abc-news-not-oneboxing-due-to-missing-description/155933
.

This commit re-introduces allowing this behaviour to avoid the need for
a plugin,
c.f. https://meta.discourse.org/t/allow-title-only-onebox/354306

For example
<https://en-americas-support.nintendo.com/app/answers/detail/a_id/67660>

This commit also unhides onebox descriptions in chat, it's not
clear why they were ever hidden in the first place
This commit is contained in:
Martin Brennan
2025-02-26 13:16:51 +10:00
committed by GitHub
parent e6df4b6c49
commit ed1543455d
6 changed files with 150 additions and 20 deletions

View File

@ -59,10 +59,6 @@
font-weight: 500;
font-size: var(--font-down-1);
}
p {
display: none;
}
}
.has-full-page-chat .chat-message .onebox:not(img),

View File

@ -15,7 +15,7 @@ describe Jobs::Chat::ProcessMessage do
it "updates cooked with oneboxes" do
described_class.new.execute(chat_message_id: chat_message.id)
expect(chat_message.reload.cooked).to eq(
"<p><a href=\"https://discourse.org/team\" class=\"onebox\" target=\"_blank\" rel=\"noopener nofollow ugc\">https://discourse.org/team</a></p>",
"<aside class=\"onebox allowlistedgeneric\" data-onebox-src=\"https://discourse.org/team\">\n <header class=\"source\">\n\n <a href=\"https://discourse.org/team\" target=\"_blank\" rel=\"nofollow ugc noopener\">discourse.org</a>\n </header>\n\n <article class=\"onebox-body\">\n \n\n<h3><a href=\"https://discourse.org/team\" target=\"_blank\" rel=\"nofollow ugc noopener\">a</a></h3>\n\n\n\n </article>\n\n <div class=\"onebox-metadata\">\n \n \n </div>\n\n <div style=\"clear: both\"></div>\n</aside>\n",
)
end