Kibou is a federated social networking server.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

lib.rs 3.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. #![feature(proc_macro_hygiene, decl_macro)]
  2. extern crate base64;
  3. extern crate bcrypt;
  4. extern crate chrono;
  5. #[macro_use]
  6. extern crate diesel;
  7. #[macro_use]
  8. extern crate lazy_static;
  9. extern crate lru;
  10. extern crate openssl;
  11. extern crate pem;
  12. extern crate regex;
  13. extern crate reqwest;
  14. #[macro_use]
  15. extern crate rocket;
  16. extern crate core;
  17. extern crate rocket_contrib;
  18. extern crate serde;
  19. extern crate serde_json;
  20. extern crate url;
  21. extern crate uuid;
  22. mod activity;
  23. mod activitypub;
  24. pub mod actor;
  25. pub mod database;
  26. pub mod env;
  27. mod html;
  28. mod kibou_api;
  29. mod mastodon_api;
  30. mod notification;
  31. mod oauth;
  32. pub mod raito_fe;
  33. mod tests;
  34. mod timeline;
  35. mod web;
  36. mod well_known;
  37. pub fn rocket_app(config: rocket::config::Config) -> rocket::Rocket {
  38. let mut app: rocket::Rocket = rocket::custom(config)
  39. .mount(
  40. "/",
  41. routes![
  42. activitypub::routes::activity,
  43. activitypub::routes::actor,
  44. activitypub::routes::actor_inbox,
  45. activitypub::routes::object,
  46. activitypub::routes::inbox
  47. ],
  48. )
  49. .mount("/", routes![kibou_api::routes::activities])
  50. .mount(
  51. "/",
  52. routes![
  53. mastodon_api::routes::account,
  54. mastodon_api::routes::account_follow,
  55. mastodon_api::routes::account_statuses,
  56. mastodon_api::routes::account_unfollow,
  57. mastodon_api::routes::account_verify_credentials,
  58. mastodon_api::routes::application,
  59. mastodon_api::routes::custom_emojis,
  60. mastodon_api::routes::filters,
  61. mastodon_api::routes::home_timeline,
  62. mastodon_api::routes::instance,
  63. mastodon_api::routes::notifications,
  64. mastodon_api::routes::status,
  65. mastodon_api::routes::status_context,
  66. mastodon_api::routes::status_favourite,
  67. mastodon_api::routes::status_post,
  68. mastodon_api::routes::status_reblog,
  69. mastodon_api::routes::public_timeline,
  70. mastodon_api::routes::options_account,
  71. mastodon_api::routes::options_account_statuses,
  72. mastodon_api::routes::options_account_verify_credentials,
  73. mastodon_api::routes::options_home_timeline,
  74. mastodon_api::routes::options_instance,
  75. mastodon_api::routes::options_public_timeline,
  76. mastodon_api::routes::options_status
  77. ],
  78. )
  79. .mount("/", raito_fe::get_routes())
  80. .mount(
  81. "/",
  82. routes![
  83. oauth::routes::authorize,
  84. oauth::routes::authorize_result,
  85. oauth::routes::token
  86. ],
  87. )
  88. .mount("/", routes![well_known::webfinger::webfinger])
  89. .mount(
  90. "/static",
  91. rocket_contrib::serve::StaticFiles::from("static"),
  92. )
  93. .attach(rocket_contrib::templates::Template::fairing());
  94. // Avoid mounting nodeinfo routes if the admin has disabled
  95. // nodeinfo in the config file.
  96. if should_mount_nodeinfo() {
  97. app = app.mount("/", well_known::nodeinfo::get_routes());
  98. }
  99. app
  100. }
  101. // Returns whether nodeinfo routes should be mounted based
  102. // on the value of a configuration entry.
  103. fn should_mount_nodeinfo() -> bool {
  104. let key = String::from("nodeinfo.enabled");
  105. let value: String = env::get_value(key).to_lowercase();
  106. // Nodeinfo will only be disabled if its configuration value is
  107. // explicitly set to false, "false", or any uppercase equivalent.
  108. value.as_str() != "false"
  109. }