BigW Consortium Gitlab

groups.rb 1.56 KB
Newer Older
1 2
module Emails
  module Groups
3 4 5
    def group_access_granted_email(group_member_id)
      @group_member = GroupMember.find(group_member_id)
      @group = @group_member.group
6

7
      @target_url = group_url(@group)
Douwe Maan committed
8
      @current_user = @group_member.user
9

10
      mail(to: @group_member.user.notification_email,
11
           subject: subject("Access to group was granted"))
12
    end
13 14 15 16 17

    def group_member_invited_email(group_member_id, token)
      @group_member = GroupMember.find group_member_id
      @group = @group_member.group
      @token = token
18

19
      @target_url = group_url(@group)
20
      @current_user = @group_member.user
21

22
      mail(to: @group_member.invite_email,
23
           subject: "Invitation to join group #{@group.name}")
24 25 26 27 28 29 30
    end

    def group_invite_accepted_email(group_member_id)
      @group_member = GroupMember.find group_member_id
      return if @group_member.created_by.nil?

      @group = @group_member.group
31

32
      @target_url = group_url(@group)
33
      @current_user = @group_member.created_by
34

35
      mail(to: @group_member.created_by.notification_email,
36
           subject: subject("Invitation accepted"))
37
    end
Douwe Maan committed
38 39 40 41 42

    def group_invite_declined_email(group_id, invite_email, access_level, created_by_id)
      return if created_by_id.nil?

      @group = Group.find(group_id)
43
      @current_user = @created_by = User.find(created_by_id)
Douwe Maan committed
44 45
      @access_level = access_level
      @invite_email = invite_email
46
      
Douwe Maan committed
47 48
      @target_url = group_url(@group)
      mail(to: @created_by.notification_email,
49
           subject: subject("Invitation declined"))
Douwe Maan committed
50
    end
51 52
  end
end