discourse/lib/topic_list_responder.rb

Failed to ignore revisions in .git-blame-ignore-revs.

29 lines
729 B
Ruby
Raw Normal View History

# frozen_string_literal: true
2015-01-09 05:44:27 +08:00
# Helps us respond with a topic list from a controller
module TopicListResponder
def respond_with_list(list)
discourse_expires_in 1.minute
list.draft_key = Draft::NEW_TOPIC
if current_user&.human?
list.draft_sequence = DraftSequence.current(current_user, list.draft_key)
list.draft = Draft.get(current_user, list.draft_key, list.draft_sequence)
end
2015-01-09 05:44:27 +08:00
respond_to do |format|
format.html do
@list = list
store_preloaded(list.preload_key, MultiJson.dump(TopicListSerializer.new(list, scope: guardian)))
render 'list/list'
2015-01-09 05:44:27 +08:00
end
format.json do
render_serialized(list, TopicListSerializer)
end
end
end
end