Maintenance: Added Zammad/NoToSymOnString cop to prevent .to_sym on Strings.

This commit is contained in:
Thorsten Eckel 2020-08-21 10:18:31 +02:00
parent 0918e4f53a
commit de22f60826
27 changed files with 216 additions and 175 deletions

View file

@ -0,0 +1,40 @@
module RuboCop
module Cop
module Zammad
# This cop is used to identify usages of `.to_sym` on Strings and
# changes them to use the `:` prefix instead.
#
# @example
# # bad
# "a-Symbol".to_sym
# 'a-Symbol'.to_sym
# "a-#{'Symbol'}".to_sym
#
# # good
# :"a-Symbol"
# :'a-Symbol'
# :"a-#{'Symbol'}"
class NoToSymOnString < Base
extend AutoCorrector
def_node_matcher :to_sym?, <<-PATTERN
{
$(send (str ...) :to_sym ...)
$(send (dstr ...) :to_sym ...)
}
PATTERN
MSG = "Don't use `.to_sym` on String. Prefer `:` prefix instead.".freeze
def on_send(node)
result = *to_sym?(node)
return if result.empty?
add_offense(node, message: MSG) do |corrector|
corrector.replace(node, ":#{result.first.source}")
end
end
end
end
end
end

View file

@ -1,2 +1,3 @@
require_relative 'cop/zammad/exists_condition'
require_relative 'cop/zammad/no_to_sym_on_string'
require_relative 'cop/zammad/prefer_negated_if_over_unless'

View file

@ -158,7 +158,7 @@ returns
end
# check ignore header
if mail['x-zammad-ignore'.to_sym] == 'true' || mail['x-zammad-ignore'.to_sym] == true
if mail[:'x-zammad-ignore'] == 'true' || mail[:'x-zammad-ignore'] == true
Rails.logger.info "ignored email with msgid '#{mail[:message_id]}' from '#{mail[:from]}' because of x-zammad-ignore header"
return
end
@ -174,7 +174,7 @@ returns
Transaction.execute(interface_handle: "#{original_interface_handle}.postmaster") do
# get sender user
session_user_id = mail['x-zammad-session-user-id'.to_sym]
session_user_id = mail[:'x-zammad-session-user-id']
if !session_user_id
raise 'No x-zammad-session-user-id, no sender set!'
end
@ -188,11 +188,11 @@ returns
UserInfo.current_user_id = session_user.id
# get ticket# based on email headers
if mail['x-zammad-ticket-id'.to_sym]
ticket = Ticket.find_by(id: mail['x-zammad-ticket-id'.to_sym])
if mail[:'x-zammad-ticket-id']
ticket = Ticket.find_by(id: mail[:'x-zammad-ticket-id'])
end
if mail['x-zammad-ticket-number'.to_sym]
ticket = Ticket.find_by(number: mail['x-zammad-ticket-number'.to_sym])
if mail[:'x-zammad-ticket-number']
ticket = Ticket.find_by(number: mail[:'x-zammad-ticket-number'])
end
# set ticket state to open if not new
@ -203,9 +203,9 @@ returns
ticket.save! if ticket.has_changes_to_save?
# set ticket to open again or keep create state
if !mail['x-zammad-ticket-followup-state'.to_sym] && !mail['x-zammad-ticket-followup-state_id'.to_sym]
if !mail[:'x-zammad-ticket-followup-state'] && !mail[:'x-zammad-ticket-followup-state_id']
new_state = Ticket::State.find_by(default_create: true)
if ticket.state_id != new_state.id && !mail['x-zammad-out-of-office'.to_sym]
if ticket.state_id != new_state.id && !mail[:'x-zammad-out-of-office']
ticket.state = Ticket::State.find_by(default_follow_up: true)
ticket.save!
end
@ -250,8 +250,8 @@ returns
end
# apply tags to ticket
if mail['x-zammad-ticket-tags'.to_sym].present?
mail['x-zammad-ticket-tags'.to_sym].each do |tag|
if mail[:'x-zammad-ticket-tags'].present?
mail[:'x-zammad-ticket-tags'].each do |tag|
ticket.tag_add(tag)
end
end

View file

