mirror of
https://github.com/Nutomic/ibis.git
synced 2024-11-23 10:21:08 +00:00
Update default config
This commit is contained in:
parent
61806e12a6
commit
22bd0d9538
8 changed files with 18 additions and 17 deletions
|
@ -1,9 +1,3 @@
|
|||
# Whether users can create new accounts
|
||||
registration_open = true
|
||||
|
||||
# Whether admins need to approve new articles
|
||||
article_approval = false
|
||||
|
||||
# Details about the PostgreSQL database connection
|
||||
[database]
|
||||
# Database connection url
|
||||
|
@ -28,3 +22,10 @@ allowlist = "good.com,friends.org"
|
|||
|
||||
# Comma separated list of instances which are blocked for federation; optional
|
||||
blocklist = "evil.com,bad.org"
|
||||
|
||||
[options]
|
||||
# Whether users can create new accounts
|
||||
registration_open = true
|
||||
|
||||
# Whether admins need to approve new articles
|
||||
article_approval = false
|
||||
|
|
|
@ -68,7 +68,7 @@ pub(in crate::backend::api) async fn create_article(
|
|||
instance_id: local_instance.id,
|
||||
local: true,
|
||||
protected: false,
|
||||
approved: !data.config.config.article_approval,
|
||||
approved: !data.config.options.article_approval,
|
||||
};
|
||||
let article = DbArticle::create(form, &data)?;
|
||||
|
||||
|
@ -214,7 +214,7 @@ pub(in crate::backend::api) async fn fork_article(
|
|||
instance_id: local_instance.id,
|
||||
local: true,
|
||||
protected: false,
|
||||
approved: !data.config.config.article_approval,
|
||||
approved: !data.config.options.article_approval,
|
||||
};
|
||||
let article = DbArticle::create(form, &data)?;
|
||||
|
||||
|
|
|
@ -102,6 +102,6 @@ pub(in crate::backend::api) async fn site_view(
|
|||
) -> MyResult<Json<SiteView>> {
|
||||
Ok(Json(SiteView {
|
||||
my_profile: user.map(|u| u.0),
|
||||
config: data.config.config.clone(),
|
||||
config: data.config.options.clone(),
|
||||
}))
|
||||
}
|
||||
|
|
|
@ -76,7 +76,7 @@ pub(in crate::backend::api) async fn register_user(
|
|||
jar: CookieJar,
|
||||
Form(form): Form<RegisterUserForm>,
|
||||
) -> MyResult<(CookieJar, Json<LocalUserView>)> {
|
||||
if !data.config.config.registration_open {
|
||||
if !data.config.options.registration_open {
|
||||
return Err(anyhow!("Registration is closed").into());
|
||||
}
|
||||
let user = DbPerson::create_local(form.username, form.password, false, &data)?;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use crate::{backend::error::MyResult, common::SharedConfig};
|
||||
use crate::{backend::error::MyResult, common::Options};
|
||||
use config::Config;
|
||||
use doku::Document;
|
||||
use serde::Deserialize;
|
||||
|
@ -13,7 +13,7 @@ pub struct IbisConfig {
|
|||
/// Details of the initial admin account
|
||||
pub setup: IbisConfigSetup,
|
||||
pub federation: IbisConfigFederation,
|
||||
pub config: SharedConfig,
|
||||
pub options: Options,
|
||||
}
|
||||
|
||||
impl IbisConfig {
|
||||
|
|
|
@ -34,7 +34,7 @@ async fn node_info(data: Data<IbisData>) -> MyResult<Json<NodeInfo>> {
|
|||
version: env!("CARGO_PKG_VERSION").to_string(),
|
||||
},
|
||||
protocols: vec!["activitypub".to_string()],
|
||||
open_registrations: data.config.config.registration_open,
|
||||
open_registrations: data.config.options.registration_open,
|
||||
}))
|
||||
}
|
||||
|
||||
|
|
|
@ -326,7 +326,7 @@ pub struct GetUserForm {
|
|||
#[serde(deny_unknown_fields)]
|
||||
#[cfg_attr(feature = "ssr", derive(Queryable, Document))]
|
||||
#[cfg_attr(feature = "ssr", diesel(check_for_backend(diesel::pg::Pg)))]
|
||||
pub struct SharedConfig {
|
||||
pub struct Options {
|
||||
/// Whether users can create new accounts
|
||||
#[default = true]
|
||||
#[cfg_attr(feature = "ssr", doku(example = "true"))]
|
||||
|
@ -342,7 +342,7 @@ pub struct SharedConfig {
|
|||
#[cfg_attr(feature = "ssr", diesel(check_for_backend(diesel::pg::Pg)))]
|
||||
pub struct SiteView {
|
||||
pub my_profile: Option<LocalUserView>,
|
||||
pub config: SharedConfig,
|
||||
pub config: Options,
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
|
@ -5,7 +5,7 @@ use ibis::{
|
|||
config::{IbisConfig, IbisConfigDatabase, IbisConfigFederation},
|
||||
start,
|
||||
},
|
||||
common::{RegisterUserForm, SharedConfig},
|
||||
common::{Options, RegisterUserForm},
|
||||
frontend::{api::ApiClient, error::MyResult},
|
||||
};
|
||||
use reqwest::ClientBuilder;
|
||||
|
@ -128,7 +128,7 @@ impl IbisInstance {
|
|||
domain: domain.clone(),
|
||||
..Default::default()
|
||||
},
|
||||
config: SharedConfig {
|
||||
options: Options {
|
||||
registration_open: true,
|
||||
article_approval,
|
||||
},
|
||||
|
|
Loading…
Reference in a new issue