このコミットが含まれているのは:
@@ -2,8 +2,9 @@
|
||||
|
||||
|
||||
module MaterialRepr
|
||||
BASE = { only: [:id, :url, :version_no, :file_suppressed_at,
|
||||
:file_suppression_reason, :created_at, :updated_at],
|
||||
BASE = { only: [:id, :url, :version_no, :source_kind, :source_uri,
|
||||
:source_path, :source_file_id, :normalized_source_key,
|
||||
:created_at, :updated_at],
|
||||
methods: [:content_type],
|
||||
include: { tag: TagRepr::BASE,
|
||||
created_by_user: UserRepr::BASE,
|
||||
@@ -13,7 +14,7 @@ module MaterialRepr
|
||||
|
||||
def base material, host:
|
||||
material.as_json(BASE).merge(
|
||||
file: if material.file.attached? && !material.file_suppressed?
|
||||
file: if material.file.attached?
|
||||
Rails.application.routes.url_helpers.rails_storage_proxy_url(
|
||||
material.file, host:)
|
||||
end,
|
||||
@@ -34,6 +35,11 @@ module MaterialRepr
|
||||
{ id: material.id,
|
||||
version_no: material.version_no,
|
||||
url: material.url,
|
||||
source_kind: material.source_kind,
|
||||
source_uri: material.source_uri,
|
||||
source_path: material.source_path,
|
||||
source_file_id: material.source_file_id,
|
||||
normalized_source_key: material.normalized_source_key,
|
||||
tag: compact_tag(material.tag),
|
||||
thumbnail: thumbnail_url(material, host:),
|
||||
thumbnail_fallback_text: thumbnail_fallback_text(material),
|
||||
@@ -41,7 +47,6 @@ module MaterialRepr
|
||||
media_kind: media_kind(material),
|
||||
content_type: material.content_type,
|
||||
file_byte_size: material.file_byte_size,
|
||||
file_suppressed_at: material.file_suppressed_at,
|
||||
created_at: material.created_at,
|
||||
updated_at: material.updated_at,
|
||||
export_paths: export_paths(material),
|
||||
@@ -68,7 +73,6 @@ module MaterialRepr
|
||||
end
|
||||
|
||||
def thumbnail_url material, host:
|
||||
return nil if material.file_suppressed?
|
||||
return nil unless material.thumbnail.attached?
|
||||
|
||||
Rails.application.routes.url_helpers.rails_storage_proxy_url(
|
||||
@@ -84,7 +88,6 @@ module MaterialRepr
|
||||
end
|
||||
|
||||
def media_kind material
|
||||
return 'suppressed' if material.file_suppressed?
|
||||
return 'url_only' unless material.file.attached?
|
||||
|
||||
content_type = material.file.blob.content_type.to_s
|
||||
|
||||
新しい課題から参照
ユーザをブロックする