diff options
author | Douwe Maan <douwe@gitlab.com> | 2016-01-14 14:38:55 +0000 |
---|---|---|
committer | Douwe Maan <douwe@gitlab.com> | 2016-01-14 14:38:55 +0000 |
commit | b6ae2def2cb2b1da3ddcb3ceee556628a1147cc4 (patch) | |
tree | 8e3511314feb1261bd28fc84a3710e5501238d72 /app/models | |
parent | 33ccee239ebcac7785c1ad466c1624a43af99c90 (diff) | |
parent | be08490863b76026b8f3ffbc422cb7f5d8b4a6a4 (diff) | |
download | gitlab-ce-b6ae2def2cb2b1da3ddcb3ceee556628a1147cc4.tar.gz |
Merge branch 'unsubscribe-from-thread-from-email-footer' into 'master'
Unsubscribe from thread through link in email footer
Closes #3437
![Screenshot_from_2015-12-11_15-35-06](/uploads/cfb3d8737d4757f527995411f103d0ce/Screenshot_from_2015-12-11_15-35-06.png)
![Screenshot_from_2015-12-11_15-35-56](/uploads/9b7121be7ce4b05e5995ca6d38c5bea4/Screenshot_from_2015-12-11_15-35-56.png)
See merge request !2068
Diffstat (limited to 'app/models')
-rw-r--r-- | app/models/concerns/issuable.rb | 6 | ||||
-rw-r--r-- | app/models/sent_notification.rb | 12 |
2 files changed, 15 insertions, 3 deletions
diff --git a/app/models/concerns/issuable.rb b/app/models/concerns/issuable.rb index 18a00f95b48..04650a9e67a 100644 --- a/app/models/concerns/issuable.rb +++ b/app/models/concerns/issuable.rb @@ -119,6 +119,12 @@ module Issuable update(subscribed: !subscribed?(user)) end + def unsubscribe(user) + subscriptions. + find_or_initialize_by(user_id: user.id). + update(subscribed: false) + end + def to_hook_data(user) { object_kind: self.class.name.underscore, diff --git a/app/models/sent_notification.rb b/app/models/sent_notification.rb index f36eda1531b..77115597d71 100644 --- a/app/models/sent_notification.rb +++ b/app/models/sent_notification.rb @@ -25,8 +25,6 @@ class SentNotification < ActiveRecord::Base class << self def reply_key - return nil unless Gitlab::IncomingEmail.enabled? - SecureRandom.hex(16) end @@ -59,11 +57,15 @@ class SentNotification < ActiveRecord::Base def record_note(note, recipient_id, reply_key, params = {}) params[:line_code] = note.line_code - + record(note.noteable, recipient_id, reply_key, params) end end + def unsubscribable? + !for_commit? + end + def for_commit? noteable_type == "Commit" end @@ -75,4 +77,8 @@ class SentNotification < ActiveRecord::Base super end end + + def to_param + self.reply_key + end end |