"Fossies" - the Fresh Open Source Software Archive

Member "db/migrate/20170516000001_trigger_recipient_update.rb" (25 Mar 2021, 825 Bytes) of package /linux/www/zammad-4.0.0.tar.bz2:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Ruby source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. See also the last Fossies "Diffs" side-by-side code changes report for "20170516000001_trigger_recipient_update.rb": 3.4.1_vs_3.5.0.

    1 class TriggerRecipientUpdate < ActiveRecord::Migration[4.2]
    2   def up
    3 
    4     # return if it's a new setup
    5     return if !Setting.exists?(name: 'system_init_done')
    6 
    7     ['auto reply (on new tickets)', 'auto reply (on follow-up of tickets)'].each do |name|
    8 
    9       trigger = Trigger.find_by(name: name)
   10       next if trigger.blank?
   11       next if trigger.perform.blank?
   12       next if trigger.perform['notification.email'].blank?
   13       next if trigger.perform['notification.email']['recipient'].blank?
   14       next if trigger.perform['notification.email']['recipient'] != 'ticket_customer'
   15 
   16       trigger.perform['notification.email']['recipient'] = 'article_last_sender'
   17       trigger.save!
   18     rescue => e
   19       Rails.logger.error "Unable to update Trigger.find(#{trigger.id}) '#{trigger.inspect}': #{e.message}"
   20 
   21     end
   22 
   23   end
   24 end