diff --git a/app/policies/controllers/postmaster_filters_controller_policy.rb b/app/policies/controllers/postmaster_filters_controller_policy.rb index 633fa26aa..8f9c6a579 100644 --- a/app/policies/controllers/postmaster_filters_controller_policy.rb +++ b/app/policies/controllers/postmaster_filters_controller_policy.rb @@ -1,5 +1,5 @@ # Copyright (C) 2012-2021 Zammad Foundation, http://zammad-foundation.org/ class Controllers::PostmasterFiltersControllerPolicy < Controllers::ApplicationControllerPolicy - default_permit!('admin.channel_email') + default_permit!(['admin.channel_email', 'admin.channel_google', 'admin.channel_microsoft365']) end diff --git a/app/policies/controllers/signatures_controller_policy.rb b/app/policies/controllers/signatures_controller_policy.rb index 55039c023..2e622d751 100644 --- a/app/policies/controllers/signatures_controller_policy.rb +++ b/app/policies/controllers/signatures_controller_policy.rb @@ -1,6 +1,6 @@ # Copyright (C) 2012-2021 Zammad Foundation, http://zammad-foundation.org/ class Controllers::SignaturesControllerPolicy < Controllers::ApplicationControllerPolicy - permit! %i[index show], to: ['ticket.agent', 'admin.channel_email'] - permit! %i[create update destroy], to: 'admin.channel_email' + permit! %i[index show], to: ['ticket.agent', 'admin.channel_email', 'admin.channel_google', 'admin.channel_microsoft365'] + permit! %i[create update destroy], to: ['admin.channel_email', 'admin.channel_google', 'admin.channel_microsoft365'] end diff --git a/db/migrate/20210914153600_issue_3194_update_permissions.rb b/db/migrate/20210914153600_issue_3194_update_permissions.rb new file mode 100644 index 000000000..3878d7132 --- /dev/null +++ b/db/migrate/20210914153600_issue_3194_update_permissions.rb @@ -0,0 +1,28 @@ +# Copyright (C) 2012-2021 Zammad Foundation, http://zammad-foundation.org/ + +class Issue3194UpdatePermissions < ActiveRecord::Migration[6.0] + def change + # return if it's a new setup + return if !Setting.exists?(name: 'system_init_done') + + settings = %w[ + ticket_subject_size + ticket_subject_re + ticket_subject_fwd + ticket_define_email_from + ticket_define_email_from_separator + postmaster_max_size + postmaster_follow_up_search_in + postmaster_sender_based_on_reply_to + postmaster_sender_is_agent_search_for_customer + postmaster_send_reject_if_mail_too_large + notification_sender + send_no_auto_response_reg_exp + ] + + Setting.where(name: settings).each do |setting| + setting.preferences[:permission] += ['admin.channel_google', 'admin.channel_microsoft365'] + setting.save + end + end +end diff --git a/db/seeds/settings.rb b/db/seeds/settings.rb index 772cb2730..ae2ff84fe 100644 --- a/db/seeds/settings.rb +++ b/db/seeds/settings.rb @@ -2530,7 +2530,7 @@ Setting.create_if_not_exists( }, state: '110', preferences: { - permission: ['admin.channel_email'], + permission: ['admin.channel_email', 'admin.channel_google', 'admin.channel_microsoft365'], }, frontend: false ) @@ -2551,7 +2551,7 @@ Setting.create_if_not_exists( }, state: 'RE', preferences: { - permission: ['admin.channel_email'], + permission: ['admin.channel_email', 'admin.channel_google', 'admin.channel_microsoft365'], }, frontend: false ) @@ -2573,7 +2573,7 @@ Setting.create_if_not_exists( }, state: 'FWD', preferences: { - permission: ['admin.channel_email'], + permission: ['admin.channel_email', 'admin.channel_google', 'admin.channel_microsoft365'], }, frontend: false ) @@ -2600,7 +2600,7 @@ Setting.create_if_not_exists( }, state: 'AgentNameSystemAddressName', preferences: { - permission: ['admin.channel_email'], + permission: ['admin.channel_email', 'admin.channel_google', 'admin.channel_microsoft365'], }, frontend: false ) @@ -2622,7 +2622,7 @@ Setting.create_if_not_exists( }, state: 'via', preferences: { - permission: ['admin.channel_email'], + permission: ['admin.channel_email', 'admin.channel_google', 'admin.channel_microsoft365'], }, frontend: false ) @@ -2672,7 +2672,7 @@ Setting.create_if_not_exists( state: 10, preferences: { online_service_disable: true, - permission: ['admin.channel_email'], + permission: ['admin.channel_email', 'admin.channel_google', 'admin.channel_microsoft365'], }, frontend: false ) @@ -2699,7 +2699,7 @@ Setting.create_if_not_exists( }, state: [], preferences: { - permission: ['admin.channel_email'], + permission: ['admin.channel_email', 'admin.channel_google', 'admin.channel_microsoft365'], }, frontend: false ) @@ -2726,7 +2726,7 @@ Setting.create_if_not_exists( }, state: [], preferences: { - permission: ['admin.channel_email'], + permission: ['admin.channel_email', 'admin.channel_google', 'admin.channel_microsoft365'], }, frontend: false ) @@ -2752,7 +2752,7 @@ Setting.create_if_not_exists( }, state: true, preferences: { - permission: ['admin.channel_email'], + permission: ['admin.channel_email', 'admin.channel_google', 'admin.channel_microsoft365'], }, frontend: false ) @@ -2779,7 +2779,7 @@ Setting.create_if_not_exists( state: true, preferences: { online_service_disable: true, - permission: ['admin.channel_email'], + permission: ['admin.channel_email', 'admin.channel_google', 'admin.channel_microsoft365'], }, frontend: false ) @@ -2802,7 +2802,7 @@ Setting.create_if_not_exists( state: '#{config.product_name} ', # rubocop:disable Lint/InterpolationCheck preferences: { online_service_disable: true, - permission: ['admin.channel_email'], + permission: ['admin.channel_email', 'admin.channel_google', 'admin.channel_microsoft365'], }, frontend: false ) @@ -2825,7 +2825,7 @@ Setting.create_if_not_exists( state: '(mailer-daemon|postmaster|abuse|root|noreply|noreply.+?|no-reply|no-reply.+?)@.+?', preferences: { online_service_disable: true, - permission: ['admin.channel_email'], + permission: ['admin.channel_email', 'admin.channel_google', 'admin.channel_microsoft365'], }, frontend: false ) diff --git a/spec/db/migrate/issue_3194_update_permissions_spec.rb b/spec/db/migrate/issue_3194_update_permissions_spec.rb new file mode 100644 index 000000000..066873744 --- /dev/null +++ b/spec/db/migrate/issue_3194_update_permissions_spec.rb @@ -0,0 +1,9 @@ +# Copyright (C) 2012-2021 Zammad Foundation, http://zammad-foundation.org/ + +require 'rails_helper' + +RSpec.describe Issue3194UpdatePermissions, type: :db_migration do + it 'does update settings with new permissions' do + expect { migrate }.to change { Setting.find_by(name: 'ticket_subject_size').preferences[:permission] }.to include('admin.channel_google', 'admin.channel_microsoft365') + end +end