2018-09-07 23:11:27 +00:00
|
|
|
#![feature(custom_derive, plugin, decl_macro)]
|
2018-04-22 13:35:37 +00:00
|
|
|
#![plugin(rocket_codegen)]
|
2018-09-02 20:55:42 +00:00
|
|
|
|
2018-06-10 11:13:07 +00:00
|
|
|
extern crate activitypub;
|
2018-09-01 20:08:26 +00:00
|
|
|
extern crate atom_syndication;
|
2018-09-10 18:38:19 +00:00
|
|
|
extern crate chrono;
|
2018-06-19 13:08:44 +00:00
|
|
|
extern crate colored;
|
2018-06-23 16:36:11 +00:00
|
|
|
extern crate diesel;
|
|
|
|
extern crate dotenv;
|
2018-05-16 18:20:44 +00:00
|
|
|
extern crate failure;
|
2018-06-15 13:08:38 +00:00
|
|
|
extern crate gettextrs;
|
2018-09-02 20:55:42 +00:00
|
|
|
extern crate guid_create;
|
2018-04-24 09:21:39 +00:00
|
|
|
extern crate heck;
|
2018-09-02 20:55:42 +00:00
|
|
|
extern crate multipart;
|
2018-06-23 16:36:11 +00:00
|
|
|
extern crate plume_common;
|
|
|
|
extern crate plume_models;
|
2018-09-07 23:11:27 +00:00
|
|
|
#[macro_use]
|
2018-04-22 13:35:37 +00:00
|
|
|
extern crate rocket;
|
|
|
|
extern crate rocket_contrib;
|
2018-06-24 16:58:57 +00:00
|
|
|
extern crate rocket_csrf;
|
2018-06-17 14:28:44 +00:00
|
|
|
extern crate rocket_i18n;
|
2018-06-19 15:14:52 +00:00
|
|
|
extern crate rpassword;
|
2018-07-06 17:29:36 +00:00
|
|
|
extern crate serde;
|
|
|
|
#[macro_use]
|
|
|
|
extern crate serde_derive;
|
2018-05-01 11:48:19 +00:00
|
|
|
#[macro_use]
|
2018-04-23 15:09:05 +00:00
|
|
|
extern crate serde_json;
|
2018-06-29 12:22:43 +00:00
|
|
|
extern crate validator;
|
|
|
|
#[macro_use]
|
|
|
|
extern crate validator_derive;
|
2018-06-18 21:50:40 +00:00
|
|
|
extern crate webfinger;
|
2018-07-26 15:32:52 +00:00
|
|
|
extern crate workerpool;
|
2018-04-22 13:35:37 +00:00
|
|
|
|
2018-09-03 18:53:20 +00:00
|
|
|
use rocket::State;
|
2018-04-22 13:35:37 +00:00
|
|
|
use rocket_contrib::Template;
|
2018-06-24 16:58:57 +00:00
|
|
|
use rocket_csrf::CsrfFairingBuilder;
|
2018-07-26 15:32:52 +00:00
|
|
|
use workerpool::{Pool, thunk::ThunkWorker};
|
2018-04-22 13:35:37 +00:00
|
|
|
|
2018-06-23 16:36:11 +00:00
|
|
|
mod inbox;
|
2018-06-19 13:08:44 +00:00
|
|
|
mod setup;
|
2018-04-22 13:35:37 +00:00
|
|
|
mod routes;
|
2018-05-02 11:53:42 +00:00
|
|
|
|
2018-09-03 18:53:20 +00:00
|
|
|
type Worker<'a> = State<'a, Pool<ThunkWorker<()>>>;
|
|
|
|
|
2018-04-22 13:35:37 +00:00
|
|
|
fn main() {
|
2018-06-19 13:08:44 +00:00
|
|
|
let pool = setup::check();
|
2018-04-22 13:35:37 +00:00
|
|
|
rocket::ignite()
|
|
|
|
.mount("/", routes![
|
2018-07-20 16:42:35 +00:00
|
|
|
routes::blogs::paginated_details,
|
2018-05-13 17:41:49 +00:00
|
|
|
routes::blogs::details,
|
2018-06-17 15:26:15 +00:00
|
|
|
routes::blogs::activity_details,
|
|
|
|
routes::blogs::outbox,
|
2018-05-13 17:41:49 +00:00
|
|
|
routes::blogs::new,
|
2018-06-04 19:57:03 +00:00
|
|
|
routes::blogs::new_auth,
|
2018-05-13 17:41:49 +00:00
|
|
|
routes::blogs::create,
|
2018-09-01 20:08:26 +00:00
|
|
|
routes::blogs::atom_feed,
|
2018-05-10 18:01:16 +00:00
|
|
|
|
2018-05-13 17:41:49 +00:00
|
|
|
routes::comments::create,
|
2018-09-09 15:08:53 +00:00
|
|
|
routes::comments::activity_pub,
|
2018-04-24 08:35:45 +00:00
|
|
|
|
2018-04-29 17:50:46 +00:00
|
|
|
routes::instance::index,
|
2018-09-04 19:56:27 +00:00
|
|
|
routes::instance::paginated_local,
|
|
|
|
routes::instance::local,
|
2018-09-05 14:21:50 +00:00
|
|
|
routes::instance::paginated_feed,
|
|
|
|
routes::instance::feed,
|
2018-09-05 14:37:49 +00:00
|
|
|
routes::instance::paginated_federated,
|
|
|
|
routes::instance::federated,
|
2018-07-27 17:05:36 +00:00
|
|
|
routes::instance::admin,
|
2018-09-08 18:54:09 +00:00
|
|
|
routes::instance::admin_instances,
|
|
|
|
routes::instance::admin_instances_paginated,
|
2018-09-09 10:25:55 +00:00
|
|
|
routes::instance::admin_users,
|
|
|
|
routes::instance::admin_users_paginated,
|
|
|
|
routes::instance::ban,
|
2018-09-08 19:07:55 +00:00
|
|
|
routes::instance::toggle_block,
|
2018-07-27 17:05:36 +00:00
|
|
|
routes::instance::update_settings,
|
2018-05-13 17:39:18 +00:00
|
|
|
routes::instance::shared_inbox,
|
2018-06-10 19:33:42 +00:00
|
|
|
routes::instance::nodeinfo,
|
2018-09-01 16:39:40 +00:00
|
|
|
routes::instance::about,
|
2018-09-10 14:08:22 +00:00
|
|
|
routes::instance::web_manifest,
|
2018-04-22 18:13:12 +00:00
|
|
|
|
2018-05-13 17:41:49 +00:00
|
|
|
routes::likes::create,
|
2018-06-04 19:57:03 +00:00
|
|
|
routes::likes::create_auth,
|
2018-05-13 17:41:49 +00:00
|
|
|
|
2018-09-02 20:55:42 +00:00
|
|
|
routes::medias::list,
|
|
|
|
routes::medias::new,
|
|
|
|
routes::medias::upload,
|
|
|
|
routes::medias::details,
|
2018-09-02 21:10:15 +00:00
|
|
|
routes::medias::delete,
|
2018-09-03 12:04:17 +00:00
|
|
|
routes::medias::set_avatar,
|
2018-09-02 20:55:42 +00:00
|
|
|
routes::medias::static_files,
|
|
|
|
|
2018-07-25 13:33:54 +00:00
|
|
|
routes::notifications::paginated_notifications,
|
2018-05-13 13:35:55 +00:00
|
|
|
routes::notifications::notifications,
|
2018-06-04 19:57:03 +00:00
|
|
|
routes::notifications::notifications_auth,
|
2018-05-13 13:35:55 +00:00
|
|
|
|
2018-05-13 17:41:49 +00:00
|
|
|
routes::posts::details,
|
2018-06-21 14:00:25 +00:00
|
|
|
routes::posts::details_response,
|
2018-05-13 17:41:49 +00:00
|
|
|
routes::posts::activity_details,
|
2018-09-07 17:51:53 +00:00
|
|
|
routes::posts::edit,
|
|
|
|
routes::posts::update,
|
2018-05-13 17:41:49 +00:00
|
|
|
routes::posts::new,
|
|
|
|
routes::posts::new_auth,
|
|
|
|
routes::posts::create,
|
2018-09-01 15:28:47 +00:00
|
|
|
routes::posts::delete,
|
2018-05-13 17:41:49 +00:00
|
|
|
|
2018-05-19 09:51:10 +00:00
|
|
|
routes::reshares::create,
|
2018-06-04 19:57:03 +00:00
|
|
|
routes::reshares::create_auth,
|
2018-05-19 09:51:10 +00:00
|
|
|
|
2018-05-13 17:41:49 +00:00
|
|
|
routes::session::new,
|
2018-06-04 18:21:43 +00:00
|
|
|
routes::session::new_message,
|
2018-05-13 17:41:49 +00:00
|
|
|
routes::session::create,
|
|
|
|
routes::session::delete,
|
|
|
|
|
|
|
|
routes::static_files,
|
|
|
|
|
2018-09-06 12:06:04 +00:00
|
|
|
routes::tags::tag,
|
|
|
|
routes::tags::paginated_tag,
|
|
|
|
|
2018-04-23 09:52:44 +00:00
|
|
|
routes::user::me,
|
2018-04-22 18:13:12 +00:00
|
|
|
routes::user::details,
|
2018-06-10 17:55:08 +00:00
|
|
|
routes::user::dashboard,
|
|
|
|
routes::user::dashboard_auth,
|
2018-07-25 13:50:29 +00:00
|
|
|
routes::user::followers_paginated,
|
2018-06-17 15:26:15 +00:00
|
|
|
routes::user::followers,
|
2018-05-12 15:30:14 +00:00
|
|
|
routes::user::edit,
|
2018-06-07 08:39:22 +00:00
|
|
|
routes::user::edit_auth,
|
2018-05-12 15:30:14 +00:00
|
|
|
routes::user::update,
|
2018-09-09 19:49:24 +00:00
|
|
|
routes::user::delete,
|
2018-05-01 19:57:30 +00:00
|
|
|
routes::user::follow,
|
2018-06-07 08:39:22 +00:00
|
|
|
routes::user::follow_auth,
|
2018-04-24 12:31:02 +00:00
|
|
|
routes::user::activity_details,
|
2018-04-29 18:01:42 +00:00
|
|
|
routes::user::outbox,
|
2018-05-01 14:00:29 +00:00
|
|
|
routes::user::inbox,
|
2018-05-13 11:53:58 +00:00
|
|
|
routes::user::ap_followers,
|
2018-04-22 18:13:12 +00:00
|
|
|
routes::user::new,
|
|
|
|
routes::user::create,
|
2018-09-01 20:08:26 +00:00
|
|
|
routes::user::atom_feed,
|
2018-04-23 09:52:44 +00:00
|
|
|
|
2018-05-13 17:41:49 +00:00
|
|
|
routes::well_known::host_meta,
|
2018-06-10 19:33:42 +00:00
|
|
|
routes::well_known::nodeinfo,
|
2018-06-24 16:58:57 +00:00
|
|
|
routes::well_known::webfinger,
|
|
|
|
|
|
|
|
routes::errors::csrf_violation
|
2018-04-22 13:35:37 +00:00
|
|
|
])
|
2018-06-18 15:59:49 +00:00
|
|
|
.catch(catchers![
|
|
|
|
routes::errors::not_found,
|
|
|
|
routes::errors::server_error
|
|
|
|
])
|
2018-06-19 13:08:44 +00:00
|
|
|
.manage(pool)
|
2018-07-26 15:32:52 +00:00
|
|
|
.manage(Pool::<ThunkWorker<()>>::new(4))
|
2018-06-16 17:39:22 +00:00
|
|
|
.attach(Template::custom(|engines| {
|
2018-06-17 14:28:44 +00:00
|
|
|
rocket_i18n::tera(&mut engines.tera);
|
2018-06-16 17:39:22 +00:00
|
|
|
}))
|
2018-06-17 14:28:44 +00:00
|
|
|
.attach(rocket_i18n::I18n::new("plume"))
|
2018-09-09 09:27:03 +00: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),
|
|
|
|
("/~/<blog>/<slug>".to_owned(), "/~/<blog>/<slug>".to_owned(), rocket::http::Method::Post),
|
|
|
|
])
|
|
|
|
.finalize().unwrap())
|
2018-04-22 13:35:37 +00:00
|
|
|
.launch();
|
|
|
|
}
|