Rework imports
This commit is contained in:
parent
2a12c0d33a
commit
cd1acb083f
59 changed files with 853 additions and 326 deletions
5
server/.rustfmt.toml
vendored
5
server/.rustfmt.toml
vendored
|
@ -1,2 +1,5 @@
|
||||||
tab_spaces = 2
|
tab_spaces = 2
|
||||||
edition="2018"
|
edition="2018"
|
||||||
|
imports_layout="HorizontalVertical"
|
||||||
|
merge_imports=true
|
||||||
|
reorder_imports=true
|
||||||
|
|
26
server/Cargo.lock
generated
vendored
26
server/Cargo.lock
generated
vendored
|
@ -2,9 +2,9 @@
|
||||||
# It is not intended for manual editing.
|
# It is not intended for manual editing.
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "activitystreams"
|
name = "activitystreams"
|
||||||
version = "0.6.0"
|
version = "0.6.2"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "dd5b29a0f2c64cc56f2b79ec29cab68a9dab3b714d811a55668d072f18a8638e"
|
checksum = "464cb473bfb402b857cc15b1153974c203a43f1485da4dda15cd17a738548958"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"activitystreams-derive",
|
"activitystreams-derive",
|
||||||
"chrono",
|
"chrono",
|
||||||
|
@ -26,6 +26,17 @@ dependencies = [
|
||||||
"syn",
|
"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]]
|
[[package]]
|
||||||
name = "actix"
|
name = "actix"
|
||||||
version = "0.9.0"
|
version = "0.9.0"
|
||||||
|
@ -1544,6 +1555,7 @@ name = "lemmy_server"
|
||||||
version = "0.0.1"
|
version = "0.0.1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"activitystreams",
|
"activitystreams",
|
||||||
|
"activitystreams-new",
|
||||||
"actix",
|
"actix",
|
||||||
"actix-files",
|
"actix-files",
|
||||||
"actix-rt",
|
"actix-rt",
|
||||||
|
@ -2992,6 +3004,16 @@ version = "1.7.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "a9b2228007eba4120145f785df0f6c92ea538f5a3635a612ecf4e334c8c1446d"
|
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]]
|
[[package]]
|
||||||
name = "typenum"
|
name = "typenum"
|
||||||
version = "1.12.0"
|
version = "1.12.0"
|
||||||
|
|
6
server/Cargo.toml
vendored
6
server/Cargo.toml
vendored
|
@ -4,11 +4,15 @@ version = "0.0.1"
|
||||||
authors = ["Dessalines <happydooby@gmail.com>"]
|
authors = ["Dessalines <happydooby@gmail.com>"]
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
|
|
||||||
|
[patch.crates-io]
|
||||||
|
typed-builder = { git = "https://git.asonix.dog/asonix/typed-builder" }
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
diesel = { version = "1.4.4", features = ["postgres","chrono","r2d2","64-column-tables","serde_json"] }
|
diesel = { version = "1.4.4", features = ["postgres","chrono","r2d2","64-column-tables","serde_json"] }
|
||||||
diesel_migrations = "1.4.0"
|
diesel_migrations = "1.4.0"
|
||||||
dotenv = "0.15.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"
|
bcrypt = "0.6.2"
|
||||||
chrono = { version = "0.4.7", features = ["serde"] }
|
chrono = { version = "0.4.7", features = ["serde"] }
|
||||||
failure = "0.1.5"
|
failure = "0.1.5"
|
||||||
|
|
|
@ -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)]
|
#[derive(Serialize, Deserialize)]
|
||||||
pub struct CreateComment {
|
pub struct CreateComment {
|
||||||
|
|
|
@ -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)]
|
#[derive(Serialize, Deserialize)]
|
||||||
pub struct GetCommunity {
|
pub struct GetCommunity {
|
||||||
|
|
|
@ -1,46 +1,9 @@
|
||||||
use crate::db::category::*;
|
use crate::websocket::WebsocketInfo;
|
||||||
use crate::db::comment::*;
|
use diesel::{
|
||||||
use crate::db::comment_view::*;
|
r2d2::{ConnectionManager, Pool},
|
||||||
use crate::db::community::*;
|
PgConnection,
|
||||||
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::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 failure::Error;
|
||||||
use log::{debug, error, info};
|
|
||||||
use serde::{Deserialize, Serialize};
|
|
||||||
use std::str::FromStr;
|
|
||||||
|
|
||||||
pub mod comment;
|
pub mod comment;
|
||||||
pub mod community;
|
pub mod community;
|
||||||
|
|
|
@ -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)]
|
#[derive(Serialize, Deserialize, Debug)]
|
||||||
pub struct CreatePost {
|
pub struct CreatePost {
|
||||||
|
|
|
@ -1,5 +1,36 @@
|
||||||
use super::user::Register;
|
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)]
|
#[derive(Serialize, Deserialize)]
|
||||||
pub struct ListCategories {}
|
pub struct ListCategories {}
|
||||||
|
|
|
@ -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 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)]
|
#[derive(Serialize, Deserialize, Debug)]
|
||||||
pub struct Login {
|
pub struct Login {
|
||||||
|
|
|
@ -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(
|
pub fn populate_object_props(
|
||||||
props: &mut ObjectProperties,
|
props: &mut ObjectProperties,
|
||||||
|
|
|
@ -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)]
|
#[derive(Deserialize)]
|
||||||
pub struct CommentQuery {
|
pub struct CommentQuery {
|
||||||
|
|
|
@ -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)]
|
#[derive(Deserialize)]
|
||||||
pub struct CommunityQuery {
|
pub struct CommunityQuery {
|
||||||
|
|
|
@ -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)]
|
#[serde(untagged)]
|
||||||
#[derive(Deserialize, Debug)]
|
#[derive(Deserialize, Debug)]
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
use crate::db::category::Category;
|
use crate::db::{category::Category, Crud};
|
||||||
use crate::db::Crud;
|
use activitystreams::{ext::Extension, Actor};
|
||||||
use activitystreams::ext::Extension;
|
|
||||||
use activitystreams::Actor;
|
|
||||||
use diesel::PgConnection;
|
use diesel::PgConnection;
|
||||||
use failure::Error;
|
use failure::Error;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
use activitystreams::ext::Extension;
|
use activitystreams::{ext::Extension, Base};
|
||||||
use activitystreams::Base;
|
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
#[derive(Clone, Debug, Default, Deserialize, Serialize)]
|
#[derive(Clone, Debug, Default, Deserialize, Serialize)]
|
||||||
|
|
|
@ -5,9 +5,12 @@ use failure::Error;
|
||||||
use http::request::Builder;
|
use http::request::Builder;
|
||||||
use http_signature_normalization::Config;
|
use http_signature_normalization::Config;
|
||||||
use log::debug;
|
use log::debug;
|
||||||
use openssl::hash::MessageDigest;
|
use openssl::{
|
||||||
use openssl::sign::{Signer, Verifier};
|
hash::MessageDigest,
|
||||||
use openssl::{pkey::PKey, rsa::Rsa};
|
pkey::PKey,
|
||||||
|
rsa::Rsa,
|
||||||
|
sign::{Signer, Verifier},
|
||||||
|
};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use std::collections::BTreeMap;
|
use std::collections::BTreeMap;
|
||||||
|
|
||||||
|
|
|
@ -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.
|
// Fetch nodeinfo metadata from a remote instance.
|
||||||
fn _fetch_node_info(domain: &str) -> Result<NodeInfo, Error> {
|
fn _fetch_node_info(domain: &str) -> Result<NodeInfo, Error> {
|
||||||
|
|
|
@ -10,68 +10,29 @@ pub mod shared_inbox;
|
||||||
pub mod user;
|
pub mod user;
|
||||||
pub mod user_inbox;
|
pub mod user_inbox;
|
||||||
|
|
||||||
use crate::api::community::CommunityResponse;
|
use crate::{
|
||||||
use crate::db::activity::insert_activity;
|
apub::extensions::{
|
||||||
use crate::websocket::server::SendCommunityRoomMessage;
|
group_extensions::GroupExtension,
|
||||||
use activitystreams::object::kind::{NoteType, PageType};
|
page_extension::PageExtension,
|
||||||
use activitystreams::{
|
signatures::{PublicKey, PublicKeyExtension},
|
||||||
activity::{Accept, Create, Delete, Dislike, Follow, Like, Remove, Undo, Update},
|
},
|
||||||
actor::{kind::GroupType, properties::ApActorProperties, Group, Person},
|
convert_datetime,
|
||||||
collection::UnorderedCollection,
|
db::user::User_,
|
||||||
context,
|
Settings,
|
||||||
endpoint::EndpointProperties,
|
|
||||||
ext::{Ext, Extensible},
|
|
||||||
object::{properties::ObjectProperties, Note, Page, Tombstone},
|
|
||||||
public, BaseBox,
|
|
||||||
};
|
};
|
||||||
use actix_web::body::Body;
|
use activitystreams::{
|
||||||
use actix_web::web::Path;
|
activity::Follow,
|
||||||
use actix_web::{web, HttpRequest, HttpResponse, Result};
|
actor::{properties::ApActorProperties, Group, Person},
|
||||||
use diesel::result::Error::NotFound;
|
ext::Ext,
|
||||||
|
object::{Page, Tombstone},
|
||||||
|
};
|
||||||
|
use actix_web::{body::Body, HttpResponse, Result};
|
||||||
|
use chrono::NaiveDateTime;
|
||||||
use diesel::PgConnection;
|
use diesel::PgConnection;
|
||||||
use failure::Error;
|
use failure::Error;
|
||||||
use failure::_core::fmt::Debug;
|
use serde::Serialize;
|
||||||
use isahc::prelude::*;
|
|
||||||
use itertools::Itertools;
|
|
||||||
use log::debug;
|
|
||||||
use serde::{Deserialize, Serialize};
|
|
||||||
use std::time::Duration;
|
|
||||||
use url::Url;
|
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 GroupExt = Ext<Ext<Ext<Group, GroupExtension>, ApActorProperties>, PublicKeyExtension>;
|
||||||
type PersonExt = Ext<Ext<Person, ApActorProperties>, PublicKeyExtension>;
|
type PersonExt = Ext<Ext<Person, ApActorProperties>, PublicKeyExtension>;
|
||||||
type PageExt = Ext<Page, PageExtension>;
|
type PageExt = Ext<Page, PageExtension>;
|
||||||
|
|
|
@ -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)]
|
#[derive(Deserialize)]
|
||||||
pub struct PostQuery {
|
pub struct PostQuery {
|
||||||
|
|
|
@ -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 {
|
impl ToApub for PrivateMessage {
|
||||||
type Response = Note;
|
type Response = Note;
|
||||||
|
|
|
@ -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)]
|
#[serde(untagged)]
|
||||||
#[derive(Serialize, Deserialize, Debug)]
|
#[derive(Serialize, Deserialize, Debug)]
|
||||||
|
|
|
@ -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)]
|
#[derive(Deserialize)]
|
||||||
pub struct UserQuery {
|
pub struct UserQuery {
|
||||||
|
|
|
@ -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)]
|
#[serde(untagged)]
|
||||||
#[derive(Deserialize, Debug)]
|
#[derive(Deserialize, Debug)]
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
use super::*;
|
use crate::{db::Crud, schema::activity};
|
||||||
use crate::schema::activity;
|
use diesel::{dsl::*, result::Error, *};
|
||||||
|
use serde::{Deserialize, Serialize};
|
||||||
use serde_json::Value;
|
use serde_json::Value;
|
||||||
|
|
||||||
#[derive(Queryable, Identifiable, PartialEq, Debug, Serialize, Deserialize)]
|
#[derive(Queryable, Identifiable, PartialEq, Debug, Serialize, Deserialize)]
|
||||||
|
@ -72,8 +73,8 @@ where
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::super::user::*;
|
use super::{super::user::*, *};
|
||||||
use super::*;
|
use crate::db::{establish_unpooled_connection, Crud, ListingType, SortType};
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_crud() {
|
fn test_crud() {
|
||||||
|
|
|
@ -1,6 +1,9 @@
|
||||||
use super::*;
|
use crate::{
|
||||||
use crate::schema::category;
|
db::Crud,
|
||||||
use crate::schema::category::dsl::*;
|
schema::{category, category::dsl::*},
|
||||||
|
};
|
||||||
|
use diesel::{dsl::*, result::Error, *};
|
||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
#[derive(Queryable, Identifiable, PartialEq, Debug, Serialize, Deserialize)]
|
#[derive(Queryable, Identifiable, PartialEq, Debug, Serialize, Deserialize)]
|
||||||
#[table_name = "category"]
|
#[table_name = "category"]
|
||||||
|
@ -50,6 +53,8 @@ impl Category {
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
use crate::db::establish_unpooled_connection;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_crud() {
|
fn test_crud() {
|
||||||
let conn = establish_unpooled_connection();
|
let conn = establish_unpooled_connection();
|
||||||
|
|
|
@ -1,13 +1,17 @@
|
||||||
// This is for db migrations that require code
|
// This is for db migrations that require code
|
||||||
use super::comment::Comment;
|
use super::{
|
||||||
use super::community::{Community, CommunityForm};
|
comment::Comment,
|
||||||
use super::post::Post;
|
community::{Community, CommunityForm},
|
||||||
use super::private_message::PrivateMessage;
|
post::Post,
|
||||||
use super::user::{UserForm, User_};
|
private_message::PrivateMessage,
|
||||||
use super::*;
|
user::{UserForm, User_},
|
||||||
use crate::apub::extensions::signatures::generate_actor_keypair;
|
};
|
||||||
use crate::apub::{make_apub_endpoint, EndpointType};
|
use crate::{
|
||||||
use crate::naive_now;
|
apub::{extensions::signatures::generate_actor_keypair, make_apub_endpoint, EndpointType},
|
||||||
|
db::Crud,
|
||||||
|
naive_now,
|
||||||
|
};
|
||||||
|
use diesel::*;
|
||||||
use failure::Error;
|
use failure::Error;
|
||||||
use log::info;
|
use log::info;
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
use super::post::Post;
|
use super::{post::Post, *};
|
||||||
use super::*;
|
use crate::{
|
||||||
use crate::apub::{make_apub_endpoint, EndpointType};
|
apub::{make_apub_endpoint, EndpointType},
|
||||||
use crate::naive_now;
|
naive_now,
|
||||||
use crate::schema::{comment, comment_like, comment_saved};
|
schema::{comment, comment_like, comment_saved},
|
||||||
|
};
|
||||||
|
|
||||||
// WITH RECURSIVE MyTree AS (
|
// WITH RECURSIVE MyTree AS (
|
||||||
// SELECT * FROM comment WHERE parent_id IS NULL
|
// SELECT * FROM comment WHERE parent_id IS NULL
|
||||||
|
@ -203,10 +204,10 @@ impl Saveable<CommentSavedForm> for CommentSaved {
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::super::community::*;
|
use super::{
|
||||||
use super::super::post::*;
|
super::{community::*, post::*, user::*},
|
||||||
use super::super::user::*;
|
*,
|
||||||
use super::*;
|
};
|
||||||
#[test]
|
#[test]
|
||||||
fn test_crud() {
|
fn test_crud() {
|
||||||
let conn = establish_unpooled_connection();
|
let conn = establish_unpooled_connection();
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
use super::*;
|
use crate::db::{fuzzy_search, limit_and_offset, ListingType, MaybeOptional, SortType};
|
||||||
use diesel::pg::Pg;
|
use diesel::{dsl::*, pg::Pg, result::Error, *};
|
||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
// The faked schema since diesel doesn't do views
|
// The faked schema since diesel doesn't do views
|
||||||
table! {
|
table! {
|
||||||
|
@ -453,11 +454,12 @@ impl<'a> ReplyQueryBuilder<'a> {
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::super::comment::*;
|
use super::{
|
||||||
use super::super::community::*;
|
super::{comment::*, community::*, post::*, user::*},
|
||||||
use super::super::post::*;
|
*,
|
||||||
use super::super::user::*;
|
};
|
||||||
use super::*;
|
use crate::db::{establish_unpooled_connection, Crud, Likeable};
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_crud() {
|
fn test_crud() {
|
||||||
let conn = establish_unpooled_connection();
|
let conn = establish_unpooled_connection();
|
||||||
|
|
|
@ -1,5 +1,10 @@
|
||||||
use super::*;
|
use crate::{
|
||||||
use crate::schema::{community, community_follower, community_moderator, community_user_ban};
|
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)]
|
#[derive(Queryable, Identifiable, PartialEq, Debug, Serialize, Deserialize)]
|
||||||
#[table_name = "community"]
|
#[table_name = "community"]
|
||||||
|
@ -232,8 +237,9 @@ impl Followable<CommunityFollowerForm> for CommunityFollower {
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::super::user::*;
|
use super::{super::user::*, *};
|
||||||
use super::*;
|
use crate::db::{establish_unpooled_connection, ListingType, SortType};
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_crud() {
|
fn test_crud() {
|
||||||
let conn = establish_unpooled_connection();
|
let conn = establish_unpooled_connection();
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
use super::community_view::community_mview::BoxedQuery;
|
use super::community_view::community_mview::BoxedQuery;
|
||||||
use super::*;
|
use crate::db::{fuzzy_search, limit_and_offset, MaybeOptional, SortType};
|
||||||
use diesel::pg::Pg;
|
use diesel::{pg::Pg, result::Error, *};
|
||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
table! {
|
table! {
|
||||||
community_view (id) {
|
community_view (id) {
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
use crate::settings::Settings;
|
use crate::settings::Settings;
|
||||||
use diesel::dsl::*;
|
use diesel::{dsl::*, result::Error, *};
|
||||||
use diesel::result::Error;
|
|
||||||
use diesel::*;
|
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
pub mod activity;
|
pub mod activity;
|
||||||
|
|
|
@ -1,8 +1,19 @@
|
||||||
use super::*;
|
use crate::{
|
||||||
use crate::schema::{
|
db::Crud,
|
||||||
mod_add, mod_add_community, mod_ban, mod_ban_from_community, mod_lock_post, mod_remove_comment,
|
schema::{
|
||||||
mod_remove_community, mod_remove_post, mod_sticky_post,
|
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)]
|
#[derive(Queryable, Identifiable, PartialEq, Debug, Serialize, Deserialize)]
|
||||||
#[table_name = "mod_remove_post"]
|
#[table_name = "mod_remove_post"]
|
||||||
|
@ -426,11 +437,12 @@ impl Crud<ModAddForm> for ModAdd {
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::super::comment::*;
|
use super::{
|
||||||
use super::super::community::*;
|
super::{comment::*, community::*, post::*, user::*},
|
||||||
use super::super::post::*;
|
*,
|
||||||
use super::super::user::*;
|
};
|
||||||
use super::*;
|
use crate::db::{establish_unpooled_connection, ListingType, SortType};
|
||||||
|
|
||||||
// use Crud;
|
// use Crud;
|
||||||
#[test]
|
#[test]
|
||||||
fn test_crud() {
|
fn test_crud() {
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
use super::*;
|
use crate::db::limit_and_offset;
|
||||||
|
use diesel::{result::Error, *};
|
||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
table! {
|
table! {
|
||||||
mod_remove_post_view (id) {
|
mod_remove_post_view (id) {
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
use super::*;
|
use crate::{
|
||||||
use crate::schema::password_reset_request;
|
db::Crud,
|
||||||
use crate::schema::password_reset_request::dsl::*;
|
schema::{password_reset_request, password_reset_request::dsl::*},
|
||||||
|
};
|
||||||
|
use diesel::{dsl::*, result::Error, *};
|
||||||
use sha2::{Digest, Sha256};
|
use sha2::{Digest, Sha256};
|
||||||
|
|
||||||
#[derive(Queryable, Identifiable, PartialEq, Debug)]
|
#[derive(Queryable, Identifiable, PartialEq, Debug)]
|
||||||
|
@ -79,8 +81,8 @@ impl PasswordResetRequest {
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::super::user::*;
|
use super::{super::user::*, *};
|
||||||
use super::*;
|
use crate::db::{establish_unpooled_connection, ListingType, SortType};
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_crud() {
|
fn test_crud() {
|
||||||
|
|
|
@ -1,7 +1,11 @@
|
||||||
use super::*;
|
use crate::{
|
||||||
use crate::apub::{make_apub_endpoint, EndpointType};
|
apub::{make_apub_endpoint, EndpointType},
|
||||||
use crate::naive_now;
|
db::{Crud, Likeable, Readable, Saveable},
|
||||||
use crate::schema::{post, post_like, post_read, post_saved};
|
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)]
|
#[derive(Queryable, Identifiable, PartialEq, Debug, Serialize, Deserialize)]
|
||||||
#[table_name = "post"]
|
#[table_name = "post"]
|
||||||
|
@ -237,9 +241,12 @@ impl Readable<PostReadForm> for PostRead {
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::super::community::*;
|
use super::{
|
||||||
use super::super::user::*;
|
super::{community::*, user::*},
|
||||||
use super::*;
|
*,
|
||||||
|
};
|
||||||
|
use crate::db::{establish_unpooled_connection, ListingType, SortType};
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_crud() {
|
fn test_crud() {
|
||||||
let conn = establish_unpooled_connection();
|
let conn = establish_unpooled_connection();
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
use super::post_view::post_mview::BoxedQuery;
|
use super::post_view::post_mview::BoxedQuery;
|
||||||
use super::*;
|
use crate::db::{fuzzy_search, limit_and_offset, ListingType, MaybeOptional, SortType};
|
||||||
use diesel::pg::Pg;
|
use diesel::{dsl::*, pg::Pg, result::Error, *};
|
||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
// The faked schema since diesel doesn't do views
|
// The faked schema since diesel doesn't do views
|
||||||
table! {
|
table! {
|
||||||
|
@ -363,10 +364,12 @@ impl PostView {
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::super::community::*;
|
use super::{
|
||||||
use super::super::post::*;
|
super::{community::*, post::*, user::*},
|
||||||
use super::super::user::*;
|
*,
|
||||||
use super::*;
|
};
|
||||||
|
use crate::db::{establish_unpooled_connection, Crud, Likeable};
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_crud() {
|
fn test_crud() {
|
||||||
let conn = establish_unpooled_connection();
|
let conn = establish_unpooled_connection();
|
||||||
|
|
|
@ -1,6 +1,10 @@
|
||||||
use super::*;
|
use crate::{
|
||||||
use crate::apub::{make_apub_endpoint, EndpointType};
|
apub::{make_apub_endpoint, EndpointType},
|
||||||
use crate::schema::private_message;
|
db::Crud,
|
||||||
|
schema::private_message,
|
||||||
|
};
|
||||||
|
use diesel::{dsl::*, result::Error, *};
|
||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
#[derive(Queryable, Identifiable, PartialEq, Debug, Serialize, Deserialize)]
|
#[derive(Queryable, Identifiable, PartialEq, Debug, Serialize, Deserialize)]
|
||||||
#[table_name = "private_message"]
|
#[table_name = "private_message"]
|
||||||
|
@ -85,8 +89,9 @@ impl PrivateMessage {
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::super::user::*;
|
use super::{super::user::*, *};
|
||||||
use super::*;
|
use crate::db::{establish_unpooled_connection, ListingType, SortType};
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_crud() {
|
fn test_crud() {
|
||||||
let conn = establish_unpooled_connection();
|
let conn = establish_unpooled_connection();
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
use super::*;
|
use crate::db::{limit_and_offset, MaybeOptional};
|
||||||
use diesel::pg::Pg;
|
use diesel::{pg::Pg, result::Error, *};
|
||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
// The faked schema since diesel doesn't do views
|
// The faked schema since diesel doesn't do views
|
||||||
table! {
|
table! {
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
use super::*;
|
use crate::{db::Crud, schema::site};
|
||||||
use crate::schema::site;
|
use diesel::{dsl::*, result::Error, *};
|
||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
#[derive(Queryable, Identifiable, PartialEq, Debug, Serialize, Deserialize)]
|
#[derive(Queryable, Identifiable, PartialEq, Debug, Serialize, Deserialize)]
|
||||||
#[table_name = "site"]
|
#[table_name = "site"]
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
use super::*;
|
use diesel::{result::Error, *};
|
||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
table! {
|
table! {
|
||||||
site_view (id) {
|
site_view (id) {
|
||||||
|
|
|
@ -1,9 +1,14 @@
|
||||||
use super::*;
|
use crate::{
|
||||||
use crate::schema::user_;
|
db::Crud,
|
||||||
use crate::schema::user_::dsl::*;
|
is_email_regex,
|
||||||
use crate::{is_email_regex, naive_now, Settings};
|
naive_now,
|
||||||
|
schema::{user_, user_::dsl::*},
|
||||||
|
settings::Settings,
|
||||||
|
};
|
||||||
use bcrypt::{hash, DEFAULT_COST};
|
use bcrypt::{hash, DEFAULT_COST};
|
||||||
|
use diesel::{dsl::*, result::Error, *};
|
||||||
use jsonwebtoken::{decode, encode, DecodingKey, EncodingKey, Header, TokenData, Validation};
|
use jsonwebtoken::{decode, encode, DecodingKey, EncodingKey, Header, TokenData, Validation};
|
||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
#[derive(Queryable, Identifiable, PartialEq, Debug)]
|
#[derive(Queryable, Identifiable, PartialEq, Debug)]
|
||||||
#[table_name = "user_"]
|
#[table_name = "user_"]
|
||||||
|
@ -208,8 +213,8 @@ impl User_ {
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::User_;
|
use super::{User_, *};
|
||||||
use super::*;
|
use crate::db::{establish_unpooled_connection, ListingType, SortType};
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_crud() {
|
fn test_crud() {
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
use super::comment::Comment;
|
use super::comment::Comment;
|
||||||
use super::*;
|
use crate::{db::Crud, schema::user_mention};
|
||||||
use crate::schema::user_mention;
|
use diesel::{dsl::*, result::Error, *};
|
||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
#[derive(Queryable, Associations, Identifiable, PartialEq, Debug, Serialize, Deserialize)]
|
#[derive(Queryable, Associations, Identifiable, PartialEq, Debug, Serialize, Deserialize)]
|
||||||
#[belongs_to(Comment)]
|
#[belongs_to(Comment)]
|
||||||
|
@ -53,11 +54,12 @@ impl Crud<UserMentionForm> for UserMention {
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::super::comment::*;
|
use super::{
|
||||||
use super::super::community::*;
|
super::{comment::*, community::*, post::*, user::*},
|
||||||
use super::super::post::*;
|
*,
|
||||||
use super::super::user::*;
|
};
|
||||||
use super::*;
|
use crate::db::{establish_unpooled_connection, ListingType, SortType};
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_crud() {
|
fn test_crud() {
|
||||||
let conn = establish_unpooled_connection();
|
let conn = establish_unpooled_connection();
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
use super::*;
|
use crate::db::{limit_and_offset, MaybeOptional, SortType};
|
||||||
use diesel::pg::Pg;
|
use diesel::{dsl::*, pg::Pg, result::Error, *};
|
||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
// The faked schema since diesel doesn't do views
|
// The faked schema since diesel doesn't do views
|
||||||
table! {
|
table! {
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
use super::user_view::user_mview::BoxedQuery;
|
use super::user_view::user_mview::BoxedQuery;
|
||||||
use super::*;
|
use crate::db::{fuzzy_search, limit_and_offset, MaybeOptional, SortType};
|
||||||
use diesel::pg::Pg;
|
use diesel::{dsl::*, pg::Pg, result::Error, *};
|
||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
table! {
|
table! {
|
||||||
user_view (id) {
|
user_view (id) {
|
||||||
|
|
|
@ -40,15 +40,20 @@ use crate::settings::Settings;
|
||||||
use actix_web::dev::ConnectionInfo;
|
use actix_web::dev::ConnectionInfo;
|
||||||
use chrono::{DateTime, FixedOffset, Local, NaiveDateTime, Utc};
|
use chrono::{DateTime, FixedOffset, Local, NaiveDateTime, Utc};
|
||||||
use isahc::prelude::*;
|
use isahc::prelude::*;
|
||||||
use lettre::smtp::authentication::{Credentials, Mechanism};
|
use lettre::{
|
||||||
use lettre::smtp::extension::ClientId;
|
smtp::{
|
||||||
use lettre::smtp::ConnectionReuseParameters;
|
authentication::{Credentials, Mechanism},
|
||||||
use lettre::{ClientSecurity, SmtpClient, Transport};
|
extension::ClientId,
|
||||||
|
ConnectionReuseParameters,
|
||||||
|
},
|
||||||
|
ClientSecurity,
|
||||||
|
SmtpClient,
|
||||||
|
Transport,
|
||||||
|
};
|
||||||
use lettre_email::Email;
|
use lettre_email::Email;
|
||||||
use log::error;
|
use log::error;
|
||||||
use percent_encoding::{utf8_percent_encode, NON_ALPHANUMERIC};
|
use percent_encoding::{utf8_percent_encode, NON_ALPHANUMERIC};
|
||||||
use rand::distributions::Alphanumeric;
|
use rand::{distributions::Alphanumeric, thread_rng, Rng};
|
||||||
use rand::{thread_rng, Rng};
|
|
||||||
use regex::{Regex, RegexBuilder};
|
use regex::{Regex, RegexBuilder};
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
|
|
||||||
|
|
|
@ -4,8 +4,10 @@ extern crate diesel_migrations;
|
||||||
|
|
||||||
use actix::prelude::*;
|
use actix::prelude::*;
|
||||||
use actix_web::*;
|
use actix_web::*;
|
||||||
use diesel::r2d2::{ConnectionManager, Pool};
|
use diesel::{
|
||||||
use diesel::PgConnection;
|
r2d2::{ConnectionManager, Pool},
|
||||||
|
PgConnection,
|
||||||
|
};
|
||||||
use failure::Error;
|
use failure::Error;
|
||||||
use lemmy_server::{
|
use lemmy_server::{
|
||||||
db::code_migrations::run_advanced_migrations,
|
db::code_migrations::run_advanced_migrations,
|
||||||
|
|
|
@ -1,23 +1,18 @@
|
||||||
pub mod rate_limiter;
|
|
||||||
|
|
||||||
use super::{IPAddr, Settings};
|
use super::{IPAddr, Settings};
|
||||||
use crate::api::APIError;
|
use crate::{api::APIError, get_ip, settings::RateLimitConfig};
|
||||||
use crate::get_ip;
|
|
||||||
use crate::settings::RateLimitConfig;
|
|
||||||
use actix_web::dev::{Service, ServiceRequest, ServiceResponse, Transform};
|
use actix_web::dev::{Service, ServiceRequest, ServiceResponse, Transform};
|
||||||
use failure::Error;
|
|
||||||
use futures::future::{ok, Ready};
|
use futures::future::{ok, Ready};
|
||||||
use log::debug;
|
|
||||||
use rate_limiter::{RateLimitType, RateLimiter};
|
use rate_limiter::{RateLimitType, RateLimiter};
|
||||||
use std::collections::HashMap;
|
use std::{
|
||||||
use std::future::Future;
|
future::Future,
|
||||||
use std::pin::Pin;
|
pin::Pin,
|
||||||
use std::sync::Arc;
|
sync::Arc,
|
||||||
use std::task::{Context, Poll};
|
task::{Context, Poll},
|
||||||
use std::time::SystemTime;
|
};
|
||||||
use strum::IntoEnumIterator;
|
|
||||||
use tokio::sync::Mutex;
|
use tokio::sync::Mutex;
|
||||||
|
|
||||||
|
pub mod rate_limiter;
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
pub struct RateLimit {
|
pub struct RateLimit {
|
||||||
pub rate_limiter: Arc<Mutex<RateLimiter>>,
|
pub rate_limiter: Arc<Mutex<RateLimiter>>,
|
||||||
|
@ -92,7 +87,7 @@ impl RateLimited {
|
||||||
}
|
}
|
||||||
RateLimitType::Post => {
|
RateLimitType::Post => {
|
||||||
limiter.check_rate_limit_full(
|
limiter.check_rate_limit_full(
|
||||||
self.type_.clone(),
|
self.type_,
|
||||||
&ip_addr,
|
&ip_addr,
|
||||||
rate_limit.post,
|
rate_limit.post,
|
||||||
rate_limit.post_per_second,
|
rate_limit.post_per_second,
|
||||||
|
|
|
@ -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)]
|
#[derive(Debug, Clone)]
|
||||||
pub struct RateLimitBucket {
|
pub struct RateLimitBucket {
|
||||||
|
|
|
@ -1,10 +1,11 @@
|
||||||
use super::*;
|
use crate::{
|
||||||
use crate::api::comment::*;
|
api::{comment::*, community::*, post::*, site::*, user::*, Oper, Perform},
|
||||||
use crate::api::community::*;
|
rate_limit::RateLimit,
|
||||||
use crate::api::post::*;
|
routes::{ChatServerParam, DbPoolParam},
|
||||||
use crate::api::site::*;
|
websocket::WebsocketInfo,
|
||||||
use crate::api::user::*;
|
};
|
||||||
use crate::rate_limit::RateLimit;
|
use actix_web::{error::ErrorBadRequest, *};
|
||||||
|
use serde::Serialize;
|
||||||
|
|
||||||
pub fn config(cfg: &mut web::ServiceConfig, rate_limit: &RateLimit) {
|
pub fn config(cfg: &mut web::ServiceConfig, rate_limit: &RateLimit) {
|
||||||
cfg.service(
|
cfg.service(
|
||||||
|
|
|
@ -1,12 +1,17 @@
|
||||||
use super::*;
|
use crate::{
|
||||||
use crate::apub::comment::get_apub_comment;
|
apub::{
|
||||||
use crate::apub::community::*;
|
comment::get_apub_comment,
|
||||||
use crate::apub::community_inbox::community_inbox;
|
community::*,
|
||||||
use crate::apub::post::get_apub_post;
|
community_inbox::community_inbox,
|
||||||
use crate::apub::shared_inbox::shared_inbox;
|
post::get_apub_post,
|
||||||
use crate::apub::user::*;
|
shared_inbox::shared_inbox,
|
||||||
use crate::apub::user_inbox::user_inbox;
|
user::*,
|
||||||
use crate::apub::APUB_JSON_CONTENT_TYPE;
|
user_inbox::user_inbox,
|
||||||
|
APUB_JSON_CONTENT_TYPE,
|
||||||
|
},
|
||||||
|
settings::Settings,
|
||||||
|
};
|
||||||
|
use actix_web::*;
|
||||||
|
|
||||||
pub fn config(cfg: &mut web::ServiceConfig) {
|
pub fn config(cfg: &mut web::ServiceConfig) {
|
||||||
if Settings::get().federation.enabled {
|
if Settings::get().federation.enabled {
|
||||||
|
|
|
@ -1,11 +1,28 @@
|
||||||
use super::*;
|
use crate::{
|
||||||
use crate::db::comment_view::{ReplyQueryBuilder, ReplyView};
|
db::{
|
||||||
use crate::db::community::Community;
|
comment_view::{ReplyQueryBuilder, ReplyView},
|
||||||
use crate::db::post_view::{PostQueryBuilder, PostView};
|
community::Community,
|
||||||
use crate::db::site_view::SiteView;
|
post_view::{PostQueryBuilder, PostView},
|
||||||
use crate::db::user::{Claims, User_};
|
site_view::SiteView,
|
||||||
use crate::db::user_mention_view::{UserMentionQueryBuilder, UserMentionView};
|
user::{Claims, User_},
|
||||||
use crate::db::{ListingType, SortType};
|
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)]
|
#[derive(Deserialize)]
|
||||||
pub struct Params {
|
pub struct Params {
|
||||||
|
@ -21,8 +38,8 @@ enum RequestType {
|
||||||
|
|
||||||
pub fn config(cfg: &mut web::ServiceConfig) {
|
pub fn config(cfg: &mut web::ServiceConfig) {
|
||||||
cfg
|
cfg
|
||||||
.route("/feeds/{type}/{name}.xml", web::get().to(feeds::get_feed))
|
.route("/feeds/{type}/{name}.xml", web::get().to(get_feed))
|
||||||
.route("/feeds/all.xml", web::get().to(feeds::get_all_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> {
|
async fn get_all_feed(info: web::Query<Params>, db: DbPoolParam) -> Result<HttpResponse, Error> {
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
use super::*;
|
use crate::settings::Settings;
|
||||||
|
use actix_files::NamedFile;
|
||||||
|
use actix_web::*;
|
||||||
|
|
||||||
pub fn config(cfg: &mut web::ServiceConfig) {
|
pub fn config(cfg: &mut web::ServiceConfig) {
|
||||||
cfg
|
cfg
|
||||||
|
|
|
@ -1,33 +1,3 @@
|
||||||
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};
|
|
||||||
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 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 api;
|
||||||
pub mod federation;
|
pub mod federation;
|
||||||
pub mod feeds;
|
pub mod feeds;
|
||||||
|
@ -35,3 +5,16 @@ pub mod index;
|
||||||
pub mod nodeinfo;
|
pub mod nodeinfo;
|
||||||
pub mod webfinger;
|
pub mod webfinger;
|
||||||
pub mod websocket;
|
pub mod websocket;
|
||||||
|
|
||||||
|
use crate::{rate_limit::rate_limiter::RateLimiter, websocket::server::ChatServer};
|
||||||
|
use actix::prelude::*;
|
||||||
|
use actix_web::*;
|
||||||
|
use diesel::{
|
||||||
|
r2d2::{ConnectionManager, Pool},
|
||||||
|
PgConnection,
|
||||||
|
};
|
||||||
|
use std::sync::{Arc, Mutex};
|
||||||
|
|
||||||
|
pub type DbPoolParam = web::Data<Pool<ConnectionManager<PgConnection>>>;
|
||||||
|
pub type RateLimitParam = web::Data<Arc<Mutex<RateLimiter>>>;
|
||||||
|
pub type ChatServerParam = web::Data<Addr<ChatServer>>;
|
||||||
|
|
|
@ -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) {
|
pub fn config(cfg: &mut web::ServiceConfig) {
|
||||||
cfg
|
cfg
|
||||||
|
|
|
@ -1,5 +1,8 @@
|
||||||
use super::*;
|
use crate::{db::community::Community, routes::DbPoolParam, Settings};
|
||||||
use crate::db::community::Community;
|
use actix_web::{error::ErrorBadRequest, web::Query, *};
|
||||||
|
use regex::Regex;
|
||||||
|
use serde::Deserialize;
|
||||||
|
use serde_json::json;
|
||||||
|
|
||||||
#[derive(Deserialize)]
|
#[derive(Deserialize)]
|
||||||
pub struct Params {
|
pub struct Params {
|
||||||
|
|
|
@ -1,5 +1,12 @@
|
||||||
use super::*;
|
use crate::{
|
||||||
use crate::websocket::server::*;
|
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
|
/// How often heartbeat pings are sent
|
||||||
const HEARTBEAT_INTERVAL: Duration = Duration::from_secs(5);
|
const HEARTBEAT_INTERVAL: Duration = Duration::from_secs(5);
|
||||||
|
|
|
@ -1,10 +1,7 @@
|
||||||
use config::{Config, ConfigError, Environment, File};
|
use config::{Config, ConfigError, Environment, File};
|
||||||
use failure::Error;
|
use failure::Error;
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
use std::env;
|
use std::{env, fs, net::IpAddr, sync::RwLock};
|
||||||
use std::fs;
|
|
||||||
use std::net::IpAddr;
|
|
||||||
use std::sync::RwLock;
|
|
||||||
|
|
||||||
static CONFIG_FILE_DEFAULTS: &str = "config/defaults.hjson";
|
static CONFIG_FILE_DEFAULTS: &str = "config/defaults.hjson";
|
||||||
static CONFIG_FILE: &str = "config/config.hjson";
|
static CONFIG_FILE: &str = "config/config.hjson";
|
||||||
|
|
|
@ -2,16 +2,20 @@ pub mod server;
|
||||||
|
|
||||||
use crate::ConnectionId;
|
use crate::ConnectionId;
|
||||||
use actix::prelude::*;
|
use actix::prelude::*;
|
||||||
use diesel::r2d2::{ConnectionManager, Pool};
|
use diesel::{
|
||||||
use diesel::PgConnection;
|
r2d2::{ConnectionManager, Pool},
|
||||||
|
PgConnection,
|
||||||
|
};
|
||||||
use failure::Error;
|
use failure::Error;
|
||||||
use log::{error, info};
|
use log::{error, info};
|
||||||
use rand::{rngs::ThreadRng, Rng};
|
use rand::{rngs::ThreadRng, Rng};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use serde_json::Value;
|
use serde_json::Value;
|
||||||
use server::ChatServer;
|
use server::ChatServer;
|
||||||
use std::collections::{HashMap, HashSet};
|
use std::{
|
||||||
use std::str::FromStr;
|
collections::{HashMap, HashSet},
|
||||||
|
str::FromStr,
|
||||||
|
};
|
||||||
|
|
||||||
#[derive(EnumString, ToString, Debug, Clone)]
|
#[derive(EnumString, ToString, Debug, Clone)]
|
||||||
pub enum UserOperation {
|
pub enum UserOperation {
|
||||||
|
|
|
@ -3,15 +3,16 @@
|
||||||
//! room through `ChatServer`.
|
//! room through `ChatServer`.
|
||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
use crate::api::comment::*;
|
use crate::{
|
||||||
use crate::api::community::*;
|
api::{comment::*, community::*, post::*, site::*, user::*, *},
|
||||||
use crate::api::post::*;
|
rate_limit::RateLimit,
|
||||||
use crate::api::site::*;
|
websocket::UserOperation,
|
||||||
use crate::api::user::*;
|
CommunityId,
|
||||||
use crate::api::*;
|
ConnectionId,
|
||||||
use crate::rate_limit::RateLimit;
|
IPAddr,
|
||||||
use crate::websocket::UserOperation;
|
PostId,
|
||||||
use crate::{CommunityId, ConnectionId, IPAddr, PostId, UserId};
|
UserId,
|
||||||
|
};
|
||||||
|
|
||||||
/// Chat server sends this messages to session
|
/// Chat server sends this messages to session
|
||||||
#[derive(Message)]
|
#[derive(Message)]
|
||||||
|
@ -940,7 +941,7 @@ impl Handler<Connect> for ChatServer {
|
||||||
id,
|
id,
|
||||||
SessionInfo {
|
SessionInfo {
|
||||||
addr: msg.addr,
|
addr: msg.addr,
|
||||||
ip: msg.ip.to_owned(),
|
ip: msg.ip,
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue