Class: Course::Forum::PostNotifier

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

Instance Method Summary collapse

Instance Method Details

#post_replied(user, post) ⇒ Object

To be called when user replied a forum post.


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

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