mirror of
https://github.com/discourse/discourse.git
synced 2025-02-28 07:08:40 +08:00

If a user has an export that doesn't have a file it can cause their profile page to not load.
31 lines
555 B
Ruby
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
|