Sha256: 19a75432b252cccc60a46ea723a552fd004a4dfa3366716c11b08309d8f361f3
Contents?: true
Size: 847 Bytes
Versions: 4
Compression:
Stored size: 847 Bytes
Contents
# frozen_string_literal: true module EffectiveLogging module ActiveStorageLogger def track_downloads user = current_user if respond_to?(:current_user) key = decode_verified_key() return unless key.present? return if (key[:content_type] || '').starts_with?('image') blob = ActiveStorage::Blob.where(key: key[:key]).first return unless blob.present? blob.attachments.each do |attachment| next if attachment.name == 'embeds' next if attachment.record_type == 'ActionText::RichText' associated = attachment.record filename = blob.filename.to_s message = [associated.to_s, filename.to_s].uniq.join(' ') EffectiveLogger.download(message, associated: associated, associated_to_s: filename, filename: filename, user: user) end end end end
Version data entries
4 entries across 4 versions & 1 rubygems