Increase toot length limit to 16384 when a CW is used

master
noiob 2019-10-21 22:26:01 +02:00
parent edc31ca4a6
commit f12bbf6948
3 changed files with 11 additions and 3 deletions

View File

@ -7,10 +7,14 @@ export default class CharacterCounter extends React.PureComponent {
static propTypes = {
text: PropTypes.string.isRequired,
max: PropTypes.number.isRequired,
no_limit: PropTypes.bool.isRequired,
};
checkRemainingText (diff) {
if (diff < 0) {
if (this.props.no_limit) {
return <span className='character-counter'></span>;
}
else if (diff < 0) {
return <span className='character-counter character-counter--over'>{diff}</span>;
}

View File

@ -294,7 +294,8 @@ class ComposeForm extends ImmutablePureComponent {
let disabledButton = isSubmitting || isUploading || isChangingUpload || (!text.trim().length && !anyMedia);
const countText = `${spoilerText}${countableText(text)}${advancedOptions && advancedOptions.get('do_not_federate') ? ' 🐺' : ''}`;
const countText=spoilerText ? '∞' : `${spoilerText}${countableText(text)}${advancedOptions && advancedOptions.get('do_not_federate') ? ' 🐺': ''}`;
const no_limit = spoilerText != '';
return (
<div className='composer'>
@ -357,7 +358,7 @@ class ComposeForm extends ImmutablePureComponent {
spoiler={spoilersAlwaysOn ? (spoilerText && spoilerText.length > 0) : spoiler}
/>
<div className='compose--counter-wrapper'>
<CharacterCounter text={countText} max={maxChars} />
<CharacterCounter text={countText} max={maxChars} no_limit={no_limit} />
</div>
</div>

View File

@ -4,6 +4,9 @@ class StatusLengthValidator < ActiveModel::Validator
MAX_CHARS = (ENV['MAX_TOOT_CHARS'] || 500).to_i
def validate(status)
status.errors.add(:text, "hard limit of 16k exceeded") if status.text.length > 16384
status.errors.add(:text, "CW can't be longer than 500 characters") if status.spoiler_text.length > 500
return unless status.spoiler_text.blank?
return unless status.local? && !status.reblog?
@status = status