diff options
author | Douwe Maan <douwe@gitlab.com> | 2016-05-12 21:51:21 +0000 |
---|---|---|
committer | Douwe Maan <douwe@gitlab.com> | 2016-05-12 21:51:21 +0000 |
commit | 850234ebd2bad3f79179146abd3db81741a48434 (patch) | |
tree | 528fe9d254e4877ce88fa9c930fa521f9a26857b /app/models | |
parent | 7fc51d1908a1ce7b0a09f273881c08102efd1dae (diff) | |
parent | 0c22698bd4dbe7d0d3e4a6c8bc946ac6f5de1c12 (diff) | |
download | gitlab-ce-850234ebd2bad3f79179146abd3db81741a48434.tar.gz |
Merge branch 'feature/label-subscription-api' into 'master'
Add API endpoints for un/subscribing from/to a label
See merge request !4051
Diffstat (limited to 'app/models')
-rw-r--r-- | app/models/concerns/subscribable.rb | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/app/models/concerns/subscribable.rb b/app/models/concerns/subscribable.rb index d5a881b2445..083257f1005 100644 --- a/app/models/concerns/subscribable.rb +++ b/app/models/concerns/subscribable.rb @@ -36,6 +36,12 @@ module Subscribable update(subscribed: !subscribed?(user)) end + def subscribe(user) + subscriptions. + find_or_initialize_by(user_id: user.id). + update(subscribed: true) + end + def unsubscribe(user) subscriptions. find_or_initialize_by(user_id: user.id). |