discourse/app/serializers/user_export_serializer.rb
Blake Erickson afda973070
FIX: User profile not loading with an empty export (#31290)
If a user has an export that doesn't have a file it can cause their
profile page to not load.
2025-02-11 16:18:06 -07:00

31 lines
555 B
Ruby

# frozen_string_literal: true
class UserExportSerializer < ApplicationSerializer
attributes :id, :filename, :uri, :filesize, :extension, :retain_hours, :human_filesize
def serializable_hash(adapter_options = nil, options = {})
return {} unless object.upload
super()
end
def filename
object.upload.original_filename
end
def uri
object.upload.short_path
end
def filesize
object.upload.filesize
end
def extension
object.upload.extension
end
def human_filesize
object.upload.human_filesize
end
end