mirror of
https://github.com/mastodon/mastodon.git
synced 2025-07-12 23:43:23 +00:00
Compare commits
4 Commits
5cc6877964
...
814e75a427
Author | SHA1 | Date | |
---|---|---|---|
![]() |
814e75a427 | ||
![]() |
8c2d4af789 | ||
![]() |
703d98bc46 | ||
![]() |
bd764b2424 |
|
@ -9,11 +9,11 @@ const mapStateToProps = state => {
|
|||
const readyAttachmentsSize = state.getIn(['compose', 'media_attachments']).size ?? 0;
|
||||
const pendingAttachmentsSize = state.getIn(['compose', 'pending_media_attachments']).size ?? 0;
|
||||
const attachmentsSize = readyAttachmentsSize + pendingAttachmentsSize;
|
||||
const allowMixMedia = state.getIn(['server', 'server', 'configuration', 'media_attachments', 'allow_mix_media'], false);
|
||||
const isOverLimit = attachmentsSize > state.getIn(['server', 'server', 'configuration', 'statuses', 'max_media_attachments'])-1;
|
||||
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']),
|
||||
};
|
||||
};
|
||||
|
|
|
@ -39,6 +39,8 @@ class MediaAttachment < ApplicationRecord
|
|||
|
||||
MAX_DESCRIPTION_LENGTH = 1_500
|
||||
|
||||
ALLOW_MIX_MEDIA = false
|
||||
|
||||
IMAGE_LIMIT = 16.megabytes
|
||||
VIDEO_LIMIT = 99.megabytes
|
||||
|
||||
|
|
|
@ -87,6 +87,7 @@ class REST::InstanceSerializer < ActiveModel::Serializer
|
|||
video_frame_rate_limit: MediaAttachment::MAX_VIDEO_FRAME_RATE,
|
||||
video_matrix_limit: MediaAttachment::MAX_VIDEO_MATRIX_LIMIT,
|
||||
video_size_limit: MediaAttachment::VIDEO_LIMIT,
|
||||
allow_mix_media: MediaAttachment::ALLOW_MIX_MEDIA,
|
||||
},
|
||||
|
||||
polls: {
|
||||
|
|
|
@ -67,6 +67,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: {
|
||||
|
|
|
@ -161,7 +161,7 @@ class PostStatusService < BaseService
|
|||
not_found_ids = @options[:media_ids].map(&:to_i) - @media.map(&:id)
|
||||
raise Mastodon::ValidationError, I18n.t('media_attachments.validations.not_found', ids: not_found_ids.join(', ')) if not_found_ids.any?
|
||||
|
||||
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
|
||||
|
||||
|
|
|
@ -76,7 +76,7 @@ class UpdateStatusService < BaseService
|
|||
not_found_ids = @options[:media_ids].map(&:to_i) - media_attachments.map(&:id)
|
||||
raise Mastodon::ValidationError, I18n.t('media_attachments.validations.not_found', ids: not_found_ids.join(', ')) if not_found_ids.any?
|
||||
|
||||
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
|
||||
|
|
Loading…
Reference in New Issue
Block a user