mirror of
https://git.kescher.at/CatCatNya/catstodon.git
synced 2024-11-22 12:58:06 +01:00
Add env variable support for number of followable hashtags in feed column (#2500)
* Add env variable support for number of followable hashtags in feed column. * Add a note about performance concerns for higher values. See discussion in https://github.com/glitch-soc/mastodon/pull/2500 * Update .devcontainer/docker-compose.yml --------- Co-authored-by: Claire <claire.github-309c@sitedethib.com>
This commit is contained in:
parent
08e511cecb
commit
541cbdd963
5 changed files with 18 additions and 5 deletions
|
@ -251,6 +251,11 @@ SMTP_FROM_ADDRESS=notifications@example.com
|
||||||
# Maximum allowed character count
|
# Maximum allowed character count
|
||||||
MAX_TOOT_CHARS=500
|
MAX_TOOT_CHARS=500
|
||||||
|
|
||||||
|
# Maximum allowed hashtags to follow in a feed column
|
||||||
|
# Note that setting this value higher may cause significant
|
||||||
|
# database load
|
||||||
|
MAX_FEED_HASHTAGS=4
|
||||||
|
|
||||||
# Maximum number of pinned posts
|
# Maximum number of pinned posts
|
||||||
MAX_PINNED_TOOTS=5
|
MAX_PINNED_TOOTS=5
|
||||||
|
|
||||||
|
|
|
@ -9,6 +9,8 @@ import { NonceProvider } from 'react-select';
|
||||||
import AsyncSelect from 'react-select/async';
|
import AsyncSelect from 'react-select/async';
|
||||||
import Toggle from 'react-toggle';
|
import Toggle from 'react-toggle';
|
||||||
|
|
||||||
|
import { maxFeedHashtags } from 'flavours/glitch/initial_state';
|
||||||
|
|
||||||
import SettingToggle from '../../notifications/components/setting_toggle';
|
import SettingToggle from '../../notifications/components/setting_toggle';
|
||||||
|
|
||||||
const messages = defineMessages({
|
const messages = defineMessages({
|
||||||
|
@ -46,9 +48,9 @@ class ColumnSettings extends PureComponent {
|
||||||
onSelect = mode => value => {
|
onSelect = mode => value => {
|
||||||
const oldValue = this.tags(mode);
|
const oldValue = this.tags(mode);
|
||||||
|
|
||||||
// Prevent changes that add more than 4 tags, but allow removing
|
// Prevent changes that add more than the number of configured
|
||||||
// tags that were already added before
|
// tags, but allow removing tags that were already added before
|
||||||
if ((value.length > 4) && !(value < oldValue)) {
|
if ((value.length > maxFeedHashtags) && !(value < oldValue)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -67,6 +67,7 @@ export const hasMultiColumnPath = initialPath === '/'
|
||||||
* @property {InitialStateMeta} meta
|
* @property {InitialStateMeta} meta
|
||||||
* @property {object} local_settings
|
* @property {object} local_settings
|
||||||
* @property {number} max_toot_chars
|
* @property {number} max_toot_chars
|
||||||
|
* @property {number} max_feed_hashtags
|
||||||
* @property {number} poll_limits
|
* @property {number} poll_limits
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -130,6 +131,7 @@ export const sso_redirect = getMeta('sso_redirect');
|
||||||
|
|
||||||
// Glitch-soc-specific settings
|
// Glitch-soc-specific settings
|
||||||
export const maxChars = (initialState && initialState.max_toot_chars) || 500;
|
export const maxChars = (initialState && initialState.max_toot_chars) || 500;
|
||||||
|
export const maxFeedHashtags = (initialState && initialState.max_feed_hashtags) || 4;
|
||||||
export const favouriteModal = getMeta('favourite_modal');
|
export const favouriteModal = getMeta('favourite_modal');
|
||||||
export const pollLimits = (initialState && initialState.poll_limits);
|
export const pollLimits = (initialState && initialState.poll_limits);
|
||||||
export const defaultContentType = getMeta('default_content_type');
|
export const defaultContentType = getMeta('default_content_type');
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
class TagFeed < PublicFeed
|
class TagFeed < PublicFeed
|
||||||
LIMIT_PER_MODE = 4
|
LIMIT_PER_MODE = (ENV['MAX_FEED_HASHTAGS'] || 4).to_i
|
||||||
|
|
||||||
# @param [Tag] tag
|
# @param [Tag] tag
|
||||||
# @param [Account] account
|
# @param [Account] account
|
||||||
|
|
|
@ -5,7 +5,7 @@ class InitialStateSerializer < ActiveModel::Serializer
|
||||||
|
|
||||||
attributes :meta, :compose, :accounts,
|
attributes :meta, :compose, :accounts,
|
||||||
:media_attachments, :settings,
|
:media_attachments, :settings,
|
||||||
:max_toot_chars, :poll_limits,
|
:max_toot_chars, :max_feed_hashtags, :poll_limits,
|
||||||
:languages
|
:languages
|
||||||
|
|
||||||
attribute :critical_updates_pending, if: -> { object&.role&.can?(:view_devops) && SoftwareUpdate.check_enabled? }
|
attribute :critical_updates_pending, if: -> { object&.role&.can?(:view_devops) && SoftwareUpdate.check_enabled? }
|
||||||
|
@ -17,6 +17,10 @@ class InitialStateSerializer < ActiveModel::Serializer
|
||||||
StatusLengthValidator::MAX_CHARS
|
StatusLengthValidator::MAX_CHARS
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def max_feed_hashtags
|
||||||
|
TagFeed::LIMIT_PER_MODE
|
||||||
|
end
|
||||||
|
|
||||||
def poll_limits
|
def poll_limits
|
||||||
{
|
{
|
||||||
max_options: PollValidator::MAX_OPTIONS,
|
max_options: PollValidator::MAX_OPTIONS,
|
||||||
|
|
Loading…
Reference in a new issue