2018-06-23 18:36:11 +02:00
|
|
|
#![feature(custom_derive, decl_macro, plugin)]
|
2018-04-22 15:35:37 +02:00
|
|
|
#![plugin(rocket_codegen)]
|
2018-06-23 18:36:11 +02:00
|
|
|
|
2018-06-10 13:13:07 +02:00
|
|
|
extern crate activitypub;
|
2018-06-19 15:08:44 +02:00
|
|
|
extern crate colored;
|
2018-06-23 18:36:11 +02:00
|
|
|
extern crate diesel;
|
|
|
|
extern crate dotenv;
|
2018-05-16 20:20:44 +02:00
|
|
|
extern crate failure;
|
2018-06-15 15:08:38 +02:00
|
|
|
extern crate gettextrs;
|
2018-04-24 11:21:39 +02:00
|
|
|
extern crate heck;
|
2018-06-23 18:36:11 +02:00
|
|
|
extern crate plume_common;
|
|
|
|
extern crate plume_models;
|
2018-04-22 15:35:37 +02:00
|
|
|
extern crate rocket;
|
|
|
|
extern crate rocket_contrib;
|
2018-06-24 18:58:57 +02:00
|
|
|
extern crate rocket_csrf;
|
2018-06-17 16:28:44 +02:00
|
|
|
extern crate rocket_i18n;
|
2018-06-19 17:14:52 +02:00
|
|
|
extern crate rpassword;
|
2018-07-06 19:29:36 +02:00
|
|
|
extern crate serde;
|
|
|
|
#[macro_use]
|
|
|
|
extern crate serde_derive;
|
2018-05-01 13:48:19 +02:00
|
|
|
#[macro_use]
|
2018-04-23 17:09:05 +02:00
|
|
|
extern crate serde_json;
|
2018-06-29 14:22:43 +02:00
|
|
|
extern crate validator;
|
|
|
|
#[macro_use]
|
|
|
|
extern crate validator_derive;
|
2018-06-18 23:50:40 +02:00
|
|
|
extern crate webfinger;
|
2018-04-22 15:35:37 +02:00
|
|
|
|
|
|
|
use rocket_contrib::Template;
|
2018-06-24 18:58:57 +02:00
|
|
|
use rocket_csrf::CsrfFairingBuilder;
|
2018-04-22 15:35:37 +02:00
|
|
|
|
2018-06-23 18:36:11 +02:00
|
|
|
mod inbox;
|
2018-06-19 15:08:44 +02:00
|
|
|
mod setup;
|
2018-04-22 15:35:37 +02:00
|
|
|
mod routes;
|
2018-05-02 13:53:42 +02:00
|
|
|
|
2018-04-22 15:35:37 +02:00
|
|
|
fn main() {
|
2018-06-19 15:08:44 +02:00
|
|
|
let pool = setup::check();
|
2018-04-22 15:35:37 +02:00
|
|
|
rocket::ignite()
|
|
|
|
.mount("/", routes![
|
2018-07-20 18:42:35 +02:00
|
|
|
routes::blogs::paginated_details,
|
2018-05-13 19:41:49 +02:00
|
|
|
routes::blogs::details,
|
2018-06-17 17:26:15 +02:00
|
|
|
routes::blogs::activity_details,
|
|
|
|
routes::blogs::outbox,
|
2018-05-13 19:41:49 +02:00
|
|
|
routes::blogs::new,
|
2018-06-04 21:57:03 +02:00
|
|
|
routes::blogs::new_auth,
|
2018-05-13 19:41:49 +02:00
|
|
|
routes::blogs::create,
|
2018-05-10 20:01:16 +02:00
|
|
|
|
2018-05-13 19:41:49 +02:00
|
|
|
routes::comments::create,
|
2018-04-24 10:35:45 +02:00
|
|
|
|
2018-07-25 15:20:09 +02:00
|
|
|
routes::instance::paginated_index,
|
2018-04-29 19:50:46 +02:00
|
|
|
routes::instance::index,
|
2018-05-13 19:39:18 +02:00
|
|
|
routes::instance::shared_inbox,
|
2018-06-10 21:33:42 +02:00
|
|
|
routes::instance::nodeinfo,
|
2018-04-22 20:13:12 +02:00
|
|
|
|
2018-05-13 19:41:49 +02:00
|
|
|
routes::likes::create,
|
2018-06-04 21:57:03 +02:00
|
|
|
routes::likes::create_auth,
|
2018-05-13 19:41:49 +02:00
|
|
|
|
2018-07-25 15:33:54 +02:00
|
|
|
routes::notifications::paginated_notifications,
|
2018-05-13 15:35:55 +02:00
|
|
|
routes::notifications::notifications,
|
2018-06-04 21:57:03 +02:00
|
|
|
routes::notifications::notifications_auth,
|
2018-05-13 15:35:55 +02:00
|
|
|
|
2018-05-13 19:41:49 +02:00
|
|
|
routes::posts::details,
|
2018-06-21 16:00:25 +02:00
|
|
|
routes::posts::details_response,
|
2018-05-13 19:41:49 +02:00
|
|
|
routes::posts::activity_details,
|
|
|
|
routes::posts::new,
|
|
|
|
routes::posts::new_auth,
|
|
|
|
routes::posts::create,
|
|
|
|
|
2018-05-19 11:51:10 +02:00
|
|
|
routes::reshares::create,
|
2018-06-04 21:57:03 +02:00
|
|
|
routes::reshares::create_auth,
|
2018-05-19 11:51:10 +02:00
|
|
|
|
2018-05-13 19:41:49 +02:00
|
|
|
routes::session::new,
|
2018-06-04 20:21:43 +02:00
|
|
|
routes::session::new_message,
|
2018-05-13 19:41:49 +02:00
|
|
|
routes::session::create,
|
|
|
|
routes::session::delete,
|
|
|
|
|
|
|
|
routes::static_files,
|
|
|
|
|
2018-04-23 11:52:44 +02:00
|
|
|
routes::user::me,
|
2018-04-22 20:13:12 +02:00
|
|
|
routes::user::details,
|
2018-06-10 19:55:08 +02:00
|
|
|
routes::user::dashboard,
|
|
|
|
routes::user::dashboard_auth,
|
2018-06-17 17:26:15 +02:00
|
|
|
routes::user::followers,
|
2018-05-12 17:30:14 +02:00
|
|
|
routes::user::edit,
|
2018-06-07 10:39:22 +02:00
|
|
|
routes::user::edit_auth,
|
2018-05-12 17:30:14 +02:00
|
|
|
routes::user::update,
|
2018-05-01 21:57:30 +02:00
|
|
|
routes::user::follow,
|
2018-06-07 10:39:22 +02:00
|
|
|
routes::user::follow_auth,
|
2018-04-24 14:31:02 +02:00
|
|
|
routes::user::activity_details,
|
2018-04-29 20:01:42 +02:00
|
|
|
routes::user::outbox,
|
2018-05-01 16:00:29 +02:00
|
|
|
routes::user::inbox,
|
2018-05-13 13:53:58 +02:00
|
|
|
routes::user::ap_followers,
|
2018-04-22 20:13:12 +02:00
|
|
|
routes::user::new,
|
|
|
|
routes::user::create,
|
2018-04-23 11:52:44 +02:00
|
|
|
|
2018-05-13 19:41:49 +02:00
|
|
|
routes::well_known::host_meta,
|
2018-06-10 21:33:42 +02:00
|
|
|
routes::well_known::nodeinfo,
|
2018-06-24 18:58:57 +02:00
|
|
|
routes::well_known::webfinger,
|
|
|
|
|
|
|
|
routes::errors::csrf_violation
|
2018-04-22 15:35:37 +02:00
|
|
|
])
|
2018-06-18 17:59:49 +02:00
|
|
|
.catch(catchers![
|
|
|
|
routes::errors::not_found,
|
|
|
|
routes::errors::server_error
|
|
|
|
])
|
2018-06-19 15:08:44 +02:00
|
|
|
.manage(pool)
|
2018-06-16 19:39:22 +02:00
|
|
|
.attach(Template::custom(|engines| {
|
2018-06-17 16:28:44 +02:00
|
|
|
rocket_i18n::tera(&mut engines.tera);
|
2018-06-16 19:39:22 +02:00
|
|
|
}))
|
2018-06-17 16:28:44 +02:00
|
|
|
.attach(rocket_i18n::I18n::new("plume"))
|
2018-06-24 18:58:57 +02:00
|
|
|
.attach(CsrfFairingBuilder::new()
|
|
|
|
.set_default_target("/csrf-violation?target=<uri>".to_owned(), rocket::http::Method::Post)
|
|
|
|
.add_exceptions(vec![
|
|
|
|
("/inbox".to_owned(), "/inbox".to_owned(), rocket::http::Method::Post),
|
|
|
|
("/@/<name>/inbox".to_owned(), "/@/<name>/inbox".to_owned(), rocket::http::Method::Post),
|
|
|
|
|
|
|
|
])
|
|
|
|
.finalize().unwrap())
|
2018-04-22 15:35:37 +02:00
|
|
|
.launch();
|
|
|
|
}
|