added an option to bypass auto tracking of topics on post creation

This commit is contained in:
Sam
2013-07-22 11:40:39 +10:00
parent 9e4b0df7ff
commit 31bb08bcdd
9 changed files with 31 additions and 5 deletions

View File

@ -2,6 +2,10 @@ class TopicCreator
attr_accessor :errors
def self.create(user, guardian, opts)
self.new(user, guardian, opts).create
end
def initialize(user, guardian, opts)
@user = user
@guardian = guardian
@ -17,11 +21,19 @@ class TopicCreator
process_private_message if @opts[:archetype] == Archetype.private_message
save_topic
watch_topic
@topic
end
private
def watch_topic
unless @opts[:auto_track] == false
@topic.notifier.watch_topic!(@topic.user_id)
end
end
def setup
topic_params = {title: @opts[:title], user_id: @user.id, last_post_user_id: @user.id}
topic_params[:archetype] = @opts[:archetype] if @opts[:archetype].present?