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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e1dc7b7f4024ac664b211eba56892cd43828ec911f37361b91f1ac6496f87fb7
4
- data.tar.gz: 512c990d5a8dddfcc665e28ff7dd6ef66302ce4f855d68d87fa89af44ef79ed4
3
+ metadata.gz: e32cf9d12897b60563d0ad588e0ebea30255433ec2cc7e4479b52f4c890267af
4
+ data.tar.gz: 26aebcdf742dd9b3676a5d33fb924f33651b87c156e481fa19480f05ae306f04
5
5
  SHA512:
6
- metadata.gz: 612a1bed2cc27c80ee726a023a079e0a5a2dcf80b7d390e07bb9a692bf60da43c974d754bc29f99a17bc95d589e18457aa52261564da19e509947b47046a8f3c
7
- data.tar.gz: 798375484126e11a779eaffbdf1c53e26a5530f701440b4190660948b52ee9c728e1e7f300684b088a636d4b9df1d08087b71dc3477a434a23c2422b576b27c7
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
@@ -47,7 +47,7 @@ module Effective
47
47
  def html_part
48
48
  @log = Effective::Log.find(params[:id])
49
49
 
50
- EffectiveLogging.authorize!(self, :show, @log)
50
+ EffectiveResources.authorize!(self, :show, @log)
51
51
 
52
52
  value = @log.details[(params[:key] || '').to_sym].to_s
53
53
 
data/config/routes.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  EffectiveLogging::Engine.routes.draw do
2
- scope :module => 'effective' do
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} &rarr; #{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: { post: @post })
11
+ # mail(to: 'admin@example.com', subject: @post.title, log: @post)
12
+
12
13
  if message.header['log'].present?
13
- # This is a bit sketchy, but gives access to the object in Rails 4.2 anyway
14
- fields.merge!(message.header['log'].instance_variable_get(:@value) || {})
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, associated: 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
 
@@ -1,3 +1,3 @@
1
1
  module EffectiveLogging
2
- VERSION = '3.1.1'.freeze
2
+ VERSION = '3.1.6'.freeze
3
3
  end
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.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-02-22 00:00:00.000000000 Z
11
+ date: 2021-03-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails