mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
secure the links on the topic pages, eliminated deleted topics as well.
This commit is contained in:
@@ -4,20 +4,22 @@ require_dependency 'summarize'
|
||||
|
||||
class TopicView
|
||||
|
||||
attr_reader :topic, :posts, :index_offset, :index_reverse
|
||||
attr_reader :topic, :posts, :index_offset, :index_reverse, :guardian
|
||||
attr_accessor :draft, :draft_key, :draft_sequence
|
||||
|
||||
def initialize(topic_id, user=nil, options={})
|
||||
@topic = find_topic(topic_id)
|
||||
raise Discourse::NotFound if @topic.blank?
|
||||
|
||||
@guardian = Guardian.new(user)
|
||||
|
||||
# Special case: If the topic is private and the user isn't logged in, ask them
|
||||
# to log in!
|
||||
if @topic.present? && @topic.private_message? && user.blank?
|
||||
raise Discourse::NotLoggedIn.new
|
||||
end
|
||||
|
||||
Guardian.new(user).ensure_can_see!(@topic)
|
||||
guardian.ensure_can_see!(@topic)
|
||||
@post_number, @page = options[:post_number], options[:page]
|
||||
|
||||
@limit = options[:limit] || SiteSetting.posts_per_page;
|
||||
@@ -225,18 +227,18 @@ class TopicView
|
||||
@post_action_visibility ||= begin
|
||||
result = []
|
||||
PostActionType.types.each do |k, v|
|
||||
result << v if Guardian.new(@user).can_see_post_actors?(@topic, v)
|
||||
result << v if guardian.can_see_post_actors?(@topic, v)
|
||||
end
|
||||
result
|
||||
end
|
||||
end
|
||||
|
||||
def links
|
||||
@links ||= @topic.links_grouped
|
||||
@links ||= TopicLink.topic_summary(guardian, @topic.id)
|
||||
end
|
||||
|
||||
def link_counts
|
||||
@link_counts ||= TopicLinkClick.counts_for(@topic, posts)
|
||||
@link_counts ||= TopicLink.counts_for(guardian,@topic, posts)
|
||||
end
|
||||
|
||||
# Are we the initial page load? If so, we can return extra information like
|
||||
|
||||
Reference in New Issue
Block a user