Add limits.posts.character_limit configuration parameter
This commit is contained in:
parent
151b068d97
commit
b91e6e77b5
6 changed files with 35 additions and 10 deletions
|
@ -13,6 +13,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
|||
- Added `/api/v1/custom_emojis` endpoint.
|
||||
- Added `limits` parameter group to configuration.
|
||||
- Made file size limit adjustable with `limits.media.file_size_limit` configuration option.
|
||||
- Added `limits.posts.character_limit` configuration parameter (replaces `post_character_limit`).
|
||||
|
||||
### Changed
|
||||
|
||||
|
@ -24,6 +25,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
|||
- Use "warn" log level for delivery errors.
|
||||
- Don't allow read-only users to manage subscriptions.
|
||||
|
||||
### Deprecated
|
||||
|
||||
- Deprecated `post_character_limit` configuration option.
|
||||
|
||||
### Fixed
|
||||
|
||||
- Change max body size in nginx example config to match app limit.
|
||||
|
|
|
@ -25,8 +25,6 @@ registration:
|
|||
# EIP-4361 login message
|
||||
#login_message: 'Do not sign this message on other sites!'
|
||||
|
||||
#post_character_limit: 2000
|
||||
|
||||
# Proxy for outgoing requests
|
||||
#proxy_url: 'socks5h://127.0.0.1:9050'
|
||||
|
||||
|
@ -34,6 +32,8 @@ registration:
|
|||
#limits:
|
||||
# media:
|
||||
# file_size_limit: 20M
|
||||
# posts:
|
||||
# character_limit: 2000
|
||||
|
||||
# List of blocked domains
|
||||
#blocked_instances: []
|
||||
|
|
|
@ -59,10 +59,28 @@ impl Default for MediaLimits {
|
|||
}
|
||||
}
|
||||
|
||||
const fn default_post_character_limit() -> usize { 2000 }
|
||||
|
||||
#[derive(Clone, Deserialize)]
|
||||
pub struct PostLimits {
|
||||
#[serde(default = "default_post_character_limit")]
|
||||
pub character_limit: usize,
|
||||
}
|
||||
|
||||
impl Default for PostLimits {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
character_limit: default_post_character_limit(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Default, Deserialize)]
|
||||
pub struct Limits {
|
||||
#[serde(default)]
|
||||
pub media: MediaLimits,
|
||||
#[serde(default)]
|
||||
pub posts: PostLimits,
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
|
|
@ -113,7 +113,7 @@ pub fn parse_config() -> (Config, Vec<&'static str>) {
|
|||
|
||||
if let Some(registrations_open) = config.registrations_open {
|
||||
// Change type if 'registrations_open' parameter is used
|
||||
warnings.push("'registrations_open' setting is deprecated, use 'registration' instead");
|
||||
warnings.push("'registrations_open' setting is deprecated, use 'registration.type' instead");
|
||||
if registrations_open {
|
||||
config.registration.registration_type = RegistrationType::Open;
|
||||
} else {
|
||||
|
@ -121,6 +121,11 @@ pub fn parse_config() -> (Config, Vec<&'static str>) {
|
|||
};
|
||||
};
|
||||
|
||||
if let Some(post_character_limit) = config.post_character_limit {
|
||||
warnings.push("'post_character_limit' setting is deprecated, use 'limits.posts.character_limit' instead");
|
||||
config.limits.posts.character_limit = post_character_limit;
|
||||
};
|
||||
|
||||
// Insert instance RSA key
|
||||
config.instance_rsa_key = Some(read_instance_rsa_key(&config.storage_dir));
|
||||
|
||||
|
|
|
@ -56,8 +56,6 @@ fn default_log_level() -> LogLevel { LogLevel::Info }
|
|||
|
||||
fn default_login_message() -> String { "Do not sign this message on other sites!".to_string() }
|
||||
|
||||
fn default_post_character_limit() -> usize { 2000 }
|
||||
|
||||
#[derive(Clone, Deserialize)]
|
||||
pub struct Config {
|
||||
// Properties auto-populated from the environment
|
||||
|
@ -99,8 +97,7 @@ pub struct Config {
|
|||
#[serde(default = "default_login_message")]
|
||||
pub login_message: String,
|
||||
|
||||
#[serde(default = "default_post_character_limit")]
|
||||
pub post_character_limit: usize,
|
||||
pub(super) post_character_limit: Option<usize>, // deprecated
|
||||
|
||||
proxy_url: Option<String>,
|
||||
|
||||
|
|
|
@ -74,7 +74,7 @@ pub struct InstanceInfo {
|
|||
configuration: InstanceConfiguration,
|
||||
|
||||
login_message: String,
|
||||
post_character_limit: usize,
|
||||
post_character_limit: usize, // deprecated
|
||||
blockchains: Vec<BlockchainInfo>,
|
||||
ipfs_gateway_url: Option<String>,
|
||||
}
|
||||
|
@ -158,7 +158,7 @@ impl InstanceInfo {
|
|||
},
|
||||
configuration: InstanceConfiguration {
|
||||
statuses: InstanceStatusLimits {
|
||||
max_characters: config.post_character_limit,
|
||||
max_characters: config.limits.posts.character_limit,
|
||||
max_media_attachments: ATTACHMENTS_MAX_NUM,
|
||||
},
|
||||
media_attachments: InstanceMediaLimits {
|
||||
|
@ -168,7 +168,7 @@ impl InstanceInfo {
|
|||
},
|
||||
},
|
||||
login_message: config.login_message.clone(),
|
||||
post_character_limit: config.post_character_limit,
|
||||
post_character_limit: config.limits.posts.character_limit,
|
||||
blockchains: blockchains,
|
||||
ipfs_gateway_url: config.ipfs_gateway_url.clone(),
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue