Remove extra media attachments and support raw array
This commit is contained in:
parent
51cac0760f
commit
57c15e0d7f
6 changed files with 4 additions and 17 deletions
|
@ -70,10 +70,6 @@ export function normalizeStatus(status, normalOldStatus) {
|
||||||
normalStatus.emoji_reactions = normalizeEmojiReactions(status.emoji_reactions);
|
normalStatus.emoji_reactions = normalizeEmojiReactions(status.emoji_reactions);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (status.media_attachments_ex) {
|
|
||||||
normalStatus.media_attachments = status.media_attachments.concat(status.media_attachments_ex);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!status.visibility_ex) {
|
if (!status.visibility_ex) {
|
||||||
normalStatus.visibility_ex = status.visibility;
|
normalStatus.visibility_ex = status.visibility;
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,7 +36,7 @@ class MediaAttachment < ApplicationRecord
|
||||||
include RoutingHelper
|
include RoutingHelper
|
||||||
|
|
||||||
LOCAL_STATUS_ATTACHMENT_MAX = 4
|
LOCAL_STATUS_ATTACHMENT_MAX = 4
|
||||||
ACTIVITYPUB_STATUS_ATTACHMENT_MAX = 8
|
ACTIVITYPUB_STATUS_ATTACHMENT_MAX = 16
|
||||||
|
|
||||||
enum type: { :image => 0, :gifv => 1, :video => 2, :unknown => 3, :audio => 4 }
|
enum type: { :image => 0, :gifv => 1, :video => 2, :unknown => 3, :audio => 4 }
|
||||||
enum processing: { :queued => 0, :in_progress => 1, :complete => 2, :failed => 3 }, _prefix: true
|
enum processing: { :queued => 0, :in_progress => 1, :complete => 2, :failed => 3 }, _prefix: true
|
||||||
|
|
|
@ -291,14 +291,6 @@ class Status < ApplicationRecord
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def ordered_media_attachments_original_mastodon
|
|
||||||
ordered_media_attachments.take(4)
|
|
||||||
end
|
|
||||||
|
|
||||||
def ordered_media_attachments_extra
|
|
||||||
ordered_media_attachments.drop(4).take(4)
|
|
||||||
end
|
|
||||||
|
|
||||||
def replies_count
|
def replies_count
|
||||||
status_stat&.replies_count || 0
|
status_stat&.replies_count || 0
|
||||||
end
|
end
|
||||||
|
|
|
@ -55,6 +55,7 @@ class REST::InstanceSerializer < ActiveModel::Serializer
|
||||||
statuses: {
|
statuses: {
|
||||||
max_characters: StatusLengthValidator::MAX_CHARS,
|
max_characters: StatusLengthValidator::MAX_CHARS,
|
||||||
max_media_attachments: MediaAttachment::LOCAL_STATUS_ATTACHMENT_MAX,
|
max_media_attachments: MediaAttachment::LOCAL_STATUS_ATTACHMENT_MAX,
|
||||||
|
max_media_attachments_from_activitypub: MediaAttachment::ACTIVITYPUB_STATUS_ATTACHMENT_MAX,
|
||||||
characters_reserved_per_url: StatusLengthValidator::URL_PLACEHOLDER_CHARS,
|
characters_reserved_per_url: StatusLengthValidator::URL_PLACEHOLDER_CHARS,
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -97,7 +98,6 @@ class REST::InstanceSerializer < ActiveModel::Serializer
|
||||||
def fedibird_capabilities
|
def fedibird_capabilities
|
||||||
capabilities = [
|
capabilities = [
|
||||||
:emoji_reaction,
|
:emoji_reaction,
|
||||||
:kmyblue_extra_media_attachments,
|
|
||||||
:kmyblue_visibility_public_unlisted,
|
:kmyblue_visibility_public_unlisted,
|
||||||
:enable_wide_emoji,
|
:enable_wide_emoji,
|
||||||
:enable_wide_emoji_reaction,
|
:enable_wide_emoji_reaction,
|
||||||
|
|
|
@ -22,8 +22,7 @@ class REST::StatusSerializer < ActiveModel::Serializer
|
||||||
belongs_to :application, if: :show_application?
|
belongs_to :application, if: :show_application?
|
||||||
belongs_to :account, serializer: REST::AccountSerializer
|
belongs_to :account, serializer: REST::AccountSerializer
|
||||||
|
|
||||||
has_many :ordered_media_attachments_original_mastodon, key: :media_attachments, serializer: REST::MediaAttachmentSerializer
|
has_many :ordered_media_attachments, key: :media_attachments, serializer: REST::MediaAttachmentSerializer
|
||||||
has_many :ordered_media_attachments_extra, key: :media_attachments_ex, serializer: REST::MediaAttachmentSerializer
|
|
||||||
has_many :ordered_mentions, key: :mentions
|
has_many :ordered_mentions, key: :mentions
|
||||||
has_many :tags
|
has_many :tags
|
||||||
has_many :emojis, serializer: REST::CustomEmojiSerializer
|
has_many :emojis, serializer: REST::CustomEmojiSerializer
|
||||||
|
|
|
@ -65,6 +65,7 @@ class REST::V1::InstanceSerializer < ActiveModel::Serializer
|
||||||
statuses: {
|
statuses: {
|
||||||
max_characters: StatusLengthValidator::MAX_CHARS,
|
max_characters: StatusLengthValidator::MAX_CHARS,
|
||||||
max_media_attachments: MediaAttachment::LOCAL_STATUS_ATTACHMENT_MAX,
|
max_media_attachments: MediaAttachment::LOCAL_STATUS_ATTACHMENT_MAX,
|
||||||
|
max_media_attachments_from_activitypub: MediaAttachment::ACTIVITYPUB_STATUS_ATTACHMENT_MAX,
|
||||||
characters_reserved_per_url: StatusLengthValidator::URL_PLACEHOLDER_CHARS,
|
characters_reserved_per_url: StatusLengthValidator::URL_PLACEHOLDER_CHARS,
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -107,7 +108,6 @@ class REST::V1::InstanceSerializer < ActiveModel::Serializer
|
||||||
def fedibird_capabilities
|
def fedibird_capabilities
|
||||||
capabilities = [
|
capabilities = [
|
||||||
:emoji_reaction,
|
:emoji_reaction,
|
||||||
:kmyblue_extra_media_attachments,
|
|
||||||
:kmyblue_visibility_public_unlisted,
|
:kmyblue_visibility_public_unlisted,
|
||||||
:enable_wide_emoji,
|
:enable_wide_emoji,
|
||||||
:enable_wide_emoji_reaction,
|
:enable_wide_emoji_reaction,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue