effective_logging 3.1.1 → 3.1.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
 - data/app/controllers/admin/logs_controller.rb +0 -6
 - data/app/controllers/effective/logs_controller.rb +1 -1
 - data/config/routes.rb +1 -1
 - data/lib/effective_logging/active_record_logger.rb +3 -0
 - data/lib/effective_logging/active_storage_logger.rb +7 -1
 - data/lib/effective_logging/email_logger.rb +13 -4
 - data/lib/effective_logging/version.rb +1 -1
 - metadata +2 -2
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA256:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: e32cf9d12897b60563d0ad588e0ebea30255433ec2cc7e4479b52f4c890267af
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: 26aebcdf742dd9b3676a5d33fb924f33651b87c156e481fa19480f05ae306f04
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: 87671373f8f9b4022aa6a587e49744cd3accb149493b4f48eb52451b0ff9f24e13fdcf38e01349076bf9dcb2e33181723e92213c0c4888424aed6e211af01f0e
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: 7c64f534e0cf14b48b59ab0f03559c324f4f4bf8470e736cb0e30032c9609138f0918647d0c265ce1e87c029a8967c70a3fe39f6c6b93f5fd368a3c83bc2984f
         
     | 
| 
         @@ -10,11 +10,5 @@ module Admin 
     | 
|
| 
       10 
10 
     | 
    
         
             
                  layout(config.kind_of?(Hash) ? config[:admin] : config)
         
     | 
| 
       11 
11 
     | 
    
         
             
                end
         
     | 
| 
       12 
12 
     | 
    
         | 
| 
       13 
     | 
    
         
            -
                def index
         
     | 
| 
       14 
     | 
    
         
            -
                  EffectiveResources.authorize!(self, :index, Effective::Log)
         
     | 
| 
       15 
     | 
    
         
            -
                  @datatable = EffectiveLogsDatatable.new(self)
         
     | 
| 
       16 
     | 
    
         
            -
                  @page_title = 'Logs'
         
     | 
| 
       17 
     | 
    
         
            -
                end
         
     | 
| 
       18 
     | 
    
         
            -
             
     | 
| 
       19 
13 
     | 
    
         
             
              end
         
     | 
| 
       20 
14 
     | 
    
         
             
            end
         
     | 
    
        data/config/routes.rb
    CHANGED
    
    | 
         @@ -1,5 +1,5 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            EffectiveLogging::Engine.routes.draw do
         
     | 
| 
       2 
     | 
    
         
            -
              scope : 
     | 
| 
      
 2 
     | 
    
         
            +
              scope module: 'effective' do
         
     | 
| 
       3 
3 
     | 
    
         
             
                # Create is our javascript POST event for EffectiveLogging from JS side
         
     | 
| 
       4 
4 
     | 
    
         
             
                # The show and index routes are for user specific logs
         
     | 
| 
       5 
5 
     | 
    
         
             
                resources :logs, only: [:create, :index, :show] do
         
     | 
| 
         @@ -33,6 +33,9 @@ module EffectiveLogging 
     | 
|
| 
       33 
33 
     | 
    
         
             
                  return true if changes.blank? # If you just click save and change nothing, don't log it.
         
     | 
| 
       34 
34 
     | 
    
         | 
| 
       35 
35 
     | 
    
         
             
                  message = (['Updated'] + changes.map do |attribute, (before, after)|
         
     | 
| 
      
 36 
     | 
    
         
            +
                    before = "HTML content (#{before.length})" if before.kind_of?(String) && before.include?('<div')
         
     | 
| 
      
 37 
     | 
    
         
            +
                    after = "HTML content (#{after.length})" if after.kind_of?(String) && after.include?('<div')
         
     | 
| 
      
 38 
     | 
    
         
            +
             
     | 
| 
       36 
39 
     | 
    
         
             
                    "#{attribute}: #{before.presence || BLANK} → #{after.presence || BLANK}"
         
     | 
| 
       37 
40 
     | 
    
         
             
                  end).join("\n")
         
     | 
| 
       38 
41 
     | 
    
         | 
| 
         @@ -1,3 +1,5 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # frozen_string_literal: true
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
       1 
3 
     | 
    
         
             
            module EffectiveLogging
         
     | 
| 
       2 
4 
     | 
    
         
             
              module ActiveStorageLogger
         
     | 
| 
       3 
5 
     | 
    
         | 
| 
         @@ -6,16 +8,20 @@ module EffectiveLogging 
     | 
|
| 
       6 
8 
     | 
    
         | 
| 
       7 
9 
     | 
    
         
             
                  key = decode_verified_key()
         
     | 
| 
       8 
10 
     | 
    
         
             
                  return unless key.present?
         
     | 
| 
      
 11 
     | 
    
         
            +
                  return if (key[:content_type] || '').starts_with?('image')
         
     | 
| 
       9 
12 
     | 
    
         | 
| 
       10 
13 
     | 
    
         
             
                  blob = ActiveStorage::Blob.where(key: key[:key]).first
         
     | 
| 
       11 
14 
     | 
    
         
             
                  return unless blob.present?
         
     | 
| 
       12 
15 
     | 
    
         | 
| 
       13 
16 
     | 
    
         
             
                  blob.attachments.each do |attachment|
         
     | 
