Class: TopicConverter
- Inherits:
-
Object
- Object
- TopicConverter
- Defined in:
- app/models/topic_converter.rb
Instance Attribute Summary collapse
-
#topic ⇒ Object
readonly
Returns the value of attribute topic.
Instance Method Summary collapse
- #convert_to_private_message ⇒ Object
- #convert_to_public_topic(category_id = nil) ⇒ Object
-
#initialize(topic, user) ⇒ TopicConverter
constructor
A new instance of TopicConverter.
Constructor Details
#initialize(topic, user) ⇒ TopicConverter
Returns a new instance of TopicConverter.
6 7 8 9 |
# File 'app/models/topic_converter.rb', line 6 def initialize(topic, user) @topic = topic @user = user end |
Instance Attribute Details
#topic ⇒ Object (readonly)
Returns the value of attribute topic.
4 5 6 |
# File 'app/models/topic_converter.rb', line 4 def topic @topic end |
Instance Method Details
#convert_to_private_message ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'app/models/topic_converter.rb', line 41 def Topic.transaction do @topic.update_category_topic_count_by(-1) if @topic.visible PostRevisor.new(@topic.first_post, @topic).revise!( @user, category_id: nil, archetype: Archetype., ) add_allowed_users update_post_uploads_secure_status UserProfile.remove_featured_topic_from_all_profiles(@topic) Jobs.enqueue(:topic_action_converter, topic_id: @topic.id) Jobs.enqueue(:delete_inaccessible_notifications, topic_id: @topic.id) watch_topic(topic) end @topic end |
#convert_to_public_topic(category_id = nil) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'app/models/topic_converter.rb', line 11 def convert_to_public_topic(category_id = nil) Topic.transaction do category_id = if category_id category_id elsif SiteSetting.allow_uncategorized_topics SiteSetting.uncategorized_category_id else Category .where(read_restricted: false) .where.not(id: SiteSetting.uncategorized_category_id) .order("id asc") .pick(:id) end PostRevisor.new(@topic.first_post, @topic).revise!( @user, category_id: category_id, archetype: Archetype.default, ) update_user_stats update_post_uploads_secure_status Jobs.enqueue(:topic_action_converter, topic_id: @topic.id) Jobs.enqueue(:delete_inaccessible_notifications, topic_id: @topic.id) watch_topic(topic) end @topic end |