diff --git a/.env.production.sample b/.env.production.sample
index f9a8bb7c1..8a679044e 100644
--- a/.env.production.sample
+++ b/.env.production.sample
@@ -169,6 +169,9 @@ STREAMING_CLUSTER_NUM=1
# UID=1000
# GID=1000
+# Maximum allowed character count
+# MAX_TOOT_CHARS=500
+
# LDAP authentication (optional)
# LDAP_ENABLED=true
# LDAP_HOST=localhost
diff --git a/app/javascript/mastodon/features/compose/components/compose_form.js b/app/javascript/mastodon/features/compose/components/compose_form.js
index 6da6bdb78..2c8909839 100644
--- a/app/javascript/mastodon/features/compose/components/compose_form.js
+++ b/app/javascript/mastodon/features/compose/components/compose_form.js
@@ -21,6 +21,7 @@ import ImmutablePureComponent from 'react-immutable-pure-component';
import { length } from 'stringz';
import { countableText } from '../util/counter';
import Icon from 'mastodon/components/icon';
+import { maxChars } from '../../../initial_state';
const allowedAroundShortCode = '><\u0085\u0020\u00a0\u1680\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000\u2028\u2029\u0009\u000a\u000b\u000c\u000d';
@@ -90,7 +91,7 @@ class ComposeForm extends ImmutablePureComponent {
const { isSubmitting, isChangingUpload, isUploading, anyMedia } = this.props;
const fulltext = [this.props.spoilerText, countableText(this.props.text)].join('');
- if (isSubmitting || isUploading || isChangingUpload || length(fulltext) > 500 || (fulltext.length !== 0 && fulltext.trim().length === 0 && !anyMedia)) {
+ if (isSubmitting || isUploading || isChangingUpload || length(fulltext) > maxChars || (fulltext.length !== 0 && fulltext.trim().length === 0 && !anyMedia)) {
return;
}
@@ -183,7 +184,7 @@ class ComposeForm extends ImmutablePureComponent {
const { intl, onPaste, showSearch, anyMedia } = this.props;
const disabled = this.props.isSubmitting;
const text = [this.props.spoilerText, countableText(this.props.text)].join('');
- const disabledButton = disabled || this.props.isUploading || this.props.isChangingUpload || length(text) > 500 || (text.length !== 0 && text.trim().length === 0 && !anyMedia);
+ const disabledButton = disabled || this.props.isUploading || this.props.isChangingUpload || length(text) > maxChars || (text.length !== 0 && text.trim().length === 0 && !anyMedia);
let publishText = '';
if (this.props.privacy === 'private' || this.props.privacy === 'direct') {
@@ -246,7 +247,7 @@ class ComposeForm extends ImmutablePureComponent {
-
+
diff --git a/app/javascript/mastodon/initial_state.js b/app/javascript/mastodon/initial_state.js
index 56fb58546..deebe1815 100644
--- a/app/javascript/mastodon/initial_state.js
+++ b/app/javascript/mastodon/initial_state.js
@@ -12,6 +12,7 @@ export const boostModal = getMeta('boost_modal');
export const deleteModal = getMeta('delete_modal');
export const me = getMeta('me');
export const searchEnabled = getMeta('search_enabled');
+export const maxChars = (initialState && initialState.max_toot_chars) || 500;
export const invitesEnabled = getMeta('invites_enabled');
export const repository = getMeta('repository');
export const source_url = getMeta('source_url');
diff --git a/app/serializers/initial_state_serializer.rb b/app/serializers/initial_state_serializer.rb
index e5c43bd7b..ef65ff362 100644
--- a/app/serializers/initial_state_serializer.rb
+++ b/app/serializers/initial_state_serializer.rb
@@ -2,10 +2,15 @@
class InitialStateSerializer < ActiveModel::Serializer
attributes :meta, :compose, :accounts,
- :media_attachments, :settings
+ :media_attachments, :settings,
+ :max_toot_chars
has_one :push_subscription, serializer: REST::WebPushSubscriptionSerializer
+ def max_toot_chars
+ StatusLengthValidator::MAX_CHARS
+ end
+
def meta
store = {
streaming_api_base_url: Rails.configuration.x.streaming_api_base_url,
diff --git a/app/serializers/rest/instance_serializer.rb b/app/serializers/rest/instance_serializer.rb
index 1bd71683c..3fc251a5a 100644
--- a/app/serializers/rest/instance_serializer.rb
+++ b/app/serializers/rest/instance_serializer.rb
@@ -4,7 +4,7 @@ class REST::InstanceSerializer < ActiveModel::Serializer
include RoutingHelper
attributes :uri, :title, :short_description, :description, :email,
- :version, :urls, :stats, :thumbnail,
+ :version, :urls, :stats, :thumbnail, :max_toot_chars,
:languages, :registrations, :approval_required
has_one :contact_account, serializer: REST::AccountSerializer
@@ -39,6 +39,10 @@ class REST::InstanceSerializer < ActiveModel::Serializer
instance_presenter.thumbnail ? full_asset_url(instance_presenter.thumbnail.file.url) : full_pack_url('media/images/preview.jpg')
end
+ def max_toot_chars
+ StatusLengthValidator::MAX_CHARS
+ end
+
def stats
{
user_count: instance_presenter.user_count,
diff --git a/app/validators/status_length_validator.rb b/app/validators/status_length_validator.rb
index 93bae2fa8..92ee5e643 100644
--- a/app/validators/status_length_validator.rb
+++ b/app/validators/status_length_validator.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: true
class StatusLengthValidator < ActiveModel::Validator
- MAX_CHARS = 500
+ MAX_CHARS = (ENV['MAX_TOOT_CHARS'] || 500).to_i
def validate(status)
return unless status.local? && !status.reblog?