| 
      
 17 
     | 
    
         
            +
                    next if attachment.name == 'embeds'
         
     | 
| 
      
 18 
     | 
    
         
            +
                    next if attachment.record_type == 'ActionText::RichText'
         
     | 
| 
      
 19 
     | 
    
         
            +
             
     | 
| 
       14 
20 
     | 
    
         
             
                    associated = attachment.record
         
     | 
| 
       15 
21 
     | 
    
         
             
                    filename = blob.filename.to_s
         
     | 
| 
       16 
22 
     | 
    
         
             
                    message = [associated.to_s, filename.to_s].uniq.join(' ')
         
     | 
| 
       17 
23 
     | 
    
         | 
| 
       18 
     | 
    
         
            -
                    EffectiveLogger.download(message, associated: associated, filename: filename, user: user)
         
     | 
| 
      
 24 
     | 
    
         
            +
                    EffectiveLogger.download(message, associated: associated, associated_to_s: filename, filename: filename, user: user)
         
     | 
| 
       19 
25 
     | 
    
         
             
                  end
         
     | 
| 
       20 
26 
     | 
    
         
             
                end
         
     | 
| 
       21 
27 
     | 
    
         | 
| 
         @@ -8,10 +8,19 @@ module EffectiveLogging 
     | 
|
| 
       8 
8 
     | 
    
         
             
                  fields = { from: message.from.join(','), to: message.to, subject: message.subject, cc: message.cc, bcc: message.bcc }
         
     | 
| 
       9 
9 
     | 
    
         | 
| 
       10 
10 
     | 
    
         
             
                  # Add a log header to your mailer to pass some objects or additional things to EffectiveLogger
         
     | 
| 
       11 
     | 
    
         
            -
                  # mail(to: 'admin@example.com', subject: @post.title, log:  
     | 
| 
      
 11 
     | 
    
         
            +
                  # mail(to: 'admin@example.com', subject: @post.title, log: @post)
         
     | 
| 
      
 12 
     | 
    
         
            +
             
     | 
| 
       12 
13 
     | 
    
         
             
                  if message.header['log'].present?
         
     | 
| 
       13 
     | 
    
         
            -
                     
     | 
| 
       14 
     | 
    
         
            -
                     
     | 
| 
      
 14 
     | 
    
         
            +
                    obj = message.header['log'].instance_variable_get(:@unparsed_value)
         
     | 
| 
      
 15 
     | 
    
         
            +
                    obj ||= message.header['log'].instance_variable_get(:@value)
         
     | 
| 
      
 16 
     | 
    
         
            +
             
     | 
| 
      
 17 
     | 
    
         
            +
                    if obj.kind_of?(ActiveRecord::Base)
         
     | 
| 
      
 18 
     | 
    
         
            +
                      fields.merge!(associated: obj)
         
     | 
| 
      
 19 
     | 
    
         
            +
                    elsif obj.kind_of?(Hash)
         
     | 
| 
      
 20 
     | 
    
         
            +
                      fields.merge!(obj)
         
     | 
| 
      
 21 
     | 
    
         
            +
                    else
         
     | 
| 
      
 22 
     | 
    
         
            +
                      raise('log expected an ActiveRecord object or Hash')
         
     | 
| 
      
 23 
     | 
    
         
            +
                    end
         
     | 
| 
       15 
24 
     | 
    
         | 
| 
       16 
25 
     | 
    
         
             
                    # Get rid of the extra header, as it should not be set in the real mail message.
         
     | 
| 
       17 
26 
     | 
    
         
             
                    message.header['log'] = nil
         
     | 
| 
         @@ -49,7 +58,7 @@ module EffectiveLogging 
     | 
|
| 
       49 
58 
     | 
    
         
             
                  tos.each do |to|
         
     | 
| 
       50 
59 
     | 
    
         
             
                    user = (user_klass.where(email: to.downcase).first if user_klass.present?)
         
     | 
| 
       51 
60 
     | 
    
         | 
| 
       52 
     | 
    
         
            -
                    user_fields = fields.merge(to: to, user: user 
     | 
| 
      
 61 
     | 
    
         
            +
                    user_fields = fields.merge(to: to, user: user)
         
     | 
| 
       53 
62 
     | 
    
         
             
                    ::EffectiveLogger.email("#{message.subject} - #{tos.join(', ')}", user_fields)
         
     | 
| 
       54 
63 
     | 
    
         
             
                  end
         
     | 
| 
       55 
64 
     | 
    
         | 
    
        metadata
    CHANGED
    
    | 
         @@ -1,14 +1,14 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: effective_logging
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version: 3.1. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 3.1.6
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors:
         
     | 
| 
       7 
7 
     | 
    
         
             
            - Code and Effect
         
     | 
| 
       8 
8 
     | 
    
         
             
            autorequire:
         
     | 
| 
       9 
9 
     | 
    
         
             
            bindir: bin
         
     | 
| 
       10 
10 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       11 
     | 
    
         
            -
            date: 2021- 
     | 
| 
      
 11 
     | 
    
         
            +
            date: 2021-03-16 00:00:00.000000000 Z
         
     | 
| 
       12 
12 
     | 
    
         
             
            dependencies:
         
     | 
| 
       13 
13 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       14 
14 
     | 
    
         
             
              name: rails
         
     |