Commit

Author:

Hash:

Timestamp:

+3 -109 +/-3 browse

Kevin Schoon [me@kevinschoon.com]

ca76572e2e8b31c58762760c27b0c4863c06cb43

Sun, 18 May 2025 10:28:37 +0000 (1.1 years ago)

cleanup unused config options
1diff --git a/ayllu/src/config.rs b/ayllu/src/config.rs
2index 0561de8..d7020be 100644
3--- a/ayllu/src/config.rs
4+++ b/ayllu/src/config.rs
5 @@ -1,11 +1,9 @@
6 use std::collections::HashMap;
7 use std::error::Error;
8 use std::fs::metadata;
9- use std::num::NonZeroUsize;
10- use std::thread::available_parallelism;
11 use url::Url;
12
13- use ayllu_config::{runtime_dir, Configurable};
14+ use ayllu_config::Configurable;
15
16 use serde::{Deserialize, Serialize};
17
18 @@ -14,7 +12,7 @@ pub const EXAMPLE_CONFIG: &str = include_str!("../../config.example.toml");
19 // names that cannot be used in collections because they conflict with certain
20 // internal urls within the service.
21 const BANNED_COLLECTION_NAMES: &[&str] = &[
22- "authors", "about", "api", "browse", "config", "rss", "static", "discuss",
23+ "authors", "about", "api", "browse", "config", "rss", "static",
24 ];
25
26 const DEFAULT_ROBOTS_TXT: &str = r#"
27 @@ -29,7 +27,6 @@ Disallow: /*/*/refs/archive/*
28 Disallow: /*/*/blame/*
29 Disallow: /*/*/log/*
30 Disallow: /*/*/tree/*
31- Disallow: /*/*/chart/*
32 "#;
33
34 const DEFAULT_ABOUT_BLURB: &str = r#"
35 @@ -86,12 +83,6 @@ pub struct Collection {
36 }
37
38 #[derive(Deserialize, Serialize, Clone, Debug)]
39- pub struct List {
40- pub address: String,
41- pub description: Option<String>,
42- }
43-
44- #[derive(Deserialize, Serialize, Clone, Debug)]
45 pub struct Theme {
46 pub name: String,
47 pub css_content: String,
48 @@ -212,49 +203,6 @@ pub struct Lfs {
49 }
50
51 #[derive(Deserialize, Serialize, Clone, Debug, Default)]
52- pub struct XmppChannel {
53- pub jid: String,
54- pub description: String,
55- }
56-
57- #[derive(Deserialize, Serialize, Clone, Debug, Default)]
58- pub struct Xmpp {
59- pub channels: Vec<XmppChannel>,
60- #[serde(default = "Xmpp::default_socket_path")]
61- pub socket_path: String,
62- }
63-
64- impl Xmpp {
65- fn default_socket_path() -> String {
66- runtime_dir().to_str().unwrap().to_string() + "/ayllu-xmpp.sock"
67- }
68- }
69-
70- #[derive(Deserialize, Serialize, Clone, Debug, Default)]
71- pub struct MailingList {
72- pub name: String,
73- pub address: String,
74- pub description: Option<String>,
75- pub topics: Vec<String>,
76- pub request_address: String,
77- // pub post_policy: PostPolicy,
78- // pub subscription_policy: SubscriptionPolicy,
79- }
80-
81- #[derive(Deserialize, Serialize, Clone, Debug, Default)]
82- pub struct Mail {
83- #[serde(default = "Mail::default_socket_path")]
84- pub socket_path: String,
85- pub lists: Vec<MailingList>,
86- }
87-
88- impl Mail {
89- fn default_socket_path() -> String {
90- runtime_dir().to_str().unwrap().to_string() + "/ayllu-mail.sock"
91- }
92- }
93-
94- #[derive(Deserialize, Serialize, Clone, Debug, Default)]
95 pub struct Link {
96 pub rel: String,
97 pub href: Option<String>,
98 @@ -311,10 +259,6 @@ pub struct Config {
99 pub domain: Option<String>,
100 #[serde(default = "Git::default")]
101 pub git: Git,
102- #[serde(default = "Config::default_worker_threads")]
103- pub worker_threads: NonZeroUsize,
104- #[serde(default = "Config::default_max_blocking_threads")]
105- pub max_blocking_threads: NonZeroUsize,
106 pub sysadmin: Option<String>,
107 #[serde(default = "Config::default_about_blurb")]
108 pub blurb: String,
109 @@ -338,8 +282,6 @@ pub struct Config {
110 pub tree_sitter: Option<TreeSitter>,
111 pub languages: Option<Languages>,
112 pub lfs: Option<Lfs>,
113- pub xmpp: Option<Xmpp>,
114- pub mail: Option<Mail>,
115 pub authors: Option<Vec<Author>>,
116 }
117
118 @@ -396,14 +338,6 @@ impl Config {
119 String::from("info")
120 }
121
122- fn default_worker_threads() -> NonZeroUsize {
123- available_parallelism().unwrap()
124- }
125-
126- fn default_max_blocking_threads() -> NonZeroUsize {
127- NonZeroUsize::new(512).unwrap()
128- }
129-
130 fn default_origin() -> String {
131 format!("http://{}", Http::default().address)
132 }
133 diff --git a/ayllu/src/web2/routes/finger.rs b/ayllu/src/web2/routes/finger.rs
134index 8bce952..648eb1e 100644
135--- a/ayllu/src/web2/routes/finger.rs
136+++ b/ayllu/src/web2/routes/finger.rs
137 @@ -6,7 +6,7 @@ use url::Url;
138 use webfinger_rs::{Link, WebFingerRequest, WebFingerResponse};
139
140 use crate::{
141- config::{Author, Collection, Config, MailingList},
142+ config::{Author, Collection, Config},
143 web2::error::Error,
144 };
145 use ayllu_git::{name, Error as GitError, Wrapper as Repository};
146 @@ -48,7 +48,6 @@ fn get_all(collections: &[Collection]) -> Result<Vec<Pair>, ayllu_git::Error> {
147 #[derive(Clone, Debug)]
148 enum Resource {
149 Acct(Author),
150- MailingList(MailingList),
151 Collection((Collection, Vec<String>)),
152 Repository((Collection, PathBuf)),
153 Index,
154 @@ -60,7 +59,6 @@ enum Resource {
155 pub struct Resolver {
156 pub collections: Vec<Collection>,
157 pub authors: HashMap<String, Author>,
158- pub mailing_lists: HashMap<String, MailingList>,
159 origin: Url,
160 }
161
162 @@ -79,16 +77,6 @@ impl Resolver {
163 origin: Url::parse(&config.origin).expect("Origin URL is invalid"),
164 collections: config.collections.clone(),
165 authors,
166- mailing_lists: HashMap::from_iter(config.mail.as_ref().map_or(
167- Vec::new(),
168- |mail_config| {
169- mail_config
170- .lists
171- .iter()
172- .map(|mailing_list| (mailing_list.address.clone(), mailing_list.clone()))
173- .collect()
174- },
175- )),
176 }
177 }
178
179 @@ -119,10 +107,6 @@ impl Resolver {
180 return Ok(Resource::Index);
181 }
182
183- if let Some(mailing_list) = self.mailing_lists.get(&resource.to_string()) {
184- return Ok(Resource::MailingList(mailing_list.clone()));
185- }
186-
187 if let Some(resource) = collections.find_map(|collection| {
188 if collection.name.eq(resource.path().trim_start_matches("/")) {
189 let scanner = ayllu_git::Scanner::from_path(&collection.path).ok()?;
190 @@ -197,21 +181,6 @@ impl Resolver {
191 links,
192 })
193 }
194- Resource::MailingList(mailing_list) => {
195- // TODO: Subscribe, unsubscribe, etc.
196- Ok(WebFingerResponse {
197- subject: resource.to_string(),
198- aliases: None,
199- properties: None,
200- links: vec![Link::builder(DESCRIPTION)
201- .href(format!("mailto://{}", mailing_list.address))
202- .properties(HashMap::from_iter(vec![(
203- "description".to_string(),
204- mailing_list.description.clone(),
205- )]))
206- .build()],
207- })
208- }
209 Resource::Collection((collection, repositories)) => {
210 let mut links: Vec<Link> = repositories
211 .iter()
212 diff --git a/config.example.toml b/config.example.toml
213index f28eda9..f6e40ec 100644
214--- a/config.example.toml
215+++ b/config.example.toml
216 @@ -7,15 +7,6 @@ origin = "localhost:10000"
217 # sysadmin contact address
218 sysadmin = "admin@example.org"
219
220- # number of background threads to drive asynchronous tasks forward with in the
221- # web server and any other component that is multithreaded. Note that all
222- # plugin components are currently single threaded. If unspecified this will
223- # default to the number of CPU cores on your system.
224- # worker_threads = 8
225- # number of additional blocking threads that may be spawned by the tokio
226- # runtime. See https://docs.rs/tokio/latest/tokio/runtime/struct.Builder.html#method.max_blocking_threads
227- # max_blocking_threads = 512
228-
229 # logging level
230 log_level = "INFO"
231