mirror of
https://github.com/mastodon/mastodon.git
synced 2025-01-08 19:35:11 +01:00
[Add] Add flag indicating allowing mix media types
This commit is contained in:
parent
3a7aec2807
commit
bd764b2424
@ -10,10 +10,10 @@ const mapStateToProps = state => {
|
|||||||
const pendingAttachmentsSize = state.getIn(['compose', 'pending_media_attachments']).size ?? 0;
|
const pendingAttachmentsSize = state.getIn(['compose', 'pending_media_attachments']).size ?? 0;
|
||||||
const attachmentsSize = readyAttachmentsSize + pendingAttachmentsSize;
|
const attachmentsSize = readyAttachmentsSize + pendingAttachmentsSize;
|
||||||
const isOverLimit = attachmentsSize > 3;
|
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')));
|
const hasVideoOrAudio = state.getIn(['compose', 'media_attachments']).some(m => ['video', 'audio'].includes(m.get('type')));
|
||||||
|
|
||||||
return {
|
return {
|
||||||
disabled: isPoll || isUploading || isOverLimit || hasVideoOrAudio,
|
disabled: isPoll || isUploading || isOverLimit || (!allowMixMedia && hasVideoOrAudio),
|
||||||
resetFileKey: state.getIn(['compose', 'resetFileKey']),
|
resetFileKey: state.getIn(['compose', 'resetFileKey']),
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
@ -39,6 +39,8 @@ class MediaAttachment < ApplicationRecord
|
|||||||
|
|
||||||
MAX_DESCRIPTION_LENGTH = 1_500
|
MAX_DESCRIPTION_LENGTH = 1_500
|
||||||
|
|
||||||
|
ALLOW_MIX_MEDIA = false
|
||||||
|
|
||||||
IMAGE_LIMIT = 16.megabytes
|
IMAGE_LIMIT = 16.megabytes
|
||||||
VIDEO_LIMIT = 99.megabytes
|
VIDEO_LIMIT = 99.megabytes
|
||||||
|
|
||||||
|
@ -70,6 +70,7 @@ class REST::InstanceSerializer < ActiveModel::Serializer
|
|||||||
video_size_limit: MediaAttachment::VIDEO_LIMIT,
|
video_size_limit: MediaAttachment::VIDEO_LIMIT,
|
||||||
video_frame_rate_limit: MediaAttachment::MAX_VIDEO_FRAME_RATE,
|
video_frame_rate_limit: MediaAttachment::MAX_VIDEO_FRAME_RATE,
|
||||||
video_matrix_limit: MediaAttachment::MAX_VIDEO_MATRIX_LIMIT,
|
video_matrix_limit: MediaAttachment::MAX_VIDEO_MATRIX_LIMIT,
|
||||||
|
allow_mix_media: MediaAttachment::ALLOW_MIX_MEDIA,
|
||||||
},
|
},
|
||||||
|
|
||||||
polls: {
|
polls: {
|
||||||
|
@ -75,6 +75,7 @@ class REST::V1::InstanceSerializer < ActiveModel::Serializer
|
|||||||
video_size_limit: MediaAttachment::VIDEO_LIMIT,
|
video_size_limit: MediaAttachment::VIDEO_LIMIT,
|
||||||
video_frame_rate_limit: MediaAttachment::MAX_VIDEO_FRAME_RATE,
|
video_frame_rate_limit: MediaAttachment::MAX_VIDEO_FRAME_RATE,
|
||||||
video_matrix_limit: MediaAttachment::MAX_VIDEO_MATRIX_LIMIT,
|
video_matrix_limit: MediaAttachment::MAX_VIDEO_MATRIX_LIMIT,
|
||||||
|
allow_mix_media: MediaAttachment::ALLOW_MIX_MEDIA,
|
||||||
},
|
},
|
||||||
|
|
||||||
polls: {
|
polls: {
|
||||||
|
@ -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))
|
@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?)
|
raise Mastodon::ValidationError, I18n.t('media_attachments.validations.not_ready') if @media.any?(&:not_processed?)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -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
|
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?)
|
raise Mastodon::ValidationError, I18n.t('media_attachments.validations.not_ready') if media_attachments.any?(&:not_processed?)
|
||||||
|
|
||||||
media_attachments
|
media_attachments
|
||||||
|
Loading…
Reference in New Issue
Block a user