diff options
59 files changed, 885 insertions, 337 deletions
diff --git a/server/.rustfmt.toml b/server/.rustfmt.toml index 684a7f8a..f3efdc30 100644 --- a/server/.rustfmt.toml +++ b/server/.rustfmt.toml @@ -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 diff --git a/server/Cargo.lock b/server/Cargo.lock index c71b8190..0a59a609 100644 --- a/server/Cargo.lock +++ b/server/Cargo.lock @@ -2,9 +2,9 @@ # It is not intended for manual editing. [[package]] name = "activitystreams" -version = "0.6.1" +version = "0.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "edf0082191df1d6d39577b28b5daa7b8318b812038d0f7a83f05331f17580934" +checksum = "464cb473bfb402b857cc15b1153974c203a43f1485da4dda15cd17a738548958" dependencies = [ "activitystreams-derive", "chrono", @@ -27,6 +27,17 @@ dependencies = [ ] [[package]] +name = "activitystreams-new" +version = "0.1.0" +source = "git+https://git.asonix.dog/asonix/activitystreams-sketch#2fb52d32bbce9716c76e08579cf5c716366945fe" +dependencies = [ + "activitystreams", + "serde 1.0.110", + "serde_json 1.0.53", + "typed-builder", +] + +[[package]] name = "actix" version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -864,9 +875,9 @@ dependencies = [ [[package]] name = "derive_more" -version = "0.99.6" +version = "0.99.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "46b046a346c374c6c3c84d2070bfe33904504686bdf949c2d8eb22edad3f270c" +checksum = "2127768764f1556535c01b5326ef94bd60ff08dcfbdc544d53e69ed155610f5d" dependencies = [ "proc-macro2", "quote", @@ -1325,9 +1336,9 @@ dependencies = [ [[package]] name = "hermit-abi" -version = "0.1.12" +version = "0.1.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61565ff7aaace3525556587bd2dc31d4a07071957be715e63ce7b1eccf51a8f4" +checksum = "91780f809e750b0a89f5544be56617ff6b1227ee485bcb06ebe10cdf89bd3b71" dependencies = [ "libc", ] @@ -1554,6 +1565,7 @@ name = "lemmy_server" version = "0.0.1" dependencies = [ "activitystreams", + "activitystreams-new", "actix", "actix-files", "actix-rt", @@ -2119,9 +2131,9 @@ checksum = "05da548ad6865900e60eaba7f589cc0783590a92e940c26953ff81ddbab2d677" [[package]] name = "ppv-lite86" -version = "0.2.6" +version = "0.2.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "74490b50b9fbe561ac330df47c08f3f33073d2d00c150f719147d7c54522fa1b" +checksum = "d1e4df3c96bec4c7ce0e32fe5960c98ffc869443ec9592a0411ca1ee96e5e2f0" [[package]] name = "pq-sys" @@ -2146,9 +2158,9 @@ checksum = "8e946095f9d3ed29ec38de908c22f95d9ac008e424c7bcae54c75a79c527c694" [[package]] name = "proc-macro2" -version = "1.0.12" +version = "1.0.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8872cf6f48eee44265156c111456a700ab3483686b3f96df4cf5481c89157319" +checksum = "53f5ffe53a6b28e37c9c1ce74893477864d64f74778a93a4beb43c8fa167f639" dependencies = [ "unicode-xid", ] @@ -2781,9 +2793,9 @@ dependencies = [ [[package]] name = "syn" -version = "1.0.21" +version = "1.0.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4696caa4048ac7ce2bcd2e484b3cef88c1004e41b8e945a277e2c25dc0b72060" +checksum = "1425de3c33b0941002740a420b1a906a350b88d08b82b2c8a01035a3f9447bac" dependencies = [ "proc-macro2", "quote", @@ -2836,18 +2848,18 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.17" +version = "1.0.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "467e5ff447618a916519a4e0d62772ab14f434897f3d63f05d8700ef1e9b22c1" +checksum = "5976891d6950b4f68477850b5b9e5aa64d955961466f9e174363f573e54e8ca7" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.17" +version = "1.0.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e63c1091225b9834089b429bc4a2e01223470e3183e891582909e9d1c4cb55d9" +checksum = "ab81dbd1cd69cd2ce22ecfbdd3bdb73334ba25350649408cc6c085f46d89573d" dependencies = [ "proc-macro2", "quote", @@ -3015,6 +3027,16 @@ 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" source = "registry+https://github.com/rust-lang/crates.io-index" diff --git a/server/Cargo.toml b/server/Cargo.toml index cf680b66..a28f98e8 100644 --- a/server/Cargo.toml +++ b/server/Cargo.toml @@ -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.1" +activitystreams = "0.6.2" +activitystreams-new = { version = "0.1.0", git = "https://git.asonix.dog/asonix/activitystreams-sketch" } bcrypt = "0.8.0" chrono = { version = "0.4.7", features = ["serde"] } failure = "0.1.8" diff --git a/server/src/api/comment.rs b/server/src/api/comment.rs index f469b462..369cba5c 100644 --- a/server/src/api/comment.rs +++ b/server/src/api/comment.rs @@ -1,4 +1,42 @@ -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, + }, + naive_now, + remove_slurs, + scrape_text_for_mentions, + send_email, + settings::Settings, + websocket::{ + server::{JoinCommunityRoom, SendComment}, + UserOperation, + WebsocketInfo, + }, + MentionData, +}; +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 { diff --git a/server/src/api/community.rs b/server/src/api/community.rs index 55c55ee1..cb412fcc 100644 --- a/server/src/api/community.rs +++ b/server/src/api/community.rs @@ -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 { diff --git a/server/src/api/mod.rs b/server/src/api/mod.rs index fca7c035..5120e9bc 100644 --- a/server/src/api/mod.rs +++ b/server/src/api/mod.rs @@ -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::{ - fetch_iframely_and_pictshare_data, generate_random_string, naive_from_unix, naive_now, - remove_slurs, scrape_text_for_mentions, send_email, slur_check, slurs_vec_to_str, MentionData, +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; diff --git a/server/src/api/post.rs b/server/src/api/post.rs index 42c35074..9bbde791 100644 --- a/server/src/api/post.rs +++ b/server/src/api/post.rs @@ -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 { diff --git a/server/src/api/site.rs b/server/src/api/site.rs index 1a4ed0be..faee30cb 100644 --- a/server/src/api/site.rs +++ b/server/src/api/site.rs @@ -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 {} diff --git a/server/src/api/user.rs b/server/src/api/user.rs index b5336609..18d30985 100644 --- a/server/src/api/user.rs +++ b/server/src/api/user.rs @@ -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 { diff --git a/server/src/apub/activities.rs b/server/src/apub/activities.rs index 9fc1fa1f..3816093c 100644 --- a/server/src/apub/activities.rs +++ b/server/src/apub/activities.rs @@ -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, diff --git a/server/src/apub/comment.rs b/server/src/apub/comment.rs index f746fc0f..90e9f07b 100644 --- a/server/src/apub/comment.rs +++ b/server/src/apub/comment.rs @@ -1,4 +1,42 @@ -use super::*; +use crate::{ + apub::{ + activities::{populate_object_props, send_activity}, + create_apub_response, + create_apub_tombstone_response, + create_tombstone, + fetch_webfinger_url, + 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, + scrape_text_for_mentions, + MentionData, +}; +use activitystreams::{ + activity::{Create, Delete, Dislike, Like, Remove, Undo, Update}, + context, + link::Mention, + object::{kind::NoteType, properties::ObjectProperties, Note, Tombstone}, +}; +use actix_web::{body::Body, web::Path, HttpResponse, Result}; +use diesel::PgConnection; +use failure::Error; +use itertools::Itertools; +use log::debug; +use serde::Deserialize; #[derive(Deserialize)] pub struct CommentQuery { diff --git a/server/src/apub/community.rs b/server/src/apub/community.rs index d8ea86c7..d91cb4ba 100644 --- a/server/src/apub/community.rs +++ b/server/src/apub/community.rs @@ -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 { diff --git a/server/src/apub/community_inbox.rs b/server/src/apub/community_inbox.rs index 6c35ce0a..2ae2e0eb 100644 --- a/server/src/apub/community_inbox.rs +++ b/server/src/apub/community_inbox.rs @@ -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)] diff --git a/server/src/apub/extensions/group_extensions.rs b/server/src/apub/extensions/group_extensions.rs index 10cee5c7..ece97706 100644 --- a/server/src/apub/extensions/group_extensions.rs +++ b/server/src/apub/extensions/group_extensions.rs @@ -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}; diff --git a/server/src/apub/extensions/page_extension.rs b/server/src/apub/extensions/page_extension.rs index 435a869a..484807e3 100644 --- a/server/src/apub/extensions/page_extension.rs +++ b/server/src/apub/extensions/page_extension.rs @@ -1,5 +1,4 @@ -use activitystreams::ext::Extension; -use activitystreams::Base; +use activitystreams::{ext::Extension, Base}; use serde::{Deserialize, Serialize}; |