@ -5,34 +5,34 @@ module Channel::Filter::AutoResponseCheck
def self.run(_channel, mail)
# if header is available, do not generate auto response
mail[ 'x-zammad-send-auto-response'.to_sym ] = false
mail[ 'x-zammad-is-auto-response'.to_sym ] = true
mail[ :'x-zammad-send-auto-response' ] = false
mail[ :'x-zammad-is-auto-response' ] = true
if !mail[ 'x-zammad-article-preferences'.to_sym ]
mail[ 'x-zammad-article-preferences'.to_sym ] = {}
if !mail[ :'x-zammad-article-preferences' ]
mail[ :'x-zammad-article-preferences' ] = {}
end
mail[ 'x-zammad-article-preferences'.to_sym ]['send-auto-response'] = false
mail[ 'x-zammad-article-preferences'.to_sym ]['is-auto-response'] = true
mail[ :'x-zammad-article-preferences' ]['send-auto-response'] = false
mail[ :'x-zammad-article-preferences' ]['is-auto-response'] = true
# do not send an auto response if one of the following headers exists
return if mail[ 'list-unsubscribe'.to_sym ] && mail[ 'list-unsubscribe'.to_sym ] =~ /.../
return if mail[ 'x-loop'.to_sym ] && mail[ 'x-loop'.to_sym ] =~ /(yes|true)/i
return if mail[ 'precedence'.to_sym ] && mail[ 'precedence'.to_sym ] =~ /(bulk|list|junk)/i
return if mail[ 'auto-submitted'.to_sym ] && mail[ 'auto-submitted'.to_sym ] =~ /auto-(generated|replied)/i
return if mail[ 'x-auto-response-suppress'.to_sym ] && mail[ 'x-auto-response-suppress'.to_sym ] =~ /all/i
return if mail[ :'list-unsubscribe' ] && mail[ :'list-unsubscribe' ] =~ /.../
return if mail[ :'x-loop' ] && mail[ :'x-loop' ] =~ /(yes|true)/i
return if mail[ :precedence ] && mail[ :precedence ] =~ /(bulk|list|junk)/i
return if mail[ :'auto-submitted' ] && mail[ :'auto-submitted' ] =~ /auto-(generated|replied)/i
return if mail[ :'x-auto-response-suppress' ] && mail[ :'x-auto-response-suppress' ] =~ /all/i
# do not send an auto response if sender is system itself
message_id = mail[ 'message_id'.to_sym ]
message_id = mail[ :message_id ]
if message_id
fqdn = Setting.get('fqdn')
return if message_id.match?(/@#{Regexp.quote(fqdn)}/i)
end
mail[ 'x-zammad-send-auto-response'.to_sym ] = true
mail[ 'x-zammad-is-auto-response'.to_sym ] = false
mail[ :'x-zammad-send-auto-response' ] = true
mail[ :'x-zammad-is-auto-response' ] = false
mail[ 'x-zammad-article-preferences'.to_sym ]['send-auto-response'] = true
mail[ 'x-zammad-article-preferences'.to_sym ]['is-auto-response'] = false
mail[ :'x-zammad-article-preferences' ]['send-auto-response'] = true
mail[ :'x-zammad-article-preferences' ]['is-auto-response'] = false
end
end

View file

@ -10,7 +10,7 @@ module Channel::Filter::BounceDeliveryTemporaryFailed
return if mail[:mail_instance].error_status != '4.4.1'
# if header is available, do change current ticket state
mail['x-zammad-out-of-office'.to_sym] = true
mail[:'x-zammad-out-of-office'] = true
true
end

View file

@ -7,7 +7,7 @@ module Channel::Filter::BounceFollowUpCheck
return if !mail[:mail_instance]
return if !mail[:mail_instance].bounced?
return if !mail[:attachments]
return if mail[ 'x-zammad-ticket-id'.to_sym ]
return if mail[ :'x-zammad-ticket-id' ]
mail[:attachments].each do |attachment|
next if !attachment[:preferences]
@ -22,8 +22,8 @@ module Channel::Filter::BounceFollowUpCheck
next if !article
Rails.logger.debug { "Follow-up for '##{article.ticket.number}' in bounce email." }
mail[ 'x-zammad-ticket-id'.to_sym ] = article.ticket_id
mail[ 'x-zammad-is-auto-response'.to_sym ] = true
mail[ :'x-zammad-ticket-id' ] = article.ticket_id
mail[ :'x-zammad-is-auto-response' ] = true
return true
end

View file

@ -4,13 +4,13 @@ module Channel::Filter::FollowUpCheck
def self.run(_channel, mail)
return if mail['x-zammad-ticket-id'.to_sym]
return if mail[:'x-zammad-ticket-id']
# get ticket# from subject
ticket = Ticket::Number.check(mail[:subject])
if ticket
Rails.logger.debug { "Follow-up for '##{ticket.number}' in subject." }
mail['x-zammad-ticket-id'.to_sym] = ticket.id
mail[:'x-zammad-ticket-id'] = ticket.id
return true
end
@ -21,7 +21,7 @@ module Channel::Filter::FollowUpCheck
ticket = Ticket::Number.check(mail[:body].html2text)
if ticket
Rails.logger.debug { "Follow-up for '##{ticket.number}' in body." }
mail['x-zammad-ticket-id'.to_sym] = ticket.id
mail[:'x-zammad-ticket-id'] = ticket.id
return true
end
end
@ -49,24 +49,24 @@ module Channel::Filter::FollowUpCheck
next if !ticket
Rails.logger.debug { "Follow-up for '##{ticket.number}' in attachment." }
mail['x-zammad-ticket-id'.to_sym] = ticket.id
mail[:'x-zammad-ticket-id'] = ticket.id
return true
end
end
# get ticket# from references
if setting.include?('references') || (mail['x-zammad-is-auto-response'.to_sym] == true || Setting.get('ticket_hook_position') == 'none')
if setting.include?('references') || (mail[:'x-zammad-is-auto-response'] == true || Setting.get('ticket_hook_position') == 'none')
# get all references 'References' + 'In-Reply-To'
references = ''
if mail[:references]
references += mail[:references]
end
if mail['in-reply-to'.to_sym]
if mail[:'in-reply-to']
if references != ''
references += ' '
end
references += mail['in-reply-to'.to_sym]
references += mail[:'in-reply-to']
end
if references != ''
message_ids = references.split(/\s+/)
@ -76,7 +76,7 @@ module Channel::Filter::FollowUpCheck
next if !article
Rails.logger.debug { "Follow-up for '##{article.ticket.number}' in references." }
mail['x-zammad-ticket-id'.to_sym] = article.ticket_id
mail[:'x-zammad-ticket-id'] = article.ticket_id
return true
end
end
@ -90,11 +90,11 @@ module Channel::Filter::FollowUpCheck
if mail[:references]
references += mail[:references]
end
if mail['in-reply-to'.to_sym]
if mail[:'in-reply-to']
if references != ''
references += ' '
end
references += mail['in-reply-to'.to_sym]
references += mail[:'in-reply-to']
end
if references != ''
message_ids = references.split(/\s+/)
@ -117,7 +117,7 @@ module Channel::Filter::FollowUpCheck
next if subject_to_check != article_first.subject
Rails.logger.debug { "Follow-up for '##{article.ticket.number}' in references with same subject as inital article." }
mail['x-zammad-ticket-id'.to_sym] = article_first.ticket_id
mail[:'x-zammad-ticket-id'] = article_first.ticket_id
return true
end
end

View file

@ -3,7 +3,7 @@
module Channel::Filter::FollowUpPossibleCheck
def self.run(_channel, mail)
ticket_id = mail['x-zammad-ticket-id'.to_sym]
ticket_id = mail[:'x-zammad-ticket-id']
return true if !ticket_id
ticket = Ticket.lookup(id: ticket_id)
@ -13,9 +13,9 @@ module Channel::Filter::FollowUpPossibleCheck
# in case of closed tickets, remove follow-up information
case ticket.group.follow_up_possible
when 'new_ticket'
mail[:subject] = ticket.subject_clean(mail[:subject])
mail['x-zammad-ticket-id'.to_sym] = nil
mail['x-zammad-ticket-number'.to_sym] = nil
mail[:subject] = ticket.subject_clean(mail[:subject])
mail[:'x-zammad-ticket-id'] = nil
mail[:'x-zammad-ticket-number'] = nil
end
true

View file

@ -4,7 +4,7 @@ module Channel::Filter::IdentifySender
def self.run(_channel, mail)
customer_user_id = mail[ 'x-zammad-ticket-customer_id'.to_sym ]
customer_user_id = mail[ :'x-zammad-ticket-customer_id' ]
customer_user = nil
if customer_user_id.present?
customer_user = User.lookup(id: customer_user_id)
@ -16,20 +16,20 @@ module Channel::Filter::IdentifySender
end
# check if sender exists in database
if !customer_user && mail[ 'x-zammad-customer-login'.to_sym ].present?
customer_user = User.find_by(login: mail[ 'x-zammad-customer-login'.to_sym ])
if !customer_user && mail[ :'x-zammad-customer-login' ].present?
customer_user = User.find_by(login: mail[ :'x-zammad-customer-login' ])
end
if !customer_user && mail[ 'x-zammad-customer-email'.to_sym ].present?
customer_user = User.find_by(email: mail[ 'x-zammad-customer-email'.to_sym ])
if !customer_user && mail[ :'x-zammad-customer-email' ].present?
customer_user = User.find_by(email: mail[ :'x-zammad-customer-email' ])
end
# get correct customer
if !customer_user && Setting.get('postmaster_sender_is_agent_search_for_customer') == true
if mail[ 'x-zammad-ticket-create-article-sender'.to_sym ] == 'Agent'
if mail[ :'x-zammad-ticket-create-article-sender' ] == 'Agent'
# get first recipient and set customer
begin
to = 'raw-to'.to_sym
to = :'raw-to'
if mail[to]&.addrs
items = mail[to].addrs
items.each do |item|
@ -54,18 +54,18 @@ module Channel::Filter::IdentifySender
# take regular from as customer
if !customer_user
customer_user = user_create(
login: mail[ 'x-zammad-customer-login'.to_sym ] || mail[ 'x-zammad-customer-email'.to_sym ] || mail[:from_email],
firstname: mail[ 'x-zammad-customer-firstname'.to_sym ] || mail[:from_display_name],
lastname: mail[ 'x-zammad-customer-lastname'.to_sym ],
email: mail[ 'x-zammad-customer-email'.to_sym ] || mail[:from_email],
login: mail[ :'x-zammad-customer-login' ] || mail[ :'x-zammad-customer-email' ] || mail[:from_email],
firstname: mail[ :'x-zammad-customer-firstname' ] || mail[:from_display_name],
lastname: mail[ :'x-zammad-customer-lastname' ],
email: mail[ :'x-zammad-customer-email' ] || mail[:from_email],
)
end
create_recipients(mail)
mail[ 'x-zammad-ticket-customer_id'.to_sym ] = customer_user.id
mail[ :'x-zammad-ticket-customer_id' ] = customer_user.id
# find session user
session_user_id = mail[ 'x-zammad-session-user-id'.to_sym ]
session_user_id = mail[ :'x-zammad-session-user-id' ]
session_user = nil
if session_user_id.present?
session_user = User.lookup(id: session_user_id)
@ -84,7 +84,7 @@ module Channel::Filter::IdentifySender
)
end
if session_user
mail[ 'x-zammad-session-user-id'.to_sym ] = session_user.id
mail[ :'x-zammad-session-user-id' ] = session_user.id
end
true

