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
|
/*
This file is part of jellything (https://codeberg.org/metamuffin/jellything)
which is licensed under the GNU Affero General Public License (version 3); see /COPYING.
Copyright (C) 2023 metamuffin <metamuffin.org>
*/
#![feature(lazy_cell)]
#![feature(int_roundings)]
use crate::routes::ui::{account::hash_password, admin::log::enable_logging};
use database::Database;
use federation::Federation;
use jellybase::CONF;
use jellycommon::user::{PermissionSet, Theme, User};
use log::{error, warn};
use routes::build_rocket;
use tokio::fs::create_dir_all;
pub use jellybase::database;
pub mod federation;
pub mod import;
pub mod routes;
#[rocket::main]
async fn main() {
enable_logging();
#[cfg(feature = "bypass-auth")]
log::warn!("authentification bypass enabled");
create_dir_all(&CONF.cache_path).await.unwrap();
let database = Database::open(&CONF.database_path).unwrap();
let federation = Federation::initialize();
database
.user
.insert(
&CONF.admin_username,
&User {
admin: true,
theme: Theme::Dark,
display_name: "Admin".to_string(),
name: CONF.admin_username.clone(),
password: hash_password(&CONF.admin_username, &CONF.admin_password),
permissions: PermissionSet::default(),
},
)
.unwrap();
// if let Err(err) = import::import(&database, &federation).await {
// log::error!("import not sucessful: {err:?}")
// }
let r = build_rocket(database, federation).launch().await;
match r {
Ok(_) => warn!("server shutdown"),
Err(e) => error!("server exited: {e}"),
}
}
|