BigW Consortium Gitlab

users_project_observer.rb 552 Bytes
Newer Older
1
class UsersProjectObserver < ActiveRecord::Observer
2
  def after_commit(users_project)
3
    return if users_project.destroyed?
4
    Notify.delay.project_access_granted_email(users_project.id)
5
  end
6

Alex Denisov committed
7
  def after_create(users_project)
8 9 10 11 12
    Event.create(
      project_id: users_project.project.id,
      action: Event::Joined,
      author_id: users_project.user.id
    )
13
  end
14

15 16
  def after_destroy(users_project)
    Event.create(
randx committed
17 18
      project_id: users_project.project.id,
      action: Event::Left,
19 20 21
      author_id: users_project.user.id
    )
  end
22
end