View file

@ -24,7 +24,7 @@ class Channel::Filter::MonitoringBase
return if mail[:from].blank?
return if mail[:body].blank?
session_user_id = mail[ 'x-zammad-session-user-id'.to_sym ]
session_user_id = mail[ :'x-zammad-session-user-id' ]
return if !session_user_id
# check if sender is monitoring
@ -94,40 +94,40 @@ class Channel::Filter::MonitoringBase
next if ticket.preferences[integration]['service'] != result['service']
# found open ticket for service+host
mail[ 'x-zammad-ticket-id'.to_sym ] = ticket.id
mail[ :'x-zammad-ticket-id' ] = ticket.id
# check if service is recovered
if auto_close && result['state'].present? && result['state'].match(/#{state_recovery_match}/i)
Rails.logger.info "MonitoringBase.#{integration} set autoclose to state_id #{auto_close_state_id}"
state = Ticket::State.lookup(id: auto_close_state_id)
if state
mail[ 'x-zammad-ticket-followup-state'.to_sym ] = state.name
mail[ :'x-zammad-ticket-followup-state' ] = state.name
end
end
return true
end
# new ticket, set meta data
if !mail[ 'x-zammad-ticket-id'.to_sym ]
if !mail[ 'x-zammad-ticket-preferences'.to_sym ]
mail[ 'x-zammad-ticket-preferences'.to_sym ] = {}
if !mail[ :'x-zammad-ticket-id' ]
if !mail[ :'x-zammad-ticket-preferences' ]
mail[ :'x-zammad-ticket-preferences' ] = {}
end
preferences = {}
preferences[integration] = result
preferences.each do |key, value|
mail[ 'x-zammad-ticket-preferences'.to_sym ][key] = value
mail[ :'x-zammad-ticket-preferences' ][key] = value
end
end
# ignore states
if state_ignore_match.present? && result['state'].present? && result['state'].match(/#{state_ignore_match}/i)
mail[ 'x-zammad-ignore'.to_sym ] = true
mail[ :'x-zammad-ignore' ] = true
return true
end
# if now problem exists, just ignore the email
if result['state'].present? && result['state'].match(/#{state_recovery_match}/i)
mail[ 'x-zammad-ignore'.to_sym ] = true
mail[ :'x-zammad-ignore' ] = true
return true
end

View file

@ -4,32 +4,32 @@ module Channel::Filter::OutOfOfficeCheck
def self.run(_channel, mail)
mail[ 'x-zammad-out-of-office'.to_sym ] = false
mail[ :'x-zammad-out-of-office' ] = false
# check ms out of office characteristics
if mail[ 'x-auto-response-suppress'.to_sym ]
return if !mail[ 'x-auto-response-suppress'.to_sym ].match?(/all/i)
return if !mail[ 'x-ms-exchange-inbox-rules-loop'.to_sym ]
if mail[ :'x-auto-response-suppress' ]
return if !mail[ :'x-auto-response-suppress' ].match?(/all/i)
return if !mail[ :'x-ms-exchange-inbox-rules-loop' ]
mail[ 'x-zammad-out-of-office'.to_sym ] = true
mail[ :'x-zammad-out-of-office' ] = true
return
end
if mail[ 'auto-submitted'.to_sym ]
if mail[ :'auto-submitted' ]
# check zimbra out of office characteristics
if mail[ 'auto-submitted'.to_sym ].match?(/vacation/i)
mail[ 'x-zammad-out-of-office'.to_sym ] = true
if mail[ :'auto-submitted' ].match?(/vacation/i)
mail[ :'x-zammad-out-of-office' ] = true
end
# check cloud out of office characteristics
if mail[ 'auto-submitted'.to_sym ].match?(/auto-replied;\sowner-email=/i)
mail[ 'x-zammad-out-of-office'.to_sym ] = true
if mail[ :'auto-submitted' ].match?(/auto-replied;\sowner-email=/i)
mail[ :'x-zammad-out-of-office' ] = true
end
# gmail check out of office characteristics
if mail[ 'auto-submitted'.to_sym ] =~ /auto-replied/i && mail[ 'subject'.to_sym ] =~ /vacation/i
mail[ 'x-zammad-out-of-office'.to_sym ] = true
if mail[ :'auto-submitted' ] =~ /auto-replied/i && mail[ :subject ] =~ /vacation/i
mail[ :'x-zammad-out-of-office' ] = true
end
return

View file

@ -4,17 +4,17 @@ module Channel::Filter::OwnNotificationLoopDetection
def self.run(_channel, mail)
message_id = mail['message-id'.to_sym]
message_id = mail[:'message-id']
return if !message_id
recedence = mail['precedence'.to_sym]
recedence = mail[:precedence]
return if !recedence
return if !recedence.match?(/bulk/i)
fqdn = Setting.get('fqdn')
return if !message_id.match?(/@#{Regexp.quote(fqdn)}>/i)
mail[ 'x-zammad-ignore'.to_sym ] = true
mail[ :'x-zammad-ignore' ] = true
Rails.logger.info "Detected own sent notification mail and dropped it to prevent loops (message_id: #{message_id}, from: #{mail[:from]}, to: #{mail[:to]})"
end

View file

@ -4,19 +4,19 @@ module Channel::Filter::ReplyToBasedSender
def self.run(_channel, mail)
reply_to = mail['reply-to'.to_sym]
reply_to = mail[:'reply-to']
return if reply_to.blank?
setting = Setting.get('postmaster_sender_based_on_reply_to')
return if setting.blank?
# remember original sender
mail['raw-origin_from'.to_sym] = mail['raw-from'.to_sym]
mail['origin_from'.to_sym] = mail[:from]
mail['origin_from_email'.to_sym] = mail[:from_email]
mail['origin_from_local'.to_sym] = mail[:from_local]
mail['origin_from_domain'.to_sym] = mail[:from_domain]
mail['origin_from_display_name'.to_sym] = mail[:from_display_name]
mail[:'raw-origin_from'] = mail[:'raw-from']
mail[:origin_from] = mail[:from]
mail[:origin_from_email] = mail[:from_email]
mail[:origin_from_local] = mail[:from_local]
mail[:origin_from_domain] = mail[:from_domain]
mail[:origin_from_display_name] = mail[:from_display_name]
# get properties of reply-to header
result = Channel::EmailParser.sender_attributes(reply_to)
@ -24,7 +24,7 @@ module Channel::Filter::ReplyToBasedSender
if setting == 'as_sender_of_email'
# set new sender
mail['raw-from'.to_sym] = mail['raw-reply-to'.to_sym]
mail[:'raw-from'] = mail[:'raw-reply-to']
mail[:from] = reply_to
mail[:from_email] = result[:from_email]
mail[:from_local] = result[:from_local]
@ -36,11 +36,11 @@ module Channel::Filter::ReplyToBasedSender
if setting == 'as_sender_of_email_use_from_realname'
# set new sender
mail['raw-from'.to_sym] = mail['raw-reply-to'.to_sym]
mail[:from] = reply_to
mail[:from_email] = result[:from_email]
mail[:from_local] = result[:from_local]
mail[:from_domain] = result[:from_domain]
mail[:'raw-from'] = mail[:'raw-reply-to']
mail[:from] = reply_to
mail[:from_email] = result[:from_email]
mail[:from_local] = result[:from_local]
mail[:from_domain] = result[:from_domain]
return
end

View file

@ -5,11 +5,11 @@ module Channel::Filter::SenderIsSystemAddress
def self.run(_channel, mail)
# if attributes already set by header
return if mail['x-zammad-ticket-create-article-sender'.to_sym]
return if mail['x-zammad-article-sender'.to_sym]
return if mail[:'x-zammad-ticket-create-article-sender']
return if mail[:'x-zammad-article-sender']
# check if sender address is system
form = 'raw-from'.to_sym
form = :'raw-from'
return if mail[form].blank?
return if mail[:to].blank?
@ -21,8 +21,8 @@ module Channel::Filter::SenderIsSystemAddress
items.each do |item|
next if !EmailAddress.exists?(email: item.address.downcase)
mail['x-zammad-ticket-create-article-sender'.to_sym] = 'Agent'
mail['x-zammad-article-sender'.to_sym] = 'Agent'
mail[:'x-zammad-ticket-create-article-sender'] = 'Agent'
mail[:'x-zammad-article-sender'] = 'Agent'
return true
end
rescue => e
@ -37,18 +37,18 @@ module Channel::Filter::SenderIsSystemAddress
return if !user
return if !user.permissions?('ticket.agent')
mail['x-zammad-ticket-create-article-sender'.to_sym] = 'Agent'
mail['x-zammad-article-sender'.to_sym] = 'Agent'
mail[:'x-zammad-ticket-create-article-sender'] = 'Agent'
mail[:'x-zammad-article-sender'] = 'Agent'
# if the agent is also customer of the ticket then
# we need to set the sender as customer.
ticket_id = mail['x-zammad-ticket-id'.to_sym]
ticket_id = mail[:'x-zammad-ticket-id']
if ticket_id.present?
ticket = Ticket.lookup(id: ticket_id)
if ticket.present? && ticket.customer_id == user.id
mail['x-zammad-ticket-create-article-sender'.to_sym] = 'Customer'
mail['x-zammad-article-sender'.to_sym] = 'Customer'
mail[:'x-zammad-ticket-create-article-sender'] = 'Customer'
mail[:'x-zammad-article-sender'] = 'Customer'
end
end
return true

View file

@ -80,6 +80,6 @@ returns:
)
return if sync_entry.blank?
mail[ 'x-zammad-ticket-id'.to_sym ] = sync_entry.o_id
mail[ :'x-zammad-ticket-id' ] = sync_entry.o_id
end
end

View file

@ -32,7 +32,7 @@ module CanBePublished
after_touch :update_active_publicly
%i[archived published internal].each do |scope_name|
local = "#{scope_name}_by".to_sym
local = :"#{scope_name}_by"
remote = inverse_relation_name(scope_name).to_sym
belongs_to local, class_name: 'User', inverse_of: remote, optional: true

View file

@ -19,7 +19,7 @@ module ChecksHtmlSanitized
next if value.blank?
next if !sanitizeable?(attribute, value)
send("#{attribute}=".to_sym, HtmlSanitizer.strict(value))
send(:"#{attribute}=", HtmlSanitizer.strict(value))
end
true
end

View file

@ -19,7 +19,7 @@ module HasAgentAllowedParams
return [] if !const_defined?(:AGENT_ALLOWED_NESTED_RELATIONS)
const_get(:AGENT_ALLOWED_NESTED_RELATIONS).map do |relation_identifier|
key = "#{relation_identifier}_attributes".to_sym
key = :"#{relation_identifier}_attributes"
value = reflect_on_association(relation_identifier).klass.agent_allowed_params
if reflect_on_association(relation_identifier).is_a? ActiveRecord::Reflection::HasManyReflection

View file

@ -59,7 +59,7 @@ module HasGroupRelationDefinition
end
def ref_key
@ref_key ||= "#{group_relation_model_identifier}_id".to_sym
@ref_key ||= :"#{group_relation_model_identifier}_id"
end
end
end

View file

@ -355,7 +355,7 @@ module HasGroups
#
# @return [Symbol] The relation identifier
def group_through_identifier
"#{name.downcase}_groups".to_sym
:"#{name.downcase}_groups"
end
def ensure_group_id_parameter(group_or_id)

View file

@ -87,7 +87,7 @@ module Import
result_key = if %i[text id].include?(key) && ( !result[result_key] || result[result_key] == value )
prefix
else
"#{prefix}.#{key}".to_sym
:"#{prefix}.#{key}"
end
end
result_key = result_key.to_s.downcase

View file

@ -35,7 +35,7 @@ class SecureMailing::SMIME::Incoming < SecureMailing::Backend::Handler
def article_preferences
@article_preferences ||= begin
key = 'x-zammad-article-preferences'.to_sym
key = :'x-zammad-article-preferences'
@mail[ key ] ||= {}
@mail[ key ]
end

View file

@ -23,7 +23,7 @@ class Sequencer
end
def indirect_map(channel)
method_name = "remote_name_#{channel}".to_sym
method_name = :"remote_name_#{channel}"
send(method_name) if respond_to?(method_name, true)
end

View file

@ -7,7 +7,7 @@ class Sequencer
module ClassMethods
def resource_map
"#{resource_klass.underscore}_map".to_sym
:"#{resource_klass.underscore}_map"
end
def inherited(base)

View file

@ -14,6 +14,6 @@ RSpec.configure do |config|
# set custom Zammad driver (e.g. zammad_chrome) for special
# functionalities and CI requirements
driven_by("zammad_#{ENV.fetch('BROWSER', 'firefox')}".to_sym)
driven_by(:"zammad_#{ENV.fetch('BROWSER', 'firefox')}")
end
end

View file

@ -57,7 +57,7 @@ Subject: some new subject
Some Text"
_ticket_p, article_p, _user_p, mail = Channel::EmailParser.new.process({}, email_raw_string)
assert_equal(true, mail['x-zammad-send-auto-response'.to_sym])
assert_equal(true, mail[:'x-zammad-send-auto-response'])
Scheduler.worker(true)
assert_equal(2, article_p.ticket.articles.count)
@ -69,7 +69,7 @@ X-Loop: yes
Some Text"
_ticket_p, article_p, _user_p, mail = Channel::EmailParser.new.process({}, email_raw_string)
assert_equal(false, mail['x-zammad-send-auto-response'.to_sym])
assert_equal(false, mail[:'x-zammad-send-auto-response'])
Scheduler.worker(true)
assert_equal(1, article_p.ticket.articles.count)
@ -81,7 +81,7 @@ Precedence: Bulk
Some Text"
_ticket_p, article_p, _user_p, mail = Channel::EmailParser.new.process({}, email_raw_string)
assert_equal(false, mail['x-zammad-send-auto-response'.to_sym])
assert_equal(false, mail[:'x-zammad-send-auto-response'])
email_raw_string = "From: me@example.com
To: customer@example.com
@ -93,7 +93,7 @@ Some Text"
assert_equal(1, article_p.ticket.articles.count)
_ticket_p, _article_p, _user_p, mail = Channel::EmailParser.new.process({}, email_raw_string)
assert_equal(false, mail['x-zammad-send-auto-response'.to_sym])
assert_equal(false, mail[:'x-zammad-send-auto-response'])
email_raw_string = "From: me@example.com
To: customer@example.com
@ -104,7 +104,7 @@ X-Auto-Response-Suppress: All
Some Text"
_ticket_p, article_p, _user_p, mail = Channel::EmailParser.new.process({}, email_raw_string)
assert_equal(false, mail['x-zammad-send-auto-response'.to_sym])
assert_equal(false, mail[:'x-zammad-send-auto-response'])
Scheduler.worker(true)
assert_equal(1, article_p.ticket.articles.count)
@ -117,7 +117,7 @@ Message-ID: <1234@#{fqdn}>
Some Text"
_ticket_p, article_p, _user_p, mail = Channel::EmailParser.new.process({}, email_raw_string)
assert_equal(false, mail['x-zammad-send-auto-response'.to_sym])
assert_equal(false, mail[:'x-zammad-send-auto-response'])
Scheduler.worker(true)
assert_equal(1, article_p.ticket.articles.count)
@ -130,7 +130,7 @@ Message-ID: <1234@not_matching.#{fqdn}>
Some Text"
_ticket_p, article_p, _user_p, mail = Channel::EmailParser.new.process({}, email_raw_string)
assert_equal(true, mail['x-zammad-send-auto-response'.to_sym])
assert_equal(true, mail[:'x-zammad-send-auto-response'])
Scheduler.worker(true)
assert_equal(2, article_p.ticket.articles.count)
@ -180,7 +180,7 @@ Content-Disposition: inline
test"
_ticket_p, article_p, _user_p, mail = Channel::EmailParser.new.process({}, email_raw_string)
assert_equal(false, mail['x-zammad-send-auto-response'.to_sym])
assert_equal(false, mail[:'x-zammad-send-auto-response'])
Scheduler.worker(true)
assert_equal(1, article_p.ticket.articles.count)
@ -221,7 +221,7 @@ X-Loop: yes
Some Text"
ticket_p, article_p, _user_p, mail = Channel::EmailParser.new.process({}, email_raw_string)
assert_equal(false, mail['x-zammad-send-auto-response'.to_sym])
assert_equal(false, mail[:'x-zammad-send-auto-response'])
Scheduler.worker(true)
tags = ticket_p.tag_list
@ -247,7 +247,7 @@ Some Text"
Setting.set('ticket_trigger_recursive', true)
ticket_p, article_p, _user_p, mail = Channel::EmailParser.new.process({}, email_raw_string)
assert_equal(false, mail['x-zammad-send-auto-response'.to_sym])
assert_equal(false, mail[:'x-zammad-send-auto-response'])
Scheduler.worker(true)
tags = ticket_p.tag_list
@ -279,7 +279,7 @@ Subject: some new subject
Some Text"
ticket_p, article_p, _user_p, mail = Channel::EmailParser.new.process({}, email_raw_string)
assert_equal(true, mail['x-zammad-send-auto-response'.to_sym])
assert_equal(true, mail[:'x-zammad-send-auto-response'])
Scheduler.worker(true)
tags = ticket_p.tag_list
@ -310,7 +310,7 @@ Some Text"
Setting.set('ticket_trigger_recursive', true)
ticket_p, article_p, _user_p, mail = Channel::EmailParser.new.process({}, email_raw_string)
assert_equal(true, mail['x-zammad-send-auto-response'.to_sym])
assert_equal(true, mail[:'x-zammad-send-auto-response'])
Scheduler.worker(true)
tags = ticket_p.tag_list
assert_equal('new', ticket_p.state.name)
@ -394,7 +394,7 @@ Subject: some new subject
Some Text"
_ticket_p, article_p, _user_p, mail = Channel::EmailParser.new.process({}, email_raw_string)
assert_equal(true, mail['x-zammad-send-auto-response'.to_sym])
assert_equal(true, mail[:'x-zammad-send-auto-response'])
Scheduler.worker(true)
assert_equal(2, article_p.ticket.articles.count)
@ -406,7 +406,7 @@ X-Loop: yes
Some Text"
_ticket_p, article_p, _user_p, mail = Channel::EmailParser.new.process({}, email_raw_string)
assert_equal(false, mail['x-zammad-send-auto-response'.to_sym])
assert_equal(false, mail[:'x-zammad-send-auto-response'])
Scheduler.worker(true)
assert_equal(1, article_p.ticket.articles.count)
@ -418,7 +418,7 @@ Precedence: Bulk
Some Text"
_ticket_p, article_p, _user_p, mail = Channel::EmailParser.new.process({}, email_raw_string)
assert_equal(false, mail['x-zammad-send-auto-response'.to_sym])
assert_equal(false, mail[:'x-zammad-send-auto-response'])
email_raw_string = "From: me@example.com
To: customer@example.com
@ -430,7 +430,7 @@ Some Text"
assert_equal(1, article_p.ticket.articles.count)
_ticket_p, _article_p, _user_p, mail = Channel::EmailParser.new.process({}, email_raw_string)
assert_equal(false, mail['x-zammad-send-auto-response'.to_sym])
assert_equal(false, mail[:'x-zammad-send-auto-response'])
email_raw_string = "From: me@example.com
To: customer@example.com
@ -441,7 +441,7 @@ X-Auto-Response-Suppress: All
Some Text"
_ticket_p, article_p, _user_p, mail = Channel::EmailParser.new.process({}, email_raw_string)
assert_equal(false, mail['x-zammad-send-auto-response'.to_sym])
assert_equal(false, mail[:'x-zammad-send-auto-response'])
Scheduler.worker(true)
assert_equal(1, article_p.ticket.articles.count)
@ -454,7 +454,7 @@ Message-ID: <1234@#{fqdn}>
Some Text"
_ticket_p, article_p, _user_p, mail = Channel::EmailParser.new.process({}, email_raw_string)
assert_equal(false, mail['x-zammad-send-auto-response'.to_sym])
assert_equal(false, mail[:'x-zammad-send-auto-response'])
Scheduler.worker(true)
assert_equal(1, article_p.ticket.articles.count)
@ -467,7 +467,7 @@ Message-ID: <1234@not_matching.#{fqdn}>
Some Text"
_ticket_p, article_p, _user_p, mail = Channel::EmailParser.new.process({}, email_raw_string)
assert_equal(true, mail['x-zammad-send-auto-response'.to_sym])
assert_equal(true, mail[:'x-zammad-send-auto-response'])
Scheduler.worker(true)
assert_equal(2, article_p.ticket.articles.count)
@ -517,7 +517,7 @@ Content-Disposition: inline
test"
_ticket_p, article_p, _user_p, mail = Channel::EmailParser.new.process({}, email_raw_string)
assert_equal(false, mail['x-zammad-send-auto-response'.to_sym])
assert_equal(false, mail[:'x-zammad-send-auto-response'])
Scheduler.worker(true)
assert_equal(1, article_p.ticket.articles.count)
@ -558,7 +558,7 @@ X-Loop: yes
Some Text"
ticket_p, article_p, _user_p, mail = Channel::EmailParser.new.process({}, email_raw_string)
assert_equal(false, mail['x-zammad-send-auto-response'.to_sym])
assert_equal(false, mail[:'x-zammad-send-auto-response'])
Scheduler.worker(true)
tags = ticket_p.tag_list
@ -584,7 +584,7 @@ Some Text"
Setting.set('ticket_trigger_recursive', true)
ticket_p, article_p, _user_p, mail = Channel::EmailParser.new.process({}, email_raw_string)
assert_equal(false, mail['x-zammad-send-auto-response'.to_sym])
assert_equal(false, mail[:'x-zammad-send-auto-response'])
Scheduler.worker(true)
tags = ticket_p.tag_list
@ -616,7 +616,7 @@ Subject: some new subject
Some Text"
ticket_p, article_p, _user_p, mail = Channel::EmailParser.new.process({}, email_raw_string)
assert_equal(true, mail['x-zammad-send-auto-response'.to_sym])
assert_equal(true, mail[:'x-zammad-send-auto-response'])
Scheduler.worker(true)
tags = ticket_p.tag_list
@ -647,7 +647,7 @@ Some Text"
Setting.set('ticket_trigger_recursive', true)
ticket_p, article_p, _user_p, mail = Channel::EmailParser.new.process({}, email_raw_string)
assert_equal(true, mail['x-zammad-send-auto-response'.to_sym])
assert_equal(true, mail[:'x-zammad-send-auto-response'])
Scheduler.worker(true)
tags = ticket_p.tag_list
assert_equal('new', ticket_p.state.name)
@ -764,7 +764,7 @@ X-Loop: yes
Some Text"
ticket_p, article_p, _user_p, mail = Channel::EmailParser.new.process({}, email_raw_string)
assert_equal(false, mail['x-zammad-send-auto-response'.to_sym])
assert_equal(false, mail[:'x-zammad-send-auto-response'])
Scheduler.worker(true)
tags = ticket_p.tag_list
@ -790,7 +790,7 @@ Some Text"
Setting.set('ticket_trigger_recursive', true)
ticket_p, article_p, _user_p, mail = Channel::EmailParser.new.process({}, email_raw_string)
assert_equal(false, mail['x-zammad-send-auto-response'.to_sym])
assert_equal(false, mail[:'x-zammad-send-auto-response'])
Scheduler.worker(true)
tags = ticket_p.tag_list
@ -822,7 +822,7 @@ Subject: some new subject
Some Text"
ticket_p, article_p, _user_p, mail = Channel::EmailParser.new.process({}, email_raw_string)
assert_equal(true, mail['x-zammad-send-auto-response'.to_sym])
assert_equal(true, mail[:'x-zammad-send-auto-response'])
Scheduler.worker(true)
tags = ticket_p.tag_list
@ -847,7 +847,7 @@ Some Text"
Setting.set('ticket_trigger_recursive', true)
ticket_p, article_p, _user_p, mail = Channel::EmailParser.new.process({}, email_raw_string)
assert_equal(true, mail['x-zammad-send-auto-response'.to_sym])
assert_equal(true, mail[:'x-zammad-send-auto-response'])
Scheduler.worker(true)
tags = ticket_p.tag_list
assert_equal('open', ticket_p.state.name)

View file

@ -20,12 +20,12 @@ Some Text"
assert_equal('marketing_tool@example.com', ticket_p.customer.email)
assert_equal('Bob', ticket_p.customer.firstname)
assert_equal('Smith', ticket_p.customer.lastname)
assert_nil(mail['raw-origin_from'.to_sym])
assert_nil(mail['origin_from'.to_sym])
assert_nil(mail['origin_from_email'.to_sym])
assert_nil(mail['origin_from_local'.to_sym])
assert_nil(mail['origin_from_domain'.to_sym])
assert_nil(mail['origin_from_display_name'.to_sym])
assert_nil(mail[:'raw-origin_from'])
assert_nil(mail[:origin_from])
assert_nil(mail[:origin_from_email])
assert_nil(mail[:origin_from_local])
assert_nil(mail[:origin_from_domain])
assert_nil(mail[:origin_from_display_name])
end
test 'normal processing - take reply to as customer' do
@ -60,12 +60,12 @@ Some Text"
assert_equal('replay_to_customer_process2-1@example.com', ticket_p.customer.email)
assert_equal('Some', ticket_p.customer.firstname)
assert_equal('Name', ticket_p.customer.lastname)
assert_equal('Bob Smith <marketing_tool@example.com>', mail['raw-origin_from'.to_sym].to_s)
assert_equal('Bob Smith <marketing_tool@example.com>', mail['origin_from'.to_sym])
assert_equal('marketing_tool@example.com', mail['origin_from_email'.to_sym])
assert_equal('marketing_tool', mail['origin_from_local'.to_sym])
assert_equal('example.com', mail['origin_from_domain'.to_sym])
assert_equal('Bob Smith', mail['origin_from_display_name'.to_sym])
assert_equal('Bob Smith <marketing_tool@example.com>', mail[:'raw-origin_from'].to_s)
assert_equal('Bob Smith <marketing_tool@example.com>', mail[:origin_from])
assert_equal('marketing_tool@example.com', mail[:origin_from_email])
assert_equal('marketing_tool', mail[:origin_from_local])
assert_equal('example.com', mail[:origin_from_domain])
assert_equal('Bob Smith', mail[:origin_from_display_name])
end
test 'normal processing - take reply to as customer and use from as realname' do
@ -84,12 +84,12 @@ Some Text"
assert_equal('replay_to_customer_process3@example.com', ticket_p.customer.email)
assert_equal('Bob', ticket_p.customer.firstname)
assert_equal('Smith', ticket_p.customer.lastname)
assert_equal('Bob Smith <marketing_tool@example.com>', mail['raw-origin_from'.to_sym].to_s)
assert_equal('Bob Smith <marketing_tool@example.com>', mail['origin_from'.to_sym])
assert_equal('marketing_tool@example.com', mail['origin_from_email'.to_sym])
assert_equal('marketing_tool', mail['origin_from_local'.to_sym])
assert_equal('example.com', mail['origin_from_domain'.to_sym])
assert_equal('Bob Smith', mail['origin_from_display_name'.to_sym])
assert_equal('Bob Smith <marketing_tool@example.com>', mail[:'raw-origin_from'].to_s)
assert_equal('Bob Smith <marketing_tool@example.com>', mail[:origin_from])
assert_equal('marketing_tool@example.com', mail[:origin_from_email])
assert_equal('marketing_tool', mail[:origin_from_local])
assert_equal('example.com', mail[:origin_from_domain])
assert_equal('Bob Smith', mail[:origin_from_display_name])
email = "From: Bob Smith <marketing_tool@example.com>
To: zammad@example.com
@ -106,12 +106,12 @@ Some Text"
assert_equal('replay_to_customer_process3-1@example.com', ticket_p.customer.email)
assert_equal('Bob', ticket_p.customer.firstname)
assert_equal('Smith', ticket_p.customer.lastname)
assert_equal('Bob Smith <marketing_tool@example.com>', mail['raw-origin_from'.to_sym].to_s)
assert_equal('Bob Smith <marketing_tool@example.com>', mail['origin_from'.to_sym])
assert_equal('marketing_tool@example.com', mail['origin_from_email'.to_sym])
assert_equal('marketing_tool', mail['origin_from_local'.to_sym])
assert_equal('example.com', mail['origin_from_domain'.to_sym])
assert_equal('Bob Smith', mail['origin_from_display_name'.to_sym])
assert_equal('Bob Smith <marketing_tool@example.com>', mail[:'raw-origin_from'].to_s)
assert_equal('Bob Smith <marketing_tool@example.com>', mail[:origin_from])
assert_equal('marketing_tool@example.com', mail[:origin_from_email])
assert_equal('marketing_tool', mail[:origin_from_local])
assert_equal('example.com', mail[:origin_from_domain])
assert_equal('Bob Smith', mail[:origin_from_display_name])
end
test 'normal processing - take reply to as customer and sender is system address' do
@ -141,12 +141,12 @@ Some Text"
assert_equal('replay_to_customer_process2@example.com', ticket_p.customer.email)
assert_equal('', ticket_p.customer.firstname)
assert_equal('', ticket_p.customer.lastname)
assert_equal('Marketing Tool <marketing_tool@example.com>', mail['raw-origin_from'.to_sym].to_s)
assert_equal('Marketing Tool <marketing_tool@example.com>', mail['origin_from'.to_sym])
assert_equal('marketing_tool@example.com', mail['origin_from_email'.to_sym])
assert_equal('marketing_tool', mail['origin_from_local'.to_sym])
assert_equal('example.com', mail['origin_from_domain'.to_sym])
assert_equal('Marketing Tool', mail['origin_from_display_name'.to_sym])
assert_equal('Marketing Tool <marketing_tool@example.com>', mail[:'raw-origin_from'].to_s)
assert_equal('Marketing Tool <marketing_tool@example.com>', mail[:origin_from])
assert_equal('marketing_tool@example.com', mail[:origin_from_email])
assert_equal('marketing_tool', mail[:origin_from_local])
assert_equal('example.com', mail[:origin_from_domain])
assert_equal('Marketing Tool', mail[:origin_from_display_name])
end
end