diff options
author | Douwe Maan <douwe@gitlab.com> | 2015-04-10 16:37:02 +0200 |
---|---|---|
committer | Douwe Maan <douwe@gitlab.com> | 2015-04-14 12:08:11 +0200 |
commit | e50556fcc8d81dae5978bcb3e1dd5104789aab0f (patch) | |
tree | 000c94f5da8061efa360c0e580e77261de84e8b1 /app/models | |
parent | 8949af0c9f2aa90b979043a0a6ee264ac0c036b9 (diff) | |
download | gitlab-ce-e50556fcc8d81dae5978bcb3e1dd5104789aab0f.tar.gz |
Let invites be declined.
Diffstat (limited to 'app/models')
-rw-r--r-- | app/models/member.rb | 14 | ||||
-rw-r--r-- | app/models/members/group_member.rb | 6 | ||||
-rw-r--r-- | app/models/members/project_member.rb | 6 |
3 files changed, 26 insertions, 0 deletions
diff --git a/app/models/member.rb b/app/models/member.rb index d8cc65ca6cb..2421222eaa2 100644 --- a/app/models/member.rb +++ b/app/models/member.rb @@ -76,6 +76,16 @@ class Member < ActiveRecord::Base saved end + def decline_invite! + return false unless invite? + + destroyed = self.destroy + + after_decline_invite if destroyed + + destroyed + end + def generate_invite_token raw, enc = Devise.token_generator.generate(self.class, :invite_token) @raw_invite_token = raw @@ -116,6 +126,10 @@ class Member < ActiveRecord::Base post_create_hook end + def after_decline_invite + # override in subclass + end + def system_hook_service SystemHooksService.new end diff --git a/app/models/members/group_member.rb b/app/models/members/group_member.rb index 68b7c169f72..84c91372b3f 100644 --- a/app/models/members/group_member.rb +++ b/app/models/members/group_member.rb @@ -66,4 +66,10 @@ class GroupMember < Member super end + + def after_decline_invite + notification_service.decline_group_invite(self) + + super + end end diff --git a/app/models/members/project_member.rb b/app/models/members/project_member.rb index 3b3b1bd4680..8af7499dd82 100644 --- a/app/models/members/project_member.rb +++ b/app/models/members/project_member.rb @@ -167,6 +167,12 @@ class ProjectMember < Member super end + def after_decline_invite + notification_service.decline_project_invite(self) + + super + end + def event_service EventCreateService.new end |