summaryrefslogtreecommitdiff
path: root/app/models
diff options
context:
space:
mode:
authorZeger-Jan van de Weg <mail@zjvandeweg.nl>2015-12-09 11:59:25 +0100
committerZeger-Jan van de Weg <mail@zjvandeweg.nl>2016-01-09 12:41:22 +0100
commit58867eff46dc6886b85bfe5a787341f224d09421 (patch)
tree676d1b1705678080f75a17542d998afbd3172a7e /app/models
parentc81647ae8c5dc68ac8d7dd2970a53b31bc656a1d (diff)
downloadgitlab-ce-58867eff46dc6886b85bfe5a787341f224d09421.tar.gz
Unsubscribe from thread through link in email footer
Diffstat (limited to 'app/models')
-rw-r--r--app/models/concerns/issuable.rb6
-rw-r--r--app/models/sent_notification.rb8
2 files changed, 11 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..fd12615717b 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,7 +57,7 @@ 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
@@ -75,4 +73,8 @@ class SentNotification < ActiveRecord::Base
super
end
end
+
+ def to_param
+ self.reply_key
+ end
end