From 6690185d800c28acc70719abaf2b24633d668b4a Mon Sep 17 00:00:00 2001 From: Alex Kalderimis Date: Tue, 20 Aug 2019 22:37:09 +0100 Subject: Explain what the arguments to add_model_headers are --- app/mailers/notify.rb | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/app/mailers/notify.rb b/app/mailers/notify.rb index 9d2deb35cd4..3683f2ea9a9 100644 --- a/app/mailers/notify.rb +++ b/app/mailers/notify.rb @@ -195,12 +195,16 @@ class Notify < BaseMailer @reply_key ||= SentNotification.reply_key end - def add_model_headers(model) + # This method applies threading headers to the email to identify + # the instance we are discussing. + # + # All model instances must have `#id`, and may implement `#iid`. + def add_model_headers(object) # Use replacement so we don't strip the module. - prefix = "X-GitLab-#{model.class.name.gsub(/::/, '-')}" + prefix = "X-GitLab-#{object.class.name.gsub(/::/, '-')}" - headers["#{prefix}-ID"] = model.id if model.respond_to?(:id) - headers["#{prefix}-IID"] = model.iid if model.respond_to?(:iid) + headers["#{prefix}-ID"] = object.id + headers["#{prefix}-IID"] = object.iid if object.respond_to?(:iid) end def add_project_headers -- cgit v1.2.1