Skip to content

A platform for community discussion. Free, open, simple.

FIX: local post onebox was always pointing to 1st post

Régis Hanol3be0294465ae
diff --git a/lib/onebox/templates/discourse_topic_onebox.hbs b/lib/onebox/templates/discourse_topic_onebox.hbs
index 8b6d746b71f..856d3342d47 100644
--- a/lib/onebox/templates/discourse_topic_onebox.hbs
+++ b/lib/onebox/templates/discourse_topic_onebox.hbs
@@ -1,4 +1,4 @@
-<aside class='quote' data-post="1" data-topic="{{topic_id}}">
+<aside class='quote' data-post="{{post_number}}" data-topic="{{topic_id}}">
<div class='title'>
<div class='quote-controls'></div>
{{{avatar}}}
diff --git a/lib/oneboxer.rb b/lib/oneboxer.rb
index 682251ed505..935233ead73 100644
--- a/lib/oneboxer.rb
+++ b/lib/oneboxer.rb
@@ -202,6 +202,7 @@ module Oneboxer
else
args = {
topic_id: topic.id,
+ post_number: post.post_number,
avatar: PrettyText.avatar_img(post.user.avatar_template, "tiny"),
original_url: url,
title: PrettyText.unescape_emoji(CGI::escapeHTML(topic.title)),
diff --git a/spec/components/oneboxer_spec.rb b/spec/components/oneboxer_spec.rb
index 1bbc1e76b50..6ba23c3a950 100644
--- a/spec/components/oneboxer_spec.rb
+++ b/spec/components/oneboxer_spec.rb
@@ -54,6 +54,7 @@ describe Oneboxer do
onebox = preview(public_reply.url, user, public_category)
expect(onebox).to include(public_reply.excerpt)
+ expect(onebox).to include(%{data-post="2"})
expect(onebox).to include(PrettyText.avatar_img(replier.avatar_template, "tiny"))
onebox = preview(public_reply.url, user, public_category, public_topic)