fixup! Change the API call limit from 600 to 1200
This commit is contained in:
parent
a7137add9f
commit
90b9f8100e
8 changed files with 27 additions and 7 deletions
|
@ -36,6 +36,7 @@ class Form::AdminSettings
|
|||
noindex
|
||||
require_invite_text
|
||||
allow_poll_image
|
||||
poll_max_options
|
||||
).freeze
|
||||
|
||||
BOOLEAN_KEYS = %i(
|
||||
|
@ -55,6 +56,10 @@ class Form::AdminSettings
|
|||
allow_poll_image
|
||||
).freeze
|
||||
|
||||
INTEGER_KEYS = %i(
|
||||
poll_max_options
|
||||
).freeze
|
||||
|
||||
UPLOAD_KEYS = %i(
|
||||
thumbnail
|
||||
hero
|
||||
|
@ -72,6 +77,7 @@ class Form::AdminSettings
|
|||
validates :bootstrap_timeline_accounts, existing_username: { multiple: true }
|
||||
validates :show_domain_blocks, inclusion: { in: %w(disabled users all) }
|
||||
validates :show_domain_blocks_rationale, inclusion: { in: %w(disabled users all) }
|
||||
validates :poll_max_options, numericality: { greater_than: 2, less_than_or_equal_to: PollValidator::MAX_OPTIONS_LIMIT }
|
||||
|
||||
def initialize(_attributes = {})
|
||||
super
|
||||
|
@ -105,6 +111,8 @@ class Form::AdminSettings
|
|||
def typecast_value(key, value)
|
||||
if BOOLEAN_KEYS.include?(key)
|
||||
value == '1'
|
||||
elsif INTEGER_KEYS.include?(key)
|
||||
Integer(value)
|
||||
else
|
||||
value
|
||||
end
|
||||
|
|
|
@ -120,7 +120,7 @@ class InitialStateSerializer < ActiveModel::Serializer
|
|||
store[:default_expires_action] = object.current_account.user.setting_default_expires_action
|
||||
store[:prohibited_visibilities] = object.current_account.user.setting_prohibited_visibilities.filter(&:present?)
|
||||
store[:prohibited_words] = (object.current_account.user.setting_prohibited_words || '').split(',').map(&:strip).filter(&:present?)
|
||||
store[:poll_max_options] = PollValidator::MAX_OPTIONS
|
||||
store[:poll_max_options] = [PollValidator::MAX_OPTIONS, Setting.poll_max_options].max
|
||||
end
|
||||
|
||||
store[:text] = object.text if object.text
|
||||
|
|
|
@ -85,7 +85,7 @@ class REST::InstanceSerializer < ActiveModel::Serializer
|
|||
},
|
||||
|
||||
polls: {
|
||||
max_options: PollValidator::MAX_OPTIONS,
|
||||
max_options: [PollValidator::MAX_OPTIONS, Setting.poll_max_options].max,
|
||||
max_characters_per_option: PollValidator::MAX_OPTION_CHARS,
|
||||
min_expiration: PollValidator::MIN_EXPIRATION,
|
||||
max_expiration: PollValidator::MAX_EXPIRATION,
|
||||
|
|
|
@ -1,16 +1,18 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class PollValidator < ActiveModel::Validator
|
||||
MAX_OPTIONS = 10
|
||||
MAX_OPTIONS = 4
|
||||
MAX_OPTIONS_LIMIT = 20
|
||||
MAX_OPTION_CHARS = 50
|
||||
MAX_EXPIRATION = 1.month.freeze
|
||||
MIN_EXPIRATION = 5.minutes.freeze
|
||||
|
||||
def validate(poll)
|
||||
current_time = Time.now.utc
|
||||
max_options = [MAX_OPTIONS, Setting.poll_max_options].max
|
||||
|
||||
poll.errors.add(:options, I18n.t('polls.errors.too_few_options')) unless poll.options.size > 1
|
||||
poll.errors.add(:options, I18n.t('polls.errors.too_many_options', max: MAX_OPTIONS)) if poll.options.size > MAX_OPTIONS
|
||||
poll.errors.add(:options, I18n.t('polls.errors.too_many_options', max: max_options)) if poll.options.size > max_options
|
||||
poll.errors.add(:options, I18n.t('polls.errors.over_character_limit', max: MAX_OPTION_CHARS)) if poll.options.any? { |option| option.mb_chars.grapheme_length > MAX_OPTION_CHARS }
|
||||
poll.errors.add(:options, I18n.t('polls.errors.duplicate_options')) unless poll.options.uniq.size == poll.options.size
|
||||
poll.errors.add(:expires_at, I18n.t('polls.errors.duration_too_long')) if poll.expires_at.nil? || poll.expires_at - current_time > MAX_EXPIRATION
|
||||
|
|
|
@ -95,6 +95,9 @@
|
|||
.fields-group
|
||||
= f.input :allow_poll_image, as: :boolean, wrapper: :with_label, label: t('admin.settings.allow_poll_image.title'), hint: t('admin.settings.allow_poll_image.desc_html'), fedibird_features: true
|
||||
|
||||
.fields-group
|
||||
= f.input :poll_max_options, wrapper: :with_label, label: t('admin.settings.poll_max_options.title'), hint: t('admin.settings.poll_max_options.desc_html', count: PollValidator::MAX_OPTIONS_LIMIT), fedibird_features: true
|
||||
|
||||
%hr.spacer/
|
||||
|
||||
.fields-group
|
||||
|
|
|
@ -658,6 +658,9 @@ en:
|
|||
peers_api_enabled:
|
||||
desc_html: Domain names this server has encountered in the fediverse
|
||||
title: Publish list of discovered servers in the API
|
||||
poll_max_options:
|
||||
desc_html: "Specifies the maximum number of polls (<= %{count})"
|
||||
title: Maximum number of Polls
|
||||
preview_sensitive_media:
|
||||
desc_html: Link previews on other websites will display a thumbnail even if the media is marked as sensitive
|
||||
title: Show sensitive media in OpenGraph previews
|
||||
|
|
|
@ -637,6 +637,9 @@ ja:
|
|||
peers_api_enabled:
|
||||
desc_html: 連合内でこのサーバーが遭遇したドメインの名前
|
||||
title: 接続しているサーバーのリストを公開する
|
||||
poll_max_options:
|
||||
desc_html: "投票の選択肢の最大数(%{count}以下)を指定します。"
|
||||
title: 投票の選択肢の最大数
|
||||
preview_sensitive_media:
|
||||
desc_html: 他のウェブサイトにリンクを貼った際、メディアが閲覧注意としてマークされていてもサムネイルが表示されます
|
||||
title: OpenGraphによるプレビューで閲覧注意のメディアも表示する
|
||||
|
|
|
@ -139,6 +139,7 @@ defaults: &defaults
|
|||
hide_photo_preview: false
|
||||
hide_video_preview: false
|
||||
allow_poll_image: false
|
||||
poll_max_options: 4
|
||||
|
||||
development:
|
||||
<<: *defaults
|
||||
|
|
Loading…
Reference in a new issue