diff --git a/app/controllers/embed_controller.rb b/app/controllers/embed_controller.rb index 6a6ded4cb..58b6cbda3 100644 --- a/app/controllers/embed_controller.rb +++ b/app/controllers/embed_controller.rb @@ -29,8 +29,10 @@ class EmbedController < ApplicationController @posts_left = @topic_view.topic.posts_count - SiteSetting.embed_post_limit - 1 end - @reply_count = @topic_view.topic.posts_count - 1 - @reply_count = 0 if @reply_count < 0 + if @topic_view + @reply_count = @topic_view.topic.posts_count - 1 + @reply_count = 0 if @reply_count < 0 + end elsif embed_url.present? Jobs.enqueue(:retrieve_topic, user_id: current_user.try(:id), embed_url: embed_url)