1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
|
use types::util::MimeType;
// use chrono::Duration;
/// Configuration read from a configuration file
#[derive(Serialize, Deserialize, Debug)]
pub struct Configuration {
#[serde(rename = "ipfs-api-url")]
/// The URL of the API
api_url: String,
#[serde(rename = "ipfs-api-port")]
/// The Port of the API
api_port: u16,
#[serde(rename = "autoserve-chains")]
/// Whether to automatically "ipfs pin" chain objects
autoserve_chains: bool,
#[serde(rename = "autoserve-text-posts")]
/// Whether to automatically "ipfs pin" foreign posts if their content is text
autoserve_text_posts: bool,
#[serde(rename = "serve-blocked")]
/// Whether to serve content/chains from blocked profiles
serve_blocked: bool,
#[serde(rename = "autoserve-followed")]
/// Whether to automatically "ipfs pin" followed profiles
autoserve_followed: bool,
#[serde(rename = "max-autoload-per-post")]
/// Default amount of bytes which are loaded for each post
max_autoload_per_post: usize,
#[serde(rename = "autoserve-blacklist")]
/// List of Mimetypes which should not be served
autoserve_blacklist: Vec<MimeType>,
#[serde(rename = "autoserve-whitelist")]
/// List of Mimetypes which can be served
autoserve_whitelist: Vec<MimeType>,
// #[serde(rename = "merge-timeout")]
// /// Timeout before merge should be attempted
// merge_timeout: Duration,
}
impl Default for Configuration {
fn default() -> Self {
Configuration {
api_url : String::from("127.0.0.1"),
api_port : 5001,
autoserve_chains : true,
autoserve_text_posts : true,
serve_blocked : false,
autoserve_followed : true,
max_autoload_per_post : 1024 * 1024,
autoserve_blacklist : Vec::new(),
autoserve_whitelist : Vec::new(),
// merge_timeout : Duration::minutes(15),
}
}
}
impl Configuration {
pub fn api_url(&self) -> &String {
&self.api_url
}
pub fn api_port(&self) -> u16 {
self.api_port
}
pub fn autoserve_chains(&self) -> bool {
self.autoserve_chains
}
pub fn autoserve_text_posts(&self) -> bool {
self.autoserve_text_posts
}
pub fn serve_blocked(&self) -> bool {
self.serve_blocked
}
pub fn autoserve_followed(&self) -> bool {
self.autoserve_followed
}
pub fn max_autoload_per_post(&self) -> usize {
self.max_autoload_per_post
}
pub fn autoserve_blacklist(&self) -> &Vec<MimeType> {
&self.autoserve_blacklist
}
pub fn autoserve_whitelist(&self) -> &Vec<MimeType> {
&self.autoserve_whitelist
}
}
|