BigW Consortium Gitlab

users_project_observer.rb 619 Bytes
Newer Older
1
class UsersProjectObserver < BaseObserver
2
  def after_commit(users_project)
3
    return if users_project.destroyed?
4
  end
5

Alex Denisov committed
6
  def after_create(users_project)
7 8
    Event.create(
      project_id: users_project.project.id,
9
      action: Event::JOINED,
10 11
      author_id: users_project.user.id
    )
12 13 14 15 16 17

    notification.new_team_member(users_project)
  end

  def after_update(users_project)
    notification.update_team_member(users_project)
18
  end
19

20 21
  def after_destroy(users_project)
    Event.create(
randx committed
22
      project_id: users_project.project.id,
23
      action: Event::LEFT,
24 25 26
      author_id: users_project.user.id
    )
  end
27
end