]> Untitled Git - lemmy.git/commitdiff
Rework imports
authorFelix <me@nutomic.com>
Sat, 16 May 2020 14:04:08 +0000 (16:04 +0200)
committerFelix <me@nutomic.com>
Sat, 16 May 2020 18:04:17 +0000 (20:04 +0200)
59 files changed:
server/.rustfmt.toml
server/Cargo.lock
server/Cargo.toml
server/src/api/comment.rs
server/src/api/community.rs
server/src/api/mod.rs
server/src/api/post.rs
server/src/api/site.rs
server/src/api/user.rs
server/src/apub/activities.rs
server/src/apub/comment.rs
server/src/apub/community.rs
server/src/apub/community_inbox.rs
server/src/apub/extensions/group_extensions.rs
server/src/apub/extensions/page_extension.rs
server/src/apub/extensions/signatures.rs
server/src/apub/fetcher.rs
server/src/apub/mod.rs
server/src/apub/post.rs
server/src/apub/private_message.rs
server/src/apub/shared_inbox.rs
server/src/apub/user.rs
server/src/apub/user_inbox.rs
server/src/db/activity.rs
server/src/db/category.rs
server/src/db/code_migrations.rs
server/src/db/comment.rs
server/src/db/comment_view.rs
server/src/db/community.rs
server/src/db/community_view.rs
server/src/db/mod.rs
server/src/db/moderator.rs
server/src/db/moderator_views.rs
server/src/db/password_reset_request.rs
server/src/db/post.rs
server/src/db/post_view.rs
server/src/db/private_message.rs
server/src/db/private_message_view.rs
server/src/db/site.rs
server/src/db/site_view.rs
server/src/db/user.rs
server/src/db/user_mention.rs
server/src/db/user_mention_view.rs
server/src/db/user_view.rs
server/src/lib.rs
server/src/main.rs
server/src/rate_limit/mod.rs
server/src/rate_limit/rate_limiter.rs
server/src/routes/api.rs
server/src/routes/federation.rs
server/src/routes/feeds.rs
server/src/routes/index.rs
server/src/routes/mod.rs
server/src/routes/nodeinfo.rs
server/src/routes/webfinger.rs
server/src/routes/websocket.rs
server/src/settings.rs
server/src/websocket/mod.rs
server/src/websocket/server.rs

index 684a7f8a27ae738ba679bcbdc8a3fc4ac1b9c305..f3efdc308472dcc95439ed2ecb08c6194e22d315 100644 (file)
@@ -1,2 +1,5 @@
 tab_spaces = 2
-edition="2018"
\ No newline at end of file
+edition="2018"
+imports_layout="HorizontalVertical"
+merge_imports=true
+reorder_imports=true
index 714422b64f49d29c45da7f670478e1d8f26dc771..cc43028b58fc3b488e37b41ca5d438f25080e519 100644 (file)
@@ -2,9 +2,9 @@
 # It is not intended for manual editing.
 [[package]]
 name = "activitystreams"
