Copy the Chatwoot (v4.14.0) frontend runnable subset into frontend/ for customization: - app/javascript/ (Vue SPA: dashboard, widget, sdk, portal, superadmin) - app/views/ (ERB templates for vite-plugin-ruby entrypoint resolution) - app/helpers/, app/assets/ (Rails view helpers, static assets) - enterprise/ (Enterprise edition frontend overlay) - config/vite.json, vite.config.ts, bin/vite (Vite-Rails toolchain) - package.json, pnpm-lock.yaml, tailwind/postcss/eslint configs - Gemfile, Gemfile.lock (vite_rails gem for bin/vite binstub) Excluded Rails backend: controllers, models, services, jobs, mailers, policies, db, lib, spec, public, node_modules. Update references to the new frontend location: - .gitignore: exclude frontend build artifacts (node_modules, tmp, packs), keep frontend/bin/ and frontend/vendor/ via negation - backend/scripts/parity_frontend_smoke.sh: CHATWOOT_DIR default reference/chatwoot -> ../frontend - backend/scripts/parity_frontend_browser_smoke.mjs: same default update - AGENTS.md: add frontend section with Rails/Vite coupling notes - README: architecture tree includes frontend/
55 lines
1.7 KiB
Ruby
55 lines
1.7 KiB
Ruby
# Allow audio attachments (call recordings, voice notes) to serve inline so the
|
|
# in-app <audio> player can stream them. Without this, ActiveStorage's blob model
|
|
# forces Content-Disposition: attachment for any MIME outside the default allowlist
|
|
# (images + PDF), which makes the browser download instead of play.
|
|
Rails.application.config.active_storage.content_types_allowed_inline += %w[
|
|
audio/webm
|
|
audio/ogg
|
|
audio/mpeg
|
|
audio/mp4
|
|
audio/x-m4a
|
|
audio/wav
|
|
audio/x-wav
|
|
]
|
|
|
|
module ActiveStorageDirectUploadMetadataFilter
|
|
INTERNAL_METADATA_KEYS = %w[identified analyzed composed].freeze
|
|
|
|
private
|
|
|
|
def blob_args
|
|
super.tap do |args|
|
|
args[:metadata]&.except!(*INTERNAL_METADATA_KEYS, *INTERNAL_METADATA_KEYS.map(&:to_sym))
|
|
end
|
|
end
|
|
end
|
|
|
|
module ActiveStorageProxyRangeLimit
|
|
STREAMING_MAX_RANGES = 1
|
|
STREAMING_CHUNK_MAX_SIZE = 100.megabytes
|
|
|
|
private
|
|
|
|
def send_blob_byte_range_data(blob, range_header, disposition: nil)
|
|
ranges = Rack::Utils.get_byte_ranges(range_header, blob.byte_size)
|
|
return head(:range_not_satisfiable) unless valid_ranges?(ranges)
|
|
|
|
super
|
|
end
|
|
|
|
def valid_ranges?(ranges)
|
|
ranges.present? &&
|
|
ranges.any?(&:present?) &&
|
|
ranges.length <= STREAMING_MAX_RANGES &&
|
|
ranges.sum { |range| range.end - range.begin } < STREAMING_CHUNK_MAX_SIZE
|
|
end
|
|
end
|
|
|
|
Rails.application.config.to_prepare do
|
|
unless ActiveStorage::DirectUploadsController < ActiveStorageDirectUploadMetadataFilter
|
|
ActiveStorage::DirectUploadsController.prepend(ActiveStorageDirectUploadMetadataFilter)
|
|
end
|
|
|
|
ActiveStorage::Streaming.prepend(ActiveStorageProxyRangeLimit) unless ActiveStorage::Streaming < ActiveStorageProxyRangeLimit
|
|
end
|