summaryrefslogtreecommitdiff
path: root/app/models/concerns/subscribable.rb
diff options
context:
space:
mode:
authorAhmad Sherif <me@ahmadsherif.com>2016-05-12 22:48:09 +0200
committerAhmad Sherif <me@ahmadsherif.com>2016-05-12 22:48:09 +0200
commit0c22698bd4dbe7d0d3e4a6c8bc946ac6f5de1c12 (patch)
tree775771cbe8f3c16dedebe1f27acadd464c96099e /app/models/concerns/subscribable.rb
parent74c69709dc19dbaf56c226b5a7955f229af10f4f (diff)
downloadgitlab-ce-0c22698bd4dbe7d0d3e4a6c8bc946ac6f5de1c12.tar.gz
Add API endpoints for un/subscribing from/to a label
Closes #15638
Diffstat (limited to 'app/models/concerns/subscribable.rb')
-rw-r--r--app/models/concerns/subscribable.rb6
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).