-version = "0.6.0"
+version = "0.6.2"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "dd5b29a0f2c64cc56f2b79ec29cab68a9dab3b714d811a55668d072f18a8638e"
+checksum = "464cb473bfb402b857cc15b1153974c203a43f1485da4dda15cd17a738548958"
 dependencies = [
  "activitystreams-derive",
  "chrono",
@@ -26,6 +26,17 @@ dependencies = [
  "syn",
 ]
 
+[[package]]
+name = "activitystreams-new"
+version = "0.1.0"
+source = "git+https://git.asonix.dog/asonix/activitystreams-sketch#3f75e56190bd2e942621e8265435c74132639a47"
+dependencies = [
+ "activitystreams",
+ "serde 1.0.106",
+ "serde_json 1.0.51",
+ "typed-builder",
+]
+
 [[package]]
 name = "actix"
 version = "0.9.0"
@@ -1544,6 +1555,7 @@ name = "lemmy_server"
 version = "0.0.1"
 dependencies = [
  "activitystreams",
+ "activitystreams-new",
  "actix",
  "actix-files",
  "actix-rt",
@@ -2992,6 +3004,16 @@ version = "1.7.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "a9b2228007eba4120145f785df0f6c92ea538f5a3635a612ecf4e334c8c1446d"
 
+[[package]]
+name = "typed-builder"
+version = "0.5.1"
+source = "git+https://git.asonix.dog/asonix/typed-builder#3dadcaaa6184ef720093c8f0632a7d423d2537b0"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn",
+]
+
 [[package]]
 name = "typenum"
 version = "1.12.0"
index ab76d06fa11b1f85daf0da7f7a260a3f6c9f226e..2c11c1914a22a690160b9ce30f3fb6013765f52c 100644 (file)
@@ -4,11 +4,15 @@ version = "0.0.1"
 authors = ["Dessalines <happydooby@gmail.com>"]
 edition = "2018"
 
+[patch.crates-io]
+typed-builder = { git = "https://git.asonix.dog/asonix/typed-builder" }
+
 [dependencies]
 diesel = { version = "1.4.4", features = ["postgres","chrono","r2d2","64-column-tables","serde_json"] }
 diesel_migrations = "1.4.0"
 dotenv = "0.15.0"
-activitystreams = "0.6.0"
+activitystreams = "0.6.2"
+activitystreams-new = { version = "0.1.0", git = "https://git.asonix.dog/asonix/activitystreams-sketch" }
 bcrypt = "0.6.2"
 chrono = { version = "0.4.7", features = ["serde"] }
 failure = "0.1.5"
index 0660a52c8598dfdc5fac6ae88899db2a04233bb1..40f87ac9c8cce512b1a2aa39de4b8a0366c4fbdc 100644 (file)
@@ -1,4 +1,41 @@
-use super::*;
+use crate::{
+  api::{APIError, Oper, Perform},
+  apub::{ApubLikeableType, ApubObjectType},
+  db::{
+    comment::*,
+    comment_view::*,
+    community_view::*,
+    moderator::*,
+    post::*,
+    site_view::*,
+    user::*,
+    user_mention::*,
+    user_view::*,
+    Crud,
+    Likeable,
+    ListingType,
+    Saveable,
+    SortType,
+  },
+  extract_usernames,
+  naive_now,
+  remove_slurs,
+  send_email,
+  settings::Settings,
+  websocket::{
+    server::{JoinCommunityRoom, SendComment},
+    UserOperation,
+    WebsocketInfo,
+  },
+};
+use diesel::{
+  r2d2::{ConnectionManager, Pool},
+  PgConnection,
+};
+use failure::Error;
+use log::error;
+use serde::{Deserialize, Serialize};
+use std::str::FromStr;
 
 #[derive(Serialize, Deserialize)]
 pub struct CreateComment {
index 55c55ee12b3983e7f39d3619ab7d357ebf334604..cb412fccade6b45174f3a72b81fac99cd1064cb3 100644 (file)
@@ -1,4 +1,41 @@
-use super::*;
+use crate::{
+  api::{APIError, Oper, Perform},
+  apub::{
+    extensions::signatures::generate_actor_keypair,
+    make_apub_endpoint,
+    ActorType,
+    EndpointType,
+  },
+  db::{
+    community::*,
+    community_view::*,
+    moderator::*,
+    site::*,
+    user::*,
+    user_view::*,
+    Bannable,
+    Crud,
+    Followable,
+    Joinable,
+    SortType,
+  },
+  naive_from_unix,
+  naive_now,
+  slur_check,
+  slurs_vec_to_str,
+  websocket::{
+    server::{JoinCommunityRoom, SendCommunityRoomMessage},
+    UserOperation,
+    WebsocketInfo,
+  },
+};
+use diesel::{
+  r2d2::{ConnectionManager, Pool},
+  PgConnection,
+};
+use failure::Error;
+use serde::{Deserialize, Serialize};
+use std::str::FromStr;
 
 #[derive(Serialize, Deserialize)]
 pub struct GetCommunity {
index 9112a3be32829febd3b3888c915b48d0059d92db..5120e9bc949fb5b9bc9cbe54a082f015802423ad 100644 (file)
@@ -1,46 +1,9 @@
-use crate::db::category::*;
-use crate::db::comment::*;
-use crate::db::comment_view::*;
-use crate::db::community::*;
-use crate::db::community_view::*;
-use crate::db::moderator::*;
-use crate::db::moderator_views::*;
-use crate::db::password_reset_request::*;
-use crate::db::post::*;
-use crate::db::post_view::*;
-use crate::db::private_message::*;
-use crate::db::private_message_view::*;
-use crate::db::site::*;
-use crate::db::site_view::*;
-use crate::db::user::*;
-use crate::db::user_mention::*;
-use crate::db::user_mention_view::*;
-use crate::db::user_view::*;
-use crate::db::*;
-use crate::{
-  extract_usernames, fetch_iframely_and_pictshare_data, generate_random_string, naive_from_unix,
-  naive_now, remove_slurs, send_email, slur_check, slurs_vec_to_str,
+use crate::websocket::WebsocketInfo;
+use diesel::{
+  r2d2::{ConnectionManager, Pool},
+  PgConnection,
 };
-
-use crate::apub::{
-  extensions::signatures::generate_actor_keypair,
-  fetcher::search_by_apub_id,
-  {make_apub_endpoint, ActorType, ApubLikeableType, ApubObjectType, EndpointType},
-};
-use crate::settings::Settings;
-use crate::websocket::{
-  server::{
-    JoinCommunityRoom, JoinPostRoom, JoinUserRoom, SendAllMessage, SendComment,
-    SendCommunityRoomMessage, SendPost, SendUserRoomMessage,
-  },
-  UserOperation, WebsocketInfo,
-};
-use diesel::r2d2::{ConnectionManager, Pool};
-use diesel::PgConnection;
 use failure::Error;
-use log::{debug, error, info};
-use serde::{Deserialize, Serialize};
-use std::str::FromStr;
 
 pub mod comment;
 pub mod community;
index 42c350741933322c02787e4e832835ff72d6ce63..9bbde791977b8f4f16b2010b85a66616f311473b 100644 (file)
@@ -1,4 +1,39 @@
-use super::*;
+use crate::{
+  api::{APIError, Oper, Perform},
+  apub::{ApubLikeableType, ApubObjectType},
+  db::{
+    comment_view::*,
+    community_view::*,
+    moderator::*,
+    post::*,
+    post_view::*,
+    site::*,
+    site_view::*,
+    user::*,
+    user_view::*,
+    Crud,
+    Likeable,
+    ListingType,
+    Saveable,
+    SortType,
+  },
+  fetch_iframely_and_pictshare_data,
+  naive_now,
+  slur_check,
+  slurs_vec_to_str,
+  websocket::{
+    server::{JoinCommunityRoom, JoinPostRoom, SendPost},
+    UserOperation,
+    WebsocketInfo,
+  },
+};
+use diesel::{
+  r2d2::{ConnectionManager, Pool},
+  PgConnection,
+};
+use failure::Error;
+use serde::{Deserialize, Serialize};
+use std::str::FromStr;
 
 #[derive(Serialize, Deserialize, Debug)]
 pub struct CreatePost {
index 1a4ed0be5c99f66fdf423382988afbd8d78a3cfe..faee30cbb5fd5af1d0dc87e69212c5a075df7e1b 100644 (file)
@@ -1,5 +1,36 @@
 use super::user::Register;
-use super::*;
+use crate::{
+  api::{APIError, Oper, Perform},
+  apub::fetcher::search_by_apub_id,
+  db::{
+    category::*,
+    comment_view::*,
+    community_view::*,
+    moderator::*,
+    moderator_views::*,
+    post_view::*,
+    site::*,
+    site_view::*,
+    user::*,
+    user_view::*,
+    Crud,
+    SearchType,
+    SortType,
+  },
+  naive_now,
+  settings::Settings,
+  slur_check,
+  slurs_vec_to_str,
+  websocket::{server::SendAllMessage, UserOperation, WebsocketInfo},
+};
+use diesel::{
+  r2d2::{ConnectionManager, Pool},
+  PgConnection,
+};
+use failure::Error;
+use log::{debug, info};
+use serde::{Deserialize, Serialize};
+use std::str::FromStr;
 
 #[derive(Serialize, Deserialize)]
 pub struct ListCategories {}
index b5336609a3d3ba45f67b43996fc3893108c526ab..18d309850840a4edf6b8c8d235cb03f300a6c20f 100644 (file)
@@ -1,5 +1,57 @@
-use super::*;
+use crate::{
+  api::{APIError, Oper, Perform},
+  apub::{
+    extensions::signatures::generate_actor_keypair,
+    make_apub_endpoint,
+    ApubObjectType,
+    EndpointType,
+  },
+  db::{
+    comment::*,
+    comment_view::*,
+    community::*,
+    community_view::*,
+    moderator::*,
+    password_reset_request::*,
+    post::*,
+    post_view::*,
+    private_message::*,
+    private_message_view::*,
+    site::*,
+    site_view::*,
+    user::*,
+    user_mention::*,
+    user_mention_view::*,
+    user_view::*,
+    Crud,
+    Followable,
+    Joinable,
+    ListingType,
+    SortType,
+  },
+  generate_random_string,
+  naive_from_unix,
+  naive_now,
+  remove_slurs,
+  send_email,
+  settings::Settings,
+  slur_check,
+  slurs_vec_to_str,
+  websocket::{
+    server::{JoinUserRoom, SendAllMessage, SendUserRoomMessage},
+    UserOperation,
+    WebsocketInfo,
+  },
+};
 use bcrypt::verify;
+use diesel::{
+  r2d2::{ConnectionManager, Pool},
+  PgConnection,
+};
+use failure::Error;
+use log::error;
+use serde::{Deserialize, Serialize};
+use std::str::FromStr;
 
 #[derive(Serialize, Deserialize, Debug)]
 pub struct Login {
index 23ae969872b63ebd8f00e82c809b9670ac21542c..655e4a7a5af317ab7d9a8de3e605d1c3d5ad8663 100644 (file)
@@ -1,4 +1,10 @@
-use super::*;
+use crate::apub::{extensions::signatures::sign, is_apub_id_valid, ActorType};
+use activitystreams::{context, object::properties::ObjectProperties, public};
+use failure::{Error, _core::fmt::Debug};
+use isahc::prelude::*;
+use log::debug;
+use serde::Serialize;
+use url::Url;
 
 pub fn populate_object_props(
   props: &mut ObjectProperties,
index df41f67be6707f3a5d38d07fbc7c18defc7e22b3..97f9c27246e9026788dce69458d99825223b1247 100644 (file)
@@ -1,4 +1,36 @@
-use super::*;
+use crate::{
+  apub::{
+    activities::{populate_object_props, send_activity},
+    create_apub_response,
+    create_apub_tombstone_response,
+    create_tombstone,
+    fetcher::get_or_fetch_and_upsert_remote_user,
+    ActorType,
+    ApubLikeableType,
+    ApubObjectType,
+    FromApub,
+    ToApub,
+  },
+  convert_datetime,
+  db::{
+    activity::insert_activity,
+    comment::{Comment, CommentForm},
+    community::Community,
+    post::Post,
+    user::User_,
+    Crud,
+  },
+  routes::DbPoolParam,
+};
+use activitystreams::{
+  activity::{Create, Delete, Dislike, Like, Remove, Undo, Update},
+  context,
+  object::{kind::NoteType, properties::ObjectProperties, Note, Tombstone},
+};
+use actix_web::{body::Body, web::Path, HttpResponse, Result};
+use diesel::PgConnection;
+use failure::Error;
+use serde::Deserialize;
 
 #[derive(Deserialize)]
 pub struct CommentQuery {
index f4e8848f234c071f15dedc29409ce296961a6f20..12ce2800acd658a318c4b12ef22546d5aba3c172 100644 (file)
@@ -1,4 +1,42 @@
-use super::*;
+use crate::{
+  apub::{
+    activities::{populate_object_props, send_activity},
+    create_apub_response,
+    create_apub_tombstone_response,
+    create_tombstone,
+    extensions::{group_extensions::GroupExtension, signatures::PublicKey},
+    fetcher::get_or_fetch_and_upsert_remote_user,
+    get_shared_inbox,
+    ActorType,
+    FromApub,
+    GroupExt,
+    ToApub,
+  },
+  convert_datetime,
+  db::{
+    activity::insert_activity,
+    community::{Community, CommunityForm},
+    community_view::{CommunityFollowerView, CommunityModeratorView},
+    user::User_,
+  },
+  naive_now,
+  routes::DbPoolParam,
+};
+use activitystreams::{
+  activity::{Accept, Delete, Follow, Remove, Undo},
+  actor::{kind::GroupType, properties::ApActorProperties, Group},
+  collection::UnorderedCollection,
+  context,
+  endpoint::EndpointProperties,
+  ext::Extensible,
+  object::{properties::ObjectProperties, Tombstone},
+  BaseBox,
+};
+use actix_web::{body::Body, web::Path, HttpResponse, Result};
+use diesel::PgConnection;
+use failure::Error;
+use itertools::Itertools;
+use serde::Deserialize;
 
 #[derive(Deserialize)]
 pub struct CommunityQuery {
index 6c35ce0aa59060468869b60869ba0e4ac7e2ddf6..2ae2e0ebc01c2231946b3ebc79d79f05b9cad8a7 100644 (file)
@@ -1,4 +1,23 @@
-use super::*;
+use crate::{
+  apub::{
+    extensions::signatures::verify,
+    fetcher::{get_or_fetch_and_upsert_remote_community, get_or_fetch_and_upsert_remote_user},
+    ActorType,
+  },
+  db::{
+    activity::insert_activity,
+    community::{Community, CommunityFollower, CommunityFollowerForm},
+    user::User_,
+    Followable,
+  },
+  routes::{ChatServerParam, DbPoolParam},
+};
+use activitystreams::activity::{Follow, Undo};
+use actix_web::{web, HttpRequest, HttpResponse, Result};
+use diesel::PgConnection;
+use failure::{Error, _core::fmt::Debug};
+use log::debug;
+use serde::Deserialize;
 
 #[serde(untagged)]
 #[derive(Deserialize, Debug)]
index 10cee5c72bba54cd7f8b622d9c6efeccda1e7482..ece97706cede84438cdff4f4dff6ed4622ed89b4 100644 (file)
@@ -1,7 +1,5 @@
-use crate::db::category::Category;
-use crate::db::Crud;
-use activitystreams::ext::Extension;
-use activitystreams::Actor;
+use crate::db::{category::Category, Crud};
+use activitystreams::{ext::Extension, Actor};
 use diesel::PgConnection;
 use failure::Error;
 use serde::{Deserialize, Serialize};
index 435a869a9c3894391cb0782be17393d38c5e9fba..484807e3eaa208ecb87b2cb5cdccc32ff5d27114 100644 (file)
@@ -1,5 +1,4 @@
-use activitystreams::ext::Extension;
-use activitystreams::Base;
+use activitystreams::{ext::Extension, Base};
 use serde::{Deserialize, Serialize};
 
 #[derive(Clone, Debug, Default, Deserialize, Serialize)]
index e8630f214309bb45608ac6d43235dd17e50a34bd..a78488276ad531b2718faa7d6dc4939f17a94d5d 100644 (file)
@@ -5,9 +5,12 @@ use failure::Error;
 use http::request::Builder;
 use http_signature_normalization::Config;
 use log::debug;
-use openssl::hash::MessageDigest;
-use openssl::sign::{Signer, Verifier};
-use openssl::{pkey::PKey, rsa::Rsa};
+use openssl::{
+  hash::MessageDigest,
+  pkey::PKey,
+  rsa::Rsa,
+  sign::{Signer, Verifier},
+};
 use serde::{Deserialize, Serialize};
 use std::collections::BTreeMap;
 
index 994e75f2bbb5a6fcf09730d7d1bccba505ded2cd..9379dd96b98948f77241e171f6a2ea767ef690ca 100644 (file)
@@ -1,4 +1,43 @@
-use super::*;
+use activitystreams::object::Note;
+use actix_web::Result;
+use diesel::{result::Error::NotFound, PgConnection};
+use failure::{Error, _core::fmt::Debug};
+use isahc::prelude::*;
+use log::debug;
+use serde::Deserialize;
+use std::time::Duration;
+use url::Url;
+
+use crate::{
+  api::site::SearchResponse,
+  db::{
+    comment::{Comment, CommentForm},
+    comment_view::CommentView,
+    community::{Community, CommunityForm, CommunityModerator, CommunityModeratorForm},
+    community_view::CommunityView,
+    post::{Post, PostForm},
+    post_view::PostView,
+    user::{UserForm, User_},
+    Crud,
+    Joinable,
+    SearchType,
+  },
+  naive_now,
+  routes::nodeinfo::{NodeInfo, NodeInfoWellKnown},
+};
+
+use crate::{
+  apub::{
+    get_apub_protocol_string,
+    is_apub_id_valid,
+    FromApub,
+    GroupExt,
+    PageExt,
+    PersonExt,
+    APUB_JSON_CONTENT_TYPE,
+  },
+  db::user_view::UserView,
+};
 
 // Fetch nodeinfo metadata from a remote instance.
 fn _fetch_node_info(domain: &str) -> Result<NodeInfo, Error> {
index 6ff6a0f8fac0d8c1e4ff2621bbc5b9171c4c8f86..fdd781094bfb381d91e2ee69e0f70722298a5bf4 100644 (file)
@@ -10,68 +10,29 @@ pub mod shared_inbox;
 pub mod user;
 pub mod user_inbox;
 
-use crate::api::community::CommunityResponse;
-use crate::db::activity::insert_activity;
-use crate::websocket::server::SendCommunityRoomMessage;
-use activitystreams::object::kind::{NoteType, PageType};
+use crate::{
+  apub::extensions::{
+    group_extensions::GroupExtension,
+    page_extension::PageExtension,
+    signatures::{PublicKey, PublicKeyExtension},
+  },
+  convert_datetime,
+  db::user::User_,
+  Settings,
+};
 use activitystreams::{
-  activity::{Accept, Create, Delete, Dislike, Follow, Like, Remove, Undo, Update},
-  actor::{kind::GroupType, properties::ApActorProperties, Group, Person},
-  collection::UnorderedCollection,
-  context,
-  endpoint::EndpointProperties,
-  ext::{Ext, Extensible},
-  object::{properties::ObjectProperties, Note, Page, Tombstone},
-  public, BaseBox,
+  activity::Follow,
+  actor::{properties::ApActorProperties, Group, Person},
+  ext::Ext,
+  object::{Page, Tombstone},
 };
-use actix_web::body::Body;
-use actix_web::web::Path;
-use actix_web::{web, HttpRequest, HttpResponse, Result};
-use diesel::result::Error::NotFound;
+use actix_web::{body::Body, HttpResponse, Result};
+use chrono::NaiveDateTime;
 use diesel::PgConnection;
 use failure::Error;
-use failure::_core::fmt::Debug;
-use isahc::prelude::*;
-use itertools::Itertools;
-use log::debug;
-use serde::{Deserialize, Serialize};
-use std::time::Duration;
+use serde::Serialize;
 use url::Url;
 
-use crate::api::comment::CommentResponse;
-use crate::api::post::PostResponse;
-use crate::api::site::SearchResponse;
-use crate::api::user::PrivateMessageResponse;
-use crate::db::comment::{Comment, CommentForm, CommentLike, CommentLikeForm};
-use crate::db::comment_view::CommentView;
-use crate::db::community::{
-  Community, CommunityFollower, CommunityFollowerForm, CommunityForm, CommunityModerator,
-  CommunityModeratorForm,
-};
-use crate::db::community_view::{CommunityFollowerView, CommunityModeratorView, CommunityView};
-use crate::db::post::{Post, PostForm, PostLike, PostLikeForm};
-use crate::db::post_view::PostView;
-use crate::db::private_message::{PrivateMessage, PrivateMessageForm};
-use crate::db::private_message_view::PrivateMessageView;
-use crate::db::user::{UserForm, User_};
-use crate::db::user_view::UserView;
-use crate::db::{Crud, Followable, Joinable, Likeable, SearchType};
-use crate::routes::nodeinfo::{NodeInfo, NodeInfoWellKnown};
-use crate::routes::{ChatServerParam, DbPoolParam};
-use crate::websocket::{
-  server::{SendComment, SendPost, SendUserRoomMessage},
-  UserOperation,
-};
-use crate::{convert_datetime, naive_now, Settings};
-
-use crate::apub::extensions::group_extensions::GroupExtension;
-use crate::apub::extensions::page_extension::PageExtension;
-use activities::{populate_object_props, send_activity};
-use chrono::NaiveDateTime;
-use extensions::signatures::verify;
-use extensions::signatures::{sign, PublicKey, PublicKeyExtension};
-use fetcher::{get_or_fetch_and_upsert_remote_community, get_or_fetch_and_upsert_remote_user};
-
 type GroupExt = Ext<Ext<Ext<Group, GroupExtension>, ApActorProperties>, PublicKeyExtension>;
 type PersonExt = Ext<Ext<Person, ApActorProperties>, PublicKeyExtension>;
 type PageExt = Ext<Page, PageExtension>;
index b2374ffd7d585e1877518607cb0c0b641b5be9b6..2e567ab04ae25a12742dcda69fe7fa86ec0a7d17 100644 (file)
@@ -1,4 +1,38 @@
-use super::*;
+use crate::{
+  apub::{
+    activities::{populate_object_props, send_activity},
+    create_apub_response,
+    create_apub_tombstone_response,
+    create_tombstone,
+    extensions::page_extension::PageExtension,
+    fetcher::{get_or_fetch_and_upsert_remote_community, get_or_fetch_and_upsert_remote_user},
+    ActorType,
+    ApubLikeableType,
+    ApubObjectType,
+    FromApub,
+    PageExt,
+    ToApub,
+  },
+  convert_datetime,
+  db::{
+    activity::insert_activity,
+    community::Community,
+    post::{Post, PostForm},
+    user::User_,
+    Crud,
+  },
+  routes::DbPoolParam,
+};
+use activitystreams::{
+  activity::{Create, Delete, Dislike, Like, Remove, Undo, Update},
+  context,
+  ext::Extensible,
+  object::{kind::PageType, properties::ObjectProperties, Page, Tombstone},
+};
+use actix_web::{body::Body, web::Path, HttpResponse, Result};
+use diesel::PgConnection;
+use failure::Error;
+use serde::Deserialize;
 
 #[derive(Deserialize)]
 pub struct PostQuery {
index 3fff75dc2365a1b67cff885e8dc177be3856502a..a222b1fef4ea172ba866ef9ead9a3779b6ce8131 100644 (file)
@@ -1,4 +1,28 @@
-use super::*;
+use crate::{
+  apub::{
+    activities::send_activity,
+    create_tombstone,
+    fetcher::get_or_fetch_and_upsert_remote_user,
+    ApubObjectType,
+    FromApub,
+    ToApub,
+  },
+  convert_datetime,
+  db::{
+    activity::insert_activity,
+    private_message::{PrivateMessage, PrivateMessageForm},
+    user::User_,
+    Crud,
+  },
+};
+use activitystreams::{
+  activity::{Create, Delete, Undo, Update},
+  context,
+  object::{kind::NoteType, properties::ObjectProperties, Note, Tombstone},
+};
+use actix_web::Result;
+use diesel::PgConnection;
+use failure::Error;
 
 impl ToApub for PrivateMessage {
   type Response = Note;
index 6bbe9725138860decb5116aace3a8e6c7fab3b7f..51b7826df3b9c37f8a59bfdcb611608fa15a375b 100644 (file)
@@ -1,4 +1,40 @@
-use super::*;
+use crate::{
+  api::{comment::CommentResponse, community::CommunityResponse, post::PostResponse},
+  apub::{
+    extensions::signatures::verify,
+    fetcher::get_or_fetch_and_upsert_remote_user,
+    FromApub,
+    GroupExt,
+    PageExt,
+  },
+  db::{
+    activity::insert_activity,
+    comment::{Comment, CommentForm, CommentLike, CommentLikeForm},
+    comment_view::CommentView,
+    community::{Community, CommunityForm},
+    community_view::CommunityView,
+    post::{Post, PostForm, PostLike, PostLikeForm},
+    post_view::PostView,
+    Crud,
+    Likeable,
+  },
+  naive_now,
+  routes::{ChatServerParam, DbPoolParam},
+  websocket::{
+    server::{SendComment, SendCommunityRoomMessage, SendPost},
+    UserOperation,
+  },
+};
+use activitystreams::{
+  activity::{Create, Delete, Dislike, Like, Remove, Undo, Update},
+  object::Note,
+  BaseBox,
+};
+use actix_web::{web, HttpRequest, HttpResponse, Result};
+use diesel::PgConnection;
+use failure::{Error, _core::fmt::Debug};
+use log::debug;
+use serde::{Deserialize, Serialize};
 
 #[serde(untagged)]
 #[derive(Serialize, Deserialize, Debug)]
index 61661de47e2b5a792ebc3496f4d486b930d7f234..dac6bc313bd0ea25b059bd7c71ae55574d524035 100644 (file)
@@ -1,4 +1,33 @@
-use super::*;
+use crate::{
+  apub::{
+    activities::send_activity,
+    create_apub_response,
+    extensions::signatures::PublicKey,
+    ActorType,
+    FromApub,
+    PersonExt,
+    ToApub,
+  },
+  convert_datetime,
+  db::{
+    activity::insert_activity,
+    user::{UserForm, User_},
+  },
+  naive_now,
+  routes::DbPoolParam,
+};
+use activitystreams::{
+  activity::{Follow, Undo},
+  actor::{properties::ApActorProperties, Person},
+  context,
+  endpoint::EndpointProperties,
+  ext::Extensible,
+  object::{properties::ObjectProperties, Tombstone},
+};
+use actix_web::{body::Body, web::Path, HttpResponse, Result};
+use diesel::PgConnection;
+use failure::Error;
+use serde::Deserialize;
 
 #[derive(Deserialize)]
 pub struct UserQuery {
index 3035deba8acbd4752e6fe33ad4f0a0bca82661e0..f60a2ba9b692f1f43ed23ea1212ce1dd1683fdea 100644 (file)
@@ -1,4 +1,32 @@
-use super::*;
+use crate::{
+  api::user::PrivateMessageResponse,
+  apub::{
+    extensions::signatures::verify,
+    fetcher::{get_or_fetch_and_upsert_remote_community, get_or_fetch_and_upsert_remote_user},
+    FromApub,
+  },
+  db::{
+    activity::insert_activity,
+    community::{CommunityFollower, CommunityFollowerForm},
+    private_message::{PrivateMessage, PrivateMessageForm},
+    private_message_view::PrivateMessageView,
+    user::User_,
+    Crud,
+    Followable,
+  },
+  naive_now,
+  routes::{ChatServerParam, DbPoolParam},
+  websocket::{server::SendUserRoomMessage, UserOperation},
+};
+use activitystreams::{
+  activity::{Accept, Create, Delete, Undo, Update},
+  object::Note,
+};
+use actix_web::{web, HttpRequest, HttpResponse, Result};
+use diesel::PgConnection;
+use failure::{Error, _core::fmt::Debug};
+use log::debug;
+use serde::Deserialize;
 
 #[serde(untagged)]
 #[derive(Deserialize, Debug)]
index 70f9d6b64c8f40c0614395d18ecb7f4abd648dab..bb8a74d479741903d54ae8fa6068e3f116c9349e 100644 (file)
@@ -1,5 +1,6 @@
-use super::*;
-use crate::schema::activity;
+use crate::{db::Crud, schema::activity};
+use diesel::{dsl::*, result::Error, *};
+use serde::{Deserialize, Serialize};
 use serde_json::Value;
 
 #[derive(Queryable, Identifiable, PartialEq, Debug, Serialize, Deserialize)]
@@ -72,8 +73,8 @@ where
 
 #[cfg(test)]
 mod tests {
-  use super::super::user::*;
-  use super::*;
+  use super::{super::user::*, *};
+  use crate::db::{establish_unpooled_connection, Crud, ListingType, SortType};
 
   #[test]
   fn test_crud() {
index 408c8231bfb215e43319cb4aac62dd86baeb48ea..ff49bbbee3057194d284ef349c2e104902a50a54 100644 (file)
@@ -1,6 +1,9 @@
-use super::*;
-use crate::schema::category;
-use crate::schema::category::dsl::*;
+use crate::{
+  db::Crud,
+  schema::{category, category::dsl::*},
+};
+use diesel::{dsl::*, result::Error, *};
+use serde::{Deserialize, Serialize};
 
 #[derive(Queryable, Identifiable, PartialEq, Debug, Serialize, Deserialize)]
 #[table_name = "category"]
@@ -50,6 +53,8 @@ impl Category {
 #[cfg(test)]
 mod tests {
   use super::*;
+  use crate::db::establish_unpooled_connection;
+
   #[test]
   fn test_crud() {
     let conn = establish_unpooled_connection();
index b51996db239115b81de88680d4fdc242a34937f5..204bfe791b1058c83ff58fb17d572378d3edbf5b 100644 (file)
@@ -1,13 +1,17 @@
 // This is for db migrations that require code
-use super::comment::Comment;
-use super::community::{Community, CommunityForm};
-use super::post::Post;
-use super::private_message::PrivateMessage;
-use super::user::{UserForm, User_};
-use super::*;
-use crate::apub::extensions::signatures::generate_actor_keypair;
-use crate::apub::{make_apub_endpoint, EndpointType};
-use crate::naive_now;
+use super::{
+  comment::Comment,
+  community::{Community, CommunityForm},
+  post::Post,
+  private_message::PrivateMessage,
+  user::{UserForm, User_},
+};
+use crate::{
+  apub::{extensions::signatures::generate_actor_keypair, make_apub_endpoint, EndpointType},
+  db::Crud,
+  naive_now,
+};
+use diesel::*;
 use failure::Error;
 use log::info;
 
index 2e8b54c3bb043387b2c817e3f8b1d831d87761b2..ddf1feef862ea10fb77acc31b41a6def01da7758 100644 (file)
@@ -1,8 +1,9 @@
-use super::post::Post;
-use super::*;
-use crate::apub::{make_apub_endpoint, EndpointType};
-use crate::naive_now;
-use crate::schema::{comment, comment_like, comment_saved};
+use super::{post::Post, *};
+use crate::{
+  apub::{make_apub_endpoint, EndpointType},
+  naive_now,
+  schema::{comment, comment_like, comment_saved},
+};
 
 // WITH RECURSIVE MyTree AS (
 //     SELECT * FROM comment WHERE parent_id IS NULL
@@ -203,10 +204,10 @@ impl Saveable<CommentSavedForm> for CommentSaved {
 
 #[cfg(test)]
 mod tests {
-  use super::super::community::*;
-  use super::super::post::*;
-  use super::super::user::*;
-  use super::*;
+  use super::{
+    super::{community::*, post::*, user::*},
+    *,
+  };
   #[test]
   fn test_crud() {
     let conn = establish_unpooled_connection();
index a94aa15792fa8135ab915b3ca1c00af560b32398..52f7d9490777520556f7e065918f194ea717d58c 100644 (file)
@@ -1,5 +1,6 @@
-use super::*;
-use diesel::pg::Pg;
+use crate::db::{fuzzy_search, limit_and_offset, ListingType, MaybeOptional, SortType};
+use diesel::{dsl::*, pg::Pg, result::Error, *};
+use serde::{Deserialize, Serialize};
 
 // The faked schema since diesel doesn't do views
 table! {
@@ -453,11 +454,12 @@ impl<'a> ReplyQueryBuilder<'a> {
 
 #[cfg(test)]
 mod tests {
-  use super::super::comment::*;
-  use super::super::community::*;
-  use super::super::post::*;
-  use super::super::user::*;
-  use super::*;
+  use super::{
+    super::{comment::*, community::*, post::*, user::*},
+    *,
+  };
+  use crate::db::{establish_unpooled_connection, Crud, Likeable};
+
   #[test]
   fn test_crud() {
     let conn = establish_unpooled_connection();
index 9b858fde349232ff87b966d1231ceb099025f2a0..e7d92318188f4d3c13426d0ac54c68f4d65e3b04 100644 (file)
@@ -1,5 +1,10 @@
-use super::*;
-use crate::schema::{community, community_follower, community_moderator, community_user_ban};
+use crate::{
+  db::{Bannable, Crud, Followable, Joinable},
+  schema::{community, community_follower, community_moderator, community_user_ban},
+  settings::Settings,
+};
+use diesel::{dsl::*, result::Error, *};
+use serde::{Deserialize, Serialize};
 
 #[derive(Queryable, Identifiable, PartialEq, Debug, Serialize, Deserialize)]
 #[table_name = "community"]
@@ -232,8 +237,9 @@ impl Followable<CommunityFollowerForm> for CommunityFollower {
 
 #[cfg(test)]
 mod tests {
-  use super::super::user::*;
-  use super::*;
+  use super::{super::user::*, *};
+  use crate::db::{establish_unpooled_connection, ListingType, SortType};
+
   #[test]
   fn test_crud() {
     let conn = establish_unpooled_connection();
index 3e946f472afb773a5fbe6c2310e9a5f8b4196529..ea7b2a7cadfa51950221307b63c188befa6d541c 100644 (file)
@@ -1,6 +1,7 @@
 use super::community_view::community_mview::BoxedQuery;
-use super::*;
-use diesel::pg::Pg;
+use crate::db::{fuzzy_search, limit_and_offset, MaybeOptional, SortType};
+use diesel::{pg::Pg, result::Error, *};
+use serde::{Deserialize, Serialize};
 
 table! {
   community_view (id) {
index ed334b8c7bc6c698a27b68e9c1add9269a9bc5fa..da69f8dcdc88dcf925dda24edb93dc8aa5ffae0a 100644 (file)
@@ -1,7 +1,5 @@
 use crate::settings::Settings;
-use diesel::dsl::*;
-use diesel::result::Error;
-use diesel::*;
+use diesel::{dsl::*, result::Error, *};
 use serde::{Deserialize, Serialize};
 
 pub mod activity;
index a040c0ca889a63b8cff5384c283cab9e91b423ff..d0f589e30fdfe543d960890ef9726ea6fcf94920 100644 (file)
@@ -1,8 +1,19 @@
-use super::*;
-use crate::schema::{
-  mod_add, mod_add_community, mod_ban, mod_ban_from_community, mod_lock_post, mod_remove_comment,
-  mod_remove_community, mod_remove_post, mod_sticky_post,
+use crate::{
+  db::Crud,
+  schema::{
+    mod_add,
+    mod_add_community,
+    mod_ban,
+    mod_ban_from_community,
+    mod_lock_post,
+    mod_remove_comment,
+    mod_remove_community,
+    mod_remove_post,
+    mod_sticky_post,
+  },
 };
+use diesel::{dsl::*, result::Error, *};
+use serde::{Deserialize, Serialize};
 
 #[derive(Queryable, Identifiable, PartialEq, Debug, Serialize, Deserialize)]
 #[table_name = "mod_remove_post"]
@@ -426,11 +437,12 @@ impl Crud<ModAddForm> for ModAdd {
 
 #[cfg(test)]
 mod tests {
-  use super::super::comment::*;
-  use super::super::community::*;
-  use super::super::post::*;
-  use super::super::user::*;
-  use super::*;
+  use super::{
+    super::{comment::*, community::*, post::*, user::*},
+    *,
+  };
+  use crate::db::{establish_unpooled_connection, ListingType, SortType};
+
   // use Crud;
   #[test]
   fn test_crud() {
index 0413e0b10b7a104eea72b9bae49cf0d90e4dcb42..f5b109fe6160f91437dfd147c41f96cea37e196d 100644 (file)
@@ -1,4 +1,6 @@
-use super::*;
+use crate::db::limit_and_offset;
+use diesel::{result::Error, *};
+use serde::{Deserialize, Serialize};
 
 table! {
   mod_remove_post_view (id) {
index ea8b2964a3bd2ce23c30c88445ebdd4fbabc9c07..32d7f187d0ad491f463e85ef6cab22d28aa5c507 100644 (file)
@@ -1,6 +1,8 @@
-use super::*;
-use crate::schema::password_reset_request;
-use crate::schema::password_reset_request::dsl::*;
+use crate::{
+  db::Crud,
+  schema::{password_reset_request, password_reset_request::dsl::*},
+};
+use diesel::{dsl::*, result::Error, *};
 use sha2::{Digest, Sha256};
 
 #[derive(Queryable, Identifiable, PartialEq, Debug)]
@@ -79,8 +81,8 @@ impl PasswordResetRequest {
 
 #[cfg(test)]
 mod tests {
-  use super::super::user::*;
-  use super::*;
+  use super::{super::user::*, *};
+  use crate::db::{establish_unpooled_connection, ListingType, SortType};
 
   #[test]
   fn test_crud() {
index bdd3306117afb1d2774ed4a3aa08622e72524587..d12f98d81542fdb526642db75092df13a5557dcb 100644 (file)
@@ -1,7 +1,11 @@
-use super::*;
-use crate::apub::{make_apub_endpoint, EndpointType};
-use crate::naive_now;
-use crate::schema::{post, post_like, post_read, post_saved};
+use crate::{
+  apub::{make_apub_endpoint, EndpointType},
+  db::{Crud, Likeable, Readable, Saveable},
+  naive_now,
+  schema::{post, post_like, post_read, post_saved},
+};
+use diesel::{dsl::*, result::Error, *};
+use serde::{Deserialize, Serialize};
 
 #[derive(Queryable, Identifiable, PartialEq, Debug, Serialize, Deserialize)]
 #[table_name = "post"]
@@ -237,9 +241,12 @@ impl Readable<PostReadForm> for PostRead {
 
 #[cfg(test)]
 mod tests {
-  use super::super::community::*;
-  use super::super::user::*;
-  use super::*;
+  use super::{
+    super::{community::*, user::*},
+    *,
+  };
+  use crate::db::{establish_unpooled_connection, ListingType, SortType};
+
   #[test]
   fn test_crud() {
     let conn = establish_unpooled_connection();
index a7ac58c034e6096e469b9c6fb962829fc25f1afc..0948894221f24c3440c992b92733f3906f9ded08 100644 (file)
@@ -1,6 +1,7 @@
 use super::post_view::post_mview::BoxedQuery;
-use super::*;
-use diesel::pg::Pg;
+use crate::db::{fuzzy_search, limit_and_offset, ListingType, MaybeOptional, SortType};
+use diesel::{dsl::*, pg::Pg, result::Error, *};
+use serde::{Deserialize, Serialize};
 
 // The faked schema since diesel doesn't do views
 table! {
@@ -363,10 +364,12 @@ impl PostView {
 
 #[cfg(test)]
 mod tests {
-  use super::super::community::*;
-  use super::super::post::*;
-  use super::super::user::*;
-  use super::*;
+  use super::{
+    super::{community::*, post::*, user::*},
+    *,
+  };
+  use crate::db::{establish_unpooled_connection, Crud, Likeable};
+
   #[test]
   fn test_crud() {
     let conn = establish_unpooled_connection();
index b765bef49a3d4cea6ddee6a6897643033aa0019e..e8b28485eee7cf9f0dd98fbc01c4777fcc4b381b 100644 (file)
@@ -1,6 +1,10 @@
-use super::*;
-use crate::apub::{make_apub_endpoint, EndpointType};
-use crate::schema::private_message;
+use crate::{
+  apub::{make_apub_endpoint, EndpointType},
+  db::Crud,
+  schema::private_message,
+};
+use diesel::{dsl::*, result::Error, *};
+use serde::{Deserialize, Serialize};
 
 #[derive(Queryable, Identifiable, PartialEq, Debug, Serialize, Deserialize)]
 #[table_name = "private_message"]
@@ -85,8 +89,9 @@ impl PrivateMessage {
 
 #[cfg(test)]
 mod tests {
-  use super::super::user::*;
-  use super::*;
+  use super::{super::user::*, *};
+  use crate::db::{establish_unpooled_connection, ListingType, SortType};
+
   #[test]
   fn test_crud() {
     let conn = establish_unpooled_connection();
index 436178e1e9dd06d79308bef9b664d94927a0f42f..9a1df43972ee62f5ee07ee728b592343ce5db982 100644 (file)
@@ -1,5 +1,6 @@
-use super::*;
-use diesel::pg::Pg;
+use crate::db::{limit_and_offset, MaybeOptional};
+use diesel::{pg::Pg, result::Error, *};
+use serde::{Deserialize, Serialize};
 
 // The faked schema since diesel doesn't do views
 table! {
index 3b8366d816c6188dead6fc23cf306538d9e35667..c752bfe796a6a1c731a1534182566469a9d91888 100644 (file)
@@ -1,5 +1,6 @@
-use super::*;
-use crate::schema::site;
+use crate::{db::Crud, schema::site};
+use diesel::{dsl::*, result::Error, *};
+use serde::{Deserialize, Serialize};
 
 #[derive(Queryable, Identifiable, PartialEq, Debug, Serialize, Deserialize)]
 #[table_name = "site"]
index 674a7a6e75d724092bfdd75e759a3acb3d1c1268..bb9b54aa611825eba581ae9f02ae9ea23d636285 100644 (file)
@@ -1,4 +1,5 @@
-use super::*;
+use diesel::{result::Error, *};
+use serde::{Deserialize, Serialize};
 
 table! {
   site_view (id) {
index 065b2c5789644bc364aeaf090ce0be43f3a8f6c9..8b2ff62aa739b8e1484365e0ecd559315911192b 100644 (file)
@@ -1,9 +1,14 @@
-use super::*;
-use crate::schema::user_;
-use crate::schema::user_::dsl::*;
-use crate::{is_email_regex, naive_now, Settings};
+use crate::{
+  db::Crud,
+  is_email_regex,
+  naive_now,
+  schema::{user_, user_::dsl::*},
+  settings::Settings,
+};
 use bcrypt::{hash, DEFAULT_COST};
+use diesel::{dsl::*, result::Error, *};
 use jsonwebtoken::{decode, encode, DecodingKey, EncodingKey, Header, TokenData, Validation};
+use serde::{Deserialize, Serialize};
 
 #[derive(Queryable, Identifiable, PartialEq, Debug)]
 #[table_name = "user_"]
@@ -208,8 +213,8 @@ impl User_ {
 
 #[cfg(test)]
 mod tests {
-  use super::User_;
-  use super::*;
+  use super::{User_, *};
+  use crate::db::{establish_unpooled_connection, ListingType, SortType};
 
   #[test]
   fn test_crud() {
index d8305d3958b5adef758e93280736e95445c16084..b9129b01f5cae832cf6541510114ba0dbd411965 100644 (file)
@@ -1,6 +1,7 @@
 use super::comment::Comment;
-use super::*;
-use crate::schema::user_mention;
+use crate::{db::Crud, schema::user_mention};
+use diesel::{dsl::*, result::Error, *};
+use serde::{Deserialize, Serialize};
 
 #[derive(Queryable, Associations, Identifiable, PartialEq, Debug, Serialize, Deserialize)]
 #[belongs_to(Comment)]
@@ -53,11 +54,12 @@ impl Crud<UserMentionForm> for UserMention {
 
 #[cfg(test)]
 mod tests {
-  use super::super::comment::*;
-  use super::super::community::*;
-  use super::super::post::*;
-  use super::super::user::*;
-  use super::*;
+  use super::{
+    super::{comment::*, community::*, post::*, user::*},
+    *,
+  };
+  use crate::db::{establish_unpooled_connection, ListingType, SortType};
+
   #[test]
   fn test_crud() {
     let conn = establish_unpooled_connection();
index 85fd760fcd59c0cfd1a43fc4038ac06a7d92fbfb..100445b9938371aab7c08ffff4857ba7ace7be29 100644 (file)
@@ -1,5 +1,6 @@
-use super::*;
-use diesel::pg::Pg;
+use crate::db::{limit_and_offset, MaybeOptional, SortType};
+use diesel::{dsl::*, pg::Pg, result::Error, *};
+use serde::{Deserialize, Serialize};
 
 // The faked schema since diesel doesn't do views
 table! {
index 88cbb7fb60053f446bdc833914180702321d6ef2..57e2a4c9c2524c5b9a8b4b6550c7b1105e42db5a 100644 (file)
@@ -1,6 +1,7 @@
 use super::user_view::user_mview::BoxedQuery;
-use super::*;
-use diesel::pg::Pg;
+use crate::db::{fuzzy_search, limit_and_offset, MaybeOptional, SortType};
+use diesel::{dsl::*, pg::Pg, result::Error, *};
+use serde::{Deserialize, Serialize};
 
 table! {
   user_view (id) {
index ce886754ef32bf210f44bc2ed0683d113e61479a..4630012bf92b73eff0e4bcfa19d52835368ce63c 100644 (file)
@@ -40,15 +40,20 @@ use crate::settings::Settings;
 use actix_web::dev::ConnectionInfo;
 use chrono::{DateTime, FixedOffset, Local, NaiveDateTime, Utc};
 use isahc::prelude::*;
-use lettre::smtp::authentication::{Credentials, Mechanism};
-use lettre::smtp::extension::ClientId;
-use lettre::smtp::ConnectionReuseParameters;
-use lettre::{ClientSecurity, SmtpClient, Transport};
+use lettre::{
+  smtp::{
+    authentication::{Credentials, Mechanism},
+    extension::ClientId,
+    ConnectionReuseParameters,
+  },
+  ClientSecurity,
+  SmtpClient,
+  Transport,
+};
 use lettre_email::Email;
 use log::error;
 use percent_encoding::{utf8_percent_encode, NON_ALPHANUMERIC};
-use rand::distributions::Alphanumeric;
-use rand::{thread_rng, Rng};
+use rand::{distributions::Alphanumeric, thread_rng, Rng};
 use regex::{Regex, RegexBuilder};
 use serde::Deserialize;
 
index 205d3426e6be1552025af05568d9c1bf8c53f1a7..4339e5f06f4f9824682b4fac0c006d3881de222b 100644 (file)
@@ -4,8 +4,10 @@ extern crate diesel_migrations;
 
 use actix::prelude::*;
 use actix_web::*;
-use diesel::r2d2::{ConnectionManager, Pool};
-use diesel::PgConnection;
+use diesel::{
+  r2d2::{ConnectionManager, Pool},
+  PgConnection,
+};
 use failure::Error;
 use lemmy_server::{
   db::code_migrations::run_advanced_migrations,
index fec8a5692e342e909991e75e092cb824909982d1..b4c2dc5db9a6e0e67cc3d5143b23900fd9df1251 100644 (file)
@@ -1,23 +1,18 @@
-pub mod rate_limiter;
-
 use super::{IPAddr, Settings};
-use crate::api::APIError;
-use crate::get_ip;
-use crate::settings::RateLimitConfig;
+use crate::{api::APIError, get_ip, settings::RateLimitConfig};
 use actix_web::dev::{Service, ServiceRequest, ServiceResponse, Transform};
-use failure::Error;
 use futures::future::{ok, Ready};
-use log::debug;
 use rate_limiter::{RateLimitType, RateLimiter};
-use std::collections::HashMap;
-use std::future::Future;
-use std::pin::Pin;
-use std::sync::Arc;
-use std::task::{Context, Poll};
-use std::time::SystemTime;
-use strum::IntoEnumIterator;
+use std::{
+  future::Future,
+  pin::Pin,
+  sync::Arc,
+  task::{Context, Poll},
+};
 use tokio::sync::Mutex;
 
+pub mod rate_limiter;
+
 #[derive(Debug, Clone)]
 pub struct RateLimit {
   pub rate_limiter: Arc<Mutex<RateLimiter>>,
@@ -92,7 +87,7 @@ impl RateLimited {
         }
         RateLimitType::Post => {
           limiter.check_rate_limit_full(
-            self.type_.clone(),
+            self.type_,
             &ip_addr,
             rate_limit.post,
             rate_limit.post_per_second,
index a30efa0946e17250d42b39a8f3f38a9c0ab22a12..b3ac7093c9a79ffb3902d16bb07d883a7bcb62dc 100644 (file)
@@ -1,4 +1,9 @@
-use super::*;
+use super::IPAddr;
+use crate::api::APIError;
+use failure::Error;
+use log::debug;
+use std::{collections::HashMap, time::SystemTime};
+use strum::IntoEnumIterator;
 
 #[derive(Debug, Clone)]
 pub struct RateLimitBucket {
index ec9f61e8c71a6bec94c8f3df2044c396fc6d5f1a..6ee94691d7773fcaa054f5ea455bb2cb179d26f7 100644 (file)
@@ -1,10 +1,11 @@
-use super::*;
-use crate::api::comment::*;
-use crate::api::community::*;
-use crate::api::post::*;
-use crate::api::site::*;
-use crate::api::user::*;
-use crate::rate_limit::RateLimit;
+use crate::{
+  api::{comment::*, community::*, post::*, site::*, user::*, Oper, Perform},
+  rate_limit::RateLimit,
+  routes::{ChatServerParam, DbPoolParam},
+  websocket::WebsocketInfo,
+};
+use actix_web::{error::ErrorBadRequest, *};
+use serde::Serialize;
 
 pub fn config(cfg: &mut web::ServiceConfig, rate_limit: &RateLimit) {
   cfg.service(
index ed5c25965886a432edfecd0d1edfea7eb48384b1..fe6e3365789b2bd30a19596adb950ad821f43c0b 100644 (file)
@@ -1,12 +1,17 @@
-use super::*;
-use crate::apub::comment::get_apub_comment;
-use crate::apub::community::*;
-use crate::apub::community_inbox::community_inbox;
-use crate::apub::post::get_apub_post;
-use crate::apub::shared_inbox::shared_inbox;
-use crate::apub::user::*;
-use crate::apub::user_inbox::user_inbox;
-use crate::apub::APUB_JSON_CONTENT_TYPE;
+use crate::{
+  apub::{
+    comment::get_apub_comment,
+    community::*,
+    community_inbox::community_inbox,
+    post::get_apub_post,
+    shared_inbox::shared_inbox,
+    user::*,
+    user_inbox::user_inbox,
+    APUB_JSON_CONTENT_TYPE,
+  },
+  settings::Settings,
+};
+use actix_web::*;
 
 pub fn config(cfg: &mut web::ServiceConfig) {
   if Settings::get().federation.enabled {
index 6bb70b9317e5b5621348e63567842708220b120d..e582c2f3fe9c398dbbb4380fe434550c0734146d 100644 (file)
@@ -1,11 +1,28 @@
-use super::*;
-use crate::db::comment_view::{ReplyQueryBuilder, ReplyView};
-use crate::db::community::Community;
-use crate::db::post_view::{PostQueryBuilder, PostView};
-use crate::db::site_view::SiteView;
-use crate::db::user::{Claims, User_};
-use crate::db::user_mention_view::{UserMentionQueryBuilder, UserMentionView};
-use crate::db::{ListingType, SortType};
+use crate::{
+  db::{
+    comment_view::{ReplyQueryBuilder, ReplyView},
+    community::Community,
+    post_view::{PostQueryBuilder, PostView},
+    site_view::SiteView,
+    user::{Claims, User_},
+    user_mention_view::{UserMentionQueryBuilder, UserMentionView},
+    ListingType,
+    SortType,
+  },
+  markdown_to_html,
+  routes::DbPoolParam,
+  settings::Settings,
+};
+use actix_web::{error::ErrorBadRequest, *};
+use chrono::{DateTime, NaiveDateTime, Utc};
+use diesel::{
+  r2d2::{ConnectionManager, Pool},
+  PgConnection,
+};
+use rss::{CategoryBuilder, ChannelBuilder, GuidBuilder, Item, ItemBuilder};
+use serde::Deserialize;
+use std::str::FromStr;
+use strum::ParseError;
 
 #[derive(Deserialize)]
 pub struct Params {
@@ -21,8 +38,8 @@ enum RequestType {
 
 pub fn config(cfg: &mut web::ServiceConfig) {
   cfg
-    .route("/feeds/{type}/{name}.xml", web::get().to(feeds::get_feed))
-    .route("/feeds/all.xml", web::get().to(feeds::get_all_feed));
+    .route("/feeds/{type}/{name}.xml", web::get().to(get_feed))
+    .route("/feeds/all.xml", web::get().to(get_all_feed));
 }
 
 async fn get_all_feed(info: web::Query<Params>, db: DbPoolParam) -> Result<HttpResponse, Error> {
index 895af435005e7ebf3cbe3a0aeb3ae7726f14ecd0..2f462aa5f12492446e4ba5a598ee146297396ba5 100644 (file)
@@ -1,4 +1,6 @@
-use super::*;
+use crate::settings::Settings;
+use actix_files::NamedFile;
+use actix_web::*;
 
 pub fn config(cfg: &mut web::ServiceConfig) {
   cfg
index 109dbd76d4d4c44e513309d2595651ddb4154ff1..bcb7e45fa33bd631191838008c070b1a839194d7 100644 (file)
@@ -1,37 +1,20 @@
-use crate::api::{Oper, Perform};
-use crate::apub::get_apub_protocol_string;
-use crate::db::site_view::SiteView;
-use crate::rate_limit::rate_limiter::RateLimiter;
-use crate::websocket::{server::ChatServer, WebsocketInfo};
-use crate::{get_ip, markdown_to_html, version, Settings};
+pub mod api;
+pub mod federation;
+pub mod feeds;
+pub mod index;
+pub mod nodeinfo;
+pub mod webfinger;
+pub mod websocket;
+
+use crate::{rate_limit::rate_limiter::RateLimiter, websocket::server::ChatServer};
 use actix::prelude::*;
-use actix_files::NamedFile;
-use actix_web::{body::Body, error::ErrorBadRequest, web::Query, *};
-use actix_web_actors::ws;
-use chrono::{DateTime, NaiveDateTime, Utc};
+use actix_web::*;
 use diesel::{
   r2d2::{ConnectionManager, Pool},
   PgConnection,
 };
-use log::{error, info};
-use regex::Regex;
-use rss::{CategoryBuilder, ChannelBuilder, GuidBuilder, Item, ItemBuilder};
-use serde::{Deserialize, Serialize};
-use serde_json::json;
-use std::str::FromStr;
 use std::sync::{Arc, Mutex};
-use std::time::{Duration, Instant};
-use strum::ParseError;
-use url::Url;
 
 pub type DbPoolParam = web::Data<Pool<ConnectionManager<PgConnection>>>;
 pub type RateLimitParam = web::Data<Arc<Mutex<RateLimiter>>>;
 pub type ChatServerParam = web::Data<Addr<ChatServer>>;
-
-pub mod api;
-pub mod federation;
-pub mod feeds;
-pub mod index;
-pub mod nodeinfo;
-pub mod webfinger;
-pub mod websocket;
index fa75d19bf2d142b1d09b51f0ae433d9bdcdc6852..db206a3e8a70a94533ded1161531a233dc4bd4da 100644 (file)
@@ -1,4 +1,13 @@
-use super::*;
+use crate::{
+  apub::get_apub_protocol_string,
+  db::site_view::SiteView,
+  routes::DbPoolParam,
+  version,
+  Settings,
+};
+use actix_web::{body::Body, error::ErrorBadRequest, *};
+use serde::{Deserialize, Serialize};
+use url::Url;
 
 pub fn config(cfg: &mut web::ServiceConfig) {
   cfg
index 7bdce2067b2f247d21d1fec633cd6e65ddfd8959..e6ce84110a403cb526cda05149f89946a827cf78 100644 (file)
@@ -1,5 +1,8 @@
-use super::*;
-use crate::db::community::Community;
+use crate::{db::community::Community, routes::DbPoolParam, Settings};
+use actix_web::{error::ErrorBadRequest, web::Query, *};
+use regex::Regex;
+use serde::Deserialize;
+use serde_json::json;
 
 #[derive(Deserialize)]
 pub struct Params {
index a95ff9ee820c16dba14c8b1192711395f278509c..06d9b66d2c45f9f4bbb1cc0e4e833a20efb2d455 100644 (file)
@@ -1,5 +1,12 @@
-use super::*;
-use crate::websocket::server::*;
+use crate::{
+  get_ip,
+  websocket::server::{ChatServer, *},
+};
+use actix::prelude::*;
+use actix_web::*;
+use actix_web_actors::ws;
+use log::{error, info};
+use std::time::{Duration, Instant};
 
 /// How often heartbeat pings are sent
 const HEARTBEAT_INTERVAL: Duration = Duration::from_secs(5);
index c19cb717520b2a43c398a69234a2ed16aaabe382..e1ac759c555fc96bd67e5883ac133f1476fec7c1 100644 (file)
@@ -1,10 +1,7 @@
 use config::{Config, ConfigError, Environment, File};
 use failure::Error;
 use serde::Deserialize;
-use std::env;
-use std::fs;
-use std::net::IpAddr;
-use std::sync::RwLock;
+use std::{env, fs, net::IpAddr, sync::RwLock};
 
 static CONFIG_FILE_DEFAULTS: &str = "config/defaults.hjson";
 static CONFIG_FILE: &str = "config/config.hjson";
index fd200d7d6069c7c88ff91ca50fca49f128f6faa0..4eb43e49d9528a0796d13868c71e6eb1d7bf2d83 100644 (file)
@@ -2,16 +2,20 @@ pub mod server;
 
 use crate::ConnectionId;
 use actix::prelude::*;
-use diesel::r2d2::{ConnectionManager, Pool};
-use diesel::PgConnection;
+use diesel::{
+  r2d2::{ConnectionManager, Pool},
+  PgConnection,
+};
 use failure::Error;
 use log::{error, info};
 use rand::{rngs::ThreadRng, Rng};
 use serde::{Deserialize, Serialize};
 use serde_json::Value;
 use server::ChatServer;
-use std::collections::{HashMap, HashSet};
-use std::str::FromStr;
+use std::{
+  collections::{HashMap, HashSet},
+  str::FromStr,
+};
 
 #[derive(EnumString, ToString, Debug, Clone)]
 pub enum UserOperation {
index da5098e91790860ee96248a834dbf2627a44c0f7..e4543ea1fa3321b54f7b3e8ea3c4bff811939354 100644 (file)
@@ -3,15 +3,16 @@
 //! room through `ChatServer`.
 
 use super::*;
-use crate::api::comment::*;
-use crate::api::community::*;
-use crate::api::post::*;
-use crate::api::site::*;
-use crate::api::user::*;
-use crate::api::*;
-use crate::rate_limit::RateLimit;
-use crate::websocket::UserOperation;
-use crate::{CommunityId, ConnectionId, IPAddr, PostId, UserId};
+use crate::{
+  api::{comment::*, community::*, post::*, site::*, user::*, *},
+  rate_limit::RateLimit,
+  websocket::UserOperation,
+  CommunityId,
+  ConnectionId,
+  IPAddr,
+  PostId,
+  UserId,
+};
 
 /// Chat server sends this messages to session
 #[derive(Message)]
@@ -940,7 +941,7 @@ impl Handler<Connect> for ChatServer {
       id,
       SessionInfo {
         addr: msg.addr,
-        ip: msg.ip.to_owned(),
+        ip: msg.ip,
       },
     );