Class: Course::Forum::TopicNotifier

Inherits:
Notifier::Base
  • Object
show all
Defined in:
app/notifiers/course/forum/topic_notifier.rb

Instance Method Summary collapse

Instance Method Details

#topic_created(user, topic) ⇒ Object

To be called when user created a new forum topic.


4
5
6
7
8
9
10
11
12
13
14
# File 'app/notifiers/course/forum/topic_notifier.rb', line 4

def topic_created(user, topic)
  course = topic.forum.course
  activity = create_activity(actor: user, object: topic, event: :created)
  activity.notify(course, :feed)
  if Course::Settings::ForumsComponent.email_enabled?(course, :topic_created)
    topic.forum.subscriptions.includes(:user).each do |subscription|
      activity.notify(subscription.user, :email) unless subscription.user == user
    end
  end
  activity.save!
end