2020-05-03 16:25:31 +01:00
|
|
|
#![warn(rust_2018_idioms)]
|
2020-04-09 19:47:03 +01:00
|
|
|
|
2020-06-12 12:18:25 +01:00
|
|
|
pub mod push_rules;
|
|
|
|
|
2020-04-11 08:30:11 +01:00
|
|
|
mod client_server;
|
2020-03-30 12:46:18 +01:00
|
|
|
mod database;
|
2020-05-03 16:25:31 +01:00
|
|
|
mod error;
|
2020-04-04 10:53:37 +01:00
|
|
|
mod pdu;
|
2020-02-15 21:42:21 +00:00
|
|
|
mod ruma_wrapper;
|
2020-06-03 13:16:56 +01:00
|
|
|
//mod server_server;
|
2020-03-29 12:48:44 +01:00
|
|
|
mod utils;
|
2020-02-15 21:42:21 +00:00
|
|
|
|
2020-03-30 12:46:18 +01:00
|
|
|
pub use database::Database;
|
2020-05-03 16:25:31 +01:00
|
|
|
pub use error::{Error, Result};
|
2020-04-04 10:53:37 +01:00
|
|
|
pub use pdu::PduEvent;
|
2020-07-26 04:08:00 +01:00
|
|
|
pub use rocket::State;
|
2020-06-09 14:13:17 +01:00
|
|
|
pub use ruma_wrapper::{ConduitResult, Ruma, RumaResponse};
|
2020-03-30 12:46:18 +01:00
|
|
|
|
2020-04-29 07:48:56 +01:00
|
|
|
use rocket::{fairing::AdHoc, routes};
|
2020-04-03 16:27:08 +01:00
|
|
|
|
2020-04-29 07:48:56 +01:00
|
|
|
fn setup_rocket() -> rocket::Rocket {
|
2020-02-15 21:42:21 +00:00
|
|
|
rocket::ignite()
|
2020-02-18 21:07:57 +00:00
|
|
|
.mount(
|
|
|
|
"/",
|
|
|
|
routes![
|
2020-04-11 08:30:11 +01:00
|
|
|
client_server::get_supported_versions_route,
|
2020-05-01 22:17:25 +01:00
|
|
|
client_server::get_register_available_route,
|
2020-04-11 08:30:11 +01:00
|
|
|
client_server::register_route,
|
2020-07-31 13:40:28 +01:00
|
|
|
client_server::get_login_types_route,
|
2020-04-11 08:30:11 +01:00
|
|
|
client_server::login_route,
|
2020-07-27 16:38:00 +01:00
|
|
|
client_server::whoami_route,
|
2020-05-24 21:10:09 +01:00
|
|
|
client_server::logout_route,
|
2020-07-05 07:35:19 +01:00
|
|
|
client_server::logout_all_route,
|
2020-07-02 19:38:25 +01:00
|
|
|
client_server::change_password_route,
|
2020-07-05 06:48:19 +01:00
|
|
|
client_server::deactivate_route,
|
2020-04-19 13:14:47 +01:00
|
|
|
client_server::get_capabilities_route,
|
2020-04-11 08:30:11 +01:00
|
|
|
client_server::get_pushrules_all_route,
|
2020-05-01 19:26:57 +01:00
|
|
|
client_server::set_pushrule_route,
|
|
|
|
client_server::set_pushrule_enabled_route,
|
2020-07-11 13:08:37 +01:00
|
|
|
client_server::get_room_event_route,
|
2020-04-11 08:30:11 +01:00
|
|
|
client_server::get_filter_route,
|
|
|
|
client_server::create_filter_route,
|
|
|
|
client_server::set_global_account_data_route,
|
|
|
|
client_server::get_global_account_data_route,
|
|
|
|
client_server::set_displayname_route,
|
|
|
|
client_server::get_displayname_route,
|
|
|
|
client_server::set_avatar_url_route,
|
|
|
|
client_server::get_avatar_url_route,
|
|
|
|
client_server::get_profile_route,
|
|
|
|
client_server::set_presence_route,
|
|
|
|
client_server::upload_keys_route,
|
2020-05-17 18:56:40 +01:00
|
|
|
client_server::get_keys_route,
|
|
|
|
client_server::claim_keys_route,
|
2020-06-16 11:11:38 +01:00
|
|
|
client_server::create_backup_route,
|
|
|
|
client_server::update_backup_route,
|
|
|
|
client_server::get_latest_backup_route,
|
|
|
|
client_server::get_backup_route,
|
|
|
|
client_server::add_backup_keys_route,
|
|
|
|
client_server::get_backup_keys_route,
|
2020-04-11 08:30:11 +01:00
|
|
|
client_server::set_read_marker_route,
|
2020-04-12 20:12:50 +01:00
|
|
|
client_server::create_typing_event_route,
|
2020-04-11 08:30:11 +01:00
|
|
|
client_server::create_room_route,
|
2020-05-25 22:24:13 +01:00
|
|
|
client_server::redact_event_route,
|
|
|
|
client_server::create_alias_route,
|
|
|
|
client_server::delete_alias_route,
|
2020-04-11 08:30:11 +01:00
|
|
|
client_server::get_alias_route,
|
|
|
|
client_server::join_room_by_id_route,
|
|
|
|
client_server::join_room_by_id_or_alias_route,
|
2020-07-10 07:49:05 +01:00
|
|
|
client_server::joined_members_route,
|
2020-04-19 13:14:47 +01:00
|
|
|
client_server::leave_room_route,
|
2020-04-28 18:56:34 +01:00
|
|
|
client_server::forget_room_route,
|
2020-07-25 17:35:22 +01:00
|
|
|
client_server::joined_rooms_route,
|
2020-06-04 14:02:27 +01:00
|
|
|
client_server::kick_user_route,
|
|
|
|
client_server::ban_user_route,
|
|
|
|
client_server::unban_user_route,
|
2020-04-14 12:54:32 +01:00
|
|
|
client_server::invite_user_route,
|
2020-05-25 22:24:13 +01:00
|
|
|
client_server::set_room_visibility_route,
|
|
|
|
client_server::get_room_visibility_route,
|
2020-05-19 15:28:03 +01:00
|
|
|
client_server::get_public_rooms_route,
|
2020-04-11 08:30:11 +01:00
|
|
|
client_server::get_public_rooms_filtered_route,
|
2020-04-14 12:54:32 +01:00
|
|
|
client_server::search_users_route,
|
2020-04-19 13:14:47 +01:00
|
|
|
client_server::get_member_events_route,
|
2020-04-11 08:30:11 +01:00
|
|
|
client_server::get_protocols_route,
|
2020-08-12 22:32:39 +01:00
|
|
|
client_server::send_message_event_route,
|
|
|
|
client_server::send_state_event_for_key_route,
|
|
|
|
client_server::send_state_event_for_empty_key_route,
|
2020-05-18 08:22:07 +01:00
|
|
|
client_server::get_state_events_route,
|
|
|
|
client_server::get_state_events_for_key_route,
|
|
|
|
client_server::get_state_events_for_empty_key_route,
|
2020-07-27 16:36:54 +01:00
|
|
|
client_server::sync_events_route,
|
2020-06-04 12:58:55 +01:00
|
|
|
client_server::get_context_route,
|
2020-04-28 18:56:34 +01:00
|
|
|
client_server::get_message_events_route,
|
2020-04-14 12:54:32 +01:00
|
|
|
client_server::turn_server_route,
|
2020-05-01 19:26:57 +01:00
|
|
|
client_server::send_event_to_device_route,
|
|
|
|
client_server::get_media_config_route,
|
2020-05-18 16:53:34 +01:00
|
|
|
client_server::create_content_route,
|
|
|
|
client_server::get_content_route,
|
|
|
|
client_server::get_content_thumbnail_route,
|
2020-06-03 12:41:30 +01:00
|
|
|
client_server::get_devices_route,
|
|
|
|
client_server::get_device_route,
|
|
|
|
client_server::update_device_route,
|
|
|
|
client_server::delete_device_route,
|
|
|
|
client_server::delete_devices_route,
|
2020-07-26 21:33:20 +01:00
|
|
|
client_server::get_tags_route,
|
|
|
|
client_server::update_tag_route,
|
|
|
|
client_server::delete_tag_route,
|
2020-04-11 08:30:11 +01:00
|
|
|
client_server::options_route,
|
2020-06-16 11:11:38 +01:00
|
|
|
client_server::upload_signing_keys_route,
|
|
|
|
client_server::upload_signatures_route,
|
2020-07-29 16:37:26 +01:00
|
|
|
client_server::get_key_changes_route,
|
2020-07-30 17:14:47 +01:00
|
|
|
client_server::get_pushers_route,
|
2020-06-16 11:11:38 +01:00
|
|
|
client_server::set_pushers_route,
|
2020-06-03 13:16:56 +01:00
|
|
|
//server_server::well_known_server,
|
|
|
|
//server_server::get_server_version,
|
|
|
|
//server_server::get_server_keys,
|
|
|
|
//server_server::get_server_keys_deprecated,
|
2020-02-18 21:07:57 +00:00
|
|
|
],
|
|
|
|
)
|
2020-06-16 12:53:15 +01:00
|
|
|
.attach(AdHoc::on_attach("Config", |mut rocket| async {
|
|
|
|
let data = Database::load_or_create(rocket.config().await).expect("valid config");
|
2020-04-29 07:48:56 +01:00
|
|
|
|
|
|
|
Ok(rocket.manage(data))
|
|
|
|
}))
|
2020-04-10 12:36:57 +01:00
|
|
|
}
|
|
|
|
|
2020-06-16 12:53:15 +01:00
|
|
|
#[rocket::main]
|
|
|
|
async fn main() {
|
|
|
|
// Default log level
|
2020-05-14 08:10:15 +01:00
|
|
|
if std::env::var("ROCKET_LOG").is_err() {
|
|
|
|
std::env::set_var("ROCKET_LOG", "critical");
|
2020-04-10 12:36:57 +01:00
|
|
|
}
|
|
|
|
|
2020-06-16 12:53:15 +01:00
|
|
|
setup_rocket().launch().await.unwrap();
|
2020-02-15 21:42:21 +00:00
|
|
|
}
|