Setting custom_field only for issues created via email by patching mail_handler.rb
Added by Mitchell Fang over 6 years ago
Goal: I want to set a custom_field value only for issues created via Email
My Attempt: Patch mail_handler.rb to set custom field at custom_field_values_from_keywords. This prevented emails from even being created as tickets. Am I chaining the wrong function?
module MailHandlerPatch def self.included(base) base.send(:include, ClassMethods) base.class_eval do alias_method_chain :custom_field_values_from_keywords, :mod end end module ClassMethods def custom_field_values_from_keywords_with_mod(customized) arr = custom_field_values_from_keywords_without_mod Rails.logger.info "****** #{arr.inspect} " arr["27"] = "email" return arr end end end MailHandler.send :include, MailHandlerPatch
My Env:
Environment: Redmine version 3.4.4.stable.17206 Ruby version 2.4.3-p205 (2017-12-14) [x86_64-linux] Rails version 4.2.8 Environment production Database adapter Mysql2 OS : Ubuntu
Thanks from n00b
Replies (1)
RE: Setting custom_field only for issues created via email by patching mail_handler.rb
-
Added by Mitchell Fang over 6 years ago
Figured it out
Needed to call custom_field_values_from_keywords_without_mod as custom_field_values_from_keywords_without_mod(customized)