Fixes #3503 - ticket.customer_id is current_user breaks email fetching.
This commit is contained in:
parent
decf868823
commit
871d9609e1
6 changed files with 56 additions and 13 deletions
|
@ -435,15 +435,15 @@ class App.UiElement.ApplicationSelector
|
|||
selection = $("<select class=\"form-control\" name=\"#{name}\" ></select>")
|
||||
options = {}
|
||||
if preCondition is 'user'
|
||||
options =
|
||||
'current_user.id': App.i18n.translateInline('current user')
|
||||
'specific': App.i18n.translateInline('specific user')
|
||||
'not_set': App.i18n.translateInline('not set (not defined)')
|
||||
if attributeConfig.noCurrentUser isnt true
|
||||
options['current_user.id'] = App.i18n.translateInline('current user')
|
||||
options['specific'] = App.i18n.translateInline('specific user')
|
||||
options['not_set'] = App.i18n.translateInline('not set (not defined)')
|
||||
else if preCondition is 'org'
|
||||
options =
|
||||
'current_user.organization_id': App.i18n.translateInline('current user organization')
|
||||
'specific': App.i18n.translateInline('specific organization')
|
||||
'not_set': App.i18n.translateInline('not set (not defined)')
|
||||
if attributeConfig.noCurrentUser isnt true
|
||||
options['current_user.organization_id'] = App.i18n.translateInline('current user organization')
|
||||
options['specific'] = App.i18n.translateInline('specific organization')
|
||||
options['not_set'] = App.i18n.translateInline('not set (not defined)')
|
||||
|
||||
for key, value of options
|
||||
selected = ''
|
||||
|
|
|
@ -5,7 +5,7 @@ class App.Job extends App.Model
|
|||
@configure_attributes = [
|
||||
{ name: 'name', display: 'Name', tag: 'input', type: 'text', limit: 100, null: false },
|
||||
{ name: 'timeplan', display: 'When should the job run?', tag: 'timer', null: true },
|
||||
{ name: 'condition', display: 'Conditions for effected objects', tag: 'ticket_selector', null: true, executionTime: true },
|
||||
{ name: 'condition', display: 'Conditions for effected objects', tag: 'ticket_selector', null: true, executionTime: true, noCurrentUser: true },
|
||||
{ name: 'perform', display: 'Execute changes on objects', tag: 'ticket_perform_action', null: true, notification: true, ticket_delete: true },
|
||||
{ name: 'disable_notification', display: 'Disable Notifications', tag: 'boolean', default: true },
|
||||
{ name: 'note', display: 'Note', tag: 'textarea', note: 'Notes are visible to agents only, never to customers.', limit: 250, null: true },
|
||||
|
|
|
@ -4,7 +4,7 @@ class App.Sla extends App.Model
|
|||
@url: @apiPath + '/slas'
|
||||
@configure_attributes = [
|
||||
{ name: 'name', display: 'Name', tag: 'input', type: 'text', limit: 100, null: false },
|
||||
{ name: 'condition', display: 'Ticket Selector', tag: 'ticket_selector', null: false, note: 'Create rules that single out the tickets for the Service Level Agreement.' },
|
||||
{ name: 'condition', display: 'Ticket Selector', tag: 'ticket_selector', null: false, note: 'Create rules that single out the tickets for the Service Level Agreement.', noCurrentUser: true },
|
||||
{ name: 'calendar_id', display: 'Calendar', tag: 'select', relation: 'Calendar', null: false },
|
||||
{ name: 'sla_times', display: 'SLA Times', tag: 'sla_times', null: true },
|
||||
{ name: 'created_by_id', display: 'Created by', relation: 'User', readonly: 1 },
|
||||
|
|
|
@ -1305,9 +1305,7 @@ perform active triggers on ticket
|
|||
user_id = article.updated_by_id
|
||||
end
|
||||
|
||||
user = if user_id != 1
|
||||
User.lookup(id: user_id)
|
||||
end
|
||||
user = User.lookup(id: user_id)
|
||||
|
||||
# verify is condition is matching
|
||||
ticket_count, tickets = Ticket.selectors(condition, limit: 1, execution_time: true, current_user: user, access: 'ignore')
|
||||
|
|
23
db/migrate/20210830150400_issue_3503_fix_current_user.rb
Normal file
23
db/migrate/20210830150400_issue_3503_fix_current_user.rb
Normal file
|
@ -0,0 +1,23 @@
|
|||
# Copyright (C) 2012-2021 Zammad Foundation, http://zammad-foundation.org/
|
||||
|
||||
class Issue3503FixCurrentUser < ActiveRecord::Migration[6.0]
|
||||
def change
|
||||
# return if it's a new setup
|
||||
return if !Setting.exists?(name: 'system_init_done')
|
||||
|
||||
remove_current_user(Job)
|
||||
remove_current_user(Sla)
|
||||
end
|
||||
|
||||
def remove_current_user(target)
|
||||
target.find_each do |row|
|
||||
row.condition.each do |key, condition|
|
||||
next if condition['pre_condition'].blank?
|
||||
next if condition['pre_condition'].exclude?('current_user')
|
||||
|
||||
row.condition.delete(key)
|
||||
row.save
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
22
spec/db/migrate/issue_3503_fix_current_user_spec.rb
Normal file
22
spec/db/migrate/issue_3503_fix_current_user_spec.rb
Normal file
|
@ -0,0 +1,22 @@
|
|||
# Copyright (C) 2012-2021 Zammad Foundation, http://zammad-foundation.org/
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe Issue3503FixCurrentUser, type: :db_migration do
|
||||
let!(:job) { create(:job) }
|
||||
let!(:sla) { create(:sla) }
|
||||
|
||||
before do
|
||||
condition = { 'ticket.organization_id' => { 'operator' => 'is', 'pre_condition' => 'current_user.organization_id', 'value' => '' }, 'ticket.action' => { 'operator' => 'is', 'value' => 'create' } }
|
||||
job.update_column(:condition, condition)
|
||||
sla.update_column(:condition, condition)
|
||||
end
|
||||
|
||||
it 'removes current user condition from Jobs' do
|
||||
expect { migrate }.to change { job.reload.condition }.to({ 'ticket.action'=>{ 'operator' => 'is', 'value' => 'create' } })
|
||||
end
|
||||
|
||||
it 'removes current user condition from Slas' do
|
||||
expect { migrate }.to change { sla.reload.condition }.to({ 'ticket.action'=>{ 'operator' => 'is', 'value' => 'create' } })
|
||||
end
|
||||
end
|
Loading…
Reference in a new issue