Reorganize use statements
This commit is contained in:
parent
aa233abb41
commit
b55622f2b1
|
@ -8,15 +8,19 @@ use diesel::PgConnection;
|
|||
use failure::Error;
|
||||
use serde_json;
|
||||
|
||||
use activity_pub::{broadcast, Id, IntoId};
|
||||
use activity_pub::actor::Actor as APActor;
|
||||
use activity_pub::sign::*;
|
||||
use models::blogs::Blog;
|
||||
use models::comments::*;
|
||||
use models::follows;
|
||||
use models::likes;
|
||||
use models::posts::*;
|
||||
use models::users::User;
|
||||
use activity_pub::{
|
||||
broadcast, Id, IntoId,
|
||||
actor::Actor as APActor,
|
||||
sign::*
|
||||
};
|
||||
use models::{
|
||||
blogs::Blog,
|
||||
comments::*,
|
||||
follows,
|
||||
likes,
|
||||
posts::*,
|
||||
users::User
|
||||
};
|
||||
|
||||
#[derive(Fail, Debug)]
|
||||
enum InboxError {
|
||||
|
|
|
@ -2,9 +2,11 @@ use activitystreams_traits::{Activity, Actor, Object, Link};
|
|||
use array_tool::vec::Uniq;
|
||||
use diesel::PgConnection;
|
||||
use reqwest::Client;
|
||||
use rocket::http::{ContentType, Status};
|
||||
use rocket::response::{Response, Responder, Content};
|
||||
use rocket::request::Request;
|
||||
use rocket::{
|
||||
http::{ContentType, Status},
|
||||
response::{Response, Responder, Content},
|
||||
request::Request
|
||||
};
|
||||
use rocket_contrib::Json;
|
||||
use serde_json;
|
||||
|
||||
|
|
|
@ -6,4 +6,3 @@ pub trait Object {
|
|||
|
||||
fn compute_id(&self, conn: &PgConnection) -> String;
|
||||
}
|
||||
|
||||
|
|
|
@ -27,11 +27,8 @@ pub fn signature<S: Signer>(signer: &S, headers: Headers, conn: &PgConnection) -
|
|||
let signed_string = headers.iter().map(|h| format!("{}: {}", h.name().to_lowercase(), h.value_string())).collect::<Vec<String>>().join("\n");
|
||||
let signed_headers = headers.iter().map(|h| h.name().to_string()).collect::<Vec<String>>().join(" ").to_lowercase();
|
||||
|
||||
println!("Signing {}", signed_string);
|
||||
println!("signed header {}", signed_headers);
|
||||
let data = signer.sign(signed_string);
|
||||
let sign = base64::encode(&data[..]);
|
||||
println!("sigature {}", sign);
|
||||
|
||||
Signature(format!(
|
||||
"keyId=\"{key_id}\",algorithm=\"rsa-sha256\",headers=\"{signed_headers}\",signature=\"{signature}\"",
|
||||
|
|
|
@ -1,10 +1,12 @@
|
|||
use base64;
|
||||
use chrono::Utc;
|
||||
use diesel::PgConnection;
|
||||
use hex;
|
||||
use chrono::Utc;
|
||||
use openssl::pkey::PKey;
|
||||
use openssl::rsa::Rsa;
|
||||
use openssl::sha::sha256;
|
||||
use openssl::{
|
||||
pkey::PKey,
|
||||
rsa::Rsa,
|
||||
sha::sha256
|
||||
};
|
||||
use serde_json;
|
||||
|
||||
/// Returns (public key, private key)
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
use diesel::PgConnection;
|
||||
use reqwest::Client;
|
||||
use reqwest::header::{Accept, qitem};
|
||||
use reqwest::mime::Mime;
|
||||
use reqwest::{
|
||||
header::{Accept, qitem},
|
||||
mime::Mime
|
||||
};
|
||||
use serde_json;
|
||||
|
||||
use activity_pub::ap_url;
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
use diesel::pg::PgConnection;
|
||||
use diesel::r2d2::{ConnectionManager, Pool, PooledConnection};
|
||||
use rocket::{Request, State, Outcome};
|
||||
use rocket::http::Status;
|
||||
use rocket::request::{self, FromRequest};
|
||||
use diesel::{
|
||||
pg::PgConnection,
|
||||
r2d2::{ConnectionManager, Pool, PooledConnection}
|
||||
};
|
||||
use rocket::{Request, State, Outcome, http::Status, request::{self, FromRequest}};
|
||||
use std::ops::Deref;
|
||||
|
||||
// From rocket documentation
|
||||
|
|
|
@ -33,8 +33,7 @@ extern crate serde_derive;
|
|||
extern crate serde_json;
|
||||
extern crate url;
|
||||
|
||||
use diesel::pg::PgConnection;
|
||||
use diesel::r2d2::{ConnectionManager, Pool};
|
||||
use diesel::{pg::PgConnection, r2d2::{ConnectionManager, Pool}};
|
||||
use dotenv::dotenv;
|
||||
use rocket_contrib::Template;
|
||||
use std::env;
|
||||
|
|
|
@ -1,22 +1,28 @@
|
|||
use activitystreams_traits::{Actor, Object};
|
||||
use activitystreams_types::collection::OrderedCollection;
|
||||
use reqwest::Client;
|
||||
use reqwest::header::{Accept, qitem};
|
||||
use reqwest::mime::Mime;
|
||||
use reqwest::{
|
||||
Client,
|
||||
header::{Accept, qitem},
|
||||
mime::Mime
|
||||
};
|
||||
use serde_json;
|
||||
use url::Url;
|
||||
use chrono::NaiveDateTime;
|
||||
use diesel::{self, QueryDsl, RunQueryDsl, ExpressionMethods, PgConnection};
|
||||
use openssl::hash::MessageDigest;
|
||||
use openssl::pkey::{PKey, Private};
|
||||
use openssl::rsa::Rsa;
|
||||
use openssl::sign::Signer;
|
||||
use openssl::{
|
||||
hash::MessageDigest,
|
||||
pkey::{PKey, Private},
|
||||
rsa::Rsa,
|
||||
sign::Signer
|
||||
};
|
||||
|
||||
use activity_pub::{ActivityStream, Id, IntoId};
|
||||
use activity_pub::actor::{Actor as APActor, ActorType};
|
||||
use activity_pub::inbox::WithInbox;
|
||||
use activity_pub::sign;
|
||||
use activity_pub::webfinger::*;
|
||||
use activity_pub::{
|
||||
ActivityStream, Id, IntoId,
|
||||
actor::{Actor as APActor, ActorType},
|
||||
inbox::WithInbox,
|
||||
sign,
|
||||
webfinger::*
|
||||
};
|
||||
use models::instance::Instance;
|
||||
use schema::blogs;
|
||||
|
||||
|
|
|
@ -6,11 +6,15 @@ use chrono;
|
|||
use diesel::{self, PgConnection, RunQueryDsl, QueryDsl, ExpressionMethods};
|
||||
use serde_json;
|
||||
|
||||
use activity_pub::{ap_url, IntoId, PUBLIC_VISIBILTY};
|
||||
use activity_pub::actor::Actor;
|
||||
use activity_pub::object::Object;
|
||||
use models::posts::Post;
|
||||
use models::users::User;
|
||||
use activity_pub::{
|
||||
ap_url, IntoId, PUBLIC_VISIBILTY,
|
||||
actor::Actor,
|
||||
object::Object
|
||||
};
|
||||
use models::{
|
||||
posts::Post,
|
||||
users::User
|
||||
};
|
||||
use schema::comments;
|
||||
|
||||
#[derive(Queryable, Identifiable, Serialize, Clone)]
|
||||
|
|
|
@ -3,11 +3,15 @@ use chrono;
|
|||
use diesel::{self, PgConnection, QueryDsl, RunQueryDsl, ExpressionMethods};
|
||||
use serde_json;
|
||||
|
||||
use activity_pub::IntoId;
|
||||
use activity_pub::actor::Actor;
|
||||
use activity_pub::object::Object;
|
||||
use models::posts::Post;
|
||||
use models::users::User;
|
||||
use activity_pub::{
|
||||
IntoId,
|
||||
actor::Actor,
|
||||
object::Object
|
||||
};
|
||||
use models::{
|
||||
posts::Post,
|
||||
users::User
|
||||
};
|
||||
use schema::likes;
|
||||
|
||||
#[derive(Queryable, Identifiable)]
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
use diesel::{self, PgConnection, QueryDsl, RunQueryDsl, ExpressionMethods};
|
||||
|
||||
use models::posts::Post;
|
||||
use models::users::User;
|
||||
use models::{
|
||||
posts::Post,
|
||||
users::User
|
||||
};
|
||||
use schema::post_authors;
|
||||
|
||||
#[derive(Queryable, Identifiable, Associations)]
|
||||
|
|
|
@ -8,13 +8,17 @@ use diesel::dsl::any;
|
|||
use serde_json;
|
||||
|
||||
use BASE_URL;
|
||||
use activity_pub::{PUBLIC_VISIBILTY, ap_url, Id, IntoId};
|
||||
use activity_pub::actor::Actor;
|
||||
use activity_pub::object::Object;
|
||||
use models::blogs::Blog;
|
||||
use models::likes::Like;
|
||||
use models::users::User;
|
||||
use models::post_authors::PostAuthor;
|
||||
use activity_pub::{
|
||||
PUBLIC_VISIBILTY, ap_url, Id, IntoId,
|
||||
actor::Actor,
|
||||
object::Object
|
||||
};
|
||||
use models::{
|
||||
blogs::Blog,
|
||||
likes::Like,
|
||||
post_authors::PostAuthor,
|
||||
users::User
|
||||
};
|
||||
use schema::posts;
|
||||
|
||||
#[derive(Queryable, Identifiable, Serialize)]
|
||||
|
|
|
@ -7,33 +7,42 @@ use activitystreams_types::{
|
|||
};
|
||||
use bcrypt;
|
||||
use chrono::NaiveDateTime;
|
||||
use diesel::{self, QueryDsl, RunQueryDsl, ExpressionMethods, BelongingToDsl, PgConnection};
|
||||
use diesel::dsl::any;
|
||||
use openssl::hash::MessageDigest;
|
||||
use openssl::pkey::{PKey, Private};
|
||||
use openssl::rsa::Rsa;
|
||||
use openssl::sign;
|
||||
use reqwest::Client;
|
||||
use reqwest::header::{Accept, qitem};
|
||||
use reqwest::mime::Mime;
|
||||
use rocket::request::{self, FromRequest, Request};
|
||||
use rocket::outcome::IntoOutcome;
|
||||
use diesel::{self, QueryDsl, RunQueryDsl, ExpressionMethods, BelongingToDsl, PgConnection, dsl::any};
|
||||
use openssl::{
|
||||
hash::MessageDigest,
|
||||
pkey::{PKey, Private},
|
||||
rsa::Rsa,
|
||||
sign
|
||||
};
|
||||
use reqwest::{
|
||||
Client,
|
||||
header::{Accept, qitem},
|
||||
mime::Mime
|
||||
};
|
||||
use rocket::{
|
||||
request::{self, FromRequest, Request},
|
||||
outcome::IntoOutcome
|
||||
};
|
||||
use serde_json;
|
||||
use url::Url;
|
||||
|
||||
use BASE_URL;
|
||||
use activity_pub::{ap_url, ActivityStream, Id, IntoId};
|
||||
use activity_pub::actor::{ActorType, Actor as APActor};
|
||||
use activity_pub::inbox::{Inbox, WithInbox};
|
||||
use activity_pub::sign::{Signer, gen_keypair};
|
||||
use activity_pub::webfinger::{Webfinger, resolve};
|
||||
use activity_pub::{
|
||||
ap_url, ActivityStream, Id, IntoId,
|
||||
actor::{ActorType, Actor as APActor},
|
||||
inbox::{Inbox, WithInbox},
|
||||
sign::{Signer, gen_keypair},
|
||||
webfinger::{Webfinger, resolve}
|
||||
};
|
||||
use db_conn::DbConn;
|
||||
use models::comments::Comment;
|
||||
use models::follows::Follow;
|
||||
use models::instance::Instance;
|
||||
use models::notifications::*;
|
||||
use models::post_authors::PostAuthor;
|
||||
use models::posts::Post;
|
||||
use models::{
|
||||
comments::Comment,
|
||||
follows::Follow,
|
||||
instance::Instance,
|
||||
notifications::*,
|
||||
post_authors::PostAuthor,
|
||||
posts::Post
|
||||
};
|
||||
use schema::users;
|
||||
|
||||
pub const AUTH_COOKIE: &'static str = "user_id";
|
||||
|
|
|
@ -1,17 +1,20 @@
|
|||
use activitystreams_types::collection::OrderedCollection;
|
||||
use rocket::request::Form;
|
||||
use rocket::response::Redirect;
|
||||
use rocket::{
|
||||
request::Form,
|
||||
response::Redirect
|
||||
};
|
||||
use rocket_contrib::Template;
|
||||
use serde_json;
|
||||
|
||||
use activity_pub::{ActivityStream, ActivityPub};
|
||||
use activity_pub::actor::Actor;
|
||||
use activity_pub::{ActivityStream, ActivityPub, actor::Actor};
|
||||
use db_conn::DbConn;
|
||||
use models::blog_authors::*;
|
||||
use models::blogs::*;
|
||||
use models::instance::Instance;
|
||||
use models::posts::Post;
|
||||
use models::users::User;
|
||||
use models::{
|
||||
blog_authors::*,
|
||||
blogs::*,
|
||||
instance::Instance,
|
||||
posts::Post,
|
||||
users::User
|
||||
};
|
||||
use utils;
|
||||
|
||||
#[get("/~/<name>", rank = 2)]
|
||||
|
|
|
@ -1,12 +1,13 @@
|
|||
use rocket::request::Form;
|
||||
use rocket::response::Redirect;
|
||||
use rocket::{ request::Form, response::Redirect};
|
||||
use rocket_contrib::Template;
|
||||
|
||||
use activity_pub::broadcast;
|
||||
use db_conn::DbConn;
|
||||
use models::comments::*;
|
||||
use models::posts::Post;
|
||||
use models::users::User;
|
||||
use models::{
|
||||
comments::*,
|
||||
posts::Post,
|
||||
users::User
|
||||
};
|
||||
|
||||
#[get("/~/<_blog>/<slug>/comment")]
|
||||
fn new(_blog: String, slug: String, user: User, conn: DbConn) -> Template {
|
||||
|
|
|
@ -1,14 +1,15 @@
|
|||
use rocket::request::Form;
|
||||
use rocket::response::Redirect;
|
||||
use rocket::{request::Form, response::Redirect};
|
||||
use rocket_contrib::Template;
|
||||
use serde_json;
|
||||
|
||||
use BASE_URL;
|
||||
use activity_pub::inbox::Inbox;
|
||||
use db_conn::DbConn;
|
||||
use models::posts::Post;
|
||||
use models::users::User;
|
||||
use models::instance::*;
|
||||
use models::{
|
||||
posts::Post,
|
||||
users::User,
|
||||
instance::*
|
||||
};
|
||||
|
||||
#[get("/")]
|
||||
fn index(conn: DbConn, user: Option<User>) -> Template {
|
||||
|
|
|
@ -2,9 +2,11 @@ use rocket::response::Redirect;
|
|||
|
||||
use activity_pub::broadcast;
|
||||
use db_conn::DbConn;
|
||||
use models::likes;
|
||||
use models::posts::Post;
|
||||
use models::users::User;
|
||||
use models::{
|
||||
likes,
|
||||
posts::Post,
|
||||
users::User
|
||||
};
|
||||
|
||||
#[get("/~/<blog>/<slug>/like")]
|
||||
fn create(blog: String, slug: String, user: User, conn: DbConn) -> Redirect {
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
use rocket_contrib::Template;
|
||||
|
||||
use db_conn::DbConn;
|
||||
use models::notifications::Notification;
|
||||
use models::users::User;
|
||||
use models::{notifications::Notification, users::User};
|
||||
|
||||
#[get("/notifications")]
|
||||
fn notifications(conn: DbConn, user: User) -> Template {
|
||||
|
|
|
@ -4,14 +4,15 @@ use rocket::response::Redirect;
|
|||
use rocket_contrib::Template;
|
||||
use serde_json;
|
||||
|
||||
use activity_pub::{broadcast, context, activity_pub, ActivityPub};
|
||||
use activity_pub::object::Object;
|
||||
use activity_pub::{broadcast, context, activity_pub, ActivityPub, object::Object};
|
||||
use db_conn::DbConn;
|
||||
use models::blogs::*;
|
||||
use models::comments::Comment;
|
||||
use models::post_authors::*;
|
||||
use models::posts::*;
|
||||
use models::users::User;
|
||||
use models::{
|
||||
blogs::*,
|
||||
comments::Comment,
|
||||
post_authors::*,
|
||||
posts::*,
|
||||
users::User
|
||||
};
|
||||
use utils;
|
||||
|
||||
#[get("/~/<blog>/<slug>", rank = 4)]
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
use rocket::http::{Cookie, Cookies};
|
||||
use rocket::response::Redirect;
|
||||
use rocket::response::status::NotFound;
|
||||
use rocket::request::Form;
|
||||
use rocket::{
|
||||
http::{Cookie, Cookies},
|
||||
response::{Redirect, status::NotFound},
|
||||
request::Form
|
||||
};
|
||||
use rocket_contrib::Template;
|
||||
|
||||
use db_conn::DbConn;
|
||||
|
|
|
@ -2,19 +2,22 @@ use activitystreams_types::{
|
|||
activity::Follow,
|
||||
collection::OrderedCollection
|
||||
};
|
||||
use rocket::request::Form;
|
||||
use rocket::response::Redirect;
|
||||
use rocket::{request::Form, response::Redirect};
|
||||
use rocket_contrib::Template;
|
||||
use serde_json;
|
||||
|
||||
use activity_pub::{activity_pub, ActivityPub, ActivityStream, context, broadcast, Id, IntoId};
|
||||
use activity_pub::actor::Actor;
|
||||
use activity_pub::inbox::Inbox;
|
||||
use activity_pub::{
|
||||
activity_pub, ActivityPub, ActivityStream, context, broadcast, Id, IntoId,
|
||||
actor::Actor,
|
||||
object::Object
|
||||
};
|
||||
use db_conn::DbConn;
|
||||
use models::follows;
|
||||
use models::instance::Instance;
|
||||
use models::posts::Post;
|
||||
use models::users::*;
|
||||
use models::{
|
||||
follows,
|
||||
instance::Instance,
|
||||
posts::Post,
|
||||
users::*
|
||||
};
|
||||
|
||||
#[get("/me")]
|
||||
fn me(user: User) -> Redirect {
|
||||
|
|
|
@ -2,11 +2,9 @@ use rocket::http::ContentType;
|
|||
use rocket::response::Content;
|
||||
|
||||
use BASE_URL;
|
||||
use activity_pub::ap_url;
|
||||
use activity_pub::webfinger::Webfinger;
|
||||
use activity_pub::{ap_url, webfinger::Webfinger};
|
||||
use db_conn::DbConn;
|
||||
use models::blogs::Blog;
|
||||
use models::users::User;
|
||||
use models::{blogs::Blog, users::User};
|
||||
|
||||
#[get("/.well-known/host-meta", format = "application/xml")]
|
||||
fn host_meta() -> String {
|
||||
|
|
Loading…
Reference in New Issue