This commit is contained in:
Tianwei Dong 2024-04-26 18:07:04 +00:00 committed by GitHub
commit d02101d173
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 8 additions and 4 deletions

View File

@ -10,10 +10,10 @@ const mapStateToProps = state => {
const pendingAttachmentsSize = state.getIn(['compose', 'pending_media_attachments']).size ?? 0;
const attachmentsSize = readyAttachmentsSize + pendingAttachmentsSize;
const isOverLimit = attachmentsSize > 3;
const allowMixMedia = state.getIn(['server', 'server', 'configuration', 'media_attachments', 'allow_mix_media'], false);
const hasVideoOrAudio = state.getIn(['compose', 'media_attachments']).some(m => ['video', 'audio'].includes(m.get('type')));
return {
disabled: isPoll || isUploading || isOverLimit || hasVideoOrAudio,
disabled: isPoll || isUploading || isOverLimit || (!allowMixMedia && hasVideoOrAudio),
resetFileKey: state.getIn(['compose', 'resetFileKey']),
};
};

View File

@ -39,6 +39,8 @@ class MediaAttachment < ApplicationRecord
MAX_DESCRIPTION_LENGTH = 1_500
ALLOW_MIX_MEDIA = false
IMAGE_LIMIT = 16.megabytes
VIDEO_LIMIT = 99.megabytes

View File

@ -70,6 +70,7 @@ class REST::InstanceSerializer < ActiveModel::Serializer
video_size_limit: MediaAttachment::VIDEO_LIMIT,
video_frame_rate_limit: MediaAttachment::MAX_VIDEO_FRAME_RATE,
video_matrix_limit: MediaAttachment::MAX_VIDEO_MATRIX_LIMIT,
allow_mix_media: MediaAttachment::ALLOW_MIX_MEDIA,
},
polls: {

View File

@ -75,6 +75,7 @@ class REST::V1::InstanceSerializer < ActiveModel::Serializer
video_size_limit: MediaAttachment::VIDEO_LIMIT,
video_frame_rate_limit: MediaAttachment::MAX_VIDEO_FRAME_RATE,
video_matrix_limit: MediaAttachment::MAX_VIDEO_MATRIX_LIMIT,
allow_mix_media: MediaAttachment::ALLOW_MIX_MEDIA,
},
polls: {

View File

@ -134,7 +134,7 @@ class PostStatusService < BaseService
@media = @account.media_attachments.where(status_id: nil).where(id: @options[:media_ids].take(4).map(&:to_i))
raise Mastodon::ValidationError, I18n.t('media_attachments.validations.images_and_video') if @media.size > 1 && @media.find(&:audio_or_video?)
raise Mastodon::ValidationError, I18n.t('media_attachments.validations.images_and_video') if !MediaAttachment::ALLOW_MIX_MEDIA && (@media.size > 1 && @media.find(&:audio_or_video?))
raise Mastodon::ValidationError, I18n.t('media_attachments.validations.not_ready') if @media.any?(&:not_processed?)
end

View File

@ -73,7 +73,7 @@ class UpdateStatusService < BaseService
media_attachments = @status.account.media_attachments.where(status_id: [nil, @status.id]).where(scheduled_status_id: nil).where(id: @options[:media_ids].take(4).map(&:to_i)).to_a
raise Mastodon::ValidationError, I18n.t('media_attachments.validations.images_and_video') if media_attachments.size > 1 && media_attachments.find(&:audio_or_video?)
raise Mastodon::ValidationError, I18n.t('media_attachments.validations.images_and_video') if !MediaAttachment::ALLOW_MIX_MEDIA && (media_attachments.size > 1 && media_attachments.find(&:audio_or_video?))
raise Mastodon::ValidationError, I18n.t('media_attachments.validations.not_ready') if media_attachments.any?(&:not_processed?)
media_attachments