summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrett Walker <bwalker@gitlab.com>2018-12-20 11:15:31 -0600
committerBrett Walker <bwalker@gitlab.com>2019-01-03 14:37:35 -0600
commit54eb6260e75690ec45802618a7e1b9807f0e7e08 (patch)
tree5142e97fa649b9d70f50a386c6a0e3dfc8b22a11
parent2e514314031f1722db45e2440eb1c7df105218dd (diff)
downloadgitlab-ce-54eb6260e75690ec45802618a7e1b9807f0e7e08.tar.gz
Address review feedback
-rw-r--r--lib/gitlab/email/handler/base_handler.rb2
-rw-r--r--lib/gitlab/email/handler/unsubscribe_handler.rb9
2 files changed, 7 insertions, 4 deletions
diff --git a/lib/gitlab/email/handler/base_handler.rb b/lib/gitlab/email/handler/base_handler.rb
index 35bb49ad19a..3f34a7e1d38 100644
--- a/lib/gitlab/email/handler/base_handler.rb
+++ b/lib/gitlab/email/handler/base_handler.rb
@@ -11,7 +11,7 @@ module Gitlab
@mail_key = mail_key
end
- def can_execute?
+ def can_handle?
raise NotImplementedError
end
diff --git a/lib/gitlab/email/handler/unsubscribe_handler.rb b/lib/gitlab/email/handler/unsubscribe_handler.rb
index 0155d7bd113..7589658d2fe 100644
--- a/lib/gitlab/email/handler/unsubscribe_handler.rb
+++ b/lib/gitlab/email/handler/unsubscribe_handler.rb
@@ -11,8 +11,9 @@ module Gitlab
class UnsubscribeHandler < BaseHandler
delegate :project, to: :sent_notification, allow_nil: true
- HANDLER_REGEX = /\A(?<reply_token>\w+)#{Gitlab::IncomingEmail::UNSUBSCRIBE_SUFFIX}\z/.freeze
- HANDLER_REGEX_LEGACY = /\A(?<reply_token>\w+)#{Regexp.escape(Gitlab::IncomingEmail::UNSUBSCRIBE_SUFFIX_LEGACY)}\z/.freeze
+ HANDLER_REGEX_FOR = -> (suffix) { /\A(?<reply_token>\w+)#{Regexp.escape(suffix)}\z/ }.freeze
+ HANDLER_REGEX = HANDLER_REGEX_FOR.call(Gitlab::IncomingEmail::UNSUBSCRIBE_SUFFIX).freeze
+ HANDLER_REGEX_LEGACY = HANDLER_REGEX_FOR.call(Gitlab::IncomingEmail::UNSUBSCRIBE_SUFFIX_LEGACY).freeze
def initialize(mail, mail_key)
super(mail, mail_key)
@@ -37,8 +38,10 @@ module Gitlab
private
+ attr_reader :reply_token
+
def sent_notification
- @sent_notification ||= SentNotification.for(@reply_token)
+ @sent_notification ||= SentNotification.for(reply_token)
end
end
end