mirror of
https://github.com/LemmyNet/lemmy.git
synced 2024-10-01 01:36:12 -04:00
Merge crates db_schema and db_queries
This commit is contained in:
parent
d206aad282
commit
f24999027e
30
Cargo.lock
generated
30
Cargo.lock
generated
@ -1668,7 +1668,6 @@ dependencies = [
|
|||||||
"lazy_static",
|
"lazy_static",
|
||||||
"lemmy_api_common",
|
"lemmy_api_common",
|
||||||
"lemmy_apub",
|
"lemmy_apub",
|
||||||
"lemmy_db_queries",
|
|
||||||
"lemmy_db_schema",
|
"lemmy_db_schema",
|
||||||
"lemmy_db_views",
|
"lemmy_db_views",
|
||||||
"lemmy_db_views_actor",
|
"lemmy_db_views_actor",
|
||||||
@ -1697,7 +1696,6 @@ dependencies = [
|
|||||||
"actix-web",
|
"actix-web",
|
||||||
"chrono",
|
"chrono",
|
||||||
"diesel",
|
"diesel",
|
||||||
"lemmy_db_queries",
|
|
||||||
"lemmy_db_schema",
|
"lemmy_db_schema",
|
||||||
"lemmy_db_views",
|
"lemmy_db_views",
|
||||||
"lemmy_db_views_actor",
|
"lemmy_db_views_actor",
|
||||||
@ -1732,7 +1730,6 @@ dependencies = [
|
|||||||
"lemmy_api_common",
|
"lemmy_api_common",
|
||||||
"lemmy_apub",
|
"lemmy_apub",
|
||||||
"lemmy_apub_lib",
|
"lemmy_apub_lib",
|
||||||
"lemmy_db_queries",
|
|
||||||
"lemmy_db_schema",
|
"lemmy_db_schema",
|
||||||
"lemmy_db_views",
|
"lemmy_db_views",
|
||||||
"lemmy_db_views_actor",
|
"lemmy_db_views_actor",
|
||||||
@ -1776,7 +1773,6 @@ dependencies = [
|
|||||||
"itertools",
|
"itertools",
|
||||||
"lemmy_api_common",
|
"lemmy_api_common",
|
||||||
"lemmy_apub_lib",
|
"lemmy_apub_lib",
|
||||||
"lemmy_db_queries",
|
|
||||||
"lemmy_db_schema",
|
"lemmy_db_schema",
|
||||||
"lemmy_db_views",
|
"lemmy_db_views",
|
||||||
"lemmy_db_views_actor",
|
"lemmy_db_views_actor",
|
||||||
@ -1834,15 +1830,16 @@ dependencies = [
|
|||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "lemmy_db_queries"
|
name = "lemmy_db_schema"
|
||||||
version = "0.13.0"
|
version = "0.13.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bcrypt",
|
"bcrypt",
|
||||||
"chrono",
|
"chrono",
|
||||||
"diesel",
|
"diesel",
|
||||||
|
"diesel-derive-newtype",
|
||||||
"diesel_migrations",
|
"diesel_migrations",
|
||||||
"lazy_static",
|
"lazy_static",
|
||||||
"lemmy_db_schema",
|
"lemmy_apub_lib",
|
||||||
"lemmy_utils",
|
"lemmy_utils",
|
||||||
"log",
|
"log",
|
||||||
"regex",
|
"regex",
|
||||||
@ -1855,27 +1852,11 @@ dependencies = [
|
|||||||
"url",
|
"url",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "lemmy_db_schema"
|
|
||||||
version = "0.13.0"
|
|
||||||
dependencies = [
|
|
||||||
"chrono",
|
|
||||||
"diesel",
|
|
||||||
"diesel-derive-newtype",
|
|
||||||
"lemmy_apub_lib",
|
|
||||||
"lemmy_utils",
|
|
||||||
"log",
|
|
||||||
"serde",
|
|
||||||
"serde_json",
|
|
||||||
"url",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "lemmy_db_views"
|
name = "lemmy_db_views"
|
||||||
version = "0.13.0"
|
version = "0.13.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"diesel",
|
"diesel",
|
||||||
"lemmy_db_queries",
|
|
||||||
"lemmy_db_schema",
|
"lemmy_db_schema",
|
||||||
"log",
|
"log",
|
||||||
"serde",
|
"serde",
|
||||||
@ -1888,7 +1869,6 @@ name = "lemmy_db_views_actor"
|
|||||||
version = "0.13.0"
|
version = "0.13.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"diesel",
|
"diesel",
|
||||||
"lemmy_db_queries",
|
|
||||||
"lemmy_db_schema",
|
"lemmy_db_schema",
|
||||||
"serde",
|
"serde",
|
||||||
]
|
]
|
||||||
@ -1898,7 +1878,6 @@ name = "lemmy_db_views_moderator"
|
|||||||
version = "0.13.0"
|
version = "0.13.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"diesel",
|
"diesel",
|
||||||
"lemmy_db_queries",
|
|
||||||
"lemmy_db_schema",
|
"lemmy_db_schema",
|
||||||
"serde",
|
"serde",
|
||||||
]
|
]
|
||||||
@ -1918,7 +1897,6 @@ dependencies = [
|
|||||||
"lazy_static",
|
"lazy_static",
|
||||||
"lemmy_api_common",
|
"lemmy_api_common",
|
||||||
"lemmy_apub_lib",
|
"lemmy_apub_lib",
|
||||||
"lemmy_db_queries",
|
|
||||||
"lemmy_db_schema",
|
"lemmy_db_schema",
|
||||||
"lemmy_db_views",
|
"lemmy_db_views",
|
||||||
"lemmy_db_views_actor",
|
"lemmy_db_views_actor",
|
||||||
@ -1954,7 +1932,6 @@ dependencies = [
|
|||||||
"lemmy_api_crud",
|
"lemmy_api_crud",
|
||||||
"lemmy_apub",
|
"lemmy_apub",
|
||||||
"lemmy_apub_lib",
|
"lemmy_apub_lib",
|
||||||
"lemmy_db_queries",
|
|
||||||
"lemmy_db_schema",
|
"lemmy_db_schema",
|
||||||
"lemmy_db_views",
|
"lemmy_db_views",
|
||||||
"lemmy_db_views_actor",
|
"lemmy_db_views_actor",
|
||||||
@ -2020,7 +1997,6 @@ dependencies = [
|
|||||||
"chrono",
|
"chrono",
|
||||||
"diesel",
|
"diesel",
|
||||||
"lemmy_api_common",
|
"lemmy_api_common",
|
||||||
"lemmy_db_queries",
|
|
||||||
"lemmy_db_schema",
|
"lemmy_db_schema",
|
||||||
"lemmy_db_views",
|
"lemmy_db_views",
|
||||||
"lemmy_db_views_actor",
|
"lemmy_db_views_actor",
|
||||||
|
@ -22,7 +22,6 @@ members = [
|
|||||||
"crates/apub_lib_derive",
|
"crates/apub_lib_derive",
|
||||||
"crates/apub",
|
"crates/apub",
|
||||||
"crates/utils",
|
"crates/utils",
|
||||||
"crates/db_queries",
|
|
||||||
"crates/db_schema",
|
"crates/db_schema",
|
||||||
"crates/db_views",
|
"crates/db_views",
|
||||||
"crates/db_views_actor",
|
"crates/db_views_actor",
|
||||||
@ -38,7 +37,6 @@ lemmy_apub = { version = "=0.13.0", path = "./crates/apub" }
|
|||||||
lemmy_apub_lib = { version = "=0.13.0", path = "./crates/apub_lib" }
|
lemmy_apub_lib = { version = "=0.13.0", path = "./crates/apub_lib" }
|
||||||
lemmy_utils = { version = "=0.13.0", path = "./crates/utils" }
|
lemmy_utils = { version = "=0.13.0", path = "./crates/utils" }
|
||||||
lemmy_db_schema = { version = "=0.13.0", path = "./crates/db_schema" }
|
lemmy_db_schema = { version = "=0.13.0", path = "./crates/db_schema" }
|
||||||
lemmy_db_queries = { version = "=0.13.0", path = "./crates/db_queries" }
|
|
||||||
lemmy_db_views = { version = "=0.13.0", path = "./crates/db_views" }
|
lemmy_db_views = { version = "=0.13.0", path = "./crates/db_views" }
|
||||||
lemmy_db_views_moderator = { version = "=0.13.0", path = "./crates/db_views_moderator" }
|
lemmy_db_views_moderator = { version = "=0.13.0", path = "./crates/db_views_moderator" }
|
||||||
lemmy_db_views_actor = { version = "=0.13.0", path = "./crates/db_views_actor" }
|
lemmy_db_views_actor = { version = "=0.13.0", path = "./crates/db_views_actor" }
|
||||||
|
@ -7,7 +7,7 @@ services:
|
|||||||
- "127.0.0.1:8536:8536"
|
- "127.0.0.1:8536:8536"
|
||||||
restart: always
|
restart: always
|
||||||
environment:
|
environment:
|
||||||
- RUST_LOG="warn,lemmy_server=info,lemmy_api=info,lemmy_api_common=info,lemmy_api_crud=info,lemmy_apub=info,lemmy_db_queries=info,lemmy_db_schema=info,lemmy_db_views=info,lemmy_db_views_actor=info,lemmy_db_views_moderator=info,lemmy_routes=info,lemmy_utils=info,lemmy_websocket=info"
|
- RUST_LOG="warn,lemmy_server=info,lemmy_api=info,lemmy_api_common=info,lemmy_api_crud=info,lemmy_apub=info,lemmy_db_schema=info,lemmy_db_views=info,lemmy_db_views_actor=info,lemmy_db_views_moderator=info,lemmy_routes=info,lemmy_utils=info,lemmy_websocket=info"
|
||||||
volumes:
|
volumes:
|
||||||
- ./lemmy.hjson:/config/config.hjson:ro
|
- ./lemmy.hjson:/config/config.hjson:ro
|
||||||
depends_on:
|
depends_on:
|
||||||
|
@ -3,7 +3,7 @@ set -e
|
|||||||
|
|
||||||
export APUB_TESTING_SEND_SYNC=1
|
export APUB_TESTING_SEND_SYNC=1
|
||||||
export RUST_BACKTRACE=1
|
export RUST_BACKTRACE=1
|
||||||
export RUST_LOG="warn,lemmy_server=debug,lemmy_api=debug,lemmy_api_common=debug,lemmy_api_crud=debug,lemmy_apub=debug,lemmy_db_queries=debug,lemmy_db_schema=debug,lemmy_db_views=debug,lemmy_db_views_actor=debug,lemmy_db_views_moderator=debug,lemmy_routes=debug,lemmy_utils=debug,lemmy_websocket=debug"
|
export RUST_LOG="warn,lemmy_server=debug,lemmy_api=debug,lemmy_api_common=debug,lemmy_api_crud=debug,lemmy_apub=debug,lemmy_db_schema=debug,lemmy_db_views=debug,lemmy_db_views_actor=debug,lemmy_db_views_moderator=debug,lemmy_routes=debug,lemmy_utils=debug,lemmy_websocket=debug"
|
||||||
|
|
||||||
for INSTANCE in lemmy_alpha lemmy_beta lemmy_gamma lemmy_delta lemmy_epsilon; do
|
for INSTANCE in lemmy_alpha lemmy_beta lemmy_gamma lemmy_delta lemmy_epsilon; do
|
||||||
psql "${LEMMY_DATABASE_URL}/lemmy" -c "DROP DATABASE IF EXISTS $INSTANCE"
|
psql "${LEMMY_DATABASE_URL}/lemmy" -c "DROP DATABASE IF EXISTS $INSTANCE"
|
||||||
|
@ -15,7 +15,6 @@ doctest = false
|
|||||||
[dependencies]
|
[dependencies]
|
||||||
lemmy_apub = { version = "=0.13.0", path = "../apub" }
|
lemmy_apub = { version = "=0.13.0", path = "../apub" }
|
||||||
lemmy_utils = { version = "=0.13.0", path = "../utils" }
|
lemmy_utils = { version = "=0.13.0", path = "../utils" }
|
||||||
lemmy_db_queries = { version = "=0.13.0", path = "../db_queries" }
|
|
||||||
lemmy_db_schema = { version = "=0.13.0", path = "../db_schema" }
|
lemmy_db_schema = { version = "=0.13.0", path = "../db_schema" }
|
||||||
lemmy_db_views = { version = "=0.13.0", path = "../db_views" }
|
lemmy_db_views = { version = "=0.13.0", path = "../db_views" }
|
||||||
lemmy_db_views_moderator = { version = "=0.13.0", path = "../db_views_moderator" }
|
lemmy_db_views_moderator = { version = "=0.13.0", path = "../db_views_moderator" }
|
||||||
|
@ -15,8 +15,11 @@ use lemmy_apub::{
|
|||||||
},
|
},
|
||||||
fetcher::post_or_comment::PostOrComment,
|
fetcher::post_or_comment::PostOrComment,
|
||||||
};
|
};
|
||||||
use lemmy_db_queries::{source::comment::Comment_, Likeable, Saveable};
|
use lemmy_db_schema::{
|
||||||
use lemmy_db_schema::{source::comment::*, LocalUserId};
|
newtypes::LocalUserId,
|
||||||
|
source::comment::*,
|
||||||
|
traits::{Likeable, Saveable},
|
||||||
|
};
|
||||||
use lemmy_db_views::{comment_view::CommentView, local_user_view::LocalUserView};
|
use lemmy_db_views::{comment_view::CommentView, local_user_view::LocalUserView};
|
||||||
use lemmy_utils::{ApiError, ConnectionId, LemmyError};
|
use lemmy_utils::{ApiError, ConnectionId, LemmyError};
|
||||||
use lemmy_websocket::{send::send_comment_ws_message, LemmyContext, UserOperation};
|
use lemmy_websocket::{send::send_comment_ws_message, LemmyContext, UserOperation};
|
||||||
|
@ -8,8 +8,7 @@ use lemmy_api_common::{
|
|||||||
is_mod_or_admin,
|
is_mod_or_admin,
|
||||||
};
|
};
|
||||||
use lemmy_apub::{activities::report::Report, fetcher::object_id::ObjectId};
|
use lemmy_apub::{activities::report::Report, fetcher::object_id::ObjectId};
|
||||||
use lemmy_db_queries::Reportable;
|
use lemmy_db_schema::{source::comment_report::*, traits::Reportable};
|
||||||
use lemmy_db_schema::source::comment_report::*;
|
|
||||||
use lemmy_db_views::{
|
use lemmy_db_views::{
|
||||||
comment_report_view::{CommentReportQueryBuilder, CommentReportView},
|
comment_report_view::{CommentReportQueryBuilder, CommentReportView},
|
||||||
comment_view::CommentView,
|
comment_view::CommentView,
|
||||||
|
@ -18,22 +18,32 @@ use lemmy_apub::activities::{
|
|||||||
},
|
},
|
||||||
following::{follow::FollowCommunity as FollowCommunityApub, undo::UndoFollowCommunity},
|
following::{follow::FollowCommunity as FollowCommunityApub, undo::UndoFollowCommunity},
|
||||||
};
|
};
|
||||||
use lemmy_db_queries::{
|
use lemmy_db_schema::{
|
||||||
source::{comment::Comment_, community::CommunityModerator_, post::Post_},
|
source::{
|
||||||
Bannable,
|
comment::Comment,
|
||||||
Blockable,
|
community::{
|
||||||
Crud,
|
Community,
|
||||||
Followable,
|
CommunityFollower,
|
||||||
Joinable,
|
CommunityFollowerForm,
|
||||||
};
|
CommunityModerator,
|
||||||
use lemmy_db_schema::source::{
|
CommunityModeratorForm,
|
||||||
comment::Comment,
|
CommunityPersonBan,
|
||||||
community::*,
|
CommunityPersonBanForm,
|
||||||
community_block::{CommunityBlock, CommunityBlockForm},
|
},
|
||||||
moderator::*,
|
community_block::{CommunityBlock, CommunityBlockForm},
|
||||||
person::Person,
|
moderator::{
|
||||||
post::Post,
|
ModAddCommunity,
|
||||||
site::*,
|
ModAddCommunityForm,
|
||||||
|
ModBanFromCommunity,
|
||||||
|
ModBanFromCommunityForm,
|
||||||
|
ModTransferCommunity,
|
||||||
|
ModTransferCommunityForm,
|
||||||
|
},
|
||||||
|
person::Person,
|
||||||
|
post::Post,
|
||||||
|
site::Site,
|
||||||
|
},
|
||||||
|
traits::{Bannable, Blockable, Crud, Followable, Joinable},
|
||||||
};
|
};
|
||||||
use lemmy_db_views::comment_view::CommentQueryBuilder;
|
use lemmy_db_views::comment_view::CommentQueryBuilder;
|
||||||
use lemmy_db_views_actor::{
|
use lemmy_db_views_actor::{
|
||||||
|
@ -191,15 +191,14 @@ pub(crate) fn captcha_as_wav_base64(captcha: &Captcha) -> String {
|
|||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use lemmy_api_common::check_validator_time;
|
use lemmy_api_common::check_validator_time;
|
||||||
use lemmy_db_queries::{
|
use lemmy_db_schema::{
|
||||||
establish_unpooled_connection,
|
establish_unpooled_connection,
|
||||||
source::{local_user::LocalUser_, secret::Secret_},
|
source::{
|
||||||
Crud,
|
local_user::{LocalUser, LocalUserForm},
|
||||||
};
|
person::{Person, PersonForm},
|
||||||
use lemmy_db_schema::source::{
|
secret::Secret,
|
||||||
local_user::{LocalUser, LocalUserForm},
|
},
|
||||||
person::{Person, PersonForm},
|
traits::Crud,
|
||||||
secret::Secret,
|
|
||||||
};
|
};
|
||||||
use lemmy_utils::{claims::Claims, settings::structs::Settings};
|
use lemmy_utils::{claims::Claims, settings::structs::Settings};
|
||||||
|
|
||||||
|
@ -11,25 +11,10 @@ use lemmy_api_common::{
|
|||||||
password_length_check,
|
password_length_check,
|
||||||
person::*,
|
person::*,
|
||||||
};
|
};
|
||||||
use lemmy_db_queries::{
|
use lemmy_db_schema::{
|
||||||
diesel_option_overwrite,
|
diesel_option_overwrite,
|
||||||
diesel_option_overwrite_to_url,
|
diesel_option_overwrite_to_url,
|
||||||
from_opt_str_to_opt_enum,
|
from_opt_str_to_opt_enum,
|
||||||
source::{
|
|
||||||
comment::Comment_,
|
|
||||||
community::Community_,
|
|
||||||
local_user::LocalUser_,
|
|
||||||
password_reset_request::PasswordResetRequest_,
|
|
||||||
person::Person_,
|
|
||||||
person_mention::PersonMention_,
|
|
||||||
post::Post_,
|
|
||||||
private_message::PrivateMessage_,
|
|
||||||
},
|
|
||||||
Blockable,
|
|
||||||
Crud,
|
|
||||||
SortType,
|
|
||||||
};
|
|
||||||
use lemmy_db_schema::{
|
|
||||||
naive_now,
|
naive_now,
|
||||||
source::{
|
source::{
|
||||||
comment::Comment,
|
comment::Comment,
|
||||||
@ -44,6 +29,8 @@ use lemmy_db_schema::{
|
|||||||
private_message::PrivateMessage,
|
private_message::PrivateMessage,
|
||||||
site::*,
|
site::*,
|
||||||
},
|
},
|
||||||
|
traits::{Blockable, Crud},
|
||||||
|
SortType,
|
||||||
};
|
};
|
||||||
use lemmy_db_views::{
|
use lemmy_db_views::{
|
||||||
comment_report_view::CommentReportView,
|
comment_report_view::CommentReportView,
|
||||||
|
@ -22,8 +22,10 @@ use lemmy_apub::{
|
|||||||
},
|
},
|
||||||
fetcher::post_or_comment::PostOrComment,
|
fetcher::post_or_comment::PostOrComment,
|
||||||
};
|
};
|
||||||
use lemmy_db_queries::{source::post::Post_, Crud, Likeable, Saveable};
|
use lemmy_db_schema::{
|
||||||
use lemmy_db_schema::source::{moderator::*, post::*};
|
source::{moderator::*, post::*},
|
||||||
|
traits::{Crud, Likeable, Saveable},
|
||||||
|
};
|
||||||
use lemmy_db_views::post_view::PostView;
|
use lemmy_db_views::post_view::PostView;
|
||||||
use lemmy_utils::{request::fetch_site_metadata, ApiError, ConnectionId, LemmyError};
|
use lemmy_utils::{request::fetch_site_metadata, ApiError, ConnectionId, LemmyError};
|
||||||
use lemmy_websocket::{send::send_post_ws_message, LemmyContext, UserOperation};
|
use lemmy_websocket::{send::send_post_ws_message, LemmyContext, UserOperation};
|
||||||
|
@ -14,8 +14,10 @@ use lemmy_api_common::{
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
use lemmy_apub::{activities::report::Report, fetcher::object_id::ObjectId};
|
use lemmy_apub::{activities::report::Report, fetcher::object_id::ObjectId};
|
||||||
use lemmy_db_queries::Reportable;
|
use lemmy_db_schema::{
|
||||||
use lemmy_db_schema::source::post_report::{PostReport, PostReportForm};
|
source::post_report::{PostReport, PostReportForm},
|
||||||
|
traits::Reportable,
|
||||||
|
};
|
||||||
use lemmy_db_views::{
|
use lemmy_db_views::{
|
||||||
post_report_view::{PostReportQueryBuilder, PostReportView},
|
post_report_view::{PostReportQueryBuilder, PostReportView},
|
||||||
post_view::PostView,
|
post_view::PostView,
|
||||||
|
@ -5,8 +5,7 @@ use lemmy_api_common::{
|
|||||||
get_local_user_view_from_jwt,
|
get_local_user_view_from_jwt,
|
||||||
person::{MarkPrivateMessageAsRead, PrivateMessageResponse},
|
person::{MarkPrivateMessageAsRead, PrivateMessageResponse},
|
||||||
};
|
};
|
||||||
use lemmy_db_queries::{source::private_message::PrivateMessage_, Crud};
|
use lemmy_db_schema::{source::private_message::PrivateMessage, traits::Crud};
|
||||||
use lemmy_db_schema::source::private_message::PrivateMessage;
|
|
||||||
use lemmy_utils::{ApiError, ConnectionId, LemmyError};
|
use lemmy_utils::{ApiError, ConnectionId, LemmyError};
|
||||||
use lemmy_websocket::{send::send_pm_ws_message, LemmyContext, UserOperation};
|
use lemmy_websocket::{send::send_pm_ws_message, LemmyContext, UserOperation};
|
||||||
|
|
||||||
|
@ -15,20 +15,16 @@ use lemmy_apub::{
|
|||||||
fetcher::search::{search_by_apub_id, SearchableObjects},
|
fetcher::search::{search_by_apub_id, SearchableObjects},
|
||||||
EndpointType,
|
EndpointType,
|
||||||
};
|
};
|
||||||
use lemmy_db_queries::{
|
use lemmy_db_schema::{
|
||||||
from_opt_str_to_opt_enum,
|
from_opt_str_to_opt_enum,
|
||||||
source::site::Site_,
|
newtypes::PersonId,
|
||||||
Crud,
|
source::{moderator::*, site::Site},
|
||||||
|
traits::{Crud, DeleteableOrRemoveable},
|
||||||
DbPool,
|
DbPool,
|
||||||
DeleteableOrRemoveable,
|
|
||||||
ListingType,
|
ListingType,
|
||||||
SearchType,
|
SearchType,
|
||||||
SortType,
|
SortType,
|
||||||
};
|
};
|
||||||
use lemmy_db_schema::{
|
|
||||||
source::{moderator::*, site::Site},
|
|
||||||
PersonId,
|
|
||||||
};
|
|
||||||
use lemmy_db_views::{
|
use lemmy_db_views::{
|
||||||
comment_view::{CommentQueryBuilder, CommentView},
|
comment_view::{CommentQueryBuilder, CommentView},
|
||||||
post_view::{PostQueryBuilder, PostView},
|
post_view::{PostQueryBuilder, PostView},
|
||||||
@ -450,7 +446,7 @@ impl Perform for TransferSite {
|
|||||||
|
|
||||||
is_admin(&local_user_view)?;
|
is_admin(&local_user_view)?;
|
||||||
|
|
||||||
let read_site = blocking(context.pool(), move |conn| Site::read_simple(conn)).await??;
|
let read_site = blocking(context.pool(), Site::read_simple).await??;
|
||||||
|
|
||||||
// Make sure user is the creator
|
// Make sure user is the creator
|
||||||
if read_site.creator_id != local_user_view.person.id {
|
if read_site.creator_id != local_user_view.person.id {
|
||||||
|
@ -13,7 +13,6 @@ path = "src/lib.rs"
|
|||||||
doctest = false
|
doctest = false
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
lemmy_db_queries = { version = "=0.13.0", path = "../db_queries" }
|
|
||||||
lemmy_db_views = { version = "=0.13.0", path = "../db_views" }
|
lemmy_db_views = { version = "=0.13.0", path = "../db_views" }
|
||||||
lemmy_db_views_moderator = { version = "=0.13.0", path = "../db_views_moderator" }
|
lemmy_db_views_moderator = { version = "=0.13.0", path = "../db_views_moderator" }
|
||||||
lemmy_db_views_actor = { version = "=0.13.0", path = "../db_views_actor" }
|
lemmy_db_views_actor = { version = "=0.13.0", path = "../db_views_actor" }
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
use lemmy_db_schema::{CommentId, CommentReportId, CommunityId, LocalUserId, PostId};
|
use lemmy_db_schema::newtypes::{CommentId, CommentReportId, CommunityId, LocalUserId, PostId};
|
||||||
use lemmy_db_views::{comment_report_view::CommentReportView, comment_view::CommentView};
|
use lemmy_db_views::{comment_report_view::CommentReportView, comment_view::CommentView};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
use lemmy_db_schema::{CommunityId, PersonId};
|
use lemmy_db_schema::newtypes::{CommunityId, PersonId};
|
||||||
use lemmy_db_views_actor::{
|
use lemmy_db_views_actor::{
|
||||||
community_moderator_view::CommunityModeratorView,
|
community_moderator_view::CommunityModeratorView,
|
||||||
community_view::CommunityView,
|
community_view::CommunityView,
|
||||||
|
@ -7,13 +7,8 @@ pub mod websocket;
|
|||||||
|
|
||||||
use crate::site::FederatedInstances;
|
use crate::site::FederatedInstances;
|
||||||
use diesel::PgConnection;
|
use diesel::PgConnection;
|
||||||
use lemmy_db_queries::{
|
|
||||||
source::{community::Community_, person_block::PersonBlock_, site::Site_},
|
|
||||||
Crud,
|
|
||||||
DbPool,
|
|
||||||
Readable,
|
|
||||||
};
|
|
||||||
use lemmy_db_schema::{
|
use lemmy_db_schema::{
|
||||||
|
newtypes::{CommunityId, LocalUserId, PersonId, PostId},
|
||||||
source::{
|
source::{
|
||||||
comment::Comment,
|
comment::Comment,
|
||||||
community::Community,
|
community::Community,
|
||||||
@ -24,10 +19,8 @@ use lemmy_db_schema::{
|
|||||||
secret::Secret,
|
secret::Secret,
|
||||||
site::Site,
|
site::Site,
|
||||||
},
|
},
|
||||||
CommunityId,
|
traits::{Crud, Readable},
|
||||||
LocalUserId,
|
DbPool,
|
||||||
PersonId,
|
|
||||||
PostId,
|
|
||||||
};
|
};
|
||||||
use lemmy_db_views::local_user_view::{LocalUserSettingsView, LocalUserView};
|
use lemmy_db_views::local_user_view::{LocalUserSettingsView, LocalUserView};
|
||||||
use lemmy_db_views_actor::{
|
use lemmy_db_views_actor::{
|
||||||
@ -394,7 +387,7 @@ pub async fn check_person_block(
|
|||||||
|
|
||||||
pub async fn check_downvotes_enabled(score: i16, pool: &DbPool) -> Result<(), LemmyError> {
|
pub async fn check_downvotes_enabled(score: i16, pool: &DbPool) -> Result<(), LemmyError> {
|
||||||
if score == -1 {
|
if score == -1 {
|
||||||
let site = blocking(pool, move |conn| Site::read_simple(conn)).await??;
|
let site = blocking(pool, Site::read_simple).await??;
|
||||||
if !site.enable_downvotes {
|
if !site.enable_downvotes {
|
||||||
return Err(ApiError::err_plain("downvotes_disabled").into());
|
return Err(ApiError::err_plain("downvotes_disabled").into());
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,7 @@ pub struct Login {
|
|||||||
pub username_or_email: String,
|
pub username_or_email: String,
|
||||||
pub password: String,
|
pub password: String,
|
||||||
}
|
}
|
||||||
use lemmy_db_schema::{CommunityId, PersonId, PersonMentionId, PrivateMessageId};
|
use lemmy_db_schema::newtypes::{CommunityId, PersonId, PersonMentionId, PrivateMessageId};
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize)]
|
#[derive(Serialize, Deserialize)]
|
||||||
pub struct Register {
|
pub struct Register {
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
use lemmy_db_schema::{CommunityId, PostId, PostReportId};
|
use lemmy_db_schema::newtypes::{CommunityId, PostId, PostReportId};
|
||||||
use lemmy_db_views::{
|
use lemmy_db_views::{
|
||||||
comment_view::CommentView,
|
comment_view::CommentView,
|
||||||
post_report_view::PostReportView,
|
post_report_view::PostReportView,
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
use lemmy_db_schema::{CommunityId, PersonId};
|
use lemmy_db_schema::newtypes::{CommunityId, PersonId};
|
||||||
use lemmy_db_views::{
|
use lemmy_db_views::{
|
||||||
comment_view::CommentView,
|
comment_view::CommentView,
|
||||||
local_user_view::LocalUserSettingsView,
|
local_user_view::LocalUserSettingsView,
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
use lemmy_db_schema::{CommunityId, PostId};
|
use lemmy_db_schema::newtypes::{CommunityId, PostId};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize, Debug)]
|
#[derive(Serialize, Deserialize, Debug)]
|
||||||
|
@ -11,7 +11,6 @@ documentation = "https://join-lemmy.org/docs/en/index.html"
|
|||||||
lemmy_apub = { version = "=0.13.0", path = "../apub" }
|
lemmy_apub = { version = "=0.13.0", path = "../apub" }
|
||||||
lemmy_apub_lib = { version = "=0.13.0", path = "../apub_lib" }
|
lemmy_apub_lib = { version = "=0.13.0", path = "../apub_lib" }
|
||||||
lemmy_utils = { version = "=0.13.0", path = "../utils" }
|
lemmy_utils = { version = "=0.13.0", path = "../utils" }
|
||||||
lemmy_db_queries = { version = "=0.13.0", path = "../db_queries" }
|
|
||||||
lemmy_db_schema = { version = "=0.13.0", path = "../db_schema" }
|
lemmy_db_schema = { version = "=0.13.0", path = "../db_schema" }
|
||||||
lemmy_db_views = { version = "=0.13.0", path = "../db_views" }
|
lemmy_db_views = { version = "=0.13.0", path = "../db_views" }
|
||||||
lemmy_db_views_moderator = { version = "=0.13.0", path = "../db_views_moderator" }
|
lemmy_db_views_moderator = { version = "=0.13.0", path = "../db_views_moderator" }
|
||||||
|
@ -21,12 +21,13 @@ use lemmy_apub::{
|
|||||||
generate_apub_endpoint,
|
generate_apub_endpoint,
|
||||||
EndpointType,
|
EndpointType,
|
||||||
};
|
};
|
||||||
use lemmy_db_queries::{
|
use lemmy_db_schema::{
|
||||||
source::{comment::Comment_, person_mention::PersonMention_},
|
source::{
|
||||||
Crud,
|
comment::{Comment, CommentForm, CommentLike, CommentLikeForm},
|
||||||
Likeable,
|
person_mention::PersonMention,
|
||||||
|
},
|
||||||
|
traits::{Crud, Likeable},
|
||||||
};
|
};
|
||||||
use lemmy_db_schema::source::{comment::*, person_mention::PersonMention};
|
|
||||||
use lemmy_db_views::comment_view::CommentView;
|
use lemmy_db_views::comment_view::CommentView;
|
||||||
use lemmy_utils::{
|
use lemmy_utils::{
|
||||||
utils::{remove_slurs, scrape_text_for_mentions},
|
utils::{remove_slurs, scrape_text_for_mentions},
|
||||||
|
@ -9,8 +9,15 @@ use lemmy_api_common::{
|
|||||||
send_local_notifs,
|
send_local_notifs,
|
||||||
};
|
};
|
||||||
use lemmy_apub::activities::deletion::{send_apub_delete, send_apub_remove};
|
use lemmy_apub::activities::deletion::{send_apub_delete, send_apub_remove};
|
||||||
use lemmy_db_queries::{source::comment::Comment_, Crud};
|
use lemmy_db_schema::{
|
||||||
use lemmy_db_schema::source::{comment::*, community::Community, moderator::*, post::Post};
|
source::{
|
||||||
|
comment::Comment,
|
||||||
|
community::Community,
|
||||||
|
moderator::{ModRemoveComment, ModRemoveCommentForm},
|
||||||
|
post::Post,
|
||||||
|
},
|
||||||
|
traits::Crud,
|
||||||
|
};
|
||||||
use lemmy_db_views::comment_view::CommentView;
|
use lemmy_db_views::comment_view::CommentView;
|
||||||
use lemmy_utils::{ApiError, ConnectionId, LemmyError};
|
use lemmy_utils::{ApiError, ConnectionId, LemmyError};
|
||||||
use lemmy_websocket::{send::send_comment_ws_message, LemmyContext, UserOperationCrud};
|
use lemmy_websocket::{send::send_comment_ws_message, LemmyContext, UserOperationCrud};
|
||||||
|
@ -2,7 +2,12 @@ use crate::PerformCrud;
|
|||||||
use actix_web::web::Data;
|
use actix_web::web::Data;
|
||||||
use lemmy_api_common::{blocking, comment::*, get_local_user_view_from_jwt_opt};
|
use lemmy_api_common::{blocking, comment::*, get_local_user_view_from_jwt_opt};
|
||||||
use lemmy_apub::{build_actor_id_from_shortname, EndpointType};
|
use lemmy_apub::{build_actor_id_from_shortname, EndpointType};
|
||||||
use lemmy_db_queries::{from_opt_str_to_opt_enum, DeleteableOrRemoveable, ListingType, SortType};
|
use lemmy_db_schema::{
|
||||||
|
from_opt_str_to_opt_enum,
|
||||||
|
traits::DeleteableOrRemoveable,
|
||||||
|
ListingType,
|
||||||
|
SortType,
|
||||||
|
};
|
||||||
use lemmy_db_views::comment_view::CommentQueryBuilder;
|
use lemmy_db_views::comment_view::CommentQueryBuilder;
|
||||||
use lemmy_utils::{ApiError, ConnectionId, LemmyError};
|
use lemmy_utils::{ApiError, ConnectionId, LemmyError};
|
||||||
use lemmy_websocket::LemmyContext;
|
use lemmy_websocket::LemmyContext;
|
||||||
|
@ -13,8 +13,7 @@ use lemmy_apub::activities::{
|
|||||||
comment::create_or_update::CreateOrUpdateComment,
|
comment::create_or_update::CreateOrUpdateComment,
|
||||||
CreateOrUpdateType,
|
CreateOrUpdateType,
|
||||||
};
|
};
|
||||||
use lemmy_db_queries::source::comment::Comment_;
|
use lemmy_db_schema::source::comment::Comment;
|
||||||
use lemmy_db_schema::source::comment::*;
|
|
||||||
use lemmy_db_views::comment_view::CommentView;
|
use lemmy_db_views::comment_view::CommentView;
|
||||||
use lemmy_utils::{
|
use lemmy_utils::{
|
||||||
utils::{remove_slurs, scrape_text_for_mentions},
|
utils::{remove_slurs, scrape_text_for_mentions},
|
||||||
|
@ -14,17 +14,20 @@ use lemmy_apub::{
|
|||||||
generate_shared_inbox_url,
|
generate_shared_inbox_url,
|
||||||
EndpointType,
|
EndpointType,
|
||||||
};
|
};
|
||||||
use lemmy_db_queries::{diesel_option_overwrite_to_url, Crud, Followable, Joinable};
|
use lemmy_db_schema::{
|
||||||
use lemmy_db_schema::source::{
|
diesel_option_overwrite_to_url,
|
||||||
community::{
|
source::{
|
||||||
Community,
|
community::{
|
||||||
CommunityFollower,
|
Community,
|
||||||
CommunityFollowerForm,
|
CommunityFollower,
|
||||||
CommunityForm,
|
CommunityFollowerForm,
|
||||||
CommunityModerator,
|
CommunityForm,
|
||||||
CommunityModeratorForm,
|
CommunityModerator,
|
||||||
|
CommunityModeratorForm,
|
||||||
|
},
|
||||||
|
site::Site,
|
||||||
},
|
},
|
||||||
site::Site,
|
traits::{Crud, Followable, Joinable},
|
||||||
};
|
};
|
||||||
use lemmy_db_views_actor::community_view::CommunityView;
|
use lemmy_db_views_actor::community_view::CommunityView;
|
||||||
use lemmy_utils::{
|
use lemmy_utils::{
|
||||||
|
@ -2,10 +2,12 @@ use crate::PerformCrud;
|
|||||||
use actix_web::web::Data;
|
use actix_web::web::Data;
|
||||||
use lemmy_api_common::{blocking, community::*, get_local_user_view_from_jwt, is_admin};
|
use lemmy_api_common::{blocking, community::*, get_local_user_view_from_jwt, is_admin};
|
||||||
use lemmy_apub::activities::deletion::{send_apub_delete, send_apub_remove};
|
use lemmy_apub::activities::deletion::{send_apub_delete, send_apub_remove};
|
||||||
use lemmy_db_queries::{source::community::Community_, Crud};
|
use lemmy_db_schema::{
|
||||||
use lemmy_db_schema::source::{
|
source::{
|
||||||
community::*,
|
community::Community,
|
||||||
moderator::{ModRemoveCommunity, ModRemoveCommunityForm},
|
moderator::{ModRemoveCommunity, ModRemoveCommunityForm},
|
||||||
|
},
|
||||||
|
traits::Crud,
|
||||||
};
|
};
|
||||||
use lemmy_db_views_actor::community_moderator_view::CommunityModeratorView;
|
use lemmy_db_views_actor::community_moderator_view::CommunityModeratorView;
|
||||||
use lemmy_utils::{utils::naive_from_unix, ApiError, ConnectionId, LemmyError};
|
use lemmy_utils::{utils::naive_from_unix, ApiError, ConnectionId, LemmyError};
|
||||||
|
@ -2,8 +2,13 @@ use crate::PerformCrud;
|
|||||||
use actix_web::web::Data;
|
use actix_web::web::Data;
|
||||||
use lemmy_api_common::{blocking, community::*, get_local_user_view_from_jwt_opt};
|
use lemmy_api_common::{blocking, community::*, get_local_user_view_from_jwt_opt};
|
||||||
use lemmy_apub::{build_actor_id_from_shortname, fetcher::object_id::ObjectId, EndpointType};
|
use lemmy_apub::{build_actor_id_from_shortname, fetcher::object_id::ObjectId, EndpointType};
|
||||||
use lemmy_db_queries::{from_opt_str_to_opt_enum, DeleteableOrRemoveable, ListingType, SortType};
|
use lemmy_db_schema::{
|
||||||
use lemmy_db_schema::source::community::*;
|
from_opt_str_to_opt_enum,
|
||||||
|
source::community::Community,
|
||||||
|
traits::DeleteableOrRemoveable,
|
||||||
|
ListingType,
|
||||||
|
SortType,
|
||||||
|
};
|
||||||
use lemmy_db_views_actor::{
|
use lemmy_db_views_actor::{
|
||||||
community_moderator_view::CommunityModeratorView,
|
community_moderator_view::CommunityModeratorView,
|
||||||
community_view::{CommunityQueryBuilder, CommunityView},
|
community_view::{CommunityQueryBuilder, CommunityView},
|
||||||
|
@ -6,11 +6,12 @@ use lemmy_api_common::{
|
|||||||
get_local_user_view_from_jwt,
|
get_local_user_view_from_jwt,
|
||||||
};
|
};
|
||||||
use lemmy_apub::activities::community::update::UpdateCommunity;
|
use lemmy_apub::activities::community::update::UpdateCommunity;
|
||||||
use lemmy_db_queries::{diesel_option_overwrite_to_url, Crud};
|
|
||||||
use lemmy_db_schema::{
|
use lemmy_db_schema::{
|
||||||
|
diesel_option_overwrite_to_url,
|
||||||
naive_now,
|
naive_now,
|
||||||
|
newtypes::PersonId,
|
||||||
source::community::{Community, CommunityForm},
|
source::community::{Community, CommunityForm},
|
||||||
PersonId,
|
traits::Crud,
|
||||||
};
|
};
|
||||||
use lemmy_db_views_actor::community_moderator_view::CommunityModeratorView;
|
use lemmy_db_views_actor::community_moderator_view::CommunityModeratorView;
|
||||||
use lemmy_utils::{utils::check_slurs_opt, ApiError, ConnectionId, LemmyError};
|
use lemmy_utils::{utils::check_slurs_opt, ApiError, ConnectionId, LemmyError};
|
||||||
|
@ -19,8 +19,10 @@ use lemmy_apub::{
|
|||||||
generate_apub_endpoint,
|
generate_apub_endpoint,
|
||||||
EndpointType,
|
EndpointType,
|
||||||
};
|
};
|
||||||
use lemmy_db_queries::{source::post::Post_, Crud, Likeable};
|
use lemmy_db_schema::{
|
||||||
use lemmy_db_schema::source::post::*;
|
source::post::{Post, PostForm, PostLike, PostLikeForm},
|
||||||
|
traits::{Crud, Likeable},
|
||||||
|
};
|
||||||
use lemmy_utils::{
|
use lemmy_utils::{
|
||||||
request::fetch_site_data,
|
request::fetch_site_data,
|
||||||
utils::{check_slurs, check_slurs_opt, clean_url_params, is_valid_post_title},
|
utils::{check_slurs, check_slurs_opt, clean_url_params, is_valid_post_title},
|
||||||
|
@ -9,8 +9,14 @@ use lemmy_api_common::{
|
|||||||
post::*,
|
post::*,
|
||||||
};
|
};
|
||||||
use lemmy_apub::activities::deletion::{send_apub_delete, send_apub_remove};
|
use lemmy_apub::activities::deletion::{send_apub_delete, send_apub_remove};
|
||||||
use lemmy_db_queries::{source::post::Post_, Crud};
|
use lemmy_db_schema::{
|
||||||
use lemmy_db_schema::source::{community::Community, moderator::*, post::*};
|
source::{
|
||||||
|
community::Community,
|
||||||
|
moderator::{ModRemovePost, ModRemovePostForm},
|
||||||
|
post::Post,
|
||||||
|
},
|
||||||
|
traits::Crud,
|
||||||
|
};
|
||||||
use lemmy_utils::{ApiError, ConnectionId, LemmyError};
|
use lemmy_utils::{ApiError, ConnectionId, LemmyError};
|
||||||
use lemmy_websocket::{send::send_post_ws_message, LemmyContext, UserOperationCrud};
|
use lemmy_websocket::{send::send_post_ws_message, LemmyContext, UserOperationCrud};
|
||||||
|
|
||||||
|
@ -2,7 +2,12 @@ use crate::PerformCrud;
|
|||||||
use actix_web::web::Data;
|
use actix_web::web::Data;
|
||||||
use lemmy_api_common::{blocking, get_local_user_view_from_jwt_opt, mark_post_as_read, post::*};
|
use lemmy_api_common::{blocking, get_local_user_view_from_jwt_opt, mark_post_as_read, post::*};
|
||||||
use lemmy_apub::{build_actor_id_from_shortname, EndpointType};
|
use lemmy_apub::{build_actor_id_from_shortname, EndpointType};
|
||||||
use lemmy_db_queries::{from_opt_str_to_opt_enum, DeleteableOrRemoveable, ListingType, SortType};
|
use lemmy_db_schema::{
|
||||||
|
from_opt_str_to_opt_enum,
|
||||||
|
traits::DeleteableOrRemoveable,
|
||||||
|
ListingType,
|
||||||
|
SortType,
|
||||||
|
};
|
||||||
use lemmy_db_views::{
|
use lemmy_db_views::{
|
||||||
comment_view::CommentQueryBuilder,
|
comment_view::CommentQueryBuilder,
|
||||||
post_view::{PostQueryBuilder, PostView},
|
post_view::{PostQueryBuilder, PostView},
|
||||||
|
@ -8,8 +8,11 @@ use lemmy_api_common::{
|
|||||||
post::*,
|
post::*,
|
||||||
};
|
};
|
||||||
use lemmy_apub::activities::{post::create_or_update::CreateOrUpdatePost, CreateOrUpdateType};
|
use lemmy_apub::activities::{post::create_or_update::CreateOrUpdatePost, CreateOrUpdateType};
|
||||||
use lemmy_db_queries::{source::post::Post_, Crud};
|
use lemmy_db_schema::{
|
||||||
use lemmy_db_schema::{naive_now, source::post::*};
|
naive_now,
|
||||||
|
source::post::{Post, PostForm},
|
||||||
|
traits::Crud,
|
||||||
|
};
|
||||||
use lemmy_utils::{
|
use lemmy_utils::{
|
||||||
request::fetch_site_data,
|
request::fetch_site_data,
|
||||||
utils::{check_slurs_opt, clean_url_params, is_valid_post_title},
|
utils::{check_slurs_opt, clean_url_params, is_valid_post_title},
|
||||||
|
@ -15,8 +15,10 @@ use lemmy_apub::{
|
|||||||
generate_apub_endpoint,
|
generate_apub_endpoint,
|
||||||
EndpointType,
|
EndpointType,
|
||||||
};
|
};
|
||||||
use lemmy_db_queries::{source::private_message::PrivateMessage_, Crud};
|
use lemmy_db_schema::{
|
||||||
use lemmy_db_schema::source::private_message::{PrivateMessage, PrivateMessageForm};
|
source::private_message::{PrivateMessage, PrivateMessageForm},
|
||||||
|
traits::Crud,
|
||||||
|
};
|
||||||
use lemmy_db_views::local_user_view::LocalUserView;
|
use lemmy_db_views::local_user_view::LocalUserView;
|
||||||
use lemmy_utils::{utils::remove_slurs, ApiError, ConnectionId, LemmyError};
|
use lemmy_utils::{utils::remove_slurs, ApiError, ConnectionId, LemmyError};
|
||||||
use lemmy_websocket::{send::send_pm_ws_message, LemmyContext, UserOperationCrud};
|
use lemmy_websocket::{send::send_pm_ws_message, LemmyContext, UserOperationCrud};
|
||||||
|
@ -9,8 +9,10 @@ use lemmy_apub::activities::private_message::{
|
|||||||
delete::DeletePrivateMessage as DeletePrivateMessageApub,
|
delete::DeletePrivateMessage as DeletePrivateMessageApub,
|
||||||
undo_delete::UndoDeletePrivateMessage,
|
undo_delete::UndoDeletePrivateMessage,
|
||||||
};
|
};
|
||||||
use lemmy_db_queries::{source::private_message::PrivateMessage_, Crud, DeleteableOrRemoveable};
|
use lemmy_db_schema::{
|
||||||
use lemmy_db_schema::source::private_message::PrivateMessage;
|
source::private_message::PrivateMessage,
|
||||||
|
traits::{Crud, DeleteableOrRemoveable},
|
||||||
|
};
|
||||||
use lemmy_utils::{ApiError, ConnectionId, LemmyError};
|
use lemmy_utils::{ApiError, ConnectionId, LemmyError};
|
||||||
use lemmy_websocket::{send::send_pm_ws_message, LemmyContext, UserOperationCrud};
|
use lemmy_websocket::{send::send_pm_ws_message, LemmyContext, UserOperationCrud};
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@ use lemmy_api_common::{
|
|||||||
get_local_user_view_from_jwt,
|
get_local_user_view_from_jwt,
|
||||||
person::{GetPrivateMessages, PrivateMessagesResponse},
|
person::{GetPrivateMessages, PrivateMessagesResponse},
|
||||||
};
|
};
|
||||||
use lemmy_db_queries::DeleteableOrRemoveable;
|
use lemmy_db_schema::traits::DeleteableOrRemoveable;
|
||||||
use lemmy_db_views::private_message_view::PrivateMessageQueryBuilder;
|
use lemmy_db_views::private_message_view::PrivateMessageQueryBuilder;
|
||||||
use lemmy_utils::{ConnectionId, LemmyError};
|
use lemmy_utils::{ConnectionId, LemmyError};
|
||||||
use lemmy_websocket::LemmyContext;
|
use lemmy_websocket::LemmyContext;
|
||||||
|
@ -9,8 +9,7 @@ use lemmy_apub::activities::{
|
|||||||
private_message::create_or_update::CreateOrUpdatePrivateMessage,
|
private_message::create_or_update::CreateOrUpdatePrivateMessage,
|
||||||
CreateOrUpdateType,
|
CreateOrUpdateType,
|
||||||
};
|
};
|
||||||
use lemmy_db_queries::{source::private_message::PrivateMessage_, Crud};
|
use lemmy_db_schema::{source::private_message::PrivateMessage, traits::Crud};
|
||||||
use lemmy_db_schema::source::private_message::PrivateMessage;
|
|
||||||
use lemmy_utils::{utils::remove_slurs, ApiError, ConnectionId, LemmyError};
|
use lemmy_utils::{utils::remove_slurs, ApiError, ConnectionId, LemmyError};
|
||||||
use lemmy_websocket::{send::send_pm_ws_message, LemmyContext, UserOperationCrud};
|
use lemmy_websocket::{send::send_pm_ws_message, LemmyContext, UserOperationCrud};
|
||||||
|
|
||||||
|
@ -7,13 +7,12 @@ use lemmy_api_common::{
|
|||||||
site::*,
|
site::*,
|
||||||
site_description_length_check,
|
site_description_length_check,
|
||||||
};
|
};
|
||||||
use lemmy_db_queries::{
|
use lemmy_db_schema::{
|
||||||
diesel_option_overwrite,
|
diesel_option_overwrite,
|
||||||
diesel_option_overwrite_to_url,
|
diesel_option_overwrite_to_url,
|
||||||
source::site::Site_,
|
source::site::{Site, SiteForm},
|
||||||
Crud,
|
traits::Crud,
|
||||||
};
|
};
|
||||||
use lemmy_db_schema::source::site::{Site, *};
|
|
||||||
use lemmy_db_views::site_view::SiteView;
|
use lemmy_db_views::site_view::SiteView;
|
||||||
use lemmy_utils::{
|
use lemmy_utils::{
|
||||||
utils::{check_slurs, check_slurs_opt},
|
utils::{check_slurs, check_slurs_opt},
|
||||||
@ -34,7 +33,7 @@ impl PerformCrud for CreateSite {
|
|||||||
) -> Result<SiteResponse, LemmyError> {
|
) -> Result<SiteResponse, LemmyError> {
|
||||||
let data: &CreateSite = self;
|
let data: &CreateSite = self;
|
||||||
|
|
||||||
let read_site = move |conn: &'_ _| Site::read_simple(conn);
|
let read_site = Site::read_simple;
|
||||||
if blocking(context.pool(), read_site).await?.is_ok() {
|
if blocking(context.pool(), read_site).await?.is_ok() {
|
||||||
return Err(ApiError::err_plain("site_already_exists").into());
|
return Err(ApiError::err_plain("site_already_exists").into());
|
||||||
};
|
};
|
||||||
|
@ -7,15 +7,12 @@ use lemmy_api_common::{
|
|||||||
site::{EditSite, SiteResponse},
|
site::{EditSite, SiteResponse},
|
||||||
site_description_length_check,
|
site_description_length_check,
|
||||||
};
|
};
|
||||||
use lemmy_db_queries::{
|
use lemmy_db_schema::{
|
||||||
diesel_option_overwrite,
|
diesel_option_overwrite,
|
||||||
diesel_option_overwrite_to_url,
|
diesel_option_overwrite_to_url,
|
||||||
source::site::Site_,
|
|
||||||
Crud,
|
|
||||||
};
|
|
||||||
use lemmy_db_schema::{
|
|
||||||
naive_now,
|
naive_now,
|
||||||
source::site::{Site, SiteForm},
|
source::site::{Site, SiteForm},
|
||||||
|
traits::Crud,
|
||||||
};
|
};
|
||||||
use lemmy_db_views::site_view::SiteView;
|
use lemmy_db_views::site_view::SiteView;
|
||||||
use lemmy_utils::{utils::check_slurs_opt, ApiError, ConnectionId, LemmyError};
|
use lemmy_utils::{utils::check_slurs_opt, ApiError, ConnectionId, LemmyError};
|
||||||
@ -39,7 +36,7 @@ impl PerformCrud for EditSite {
|
|||||||
// Make sure user is an admin
|
// Make sure user is an admin
|
||||||
is_admin(&local_user_view)?;
|
is_admin(&local_user_view)?;
|
||||||
|
|
||||||
let found_site = blocking(context.pool(), move |conn| Site::read_simple(conn)).await??;
|
let found_site = blocking(context.pool(), Site::read_simple).await??;
|
||||||
|
|
||||||
let sidebar = diesel_option_overwrite(&data.sidebar);
|
let sidebar = diesel_option_overwrite(&data.sidebar);
|
||||||
let description = diesel_option_overwrite(&data.description);
|
let description = diesel_option_overwrite(&data.description);
|
||||||
|
@ -8,23 +8,25 @@ use lemmy_apub::{
|
|||||||
generate_shared_inbox_url,
|
generate_shared_inbox_url,
|
||||||
EndpointType,
|
EndpointType,
|
||||||
};
|
};
|
||||||
use lemmy_db_queries::{
|
use lemmy_db_schema::{
|
||||||
source::{local_user::LocalUser_, site::Site_},
|
newtypes::CommunityId,
|
||||||
Crud,
|
source::{
|
||||||
Followable,
|
community::{
|
||||||
Joinable,
|
Community,
|
||||||
|
CommunityFollower,
|
||||||
|
CommunityFollowerForm,
|
||||||
|
CommunityForm,
|
||||||
|
CommunityModerator,
|
||||||
|
CommunityModeratorForm,
|
||||||
|
},
|
||||||
|
local_user::{LocalUser, LocalUserForm},
|
||||||
|
person::{Person, PersonForm},
|
||||||
|
site::Site,
|
||||||
|
},
|
||||||
|
traits::{Crud, Followable, Joinable},
|
||||||
ListingType,
|
ListingType,
|
||||||
SortType,
|
SortType,
|
||||||
};
|
};
|
||||||
use lemmy_db_schema::{
|
|
||||||
source::{
|
|
||||||
community::*,
|
|
||||||
local_user::{LocalUser, LocalUserForm},
|
|
||||||
person::*,
|
|
||||||
site::*,
|
|
||||||
},
|
|
||||||
CommunityId,
|
|
||||||
};
|
|
||||||
use lemmy_db_views_actor::person_view::PersonViewSafe;
|
use lemmy_db_views_actor::person_view::PersonViewSafe;
|
||||||
use lemmy_utils::{
|
use lemmy_utils::{
|
||||||
apub::generate_actor_keypair,
|
apub::generate_actor_keypair,
|
||||||
@ -48,7 +50,7 @@ impl PerformCrud for Register {
|
|||||||
let data: &Register = self;
|
let data: &Register = self;
|
||||||
|
|
||||||
// Make sure site has open registration
|
// Make sure site has open registration
|
||||||
if let Ok(site) = blocking(context.pool(), move |conn| Site::read_simple(conn)).await? {
|
if let Ok(site) = blocking(context.pool(), Site::read_simple).await? {
|
||||||
if !site.open_registration {
|
if !site.open_registration {
|
||||||
return Err(ApiError::err_plain("registration_closed").into());
|
return Err(ApiError::err_plain("registration_closed").into());
|
||||||
}
|
}
|
||||||
|
@ -2,8 +2,7 @@ use crate::PerformCrud;
|
|||||||
use actix_web::web::Data;
|
use actix_web::web::Data;
|
||||||
use bcrypt::verify;
|
use bcrypt::verify;
|
||||||
use lemmy_api_common::{blocking, get_local_user_view_from_jwt, person::*};
|
use lemmy_api_common::{blocking, get_local_user_view_from_jwt, person::*};
|
||||||
use lemmy_db_queries::source::{comment::Comment_, person::Person_, post::Post_};
|
use lemmy_db_schema::source::{comment::Comment, person::Person, post::Post};
|
||||||
use lemmy_db_schema::source::{comment::Comment, person::*, post::Post};
|
|
||||||
use lemmy_utils::{ApiError, ConnectionId, LemmyError};
|
use lemmy_utils::{ApiError, ConnectionId, LemmyError};
|
||||||
use lemmy_websocket::LemmyContext;
|
use lemmy_websocket::LemmyContext;
|
||||||
|
|
||||||
|
@ -2,8 +2,7 @@ use crate::PerformCrud;
|
|||||||
use actix_web::web::Data;
|
use actix_web::web::Data;
|
||||||
use lemmy_api_common::{blocking, get_local_user_view_from_jwt_opt, person::*};
|
use lemmy_api_common::{blocking, get_local_user_view_from_jwt_opt, person::*};
|
||||||
use lemmy_apub::{build_actor_id_from_shortname, fetcher::object_id::ObjectId, EndpointType};
|
use lemmy_apub::{build_actor_id_from_shortname, fetcher::object_id::ObjectId, EndpointType};
|
||||||
use lemmy_db_queries::{from_opt_str_to_opt_enum, SortType};
|
use lemmy_db_schema::{from_opt_str_to_opt_enum, source::person::Person, SortType};
|
||||||
use lemmy_db_schema::source::person::*;
|
|
||||||
use lemmy_db_views::{comment_view::CommentQueryBuilder, post_view::PostQueryBuilder};
|
use lemmy_db_views::{comment_view::CommentQueryBuilder, post_view::PostQueryBuilder};
|
||||||
use lemmy_db_views_actor::{
|
use lemmy_db_views_actor::{
|
||||||
community_moderator_view::CommunityModeratorView,
|
community_moderator_view::CommunityModeratorView,
|
||||||
|
@ -15,7 +15,6 @@ doctest = false
|
|||||||
[dependencies]
|
[dependencies]
|
||||||
lemmy_utils = { version = "=0.13.0", path = "../utils" }
|
lemmy_utils = { version = "=0.13.0", path = "../utils" }
|
||||||
lemmy_apub_lib = { version = "=0.13.0", path = "../apub_lib" }
|
lemmy_apub_lib = { version = "=0.13.0", path = "../apub_lib" }
|
||||||
lemmy_db_queries = { version = "=0.13.0", path = "../db_queries" }
|
|
||||||
lemmy_db_schema = { version = "=0.13.0", path = "../db_schema" }
|
lemmy_db_schema = { version = "=0.13.0", path = "../db_schema" }
|
||||||
lemmy_db_views = { version = "=0.13.0", path = "../db_views" }
|
lemmy_db_views = { version = "=0.13.0", path = "../db_views" }
|
||||||
lemmy_db_views_actor = { version = "=0.13.0", path = "../db_views_actor" }
|
lemmy_db_views_actor = { version = "=0.13.0", path = "../db_views_actor" }
|
||||||
|
@ -21,8 +21,10 @@ use lemmy_apub_lib::{
|
|||||||
values::PublicUrl,
|
values::PublicUrl,
|
||||||
verify::verify_domains_match,
|
verify::verify_domains_match,
|
||||||
};
|
};
|
||||||
use lemmy_db_queries::Crud;
|
use lemmy_db_schema::{
|
||||||
use lemmy_db_schema::source::{comment::Comment, community::Community, person::Person, post::Post};
|
source::{comment::Comment, community::Community, person::Person, post::Post},
|
||||||
|
traits::Crud,
|
||||||
|
};
|
||||||
use lemmy_utils::LemmyError;
|
use lemmy_utils::LemmyError;
|
||||||
use lemmy_websocket::{send::send_comment_ws_message, LemmyContext, UserOperationCrud};
|
use lemmy_websocket::{send::send_comment_ws_message, LemmyContext, UserOperationCrud};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
@ -7,10 +7,11 @@ use anyhow::anyhow;
|
|||||||
use itertools::Itertools;
|
use itertools::Itertools;
|
||||||
use lemmy_api_common::{blocking, send_local_notifs};
|
use lemmy_api_common::{blocking, send_local_notifs};
|
||||||
use lemmy_apub_lib::{traits::ActorType, webfinger::WebfingerResponse};
|
use lemmy_apub_lib::{traits::ActorType, webfinger::WebfingerResponse};
|
||||||
use lemmy_db_queries::{Crud, DbPool};
|
|
||||||
use lemmy_db_schema::{
|
use lemmy_db_schema::{
|
||||||
|
newtypes::LocalUserId,
|
||||||
source::{comment::Comment, community::Community, person::Person, post::Post},
|
source::{comment::Comment, community::Community, person::Person, post::Post},
|
||||||
LocalUserId,
|
traits::Crud,
|
||||||
|
DbPool,
|
||||||
};
|
};
|
||||||
use lemmy_utils::{
|
use lemmy_utils::{
|
||||||
request::{retry, RecvError},
|
request::{retry, RecvError},
|
||||||
|
@ -23,10 +23,12 @@ use lemmy_apub_lib::{
|
|||||||
traits::{ActivityFields, ActivityHandler, ActorType},
|
traits::{ActivityFields, ActivityHandler, ActorType},
|
||||||
values::PublicUrl,
|
values::PublicUrl,
|
||||||
};
|
};
|
||||||
use lemmy_db_queries::{source::community::CommunityModerator_, Joinable};
|
use lemmy_db_schema::{
|
||||||
use lemmy_db_schema::source::{
|
source::{
|
||||||
community::{Community, CommunityModerator, CommunityModeratorForm},
|
community::{Community, CommunityModerator, CommunityModeratorForm},
|
||||||
person::Person,
|
person::Person,
|
||||||
|
},
|
||||||
|
traits::Joinable,
|
||||||
};
|
};
|
||||||
use lemmy_utils::LemmyError;
|
use lemmy_utils::LemmyError;
|
||||||
use lemmy_websocket::LemmyContext;
|
use lemmy_websocket::LemmyContext;
|
||||||
|
@ -21,16 +21,18 @@ use lemmy_apub_lib::{
|
|||||||
traits::{ActivityFields, ActivityHandler, ActorType},
|
traits::{ActivityFields, ActivityHandler, ActorType},
|
||||||
values::PublicUrl,
|
values::PublicUrl,
|
||||||
};
|
};
|
||||||
use lemmy_db_queries::{Bannable, Followable};
|
use lemmy_db_schema::{
|
||||||
use lemmy_db_schema::source::{
|
source::{
|
||||||
community::{
|
community::{
|
||||||
Community,
|
Community,
|
||||||
CommunityFollower,
|
CommunityFollower,
|
||||||
CommunityFollowerForm,
|
CommunityFollowerForm,
|
||||||
CommunityPersonBan,
|
CommunityPersonBan,
|
||||||
CommunityPersonBanForm,
|
CommunityPersonBanForm,
|
||||||
|
},
|
||||||
|
person::Person,
|
||||||
},
|
},
|
||||||
person::Person,
|
traits::{Bannable, Followable},
|
||||||
};
|
};
|
||||||
use lemmy_utils::LemmyError;
|
use lemmy_utils::LemmyError;
|
||||||
use lemmy_websocket::LemmyContext;
|
use lemmy_websocket::LemmyContext;
|
||||||
|
@ -24,10 +24,12 @@ use lemmy_apub_lib::{
|
|||||||
traits::{ActivityFields, ActivityHandler, ActorType},
|
traits::{ActivityFields, ActivityHandler, ActorType},
|
||||||
values::PublicUrl,
|
values::PublicUrl,
|
||||||
};
|
};
|
||||||
use lemmy_db_queries::Joinable;
|
use lemmy_db_schema::{
|
||||||
use lemmy_db_schema::source::{
|
source::{
|
||||||
community::{Community, CommunityModerator, CommunityModeratorForm},
|
community::{Community, CommunityModerator, CommunityModeratorForm},
|
||||||
person::Person,
|
person::Person,
|
||||||
|
},
|
||||||
|
traits::Joinable,
|
||||||
};
|
};
|
||||||
use lemmy_utils::LemmyError;
|
use lemmy_utils::LemmyError;
|
||||||
use lemmy_websocket::LemmyContext;
|
use lemmy_websocket::LemmyContext;
|
||||||
|
@ -25,10 +25,12 @@ use lemmy_apub_lib::{
|
|||||||
traits::{ActivityFields, ActivityHandler, ActorType},
|
traits::{ActivityFields, ActivityHandler, ActorType},
|
||||||
values::PublicUrl,
|
values::PublicUrl,
|
||||||
};
|
};
|
||||||
use lemmy_db_queries::Bannable;
|
use lemmy_db_schema::{
|
||||||
use lemmy_db_schema::source::{
|
source::{
|
||||||
community::{Community, CommunityPersonBan, CommunityPersonBanForm},
|
community::{Community, CommunityPersonBan, CommunityPersonBanForm},
|
||||||
person::Person,
|
person::Person,
|
||||||
|
},
|
||||||
|
traits::Bannable,
|
||||||
};
|
};
|
||||||
use lemmy_utils::LemmyError;
|
use lemmy_utils::LemmyError;
|
||||||
use lemmy_websocket::LemmyContext;
|
use lemmy_websocket::LemmyContext;
|
||||||
|
@ -22,10 +22,12 @@ use lemmy_apub_lib::{
|
|||||||
traits::{ActivityFields, ActivityHandler, ActorType},
|
traits::{ActivityFields, ActivityHandler, ActorType},
|
||||||
values::PublicUrl,
|
values::PublicUrl,
|
||||||
};
|
};
|
||||||
use lemmy_db_queries::Crud;
|
use lemmy_db_schema::{
|
||||||
use lemmy_db_schema::source::{
|
source::{
|
||||||
community::{Community, CommunityForm},
|
community::{Community, CommunityForm},
|
||||||
person::Person,
|
person::Person,
|
||||||
|
},
|
||||||
|
traits::Crud,
|
||||||
};
|
};
|
||||||
use lemmy_utils::LemmyError;
|
use lemmy_utils::LemmyError;
|
||||||
use lemmy_websocket::{send::send_community_ws_message, LemmyContext, UserOperationCrud};
|
use lemmy_websocket::{send::send_community_ws_message, LemmyContext, UserOperationCrud};
|
||||||
|
@ -26,23 +26,22 @@ use lemmy_apub_lib::{
|
|||||||
traits::{ActivityFields, ActivityHandler, ActorType},
|
traits::{ActivityFields, ActivityHandler, ActorType},
|
||||||
values::PublicUrl,
|
values::PublicUrl,
|
||||||
};
|
};
|
||||||
use lemmy_db_queries::{
|
use lemmy_db_schema::{
|
||||||
source::{comment::Comment_, community::Community_, post::Post_},
|
source::{
|
||||||
Crud,
|
comment::Comment,
|
||||||
};
|
community::Community,
|
||||||
use lemmy_db_schema::source::{
|
moderator::{
|
||||||
comment::Comment,
|
ModRemoveComment,
|
||||||
community::Community,
|
ModRemoveCommentForm,
|
||||||
moderator::{
|
ModRemoveCommunity,
|
||||||
ModRemoveComment,
|
ModRemoveCommunityForm,
|
||||||
ModRemoveCommentForm,
|
ModRemovePost,
|
||||||
ModRemoveCommunity,
|
ModRemovePostForm,
|
||||||
ModRemoveCommunityForm,
|
},
|
||||||
ModRemovePost,
|
person::Person,
|
||||||
ModRemovePostForm,
|
post::Post,
|
||||||
},
|
},
|
||||||
person::Person,
|
traits::Crud,
|
||||||
post::Post,
|
|
||||||
};
|
};
|
||||||
use lemmy_utils::LemmyError;
|
use lemmy_utils::LemmyError;
|
||||||
use lemmy_websocket::{
|
use lemmy_websocket::{
|
||||||
|
@ -12,7 +12,6 @@ use lemmy_apub_lib::{
|
|||||||
traits::{ActivityFields, ActorType, ApubObject},
|
traits::{ActivityFields, ActorType, ApubObject},
|
||||||
verify::verify_domains_match,
|
verify::verify_domains_match,
|
||||||
};
|
};
|
||||||
use lemmy_db_queries::source::{comment::Comment_, community::Community_, post::Post_};
|
|
||||||
use lemmy_db_schema::source::{comment::Comment, community::Community, person::Person, post::Post};
|
use lemmy_db_schema::source::{comment::Comment, community::Community, person::Person, post::Post};
|
||||||
use lemmy_utils::LemmyError;
|
use lemmy_utils::LemmyError;
|
||||||
use lemmy_websocket::{
|
use lemmy_websocket::{
|
||||||
|
@ -27,7 +27,6 @@ use lemmy_apub_lib::{
|
|||||||
traits::{ActivityFields, ActivityHandler, ActorType},
|
traits::{ActivityFields, ActivityHandler, ActorType},
|
||||||
values::PublicUrl,
|
values::PublicUrl,
|
||||||
};
|
};
|
||||||
use lemmy_db_queries::source::{comment::Comment_, community::Community_, post::Post_};
|
|
||||||
use lemmy_db_schema::source::{comment::Comment, community::Community, person::Person, post::Post};
|
use lemmy_db_schema::source::{comment::Comment, community::Community, person::Person, post::Post};
|
||||||
use lemmy_utils::LemmyError;
|
use lemmy_utils::LemmyError;
|
||||||
use lemmy_websocket::{
|
use lemmy_websocket::{
|
||||||
|
@ -21,10 +21,12 @@ use lemmy_apub_lib::{
|
|||||||
traits::{ActivityFields, ActivityHandler, ActorType},
|
traits::{ActivityFields, ActivityHandler, ActorType},
|
||||||
verify::verify_urls_match,
|
verify::verify_urls_match,
|
||||||
};
|
};
|
||||||
use lemmy_db_queries::Followable;
|
use lemmy_db_schema::{
|
||||||
use lemmy_db_schema::source::{
|
source::{
|
||||||
community::{Community, CommunityFollower},
|
community::{Community, CommunityFollower},
|
||||||
person::Person,
|
person::Person,
|
||||||
|
},
|
||||||
|
traits::Followable,
|
||||||
};
|
};
|
||||||
use lemmy_utils::LemmyError;
|
use lemmy_utils::LemmyError;
|
||||||
use lemmy_websocket::LemmyContext;
|
use lemmy_websocket::LemmyContext;
|
||||||
|
@ -21,10 +21,12 @@ use lemmy_apub_lib::{
|
|||||||
traits::{ActivityFields, ActivityHandler, ActorType},
|
traits::{ActivityFields, ActivityHandler, ActorType},
|
||||||
verify::verify_urls_match,
|
verify::verify_urls_match,
|
||||||
};
|
};
|
||||||
use lemmy_db_queries::Followable;
|
use lemmy_db_schema::{
|
||||||
use lemmy_db_schema::source::{
|
source::{
|
||||||
community::{Community, CommunityFollower, CommunityFollowerForm},
|
community::{Community, CommunityFollower, CommunityFollowerForm},
|
||||||
person::Person,
|
person::Person,
|
||||||
|
},
|
||||||
|
traits::Followable,
|
||||||
};
|
};
|
||||||
use lemmy_utils::LemmyError;
|
use lemmy_utils::LemmyError;
|
||||||
use lemmy_websocket::LemmyContext;
|
use lemmy_websocket::LemmyContext;
|
||||||
|
@ -21,10 +21,12 @@ use lemmy_apub_lib::{
|
|||||||
traits::{ActivityFields, ActivityHandler, ActorType},
|
traits::{ActivityFields, ActivityHandler, ActorType},
|
||||||
verify::verify_urls_match,
|
verify::verify_urls_match,
|
||||||
};
|
};
|
||||||
use lemmy_db_queries::Followable;
|
use lemmy_db_schema::{
|
||||||
use lemmy_db_schema::source::{
|
source::{
|
||||||
community::{Community, CommunityFollower, CommunityFollowerForm},
|
community::{Community, CommunityFollower, CommunityFollowerForm},
|
||||||
person::Person,
|
person::Person,
|
||||||
|
},
|
||||||
|
traits::Followable,
|
||||||
};
|
};
|
||||||
use lemmy_utils::LemmyError;
|
use lemmy_utils::LemmyError;
|
||||||
use lemmy_websocket::LemmyContext;
|
use lemmy_websocket::LemmyContext;
|
||||||
|
@ -21,8 +21,10 @@ use lemmy_apub_lib::{
|
|||||||
values::PublicUrl,
|
values::PublicUrl,
|
||||||
verify::{verify_domains_match, verify_urls_match},
|
verify::{verify_domains_match, verify_urls_match},
|
||||||
};
|
};
|
||||||
use lemmy_db_queries::Crud;
|
use lemmy_db_schema::{
|
||||||
use lemmy_db_schema::source::{community::Community, person::Person, post::Post};
|
source::{community::Community, person::Person, post::Post},
|
||||||
|
traits::Crud,
|
||||||
|
};
|
||||||
use lemmy_utils::LemmyError;
|
use lemmy_utils::LemmyError;
|
||||||
use lemmy_websocket::{send::send_post_ws_message, LemmyContext, UserOperationCrud};
|
use lemmy_websocket::{send::send_post_ws_message, LemmyContext, UserOperationCrud};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
@ -12,8 +12,10 @@ use lemmy_apub_lib::{
|
|||||||
traits::{ActivityFields, ActivityHandler, ActorType},
|
traits::{ActivityFields, ActivityHandler, ActorType},
|
||||||
verify::verify_domains_match,
|
verify::verify_domains_match,
|
||||||
};
|
};
|
||||||
use lemmy_db_queries::Crud;
|
use lemmy_db_schema::{
|
||||||
use lemmy_db_schema::source::{person::Person, private_message::PrivateMessage};
|
source::{person::Person, private_message::PrivateMessage},
|
||||||
|
traits::Crud,
|
||||||
|
};
|
||||||
use lemmy_utils::LemmyError;
|
use lemmy_utils::LemmyError;
|
||||||
use lemmy_websocket::{send::send_pm_ws_message, LemmyContext, UserOperationCrud};
|
use lemmy_websocket::{send::send_pm_ws_message, LemmyContext, UserOperationCrud};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
@ -16,8 +16,10 @@ use lemmy_apub_lib::{
|
|||||||
traits::{ActivityFields, ActivityHandler, ActorType},
|
traits::{ActivityFields, ActivityHandler, ActorType},
|
||||||
verify::verify_domains_match,
|
verify::verify_domains_match,
|
||||||
};
|
};
|
||||||
use lemmy_db_queries::{source::private_message::PrivateMessage_, Crud};
|
use lemmy_db_schema::{
|
||||||
use lemmy_db_schema::source::{person::Person, private_message::PrivateMessage};
|
source::{person::Person, private_message::PrivateMessage},
|
||||||
|
traits::Crud,
|
||||||
|
};
|
||||||
use lemmy_utils::LemmyError;
|
use lemmy_utils::LemmyError;
|
||||||
use lemmy_websocket::{send::send_pm_ws_message, LemmyContext, UserOperationCrud};
|
use lemmy_websocket::{send::send_pm_ws_message, LemmyContext, UserOperationCrud};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
@ -21,8 +21,10 @@ use lemmy_apub_lib::{
|
|||||||
traits::{ActivityFields, ActivityHandler, ActorType},
|
traits::{ActivityFields, ActivityHandler, ActorType},
|
||||||
verify::{verify_domains_match, verify_urls_match},
|
verify::{verify_domains_match, verify_urls_match},
|
||||||
};
|
};
|
||||||
use lemmy_db_queries::{source::private_message::PrivateMessage_, Crud};
|
use lemmy_db_schema::{
|
||||||
use lemmy_db_schema::source::{person::Person, private_message::PrivateMessage};
|
source::{person::Person, private_message::PrivateMessage},
|
||||||
|
traits::Crud,
|
||||||
|
};
|
||||||
use lemmy_utils::LemmyError;
|
use lemmy_utils::LemmyError;
|
||||||
use lemmy_websocket::{send::send_pm_ws_message, LemmyContext, UserOperationCrud};
|
use lemmy_websocket::{send::send_pm_ws_message, LemmyContext, UserOperationCrud};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
@ -16,15 +16,15 @@ use lemmy_apub_lib::{
|
|||||||
data::Data,
|
data::Data,
|
||||||
traits::{ActivityFields, ActivityHandler, ActorType},
|
traits::{ActivityFields, ActivityHandler, ActorType},
|
||||||
};
|
};
|
||||||
use lemmy_db_queries::{Crud, Reportable};
|
|
||||||
use lemmy_db_schema::{
|
use lemmy_db_schema::{
|
||||||
|
newtypes::CommunityId,
|
||||||
source::{
|
source::{
|
||||||
comment_report::{CommentReport, CommentReportForm},
|
comment_report::{CommentReport, CommentReportForm},
|
||||||
community::Community,
|
community::Community,
|
||||||
person::Person,
|
person::Person,
|
||||||
post_report::{PostReport, PostReportForm},
|
post_report::{PostReport, PostReportForm},
|
||||||
},
|
},
|
||||||
CommunityId,
|
traits::{Crud, Reportable},
|
||||||
};
|
};
|
||||||
use lemmy_db_views::{comment_report_view::CommentReportView, post_report_view::PostReportView};
|
use lemmy_db_views::{comment_report_view::CommentReportView, post_report_view::PostReportView};
|
||||||
use lemmy_utils::LemmyError;
|
use lemmy_utils::LemmyError;
|
||||||
|
@ -1,10 +1,12 @@
|
|||||||
use crate::activities::voting::vote::VoteType;
|
use crate::activities::voting::vote::VoteType;
|
||||||
use lemmy_api_common::blocking;
|
use lemmy_api_common::blocking;
|
||||||
use lemmy_db_queries::Likeable;
|
use lemmy_db_schema::{
|
||||||
use lemmy_db_schema::source::{
|
source::{
|
||||||
comment::{Comment, CommentLike, CommentLikeForm},
|
comment::{Comment, CommentLike, CommentLikeForm},
|
||||||
person::Person,
|
person::Person,
|
||||||
post::{Post, PostLike, PostLikeForm},
|
post::{Post, PostLike, PostLikeForm},
|
||||||
|
},
|
||||||
|
traits::Likeable,
|
||||||
};
|
};
|
||||||
use lemmy_utils::LemmyError;
|
use lemmy_utils::LemmyError;
|
||||||
use lemmy_websocket::{
|
use lemmy_websocket::{
|
||||||
|
@ -27,10 +27,10 @@ use lemmy_apub_lib::{
|
|||||||
values::PublicUrl,
|
values::PublicUrl,
|
||||||
verify::verify_urls_match,
|
verify::verify_urls_match,
|
||||||
};
|
};
|
||||||
use lemmy_db_queries::Crud;
|
|
||||||
use lemmy_db_schema::{
|
use lemmy_db_schema::{
|
||||||
|
newtypes::CommunityId,
|
||||||
source::{community::Community, person::Person},
|
source::{community::Community, person::Person},
|
||||||
CommunityId,
|
traits::Crud,
|
||||||
};
|
};
|
||||||
use lemmy_utils::LemmyError;
|
use lemmy_utils::LemmyError;
|
||||||
use lemmy_websocket::LemmyContext;
|
use lemmy_websocket::LemmyContext;
|
||||||
|
@ -18,10 +18,10 @@ use lemmy_apub_lib::{
|
|||||||
traits::{ActivityFields, ActivityHandler, ActorType},
|
traits::{ActivityFields, ActivityHandler, ActorType},
|
||||||
values::PublicUrl,
|
values::PublicUrl,
|
||||||
};
|
};
|
||||||
use lemmy_db_queries::Crud;
|
|
||||||
use lemmy_db_schema::{
|
use lemmy_db_schema::{
|
||||||
|
newtypes::CommunityId,
|
||||||
source::{community::Community, person::Person},
|
source::{community::Community, person::Person},
|
||||||
CommunityId,
|
traits::Crud,
|
||||||
};
|
};
|
||||||
use lemmy_utils::LemmyError;
|
use lemmy_utils::LemmyError;
|
||||||
use lemmy_websocket::LemmyContext;
|
use lemmy_websocket::LemmyContext;
|
||||||
|
@ -7,10 +7,12 @@ use activitystreams::collection::{CollectionExt, OrderedCollection};
|
|||||||
use anyhow::Context;
|
use anyhow::Context;
|
||||||
use lemmy_api_common::blocking;
|
use lemmy_api_common::blocking;
|
||||||
use lemmy_apub_lib::{data::Data, traits::ActivityHandler};
|
use lemmy_apub_lib::{data::Data, traits::ActivityHandler};
|
||||||
use lemmy_db_queries::Joinable;
|
use lemmy_db_schema::{
|
||||||
use lemmy_db_schema::source::{
|
source::{
|
||||||
community::{Community, CommunityModerator, CommunityModeratorForm},
|
community::{Community, CommunityModerator, CommunityModeratorForm},
|
||||||
person::Person,
|
person::Person,
|
||||||
|
},
|
||||||
|
traits::Joinable,
|
||||||
};
|
};
|
||||||
use lemmy_db_views_actor::community_moderator_view::CommunityModeratorView;
|
use lemmy_db_views_actor::community_moderator_view::CommunityModeratorView;
|
||||||
use lemmy_utils::{location_info, LemmyError};
|
use lemmy_utils::{location_info, LemmyError};
|
||||||
|
@ -3,8 +3,7 @@ use anyhow::anyhow;
|
|||||||
use diesel::{NotFound, PgConnection};
|
use diesel::{NotFound, PgConnection};
|
||||||
use lemmy_api_common::blocking;
|
use lemmy_api_common::blocking;
|
||||||
use lemmy_apub_lib::{traits::ApubObject, APUB_JSON_CONTENT_TYPE};
|
use lemmy_apub_lib::{traits::ApubObject, APUB_JSON_CONTENT_TYPE};
|
||||||
use lemmy_db_queries::DbPool;
|
use lemmy_db_schema::{newtypes::DbUrl, DbPool};
|
||||||
use lemmy_db_schema::DbUrl;
|
|
||||||
use lemmy_utils::{request::retry, settings::structs::Settings, LemmyError};
|
use lemmy_utils::{request::retry, settings::structs::Settings, LemmyError};
|
||||||
use lemmy_websocket::LemmyContext;
|
use lemmy_websocket::LemmyContext;
|
||||||
use reqwest::StatusCode;
|
use reqwest::StatusCode;
|
||||||
|
@ -11,11 +11,10 @@ use lemmy_apub_lib::{
|
|||||||
traits::ApubObject,
|
traits::ApubObject,
|
||||||
webfinger::{webfinger_resolve_actor, WebfingerType},
|
webfinger::{webfinger_resolve_actor, WebfingerType},
|
||||||
};
|
};
|
||||||
use lemmy_db_queries::{
|
use lemmy_db_schema::{
|
||||||
source::{community::Community_, person::Person_},
|
source::{comment::Comment, community::Community, person::Person, post::Post},
|
||||||
DbPool,
|
DbPool,
|
||||||
};
|
};
|
||||||
use lemmy_db_schema::source::{comment::Comment, community::Community, person::Person, post::Post};
|
|
||||||
use lemmy_utils::LemmyError;
|
use lemmy_utils::LemmyError;
|
||||||
use lemmy_websocket::LemmyContext;
|
use lemmy_websocket::LemmyContext;
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
|
@ -5,8 +5,7 @@ use crate::{
|
|||||||
use actix_web::{body::Body, web, web::Path, HttpResponse};
|
use actix_web::{body::Body, web, web::Path, HttpResponse};
|
||||||
use diesel::result::Error::NotFound;
|
use diesel::result::Error::NotFound;
|
||||||
use lemmy_api_common::blocking;
|
use lemmy_api_common::blocking;
|
||||||
use lemmy_db_queries::Crud;
|
use lemmy_db_schema::{newtypes::CommentId, source::comment::Comment, traits::Crud};
|
||||||
use lemmy_db_schema::{source::comment::Comment, CommentId};
|
|
||||||
use lemmy_utils::LemmyError;
|
use lemmy_utils::LemmyError;
|
||||||
use lemmy_websocket::LemmyContext;
|
use lemmy_websocket::LemmyContext;
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
|
@ -24,7 +24,6 @@ use activitystreams::{
|
|||||||
use actix_web::{body::Body, web, web::Payload, HttpRequest, HttpResponse};
|
use actix_web::{body::Body, web, web::Payload, HttpRequest, HttpResponse};
|
||||||
use lemmy_api_common::blocking;
|
use lemmy_api_common::blocking;
|
||||||
use lemmy_apub_lib::traits::{ActivityFields, ActivityHandler};
|
use lemmy_apub_lib::traits::{ActivityFields, ActivityHandler};
|
||||||
use lemmy_db_queries::source::{activity::Activity_, community::Community_};
|
|
||||||
use lemmy_db_schema::source::{activity::Activity, community::Community};
|
use lemmy_db_schema::source::{activity::Activity, community::Community};
|
||||||
use lemmy_db_views_actor::{
|
use lemmy_db_views_actor::{
|
||||||
community_follower_view::CommunityFollowerView,
|
community_follower_view::CommunityFollowerView,
|
||||||
|
@ -24,8 +24,7 @@ use lemmy_apub_lib::{
|
|||||||
traits::{ActivityFields, ActivityHandler},
|
traits::{ActivityFields, ActivityHandler},
|
||||||
APUB_JSON_CONTENT_TYPE,
|
APUB_JSON_CONTENT_TYPE,
|
||||||
};
|
};
|
||||||
use lemmy_db_queries::{source::activity::Activity_, DbPool};
|
use lemmy_db_schema::{source::activity::Activity, DbPool};
|
||||||
use lemmy_db_schema::source::activity::Activity;
|
|
||||||
use lemmy_utils::{location_info, LemmyError};
|
use lemmy_utils::{location_info, LemmyError};
|
||||||
use lemmy_websocket::LemmyContext;
|
use lemmy_websocket::LemmyContext;
|
||||||
use log::{info, trace};
|
use log::{info, trace};
|
||||||
|
@ -25,7 +25,6 @@ use activitystreams::{
|
|||||||
use actix_web::{body::Body, web, web::Payload, HttpRequest, HttpResponse};
|
use actix_web::{body::Body, web, web::Payload, HttpRequest, HttpResponse};
|
||||||
use lemmy_api_common::blocking;
|
use lemmy_api_common::blocking;
|
||||||
use lemmy_apub_lib::traits::{ActivityFields, ActivityHandler};
|
use lemmy_apub_lib::traits::{ActivityFields, ActivityHandler};
|
||||||
use lemmy_db_queries::source::person::Person_;
|
|
||||||
use lemmy_db_schema::source::person::Person;
|
use lemmy_db_schema::source::person::Person;
|
||||||
use lemmy_utils::LemmyError;
|
use lemmy_utils::LemmyError;
|
||||||
use lemmy_websocket::LemmyContext;
|
use lemmy_websocket::LemmyContext;
|
||||||
|
@ -5,8 +5,7 @@ use crate::{
|
|||||||
use actix_web::{body::Body, web, HttpResponse};
|
use actix_web::{body::Body, web, HttpResponse};
|
||||||
use diesel::result::Error::NotFound;
|
use diesel::result::Error::NotFound;
|
||||||
use lemmy_api_common::blocking;
|
use lemmy_api_common::blocking;
|
||||||
use lemmy_db_queries::Crud;
|
use lemmy_db_schema::{newtypes::PostId, source::post::Post, traits::Crud};
|
||||||
use lemmy_db_schema::{source::post::Post, PostId};
|
|
||||||
use lemmy_utils::LemmyError;
|
use lemmy_utils::LemmyError;
|
||||||
use lemmy_websocket::LemmyContext;
|
use lemmy_websocket::LemmyContext;
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
|
@ -9,11 +9,10 @@ use crate::fetcher::post_or_comment::PostOrComment;
|
|||||||
use anyhow::{anyhow, Context};
|
use anyhow::{anyhow, Context};
|
||||||
use lemmy_api_common::blocking;
|
use lemmy_api_common::blocking;
|
||||||
use lemmy_apub_lib::{activity_queue::send_activity, traits::ActorType};
|
use lemmy_apub_lib::{activity_queue::send_activity, traits::ActorType};
|
||||||
use lemmy_db_queries::{source::activity::Activity_, DbPool};
|
|
||||||
use lemmy_db_schema::{
|
use lemmy_db_schema::{
|
||||||
|
newtypes::{CommunityId, DbUrl},
|
||||||
source::{activity::Activity, person::Person},
|
source::{activity::Activity, person::Person},
|
||||||
CommunityId,
|
DbPool,
|
||||||
DbUrl,
|
|
||||||
};
|
};
|
||||||
use lemmy_db_views_actor::community_person_ban_view::CommunityPersonBanView;
|
use lemmy_db_views_actor::community_person_ban_view::CommunityPersonBanView;
|
||||||
use lemmy_utils::{location_info, settings::structs::Settings, LemmyError};
|
use lemmy_utils::{location_info, settings::structs::Settings, LemmyError};
|
||||||
|
@ -20,15 +20,16 @@ use lemmy_apub_lib::{
|
|||||||
values::{MediaTypeHtml, MediaTypeMarkdown, PublicUrl},
|
values::{MediaTypeHtml, MediaTypeMarkdown, PublicUrl},
|
||||||
verify::verify_domains_match,
|
verify::verify_domains_match,
|
||||||
};
|
};
|
||||||
use lemmy_db_queries::{source::comment::Comment_, Crud, DbPool};
|
|
||||||
use lemmy_db_schema::{
|
use lemmy_db_schema::{
|
||||||
|
newtypes::CommentId,
|
||||||
source::{
|
source::{
|
||||||
comment::{Comment, CommentForm},
|
comment::{Comment, CommentForm},
|
||||||
community::Community,
|
community::Community,
|
||||||
person::Person,
|
person::Person,
|
||||||
post::Post,
|
post::Post,
|
||||||
},
|
},
|
||||||
CommentId,
|
traits::Crud,
|
||||||
|
DbPool,
|
||||||
};
|
};
|
||||||
use lemmy_utils::{
|
use lemmy_utils::{
|
||||||
location_info,
|
location_info,
|
||||||
|
@ -23,10 +23,10 @@ use lemmy_apub_lib::{
|
|||||||
values::{MediaTypeHtml, MediaTypeMarkdown},
|
values::{MediaTypeHtml, MediaTypeMarkdown},
|
||||||
verify::verify_domains_match,
|
verify::verify_domains_match,
|
||||||
};
|
};
|
||||||
use lemmy_db_queries::{source::community::Community_, DbPool};
|
|
||||||
use lemmy_db_schema::{
|
use lemmy_db_schema::{
|
||||||
naive_now,
|
naive_now,
|
||||||
source::community::{Community, CommunityForm},
|
source::community::{Community, CommunityForm},
|
||||||
|
DbPool,
|
||||||
};
|
};
|
||||||
use lemmy_db_views_actor::community_follower_view::CommunityFollowerView;
|
use lemmy_db_views_actor::community_follower_view::CommunityFollowerView;
|
||||||
use lemmy_utils::{
|
use lemmy_utils::{
|
||||||
|
@ -5,7 +5,7 @@ use activitystreams::{
|
|||||||
use anyhow::anyhow;
|
use anyhow::anyhow;
|
||||||
use chrono::NaiveDateTime;
|
use chrono::NaiveDateTime;
|
||||||
use lemmy_apub_lib::values::MediaTypeMarkdown;
|
use lemmy_apub_lib::values::MediaTypeMarkdown;
|
||||||
use lemmy_db_queries::DbPool;
|
use lemmy_db_schema::DbPool;
|
||||||
use lemmy_utils::{utils::convert_datetime, LemmyError};
|
use lemmy_utils::{utils::convert_datetime, LemmyError};
|
||||||
use lemmy_websocket::LemmyContext;
|
use lemmy_websocket::LemmyContext;
|
||||||
use url::Url;
|
use url::Url;
|
||||||
|
@ -19,10 +19,10 @@ use lemmy_apub_lib::{
|
|||||||
values::{MediaTypeHtml, MediaTypeMarkdown},
|
values::{MediaTypeHtml, MediaTypeMarkdown},
|
||||||
verify::verify_domains_match,
|
verify::verify_domains_match,
|
||||||
};
|
};
|
||||||
use lemmy_db_queries::{source::person::Person_, DbPool};
|
|
||||||
use lemmy_db_schema::{
|
use lemmy_db_schema::{
|
||||||
naive_now,
|
naive_now,
|
||||||
source::person::{Person as DbPerson, PersonForm},
|
source::person::{Person as DbPerson, PersonForm},
|
||||||
|
DbPool,
|
||||||
};
|
};
|
||||||
use lemmy_utils::{
|
use lemmy_utils::{
|
||||||
utils::{check_slurs, check_slurs_opt, convert_datetime, markdown_to_html},
|
utils::{check_slurs, check_slurs_opt, convert_datetime, markdown_to_html},
|
||||||
|
@ -21,7 +21,6 @@ use lemmy_apub_lib::{
|
|||||||
values::{MediaTypeHtml, MediaTypeMarkdown},
|
values::{MediaTypeHtml, MediaTypeMarkdown},
|
||||||
verify::verify_domains_match,
|
verify::verify_domains_match,
|
||||||
};
|
};
|
||||||
use lemmy_db_queries::{source::post::Post_, Crud, DbPool};
|
|
||||||
use lemmy_db_schema::{
|
use lemmy_db_schema::{
|
||||||
self,
|
self,
|
||||||
source::{
|
source::{
|
||||||
@ -29,6 +28,8 @@ use lemmy_db_schema::{
|
|||||||
person::Person,
|
person::Person,
|
||||||
post::{Post, PostForm},
|
post::{Post, PostForm},
|
||||||
},
|
},
|
||||||
|
traits::Crud,
|
||||||
|
DbPool,
|
||||||
};
|
};
|
||||||
use lemmy_utils::{
|
use lemmy_utils::{
|
||||||
request::fetch_site_data,
|
request::fetch_site_data,
|
||||||
|
@ -16,10 +16,13 @@ use lemmy_apub_lib::{
|
|||||||
values::{MediaTypeHtml, MediaTypeMarkdown},
|
values::{MediaTypeHtml, MediaTypeMarkdown},
|
||||||
verify::verify_domains_match,
|
verify::verify_domains_match,
|
||||||
};
|
};
|
||||||
use lemmy_db_queries::{source::private_message::PrivateMessage_, Crud, DbPool};
|
use lemmy_db_schema::{
|
||||||
use lemmy_db_schema::source::{
|
source::{
|
||||||
person::Person,
|
person::Person,
|
||||||
private_message::{PrivateMessage, PrivateMessageForm},
|
private_message::{PrivateMessage, PrivateMessageForm},
|
||||||
|
},
|
||||||
|
traits::Crud,
|
||||||
|
DbPool,
|
||||||
};
|
};
|
||||||
use lemmy_utils::{utils::convert_datetime, LemmyError};
|
use lemmy_utils::{utils::convert_datetime, LemmyError};
|
||||||
use lemmy_websocket::LemmyContext;
|
use lemmy_websocket::LemmyContext;
|
||||||
|
@ -1,33 +0,0 @@
|
|||||||
[package]
|
|
||||||
name = "lemmy_db_queries"
|
|
||||||
version = "0.13.0"
|
|
||||||
edition = "2018"
|
|
||||||
description = "A link aggregator for the fediverse"
|
|
||||||
license = "AGPL-3.0"
|
|
||||||
homepage = "https://join-lemmy.org/"
|
|
||||||
documentation = "https://join-lemmy.org/docs/en/index.html"
|
|
||||||
|
|
||||||
[lib]
|
|
||||||
name = "lemmy_db_queries"
|
|
||||||
path = "src/lib.rs"
|
|
||||||
doctest = false
|
|
||||||
|
|
||||||
[dependencies]
|
|
||||||
lemmy_utils = { version = "=0.13.0", path = "../utils" }
|
|
||||||
lemmy_db_schema = { version = "=0.13.0", path = "../db_schema" }
|
|
||||||
diesel = { version = "1.4.8", features = ["postgres","chrono","r2d2","serde_json"] }
|
|
||||||
diesel_migrations = "1.4.0"
|
|
||||||
chrono = { version = "0.4.19", features = ["serde"] }
|
|
||||||
serde = { version = "1.0.130", features = ["derive"] }
|
|
||||||
serde_json = { version = "1.0.68", features = ["preserve_order"] }
|
|
||||||
strum = "0.21.0"
|
|
||||||
strum_macros = "0.21.1"
|
|
||||||
log = "0.4.14"
|
|
||||||
sha2 = "0.9.8"
|
|
||||||
url = { version = "2.2.2", features = ["serde"] }
|
|
||||||
lazy_static = "1.4.0"
|
|
||||||
regex = "1.5.4"
|
|
||||||
bcrypt = "0.10.1"
|
|
||||||
|
|
||||||
[dev-dependencies]
|
|
||||||
serial_test = "0.5.1"
|
|
@ -1,348 +0,0 @@
|
|||||||
#[macro_use]
|
|
||||||
extern crate diesel;
|
|
||||||
#[macro_use]
|
|
||||||
extern crate strum_macros;
|
|
||||||
#[macro_use]
|
|
||||||
extern crate lazy_static;
|
|
||||||
// this is used in tests
|
|
||||||
#[allow(unused_imports)]
|
|
||||||
#[macro_use]
|
|
||||||
extern crate diesel_migrations;
|
|
||||||
|
|
||||||
#[cfg(test)]
|
|
||||||
extern crate serial_test;
|
|
||||||
|
|
||||||
use diesel::{result::Error, *};
|
|
||||||
use lemmy_db_schema::{CommunityId, DbUrl, PersonId};
|
|
||||||
use lemmy_utils::ApiError;
|
|
||||||
use regex::Regex;
|
|
||||||
use serde::{Deserialize, Serialize};
|
|
||||||
use std::{env, env::VarError};
|
|
||||||
use url::Url;
|
|
||||||
|
|
||||||
pub mod aggregates;
|
|
||||||
pub mod source;
|
|
||||||
|
|
||||||
pub type DbPool = diesel::r2d2::Pool<diesel::r2d2::ConnectionManager<diesel::PgConnection>>;
|
|
||||||
|
|
||||||
pub trait Crud {
|
|
||||||
type Form;
|
|
||||||
type IdType;
|
|
||||||
fn create(conn: &PgConnection, form: &Self::Form) -> Result<Self, Error>
|
|
||||||
where
|
|
||||||
Self: Sized;
|
|
||||||
fn read(conn: &PgConnection, id: Self::IdType) -> Result<Self, Error>
|
|
||||||
where
|
|
||||||
Self: Sized;
|
|
||||||
fn update(conn: &PgConnection, id: Self::IdType, form: &Self::Form) -> Result<Self, Error>
|
|
||||||
where
|
|
||||||
Self: Sized;
|
|
||||||
fn delete(_conn: &PgConnection, _id: Self::IdType) -> Result<usize, Error>
|
|
||||||
where
|
|
||||||
Self: Sized,
|
|
||||||
{
|
|
||||||
unimplemented!()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub trait Followable {
|
|
||||||
type Form;
|
|
||||||
fn follow(conn: &PgConnection, form: &Self::Form) -> Result<Self, Error>
|
|
||||||
where
|
|
||||||
Self: Sized;
|
|
||||||
fn follow_accepted(
|
|
||||||
conn: &PgConnection,
|
|
||||||
community_id: CommunityId,
|
|
||||||
person_id: PersonId,
|
|
||||||
) -> Result<Self, Error>
|
|
||||||
where
|
|
||||||
Self: Sized;
|
|
||||||
fn unfollow(conn: &PgConnection, form: &Self::Form) -> Result<usize, Error>
|
|
||||||
where
|
|
||||||
Self: Sized;
|
|
||||||
fn has_local_followers(conn: &PgConnection, community_id: CommunityId) -> Result<bool, Error>;
|
|
||||||
}
|
|
||||||
|
|
||||||
pub trait Joinable {
|
|
||||||
type Form;
|
|
||||||
fn join(conn: &PgConnection, form: &Self::Form) -> Result<Self, Error>
|
|
||||||
where
|
|
||||||
Self: Sized;
|
|
||||||
fn leave(conn: &PgConnection, form: &Self::Form) -> Result<usize, Error>
|
|
||||||
where
|
|
||||||
Self: Sized;
|
|
||||||
}
|
|
||||||
|
|
||||||
pub trait Likeable {
|
|
||||||
type Form;
|
|
||||||
type IdType;
|
|
||||||
fn like(conn: &PgConnection, form: &Self::Form) -> Result<Self, Error>
|
|
||||||
where
|
|
||||||
Self: Sized;
|
|
||||||
fn remove(
|
|
||||||
conn: &PgConnection,
|
|
||||||
person_id: PersonId,
|
|
||||||
item_id: Self::IdType,
|
|
||||||
) -> Result<usize, Error>
|
|
||||||
where
|
|
||||||
Self: Sized;
|
|
||||||
}
|
|
||||||
|
|
||||||
pub trait Bannable {
|
|
||||||
type Form;
|
|
||||||
fn ban(conn: &PgConnection, form: &Self::Form) -> Result<Self, Error>
|
|
||||||
where
|
|
||||||
Self: Sized;
|
|
||||||
fn unban(conn: &PgConnection, form: &Self::Form) -> Result<usize, Error>
|
|
||||||
where
|
|
||||||
Self: Sized;
|
|
||||||
}
|
|
||||||
|
|
||||||
pub trait Saveable {
|
|
||||||
type Form;
|
|
||||||
fn save(conn: &PgConnection, form: &Self::Form) -> Result<Self, Error>
|
|
||||||
where
|
|
||||||
Self: Sized;
|
|
||||||
fn unsave(conn: &PgConnection, form: &Self::Form) -> Result<usize, Error>
|
|
||||||
where
|
|
||||||
Self: Sized;
|
|
||||||
}
|
|
||||||
|
|
||||||
pub trait Blockable {
|
|
||||||
type Form;
|
|
||||||
fn block(conn: &PgConnection, form: &Self::Form) -> Result<Self, Error>
|
|
||||||
where
|
|
||||||
Self: Sized;
|
|
||||||
fn unblock(conn: &PgConnection, form: &Self::Form) -> Result<usize, Error>
|
|
||||||
where
|
|
||||||
Self: Sized;
|
|
||||||
}
|
|
||||||
|
|
||||||
pub trait Readable {
|
|
||||||
type Form;
|
|
||||||
fn mark_as_read(conn: &PgConnection, form: &Self::Form) -> Result<Self, Error>
|
|
||||||
where
|
|
||||||
Self: Sized;
|
|
||||||
fn mark_as_unread(conn: &PgConnection, form: &Self::Form) -> Result<usize, Error>
|
|
||||||
where
|
|
||||||
Self: Sized;
|
|
||||||
}
|
|
||||||
|
|
||||||
pub trait Reportable {
|
|
||||||
type Form;
|
|
||||||
type IdType;
|
|
||||||
fn report(conn: &PgConnection, form: &Self::Form) -> Result<Self, Error>
|
|
||||||
where
|
|
||||||
Self: Sized;
|
|
||||||
fn resolve(
|
|
||||||
conn: &PgConnection,
|
|
||||||
report_id: Self::IdType,
|
|
||||||
resolver_id: PersonId,
|
|
||||||
) -> Result<usize, Error>
|
|
||||||
where
|
|
||||||
Self: Sized;
|
|
||||||
fn unresolve(
|
|
||||||
conn: &PgConnection,
|
|
||||||
report_id: Self::IdType,
|
|
||||||
resolver_id: PersonId,
|
|
||||||
) -> Result<usize, Error>
|
|
||||||
where
|
|
||||||
Self: Sized;
|
|
||||||
}
|
|
||||||
|
|
||||||
pub trait DeleteableOrRemoveable {
|
|
||||||
fn blank_out_deleted_or_removed_info(self) -> Self;
|
|
||||||
}
|
|
||||||
|
|
||||||
pub trait MaybeOptional<T> {
|
|
||||||
fn get_optional(self) -> Option<T>;
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<T> MaybeOptional<T> for T {
|
|
||||||
fn get_optional(self) -> Option<T> {
|
|
||||||
Some(self)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<T> MaybeOptional<T> for Option<T> {
|
|
||||||
fn get_optional(self) -> Option<T> {
|
|
||||||
self
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub trait ToSafe {
|
|
||||||
type SafeColumns;
|
|
||||||
fn safe_columns_tuple() -> Self::SafeColumns;
|
|
||||||
}
|
|
||||||
|
|
||||||
pub trait ToSafeSettings {
|
|
||||||
type SafeSettingsColumns;
|
|
||||||
fn safe_settings_columns_tuple() -> Self::SafeSettingsColumns;
|
|
||||||
}
|
|
||||||
|
|
||||||
pub trait ViewToVec {
|
|
||||||
type DbTuple;
|
|
||||||
fn from_tuple_to_vec(tuple: Vec<Self::DbTuple>) -> Vec<Self>
|
|
||||||
where
|
|
||||||
Self: Sized;
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn get_database_url_from_env() -> Result<String, VarError> {
|
|
||||||
env::var("LEMMY_DATABASE_URL")
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(EnumString, ToString, Debug, Serialize, Deserialize, Clone, Copy)]
|
|
||||||
pub enum SortType {
|
|
||||||
Active,
|
|
||||||
Hot,
|
|
||||||
New,
|
|
||||||
TopDay,
|
|
||||||
TopWeek,
|
|
||||||
TopMonth,
|
|
||||||
TopYear,
|
|
||||||
TopAll,
|
|
||||||
MostComments,
|
|
||||||
NewComments,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(EnumString, ToString, Debug, Serialize, Deserialize, Clone, Copy)]
|
|
||||||
pub enum ListingType {
|
|
||||||
All,
|
|
||||||
Local,
|
|
||||||
Subscribed,
|
|
||||||
Community,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(EnumString, ToString, Debug, Serialize, Deserialize, Clone, Copy)]
|
|
||||||
pub enum SearchType {
|
|
||||||
All,
|
|
||||||
Comments,
|
|
||||||
Posts,
|
|
||||||
Communities,
|
|
||||||
Users,
|
|
||||||
Url,
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn from_opt_str_to_opt_enum<T: std::str::FromStr>(opt: &Option<String>) -> Option<T> {
|
|
||||||
opt.as_ref().map(|t| T::from_str(t).ok()).flatten()
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn fuzzy_search(q: &str) -> String {
|
|
||||||
let replaced = q.replace(" ", "%");
|
|
||||||
format!("%{}%", replaced)
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn limit_and_offset(page: Option<i64>, limit: Option<i64>) -> (i64, i64) {
|
|
||||||
let page = page.unwrap_or(1);
|
|
||||||
let limit = limit.unwrap_or(10);
|
|
||||||
let offset = limit * (page - 1);
|
|
||||||
(limit, offset)
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn is_email_regex(test: &str) -> bool {
|
|
||||||
EMAIL_REGEX.is_match(test)
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn diesel_option_overwrite(opt: &Option<String>) -> Option<Option<String>> {
|
|
||||||
match opt {
|
|
||||||
// An empty string is an erase
|
|
||||||
Some(unwrapped) => {
|
|
||||||
if !unwrapped.eq("") {
|
|
||||||
Some(Some(unwrapped.to_owned()))
|
|
||||||
} else {
|
|
||||||
Some(None)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
None => None,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn diesel_option_overwrite_to_url(
|
|
||||||
opt: &Option<String>,
|
|
||||||
) -> Result<Option<Option<DbUrl>>, ApiError> {
|
|
||||||
match opt.as_ref().map(|s| s.as_str()) {
|
|
||||||
// An empty string is an erase
|
|
||||||
Some("") => Ok(Some(None)),
|
|
||||||
Some(str_url) => match Url::parse(str_url) {
|
|
||||||
Ok(url) => Ok(Some(Some(url.into()))),
|
|
||||||
Err(e) => Err(ApiError::err("invalid_url", e)),
|
|
||||||
},
|
|
||||||
None => Ok(None),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
embed_migrations!();
|
|
||||||
|
|
||||||
pub fn establish_unpooled_connection() -> PgConnection {
|
|
||||||
let db_url = match get_database_url_from_env() {
|
|
||||||
Ok(url) => url,
|
|
||||||
Err(e) => panic!(
|
|
||||||
"Failed to read database URL from env var LEMMY_DATABASE_URL: {}",
|
|
||||||
e
|
|
||||||
),
|
|
||||||
};
|
|
||||||
let conn =
|
|
||||||
PgConnection::establish(&db_url).unwrap_or_else(|_| panic!("Error connecting to {}", db_url));
|
|
||||||
embedded_migrations::run(&conn).expect("load migrations");
|
|
||||||
conn
|
|
||||||
}
|
|
||||||
|
|
||||||
lazy_static! {
|
|
||||||
static ref EMAIL_REGEX: Regex =
|
|
||||||
Regex::new(r"^[a-zA-Z0-9.!#$%&’*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$")
|
|
||||||
.expect("compile email regex");
|
|
||||||
}
|
|
||||||
|
|
||||||
pub mod functions {
|
|
||||||
use diesel::sql_types::*;
|
|
||||||
|
|
||||||
sql_function! {
|
|
||||||
fn hot_rank(score: BigInt, time: Timestamp) -> Integer;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(test)]
|
|
||||||
mod tests {
|
|
||||||
use super::{fuzzy_search, *};
|
|
||||||
use crate::is_email_regex;
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn test_fuzzy_search() {
|
|
||||||
let test = "This is a fuzzy search";
|
|
||||||
assert_eq!(fuzzy_search(test), "%This%is%a%fuzzy%search%".to_string());
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn test_email() {
|
|
||||||
assert!(is_email_regex("gush@gmail.com"));
|
|
||||||
assert!(!is_email_regex("nada_neutho"));
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn test_diesel_option_overwrite() {
|
|
||||||
assert_eq!(diesel_option_overwrite(&None), None);
|
|
||||||
assert_eq!(diesel_option_overwrite(&Some("".to_string())), Some(None));
|
|
||||||
assert_eq!(
|
|
||||||
diesel_option_overwrite(&Some("test".to_string())),
|
|
||||||
Some(Some("test".to_string()))
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn test_diesel_option_overwrite_to_url() {
|
|
||||||
assert!(matches!(diesel_option_overwrite_to_url(&None), Ok(None)));
|
|
||||||
assert!(matches!(
|
|
||||||
diesel_option_overwrite_to_url(&Some("".to_string())),
|
|
||||||
Ok(Some(None))
|
|
||||||
));
|
|
||||||
assert!(matches!(
|
|
||||||
diesel_option_overwrite_to_url(&Some("invalid_url".to_string())),
|
|
||||||
Err(_)
|
|
||||||
));
|
|
||||||
let example_url = "https://example.com";
|
|
||||||
assert!(matches!(
|
|
||||||
diesel_option_overwrite_to_url(&Some(example_url.to_string())),
|
|
||||||
Ok(Some(Some(url))) if url == Url::parse(example_url).unwrap().into()
|
|
||||||
));
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,19 +0,0 @@
|
|||||||
use diesel::{result::Error, *};
|
|
||||||
use lemmy_db_schema::source::secret::Secret;
|
|
||||||
|
|
||||||
pub trait Secret_ {
|
|
||||||
fn init(conn: &PgConnection) -> Result<Secret, Error>;
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Secret_ for Secret {
|
|
||||||
/// Initialize the Secrets from the DB.
|
|
||||||
/// Warning: You should only call this once.
|
|
||||||
fn init(conn: &PgConnection) -> Result<Secret, Error> {
|
|
||||||
read_secrets(conn)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn read_secrets(conn: &PgConnection) -> Result<Secret, Error> {
|
|
||||||
use lemmy_db_schema::schema::secret::dsl::*;
|
|
||||||
secret.first::<Secret>(conn)
|
|
||||||
}
|
|
@ -14,9 +14,19 @@ doctest = false
|
|||||||
lemmy_utils = { version = "=0.13.0", path = "../utils" }
|
lemmy_utils = { version = "=0.13.0", path = "../utils" }
|
||||||
lemmy_apub_lib = { version = "=0.13.0", path = "../apub_lib" }
|
lemmy_apub_lib = { version = "=0.13.0", path = "../apub_lib" }
|
||||||
diesel = { version = "1.4.8", features = ["postgres","chrono","r2d2","serde_json"] }
|
diesel = { version = "1.4.8", features = ["postgres","chrono","r2d2","serde_json"] }
|
||||||
|
diesel_migrations = "1.4.0"
|
||||||
chrono = { version = "0.4.19", features = ["serde"] }
|
chrono = { version = "0.4.19", features = ["serde"] }
|
||||||
serde = { version = "1.0.130", features = ["derive"] }
|
serde = { version = "1.0.130", features = ["derive"] }
|
||||||
serde_json = { version = "1.0.68", features = ["preserve_order"] }
|
serde_json = { version = "1.0.68", features = ["preserve_order"] }
|
||||||
log = "0.4.14"
|
log = "0.4.14"
|
||||||
url = { version = "2.2.2", features = ["serde"] }
|
url = { version = "2.2.2", features = ["serde"] }
|
||||||
diesel-derive-newtype = "0.1.2"
|
diesel-derive-newtype = "0.1.2"
|
||||||
|
regex = "1.5.4"
|
||||||
|
lazy_static = "1.4.0"
|
||||||
|
strum = "0.21.0"
|
||||||
|
strum_macros = "0.21.1"
|
||||||
|
sha2 = "0.9.8"
|
||||||
|
bcrypt = "0.10.1"
|
||||||
|
|
||||||
|
[dev-dependencies]
|
||||||
|
serial_test = "0.5.1"
|
@ -1,5 +1,5 @@
|
|||||||
|
use crate::{newtypes::CommentId, schema::comment_aggregates};
|
||||||
use diesel::{result::Error, *};
|
use diesel::{result::Error, *};
|
||||||
use lemmy_db_schema::{schema::comment_aggregates, CommentId};
|
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
#[derive(
|
#[derive(
|
||||||
@ -28,14 +28,13 @@ mod tests {
|
|||||||
use crate::{
|
use crate::{
|
||||||
aggregates::comment_aggregates::CommentAggregates,
|
aggregates::comment_aggregates::CommentAggregates,
|
||||||
establish_unpooled_connection,
|
establish_unpooled_connection,
|
||||||
Crud,
|
source::{
|
||||||
Likeable,
|
comment::{Comment, CommentForm, CommentLike, CommentLikeForm},
|
||||||
};
|
community::{Community, CommunityForm},
|
||||||
use lemmy_db_schema::source::{
|
person::{Person, PersonForm},
|
||||||
comment::{Comment, CommentForm, CommentLike, CommentLikeForm},
|
post::{Post, PostForm},
|
||||||
community::{Community, CommunityForm},
|
},
|
||||||
person::{Person, PersonForm},
|
traits::{Crud, Likeable},
|
||||||
post::{Post, PostForm},
|
|
||||||
};
|
};
|
||||||
use serial_test::serial;
|
use serial_test::serial;
|
||||||
|
|
@ -1,5 +1,5 @@
|
|||||||
|
use crate::{newtypes::CommunityId, schema::community_aggregates};
|
||||||
use diesel::{result::Error, *};
|
use diesel::{result::Error, *};
|
||||||
use lemmy_db_schema::{schema::community_aggregates, CommunityId};
|
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
#[derive(
|
#[derive(
|
||||||
@ -32,14 +32,13 @@ mod tests {
|
|||||||
use crate::{
|
use crate::{
|
||||||
aggregates::community_aggregates::CommunityAggregates,
|
aggregates::community_aggregates::CommunityAggregates,
|
||||||
establish_unpooled_connection,
|
establish_unpooled_connection,
|
||||||
Crud,
|
source::{
|
||||||
Followable,
|
comment::{Comment, CommentForm},
|
||||||
};
|
community::{Community, CommunityFollower, CommunityFollowerForm, CommunityForm},
|
||||||
use lemmy_db_schema::source::{
|
person::{Person, PersonForm},
|
||||||
comment::{Comment, CommentForm},
|
post::{Post, PostForm},
|
||||||
community::{Community, CommunityFollower, CommunityFollowerForm, CommunityForm},
|
},
|
||||||
person::{Person, PersonForm},
|
traits::{Crud, Followable},
|
||||||
post::{Post, PostForm},
|
|
||||||
};
|
};
|
||||||
use serial_test::serial;
|
use serial_test::serial;
|
||||||
|
|
@ -1,5 +1,5 @@
|
|||||||
|
use crate::{newtypes::PersonId, schema::person_aggregates};
|
||||||
use diesel::{result::Error, *};
|
use diesel::{result::Error, *};
|
||||||
use lemmy_db_schema::{schema::person_aggregates, PersonId};
|
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
#[derive(
|
#[derive(
|
||||||
@ -28,14 +28,13 @@ mod tests {
|
|||||||
use crate::{
|
use crate::{
|
||||||
aggregates::person_aggregates::PersonAggregates,
|
aggregates::person_aggregates::PersonAggregates,
|
||||||
establish_unpooled_connection,
|
establish_unpooled_connection,
|
||||||
Crud,
|
source::{
|
||||||
Likeable,
|
comment::{Comment, CommentForm, CommentLike, CommentLikeForm},
|
||||||
};
|
community::{Community, CommunityForm},
|
||||||
use lemmy_db_schema::source::{
|
person::{Person, PersonForm},
|
||||||
comment::{Comment, CommentForm, CommentLike, CommentLikeForm},
|
post::{Post, PostForm, PostLike, PostLikeForm},
|
||||||
community::{Community, CommunityForm},
|
},
|
||||||
person::{Person, PersonForm},
|
traits::{Crud, Likeable},
|
||||||
post::{Post, PostForm, PostLike, PostLikeForm},
|
|
||||||
};
|
};
|
||||||
use serial_test::serial;
|
use serial_test::serial;
|
||||||
|
|
@ -1,5 +1,5 @@
|
|||||||
|
use crate::{newtypes::PostId, schema::post_aggregates};
|
||||||
use diesel::{result::Error, *};
|
use diesel::{result::Error, *};
|
||||||
use lemmy_db_schema::{schema::post_aggregates, PostId};
|
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
#[derive(
|
#[derive(
|
||||||
@ -32,14 +32,13 @@ mod tests {
|
|||||||
use crate::{
|
use crate::{
|
||||||
aggregates::post_aggregates::PostAggregates,
|
aggregates::post_aggregates::PostAggregates,
|
||||||
establish_unpooled_connection,
|
establish_unpooled_connection,
|
||||||
Crud,
|
source::{
|
||||||
Likeable,
|
comment::{Comment, CommentForm},
|
||||||
};
|
community::{Community, CommunityForm},
|
||||||
use lemmy_db_schema::source::{
|
person::{Person, PersonForm},
|
||||||
comment::{Comment, CommentForm},
|
post::{Post, PostForm, PostLike, PostLikeForm},
|
||||||
community::{Community, CommunityForm},
|
},
|
||||||
person::{Person, PersonForm},
|
traits::{Crud, Likeable},
|
||||||
post::{Post, PostForm, PostLike, PostLikeForm},
|
|
||||||
};
|
};
|
||||||
use serial_test::serial;
|
use serial_test::serial;
|
||||||
|
|
@ -1,5 +1,5 @@
|
|||||||
|
use crate::schema::site_aggregates;
|
||||||
use diesel::{result::Error, *};
|
use diesel::{result::Error, *};
|
||||||
use lemmy_db_schema::schema::site_aggregates;
|
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
#[derive(
|
#[derive(
|
||||||
@ -27,13 +27,17 @@ impl SiteAggregates {
|
|||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use crate::{aggregates::site_aggregates::SiteAggregates, establish_unpooled_connection, Crud};
|
use crate::{
|
||||||
use lemmy_db_schema::source::{
|
aggregates::site_aggregates::SiteAggregates,
|
||||||
comment::{Comment, CommentForm},
|
establish_unpooled_connection,
|
||||||
community::{Community, CommunityForm},
|
source::{
|
||||||
person::{Person, PersonForm},
|
comment::{Comment, CommentForm},
|
||||||
post::{Post, PostForm},
|
community::{Community, CommunityForm},
|
||||||
site::{Site, SiteForm},
|
person::{Person, PersonForm},
|
||||||
|
post::{Post, PostForm},
|
||||||
|
site::{Site, SiteForm},
|
||||||
|
},
|
||||||
|
traits::Crud,
|
||||||
};
|
};
|
||||||
use serial_test::serial;
|
use serial_test::serial;
|
||||||
|
|
@ -1,6 +1,5 @@
|
|||||||
use crate::Crud;
|
use crate::{newtypes::DbUrl, source::activity::*, traits::Crud};
|
||||||
use diesel::{dsl::*, result::Error, sql_types::Text, *};
|
use diesel::{dsl::*, result::Error, sql_types::Text, *};
|
||||||
use lemmy_db_schema::{source::activity::*, DbUrl};
|
|
||||||
use serde::Serialize;
|
use serde::Serialize;
|
||||||
use serde_json::Value;
|
use serde_json::Value;
|
||||||
use std::{
|
use std::{
|
||||||
@ -12,12 +11,12 @@ impl Crud for Activity {
|
|||||||
type Form = ActivityForm;
|
type Form = ActivityForm;
|
||||||
type IdType = i32;
|
type IdType = i32;
|
||||||
fn read(conn: &PgConnection, activity_id: i32) -> Result<Self, Error> {
|
fn read(conn: &PgConnection, activity_id: i32) -> Result<Self, Error> {
|
||||||
use lemmy_db_schema::schema::activity::dsl::*;
|
use crate::schema::activity::dsl::*;
|
||||||
activity.find(activity_id).first::<Self>(conn)
|
activity.find(activity_id).first::<Self>(conn)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn create(conn: &PgConnection, new_activity: &ActivityForm) -> Result<Self, Error> {
|
fn create(conn: &PgConnection, new_activity: &ActivityForm) -> Result<Self, Error> {
|
||||||
use lemmy_db_schema::schema::activity::dsl::*;
|
use crate::schema::activity::dsl::*;
|
||||||
insert_into(activity)
|
insert_into(activity)
|
||||||
.values(new_activity)
|
.values(new_activity)
|
||||||
.get_result::<Self>(conn)
|
.get_result::<Self>(conn)
|
||||||
@ -28,40 +27,19 @@ impl Crud for Activity {
|
|||||||
activity_id: i32,
|
activity_id: i32,
|
||||||
new_activity: &ActivityForm,
|
new_activity: &ActivityForm,
|
||||||
) -> Result<Self, Error> {
|
) -> Result<Self, Error> {
|
||||||
use lemmy_db_schema::schema::activity::dsl::*;
|
use crate::schema::activity::dsl::*;
|
||||||
diesel::update(activity.find(activity_id))
|
diesel::update(activity.find(activity_id))
|
||||||
.set(new_activity)
|
.set(new_activity)
|
||||||
.get_result::<Self>(conn)
|
.get_result::<Self>(conn)
|
||||||
}
|
}
|
||||||
fn delete(conn: &PgConnection, activity_id: i32) -> Result<usize, Error> {
|
fn delete(conn: &PgConnection, activity_id: i32) -> Result<usize, Error> {
|
||||||
use lemmy_db_schema::schema::activity::dsl::*;
|
use crate::schema::activity::dsl::*;
|
||||||
diesel::delete(activity.find(activity_id)).execute(conn)
|
diesel::delete(activity.find(activity_id)).execute(conn)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub trait Activity_ {
|
impl Activity {
|
||||||
fn insert<T>(
|
pub fn insert<T>(
|
||||||
conn: &PgConnection,
|
|
||||||
ap_id: DbUrl,
|
|
||||||
data: &T,
|
|
||||||
local: bool,
|
|
||||||
sensitive: bool,
|
|
||||||
) -> Result<Activity, IoError>
|
|
||||||
where
|
|
||||||
T: Serialize + Debug;
|
|
||||||
|
|
||||||
fn read_from_apub_id(conn: &PgConnection, object_id: &DbUrl) -> Result<Activity, Error>;
|
|
||||||
fn delete_olds(conn: &PgConnection) -> Result<usize, Error>;
|
|
||||||
|
|
||||||
/// Returns up to 20 activities of type `Announce/Create/Page` from the community
|
|
||||||
fn read_community_outbox(
|
|
||||||
conn: &PgConnection,
|
|
||||||
community_actor_id: &DbUrl,
|
|
||||||
) -> Result<Vec<Value>, Error>;
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Activity_ for Activity {
|
|
||||||
fn insert<T>(
|
|
||||||
conn: &PgConnection,
|
conn: &PgConnection,
|
||||||
ap_id: DbUrl,
|
ap_id: DbUrl,
|
||||||
data: &T,
|
data: &T,
|
||||||
@ -88,21 +66,21 @@ impl Activity_ for Activity {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn read_from_apub_id(conn: &PgConnection, object_id: &DbUrl) -> Result<Activity, Error> {
|
pub fn read_from_apub_id(conn: &PgConnection, object_id: &DbUrl) -> Result<Activity, Error> {
|
||||||
use lemmy_db_schema::schema::activity::dsl::*;
|
use crate::schema::activity::dsl::*;
|
||||||
activity.filter(ap_id.eq(object_id)).first::<Self>(conn)
|
activity.filter(ap_id.eq(object_id)).first::<Self>(conn)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn delete_olds(conn: &PgConnection) -> Result<usize, Error> {
|
pub fn delete_olds(conn: &PgConnection) -> Result<usize, Error> {
|
||||||
use lemmy_db_schema::schema::activity::dsl::*;
|
use crate::schema::activity::dsl::*;
|
||||||
diesel::delete(activity.filter(published.lt(now - 6.months()))).execute(conn)
|
diesel::delete(activity.filter(published.lt(now - 6.months()))).execute(conn)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn read_community_outbox(
|
pub fn read_community_outbox(
|
||||||
conn: &PgConnection,
|
conn: &PgConnection,
|
||||||
community_actor_id: &DbUrl,
|
community_actor_id: &DbUrl,
|
||||||
) -> Result<Vec<Value>, Error> {
|
) -> Result<Vec<Value>, Error> {
|
||||||
use lemmy_db_schema::schema::activity::dsl::*;
|
use crate::schema::activity::dsl::*;
|
||||||
let res: Vec<Value> = activity
|
let res: Vec<Value> = activity
|
||||||
.select(data)
|
.select(data)
|
||||||
.filter(
|
.filter(
|
||||||
@ -122,10 +100,13 @@ impl Activity_ for Activity {
|
|||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
use crate::{establish_unpooled_connection, source::activity::Activity_};
|
use crate::{
|
||||||
use lemmy_db_schema::source::{
|
establish_unpooled_connection,
|
||||||
activity::{Activity, ActivityForm},
|
newtypes::DbUrl,
|
||||||
person::{Person, PersonForm},
|
source::{
|
||||||
|
activity::{Activity, ActivityForm},
|
||||||
|
person::{Person, PersonForm},
|
||||||
|
},
|
||||||
};
|
};
|
||||||
use serde_json::Value;
|
use serde_json::Value;
|
||||||
use serial_test::serial;
|
use serial_test::serial;
|
@ -1,7 +1,6 @@
|
|||||||
use crate::{Crud, DeleteableOrRemoveable, Likeable, Saveable};
|
use crate::{
|
||||||
use diesel::{dsl::*, result::Error, *};
|
|
||||||
use lemmy_db_schema::{
|
|
||||||
naive_now,
|
naive_now,
|
||||||
|
newtypes::{CommentId, DbUrl, PersonId},
|
||||||
source::comment::{
|
source::comment::{
|
||||||
Comment,
|
Comment,
|
||||||
CommentForm,
|
CommentForm,
|
||||||
@ -10,67 +9,32 @@ use lemmy_db_schema::{
|
|||||||
CommentSaved,
|
CommentSaved,
|
||||||
CommentSavedForm,
|
CommentSavedForm,
|
||||||
},
|
},
|
||||||
CommentId,
|
traits::{Crud, DeleteableOrRemoveable, Likeable, Saveable},
|
||||||
DbUrl,
|
|
||||||
PersonId,
|
|
||||||
};
|
};
|
||||||
|
use chrono::NaiveDateTime;
|
||||||
|
use diesel::{dsl::*, result::Error, *};
|
||||||
|
use lemmy_apub_lib::traits::ApubObject;
|
||||||
|
use lemmy_utils::LemmyError;
|
||||||
|
use url::Url;
|
||||||
|
|
||||||
pub trait Comment_ {
|
impl Comment {
|
||||||
fn update_ap_id(
|
pub fn update_ap_id(
|
||||||
conn: &PgConnection,
|
|
||||||
comment_id: CommentId,
|
|
||||||
apub_id: DbUrl,
|
|
||||||
) -> Result<Comment, Error>;
|
|
||||||
fn permadelete_for_creator(
|
|
||||||
conn: &PgConnection,
|
|
||||||
for_creator_id: PersonId,
|
|
||||||
) -> Result<Vec<Comment>, Error>;
|
|
||||||
fn update_deleted(
|
|
||||||
conn: &PgConnection,
|
|
||||||
comment_id: CommentId,
|
|
||||||
new_deleted: bool,
|
|
||||||
) -> Result<Comment, Error>;
|
|
||||||
fn update_removed(
|
|
||||||
conn: &PgConnection,
|
|
||||||
comment_id: CommentId,
|
|
||||||
new_removed: bool,
|
|
||||||
) -> Result<Comment, Error>;
|
|
||||||
fn update_removed_for_creator(
|
|
||||||
conn: &PgConnection,
|
|
||||||
for_creator_id: PersonId,
|
|
||||||
new_removed: bool,
|
|
||||||
) -> Result<Vec<Comment>, Error>;
|
|
||||||
fn update_read(
|
|
||||||
conn: &PgConnection,
|
|
||||||
comment_id: CommentId,
|
|
||||||
new_read: bool,
|
|
||||||
) -> Result<Comment, Error>;
|
|
||||||
fn update_content(
|
|
||||||
conn: &PgConnection,
|
|
||||||
comment_id: CommentId,
|
|
||||||
new_content: &str,
|
|
||||||
) -> Result<Comment, Error>;
|
|
||||||
fn upsert(conn: &PgConnection, comment_form: &CommentForm) -> Result<Comment, Error>;
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Comment_ for Comment {
|
|
||||||
fn update_ap_id(
|
|
||||||
conn: &PgConnection,
|
conn: &PgConnection,
|
||||||
comment_id: CommentId,
|
comment_id: CommentId,
|
||||||
apub_id: DbUrl,
|
apub_id: DbUrl,
|
||||||
) -> Result<Self, Error> {
|
) -> Result<Self, Error> {
|
||||||
use lemmy_db_schema::schema::comment::dsl::*;
|
use crate::schema::comment::dsl::*;
|
||||||
|
|
||||||
diesel::update(comment.find(comment_id))
|
diesel::update(comment.find(comment_id))
|
||||||
.set(ap_id.eq(apub_id))
|
.set(ap_id.eq(apub_id))
|
||||||
.get_result::<Self>(conn)
|
.get_result::<Self>(conn)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn permadelete_for_creator(
|
pub fn permadelete_for_creator(
|
||||||
conn: &PgConnection,
|
conn: &PgConnection,
|
||||||
for_creator_id: PersonId,
|
for_creator_id: PersonId,
|
||||||
) -> Result<Vec<Self>, Error> {
|
) -> Result<Vec<Self>, Error> {
|
||||||
use lemmy_db_schema::schema::comment::dsl::*;
|
use crate::schema::comment::dsl::*;
|
||||||
diesel::update(comment.filter(creator_id.eq(for_creator_id)))
|
diesel::update(comment.filter(creator_id.eq(for_creator_id)))
|
||||||
.set((
|
.set((
|
||||||
content.eq("*Permananently Deleted*"),
|
content.eq("*Permananently Deleted*"),
|
||||||
@ -80,63 +44,63 @@ impl Comment_ for Comment {
|
|||||||
.get_results::<Self>(conn)
|
.get_results::<Self>(conn)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn update_deleted(
|
pub fn update_deleted(
|
||||||
conn: &PgConnection,
|
conn: &PgConnection,
|
||||||
comment_id: CommentId,
|
comment_id: CommentId,
|
||||||
new_deleted: bool,
|
new_deleted: bool,
|
||||||
) -> Result<Self, Error> {
|
) -> Result<Self, Error> {
|
||||||
use lemmy_db_schema::schema::comment::dsl::*;
|
use crate::schema::comment::dsl::*;
|
||||||
diesel::update(comment.find(comment_id))
|
diesel::update(comment.find(comment_id))
|
||||||
.set((deleted.eq(new_deleted), updated.eq(naive_now())))
|
.set((deleted.eq(new_deleted), updated.eq(naive_now())))
|
||||||
.get_result::<Self>(conn)
|
.get_result::<Self>(conn)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn update_removed(
|
pub fn update_removed(
|
||||||
conn: &PgConnection,
|
conn: &PgConnection,
|
||||||
comment_id: CommentId,
|
comment_id: CommentId,
|
||||||
new_removed: bool,
|
new_removed: bool,
|
||||||
) -> Result<Self, Error> {
|
) -> Result<Self, Error> {
|
||||||
use lemmy_db_schema::schema::comment::dsl::*;
|
use crate::schema::comment::dsl::*;
|
||||||
diesel::update(comment.find(comment_id))
|
diesel::update(comment.find(comment_id))
|
||||||
.set((removed.eq(new_removed), updated.eq(naive_now())))
|
.set((removed.eq(new_removed), updated.eq(naive_now())))
|
||||||
.get_result::<Self>(conn)
|
.get_result::<Self>(conn)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn update_removed_for_creator(
|
pub fn update_removed_for_creator(
|
||||||
conn: &PgConnection,
|
conn: &PgConnection,
|
||||||
for_creator_id: PersonId,
|
for_creator_id: PersonId,
|
||||||
new_removed: bool,
|
new_removed: bool,
|
||||||
) -> Result<Vec<Self>, Error> {
|
) -> Result<Vec<Self>, Error> {
|
||||||
use lemmy_db_schema::schema::comment::dsl::*;
|
use crate::schema::comment::dsl::*;
|
||||||
diesel::update(comment.filter(creator_id.eq(for_creator_id)))
|
diesel::update(comment.filter(creator_id.eq(for_creator_id)))
|
||||||
.set((removed.eq(new_removed), updated.eq(naive_now())))
|
.set((removed.eq(new_removed), updated.eq(naive_now())))
|
||||||
.get_results::<Self>(conn)
|
.get_results::<Self>(conn)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn update_read(
|
pub fn update_read(
|
||||||
conn: &PgConnection,
|
conn: &PgConnection,
|
||||||
comment_id: CommentId,
|
comment_id: CommentId,
|
||||||
new_read: bool,
|
new_read: bool,
|
||||||
) -> Result<Self, Error> {
|
) -> Result<Self, Error> {
|
||||||
use lemmy_db_schema::schema::comment::dsl::*;
|
use crate::schema::comment::dsl::*;
|
||||||
diesel::update(comment.find(comment_id))
|
diesel::update(comment.find(comment_id))
|
||||||
.set(read.eq(new_read))
|
.set(read.eq(new_read))
|
||||||
.get_result::<Self>(conn)
|
.get_result::<Self>(conn)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn update_content(
|
pub fn update_content(
|
||||||
conn: &PgConnection,
|
conn: &PgConnection,
|
||||||
comment_id: CommentId,
|
comment_id: CommentId,
|
||||||
new_content: &str,
|
new_content: &str,
|
||||||
) -> Result<Self, Error> {
|
) -> Result<Self, Error> {
|
||||||
use lemmy_db_schema::schema::comment::dsl::*;
|
use crate::schema::comment::dsl::*;
|
||||||
diesel::update(comment.find(comment_id))
|
diesel::update(comment.find(comment_id))
|
||||||
.set((content.eq(new_content), updated.eq(naive_now())))
|
.set((content.eq(new_content), updated.eq(naive_now())))
|
||||||
.get_result::<Self>(conn)
|
.get_result::<Self>(conn)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn upsert(conn: &PgConnection, comment_form: &CommentForm) -> Result<Comment, Error> {
|
pub fn upsert(conn: &PgConnection, comment_form: &CommentForm) -> Result<Comment, Error> {
|
||||||
use lemmy_db_schema::schema::comment::dsl::*;
|
use crate::schema::comment::dsl::*;
|
||||||
insert_into(comment)
|
insert_into(comment)
|
||||||
.values(comment_form)
|
.values(comment_form)
|
||||||
.on_conflict(ap_id)
|
.on_conflict(ap_id)
|
||||||
@ -150,17 +114,17 @@ impl Crud for Comment {
|
|||||||
type Form = CommentForm;
|
type Form = CommentForm;
|
||||||
type IdType = CommentId;
|
type IdType = CommentId;
|
||||||
fn read(conn: &PgConnection, comment_id: CommentId) -> Result<Self, Error> {
|
fn read(conn: &PgConnection, comment_id: CommentId) -> Result<Self, Error> {
|
||||||
use lemmy_db_schema::schema::comment::dsl::*;
|
use crate::schema::comment::dsl::*;
|
||||||
comment.find(comment_id).first::<Self>(conn)
|
comment.find(comment_id).first::<Self>(conn)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn delete(conn: &PgConnection, comment_id: CommentId) -> Result<usize, Error> {
|
fn delete(conn: &PgConnection, comment_id: CommentId) -> Result<usize, Error> {
|
||||||
use lemmy_db_schema::schema::comment::dsl::*;
|
use crate::schema::comment::dsl::*;
|
||||||
diesel::delete(comment.find(comment_id)).execute(conn)
|
diesel::delete(comment.find(comment_id)).execute(conn)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn create(conn: &PgConnection, comment_form: &CommentForm) -> Result<Self, Error> {
|
fn create(conn: &PgConnection, comment_form: &CommentForm) -> Result<Self, Error> {
|
||||||
use lemmy_db_schema::schema::comment::dsl::*;
|
use crate::schema::comment::dsl::*;
|
||||||
insert_into(comment)
|
insert_into(comment)
|
||||||
.values(comment_form)
|
.values(comment_form)
|
||||||
.get_result::<Self>(conn)
|
.get_result::<Self>(conn)
|
||||||
@ -171,7 +135,7 @@ impl Crud for Comment {
|
|||||||
comment_id: CommentId,
|
comment_id: CommentId,
|
||||||
comment_form: &CommentForm,
|
comment_form: &CommentForm,
|
||||||
) -> Result<Self, Error> {
|
) -> Result<Self, Error> {
|
||||||
use lemmy_db_schema::schema::comment::dsl::*;
|
use crate::schema::comment::dsl::*;
|
||||||
diesel::update(comment.find(comment_id))
|
diesel::update(comment.find(comment_id))
|
||||||
.set(comment_form)
|
.set(comment_form)
|
||||||
.get_result::<Self>(conn)
|
.get_result::<Self>(conn)
|
||||||
@ -182,7 +146,7 @@ impl Likeable for CommentLike {
|
|||||||
type Form = CommentLikeForm;
|
type Form = CommentLikeForm;
|
||||||
type IdType = CommentId;
|
type IdType = CommentId;
|
||||||
fn like(conn: &PgConnection, comment_like_form: &CommentLikeForm) -> Result<Self, Error> {
|
fn like(conn: &PgConnection, comment_like_form: &CommentLikeForm) -> Result<Self, Error> {
|
||||||
use lemmy_db_schema::schema::comment_like::dsl::*;
|
use crate::schema::comment_like::dsl::*;
|
||||||
insert_into(comment_like)
|
insert_into(comment_like)
|
||||||
.values(comment_like_form)
|
.values(comment_like_form)
|
||||||
.on_conflict((comment_id, person_id))
|
.on_conflict((comment_id, person_id))
|
||||||
@ -195,7 +159,7 @@ impl Likeable for CommentLike {
|
|||||||
person_id: PersonId,
|
person_id: PersonId,
|
||||||
comment_id: CommentId,
|
comment_id: CommentId,
|
||||||
) -> Result<usize, Error> {
|
) -> Result<usize, Error> {
|
||||||
use lemmy_db_schema::schema::comment_like::dsl;
|
use crate::schema::comment_like::dsl;
|
||||||
diesel::delete(
|
diesel::delete(
|
||||||
dsl::comment_like
|
dsl::comment_like
|
||||||
.filter(dsl::comment_id.eq(comment_id))
|
.filter(dsl::comment_id.eq(comment_id))
|
||||||
@ -208,7 +172,7 @@ impl Likeable for CommentLike {
|
|||||||
impl Saveable for CommentSaved {
|
impl Saveable for CommentSaved {
|
||||||
type Form = CommentSavedForm;
|
type Form = CommentSavedForm;
|
||||||
fn save(conn: &PgConnection, comment_saved_form: &CommentSavedForm) -> Result<Self, Error> {
|
fn save(conn: &PgConnection, comment_saved_form: &CommentSavedForm) -> Result<Self, Error> {
|
||||||
use lemmy_db_schema::schema::comment_saved::dsl::*;
|
use crate::schema::comment_saved::dsl::*;
|
||||||
insert_into(comment_saved)
|
insert_into(comment_saved)
|
||||||
.values(comment_saved_form)
|
.values(comment_saved_form)
|
||||||
.on_conflict((comment_id, person_id))
|
.on_conflict((comment_id, person_id))
|
||||||
@ -217,7 +181,7 @@ impl Saveable for CommentSaved {
|
|||||||
.get_result::<Self>(conn)
|
.get_result::<Self>(conn)
|
||||||
}
|
}
|
||||||
fn unsave(conn: &PgConnection, comment_saved_form: &CommentSavedForm) -> Result<usize, Error> {
|
fn unsave(conn: &PgConnection, comment_saved_form: &CommentSavedForm) -> Result<usize, Error> {
|
||||||
use lemmy_db_schema::schema::comment_saved::dsl::*;
|
use crate::schema::comment_saved::dsl::*;
|
||||||
diesel::delete(
|
diesel::delete(
|
||||||
comment_saved
|
comment_saved
|
||||||
.filter(comment_id.eq(comment_saved_form.comment_id))
|
.filter(comment_id.eq(comment_saved_form.comment_id))
|
||||||
@ -234,14 +198,36 @@ impl DeleteableOrRemoveable for Comment {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl ApubObject for Comment {
|
||||||
|
type DataType = PgConnection;
|
||||||
|
|
||||||
|
fn last_refreshed_at(&self) -> Option<NaiveDateTime> {
|
||||||
|
None
|
||||||
|
}
|
||||||
|
|
||||||
|
fn read_from_apub_id(conn: &PgConnection, object_id: Url) -> Result<Option<Self>, LemmyError> {
|
||||||
|
use crate::schema::comment::dsl::*;
|
||||||
|
let object_id: DbUrl = object_id.into();
|
||||||
|
Ok(comment.filter(ap_id.eq(object_id)).first::<Self>(conn).ok())
|
||||||
|
}
|
||||||
|
|
||||||
|
fn delete(self, conn: &PgConnection) -> Result<(), LemmyError> {
|
||||||
|
Comment::update_deleted(conn, self.id, true)?;
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use crate::{establish_unpooled_connection, Crud, Likeable, Saveable};
|
use crate::{
|
||||||
use lemmy_db_schema::source::{
|
establish_unpooled_connection,
|
||||||
comment::*,
|
source::{
|
||||||
community::{Community, CommunityForm},
|
comment::*,
|
||||||
person::{Person, PersonForm},
|
community::{Community, CommunityForm},
|
||||||
post::*,
|
person::{Person, PersonForm},
|
||||||
|
post::*,
|
||||||
|
},
|
||||||
|
traits::{Crud, Likeable, Saveable},
|
||||||
};
|
};
|
||||||
use serial_test::serial;
|
use serial_test::serial;
|
||||||
|
|
@ -1,11 +1,10 @@
|
|||||||
use crate::Reportable;
|
use crate::{
|
||||||
use diesel::{dsl::*, result::Error, *};
|
|
||||||
use lemmy_db_schema::{
|
|
||||||
naive_now,
|
naive_now,
|
||||||
|
newtypes::{CommentReportId, PersonId},
|
||||||
source::comment_report::{CommentReport, CommentReportForm},
|
source::comment_report::{CommentReport, CommentReportForm},
|
||||||
CommentReportId,
|
traits::Reportable,
|
||||||
PersonId,
|
|
||||||
};
|
};
|
||||||
|
use diesel::{dsl::*, result::Error, *};
|
||||||
|
|
||||||
impl Reportable for CommentReport {
|
impl Reportable for CommentReport {
|
||||||
type Form = CommentReportForm;
|
type Form = CommentReportForm;
|
||||||
@ -15,7 +14,7 @@ impl Reportable for CommentReport {
|
|||||||
/// * `conn` - the postgres connection
|
/// * `conn` - the postgres connection
|
||||||
/// * `comment_report_form` - the filled CommentReportForm to insert
|
/// * `comment_report_form` - the filled CommentReportForm to insert
|
||||||
fn report(conn: &PgConnection, comment_report_form: &CommentReportForm) -> Result<Self, Error> {
|
fn report(conn: &PgConnection, comment_report_form: &CommentReportForm) -> Result<Self, Error> {
|
||||||
use lemmy_db_schema::schema::comment_report::dsl::*;
|
use crate::schema::comment_report::dsl::*;
|
||||||
insert_into(comment_report)
|
insert_into(comment_report)
|
||||||
.values(comment_report_form)
|
.values(comment_report_form)
|
||||||
.get_result::<Self>(conn)
|
.get_result::<Self>(conn)
|
||||||
@ -31,7 +30,7 @@ impl Reportable for CommentReport {
|
|||||||
report_id: Self::IdType,
|
report_id: Self::IdType,
|
||||||
by_resolver_id: PersonId,
|
by_resolver_id: PersonId,
|
||||||
) -> Result<usize, Error> {
|
) -> Result<usize, Error> {
|
||||||
use lemmy_db_schema::schema::comment_report::dsl::*;
|
use crate::schema::comment_report::dsl::*;
|
||||||
update(comment_report.find(report_id))
|
update(comment_report.find(report_id))
|
||||||
.set((
|
.set((
|
||||||
resolved.eq(true),
|
resolved.eq(true),
|
||||||
@ -51,7 +50,7 @@ impl Reportable for CommentReport {
|
|||||||
report_id: Self::IdType,
|
report_id: Self::IdType,
|
||||||
by_resolver_id: PersonId,
|
by_resolver_id: PersonId,
|
||||||
) -> Result<usize, Error> {
|
) -> Result<usize, Error> {
|
||||||
use lemmy_db_schema::schema::comment_report::dsl::*;
|
use crate::schema::comment_report::dsl::*;
|
||||||
update(comment_report.find(report_id))
|
update(comment_report.find(report_id))
|
||||||
.set((
|
.set((
|
||||||
resolved.eq(false),
|
resolved.eq(false),
|
@ -1,7 +1,6 @@
|
|||||||
use crate::{Bannable, Crud, DeleteableOrRemoveable, Followable, Joinable};
|
use crate::{
|
||||||
use diesel::{dsl::*, result::Error, *};
|
|
||||||
use lemmy_db_schema::{
|
|
||||||
naive_now,
|
naive_now,
|
||||||
|
newtypes::{CommunityId, DbUrl, PersonId},
|
||||||
source::community::{
|
source::community::{
|
||||||
Community,
|
Community,
|
||||||
CommunityFollower,
|
CommunityFollower,
|
||||||
@ -13,14 +12,16 @@ use lemmy_db_schema::{
|
|||||||
CommunityPersonBanForm,
|
CommunityPersonBanForm,
|
||||||
CommunitySafe,
|
CommunitySafe,
|
||||||
},
|
},
|
||||||
CommunityId,
|
traits::{Bannable, Crud, DeleteableOrRemoveable, Followable, Joinable},
|
||||||
DbUrl,
|
|
||||||
PersonId,
|
|
||||||
};
|
};
|
||||||
|
use chrono::NaiveDateTime;
|
||||||
|
use diesel::{dsl::*, result::Error, ExpressionMethods, PgConnection, QueryDsl, RunQueryDsl};
|
||||||
|
use lemmy_apub_lib::traits::{ActorType, ApubObject};
|
||||||
|
use lemmy_utils::LemmyError;
|
||||||
|
use url::Url;
|
||||||
|
|
||||||
mod safe_type {
|
mod safe_type {
|
||||||
use crate::{source::community::Community, ToSafe};
|
use crate::{schema::community::*, source::community::Community, traits::ToSafe};
|
||||||
use lemmy_db_schema::schema::community::*;
|
|
||||||
|
|
||||||
type Columns = (
|
type Columns = (
|
||||||
id,
|
id,
|
||||||
@ -64,17 +65,17 @@ impl Crud for Community {
|
|||||||
type Form = CommunityForm;
|
type Form = CommunityForm;
|
||||||
type IdType = CommunityId;
|
type IdType = CommunityId;
|
||||||
fn read(conn: &PgConnection, community_id: CommunityId) -> Result<Self, Error> {
|
fn read(conn: &PgConnection, community_id: CommunityId) -> Result<Self, Error> {
|
||||||
use lemmy_db_schema::schema::community::dsl::*;
|
use crate::schema::community::dsl::*;
|
||||||
community.find(community_id).first::<Self>(conn)
|
community.find(community_id).first::<Self>(conn)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn delete(conn: &PgConnection, community_id: CommunityId) -> Result<usize, Error> {
|
fn delete(conn: &PgConnection, community_id: CommunityId) -> Result<usize, Error> {
|
||||||
use lemmy_db_schema::schema::community::dsl::*;
|
use crate::schema::community::dsl::*;
|
||||||
diesel::delete(community.find(community_id)).execute(conn)
|
diesel::delete(community.find(community_id)).execute(conn)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn create(conn: &PgConnection, new_community: &CommunityForm) -> Result<Self, Error> {
|
fn create(conn: &PgConnection, new_community: &CommunityForm) -> Result<Self, Error> {
|
||||||
use lemmy_db_schema::schema::community::dsl::*;
|
use crate::schema::community::dsl::*;
|
||||||
insert_into(community)
|
insert_into(community)
|
||||||
.values(new_community)
|
.values(new_community)
|
||||||
.get_result::<Self>(conn)
|
.get_result::<Self>(conn)
|
||||||
@ -85,81 +86,61 @@ impl Crud for Community {
|
|||||||
community_id: CommunityId,
|
community_id: CommunityId,
|
||||||
new_community: &CommunityForm,
|
new_community: &CommunityForm,
|
||||||
) -> Result<Self, Error> {
|
) -> Result<Self, Error> {
|
||||||
use lemmy_db_schema::schema::community::dsl::*;
|
use crate::schema::community::dsl::*;
|
||||||
diesel::update(community.find(community_id))
|
diesel::update(community.find(community_id))
|
||||||
.set(new_community)
|
.set(new_community)
|
||||||
.get_result::<Self>(conn)
|
.get_result::<Self>(conn)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub trait Community_ {
|
impl Community {
|
||||||
fn read_from_name(conn: &PgConnection, community_name: &str) -> Result<Community, Error>;
|
pub fn read_from_name(conn: &PgConnection, community_name: &str) -> Result<Community, Error> {
|
||||||
fn update_deleted(
|
use crate::schema::community::dsl::*;
|
||||||
conn: &PgConnection,
|
|
||||||
community_id: CommunityId,
|
|
||||||
new_deleted: bool,
|
|
||||||
) -> Result<Community, Error>;
|
|
||||||
fn update_removed(
|
|
||||||
conn: &PgConnection,
|
|
||||||
community_id: CommunityId,
|
|
||||||
new_removed: bool,
|
|
||||||
) -> Result<Community, Error>;
|
|
||||||
fn distinct_federated_communities(conn: &PgConnection) -> Result<Vec<String>, Error>;
|
|
||||||
fn read_from_followers_url(
|
|
||||||
conn: &PgConnection,
|
|
||||||
followers_url: &DbUrl,
|
|
||||||
) -> Result<Community, Error>;
|
|
||||||
fn upsert(conn: &PgConnection, community_form: &CommunityForm) -> Result<Community, Error>;
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Community_ for Community {
|
|
||||||
fn read_from_name(conn: &PgConnection, community_name: &str) -> Result<Community, Error> {
|
|
||||||
use lemmy_db_schema::schema::community::dsl::*;
|
|
||||||
community
|
community
|
||||||
.filter(local.eq(true))
|
.filter(local.eq(true))
|
||||||
.filter(name.eq(community_name))
|
.filter(name.eq(community_name))
|
||||||
.first::<Self>(conn)
|
.first::<Self>(conn)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn update_deleted(
|
pub fn update_deleted(
|
||||||
conn: &PgConnection,
|
conn: &PgConnection,
|
||||||
community_id: CommunityId,
|
community_id: CommunityId,
|
||||||
new_deleted: bool,
|
new_deleted: bool,
|
||||||
) -> Result<Community, Error> {
|
) -> Result<Community, Error> {
|
||||||
use lemmy_db_schema::schema::community::dsl::*;
|
use crate::schema::community::dsl::*;
|
||||||
diesel::update(community.find(community_id))
|
diesel::update(community.find(community_id))
|
||||||
.set((deleted.eq(new_deleted), updated.eq(naive_now())))
|
.set((deleted.eq(new_deleted), updated.eq(naive_now())))
|
||||||
.get_result::<Self>(conn)
|
.get_result::<Self>(conn)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn update_removed(
|
pub fn update_removed(
|
||||||
conn: &PgConnection,
|
conn: &PgConnection,
|
||||||
community_id: CommunityId,
|
community_id: CommunityId,
|
||||||
new_removed: bool,
|
new_removed: bool,
|
||||||
) -> Result<Community, Error> {
|
) -> Result<Community, Error> {
|
||||||
use lemmy_db_schema::schema::community::dsl::*;
|
use crate::schema::community::dsl::*;
|
||||||
diesel::update(community.find(community_id))
|
diesel::update(community.find(community_id))
|
||||||
.set((removed.eq(new_removed), updated.eq(naive_now())))
|
.set((removed.eq(new_removed), updated.eq(naive_now())))
|
||||||
.get_result::<Self>(conn)
|
.get_result::<Self>(conn)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn distinct_federated_communities(conn: &PgConnection) -> Result<Vec<String>, Error> {
|
pub fn distinct_federated_communities(conn: &PgConnection) -> Result<Vec<String>, Error> {
|
||||||
use lemmy_db_schema::schema::community::dsl::*;
|
use crate::schema::community::dsl::*;
|
||||||
community.select(actor_id).distinct().load::<String>(conn)
|
community.select(actor_id).distinct().load::<String>(conn)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn read_from_followers_url(
|
pub fn read_from_followers_url(
|
||||||
conn: &PgConnection,
|
conn: &PgConnection,
|
||||||
followers_url_: &DbUrl,
|
followers_url_: &DbUrl,
|
||||||
) -> Result<Community, Error> {
|
) -> Result<Community, Error> {
|
||||||
use lemmy_db_schema::schema::community::dsl::*;
|
use crate::schema::community::dsl::*;
|
||||||
community
|
community
|
||||||
.filter(followers_url.eq(followers_url_))
|
.filter(followers_url.eq(followers_url_))
|
||||||
.first::<Self>(conn)
|
.first::<Self>(conn)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn upsert(conn: &PgConnection, community_form: &CommunityForm) -> Result<Community, Error> {
|
pub fn upsert(conn: &PgConnection, community_form: &CommunityForm) -> Result<Community, Error> {
|
||||||
use lemmy_db_schema::schema::community::dsl::*;
|
use crate::schema::community::dsl::*;
|
||||||
insert_into(community)
|
insert_into(community)
|
||||||
.values(community_form)
|
.values(community_form)
|
||||||
.on_conflict(actor_id)
|
.on_conflict(actor_id)
|
||||||
@ -175,7 +156,7 @@ impl Joinable for CommunityModerator {
|
|||||||
conn: &PgConnection,
|
conn: &PgConnection,
|
||||||
community_moderator_form: &CommunityModeratorForm,
|
community_moderator_form: &CommunityModeratorForm,
|
||||||
) -> Result<Self, Error> {
|
) -> Result<Self, Error> {
|
||||||
use lemmy_db_schema::schema::community_moderator::dsl::*;
|
use crate::schema::community_moderator::dsl::*;
|
||||||
insert_into(community_moderator)
|
insert_into(community_moderator)
|
||||||
.values(community_moderator_form)
|
.values(community_moderator_form)
|
||||||
.get_result::<Self>(conn)
|
.get_result::<Self>(conn)
|
||||||
@ -185,7 +166,7 @@ impl Joinable for CommunityModerator {
|
|||||||
conn: &PgConnection,
|
conn: &PgConnection,
|
||||||
community_moderator_form: &CommunityModeratorForm,
|
community_moderator_form: &CommunityModeratorForm,
|
||||||
) -> Result<usize, Error> {
|
) -> Result<usize, Error> {
|
||||||
use lemmy_db_schema::schema::community_moderator::dsl::*;
|
use crate::schema::community_moderator::dsl::*;
|
||||||
diesel::delete(
|
diesel::delete(
|
||||||
community_moderator
|
community_moderator
|
||||||
.filter(community_id.eq(community_moderator_form.community_id))
|
.filter(community_id.eq(community_moderator_form.community_id))
|
||||||
@ -215,31 +196,20 @@ impl DeleteableOrRemoveable for Community {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub trait CommunityModerator_ {
|
impl CommunityModerator {
|
||||||
fn delete_for_community(
|
pub fn delete_for_community(
|
||||||
conn: &PgConnection,
|
|
||||||
for_community_id: CommunityId,
|
|
||||||
) -> Result<usize, Error>;
|
|
||||||
fn get_person_moderated_communities(
|
|
||||||
conn: &PgConnection,
|
|
||||||
for_person_id: PersonId,
|
|
||||||
) -> Result<Vec<CommunityId>, Error>;
|
|
||||||
}
|
|
||||||
|
|
||||||
impl CommunityModerator_ for CommunityModerator {
|
|
||||||
fn delete_for_community(
|
|
||||||
conn: &PgConnection,
|
conn: &PgConnection,
|
||||||
for_community_id: CommunityId,
|
for_community_id: CommunityId,
|
||||||
) -> Result<usize, Error> {
|
) -> Result<usize, Error> {
|
||||||
use lemmy_db_schema::schema::community_moderator::dsl::*;
|
use crate::schema::community_moderator::dsl::*;
|
||||||
diesel::delete(community_moderator.filter(community_id.eq(for_community_id))).execute(conn)
|
diesel::delete(community_moderator.filter(community_id.eq(for_community_id))).execute(conn)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_person_moderated_communities(
|
pub fn get_person_moderated_communities(
|
||||||
conn: &PgConnection,
|
conn: &PgConnection,
|
||||||
for_person_id: PersonId,
|
for_person_id: PersonId,
|
||||||
) -> Result<Vec<CommunityId>, Error> {
|
) -> Result<Vec<CommunityId>, Error> {
|
||||||
use lemmy_db_schema::schema::community_moderator::dsl::*;
|
use crate::schema::community_moderator::dsl::*;
|
||||||
community_moderator
|
community_moderator
|
||||||
.filter(person_id.eq(for_person_id))
|
.filter(person_id.eq(for_person_id))
|
||||||
.select(community_id)
|
.select(community_id)
|
||||||
@ -253,7 +223,7 @@ impl Bannable for CommunityPersonBan {
|
|||||||
conn: &PgConnection,
|
conn: &PgConnection,
|
||||||
community_person_ban_form: &CommunityPersonBanForm,
|
community_person_ban_form: &CommunityPersonBanForm,
|
||||||
) -> Result<Self, Error> {
|
) -> Result<Self, Error> {
|
||||||
use lemmy_db_schema::schema::community_person_ban::dsl::*;
|
use crate::schema::community_person_ban::dsl::*;
|
||||||
insert_into(community_person_ban)
|
insert_into(community_person_ban)
|
||||||
.values(community_person_ban_form)
|
.values(community_person_ban_form)
|
||||||
.get_result::<Self>(conn)
|
.get_result::<Self>(conn)
|
||||||
@ -263,7 +233,7 @@ impl Bannable for CommunityPersonBan {
|
|||||||
conn: &PgConnection,
|
conn: &PgConnection,
|
||||||
community_person_ban_form: &CommunityPersonBanForm,
|
community_person_ban_form: &CommunityPersonBanForm,
|
||||||
) -> Result<usize, Error> {
|
) -> Result<usize, Error> {
|
||||||
use lemmy_db_schema::schema::community_person_ban::dsl::*;
|
use crate::schema::community_person_ban::dsl::*;
|
||||||
diesel::delete(
|
diesel::delete(
|
||||||
community_person_ban
|
community_person_ban
|
||||||
.filter(community_id.eq(community_person_ban_form.community_id))
|
.filter(community_id.eq(community_person_ban_form.community_id))
|
||||||
@ -279,7 +249,7 @@ impl Followable for CommunityFollower {
|
|||||||
conn: &PgConnection,
|
conn: &PgConnection,
|
||||||
community_follower_form: &CommunityFollowerForm,
|
community_follower_form: &CommunityFollowerForm,
|
||||||
) -> Result<Self, Error> {
|
) -> Result<Self, Error> {
|
||||||
use lemmy_db_schema::schema::community_follower::dsl::*;
|
use crate::schema::community_follower::dsl::*;
|
||||||
insert_into(community_follower)
|
insert_into(community_follower)
|
||||||
.values(community_follower_form)
|
.values(community_follower_form)
|
||||||
.on_conflict((community_id, person_id))
|
.on_conflict((community_id, person_id))
|
||||||
@ -295,7 +265,7 @@ impl Followable for CommunityFollower {
|
|||||||
where
|
where
|
||||||
Self: Sized,
|
Self: Sized,
|
||||||
{
|
{
|
||||||
use lemmy_db_schema::schema::community_follower::dsl::*;
|
use crate::schema::community_follower::dsl::*;
|
||||||
diesel::update(
|
diesel::update(
|
||||||
community_follower
|
community_follower
|
||||||
.filter(community_id.eq(community_id_))
|
.filter(community_id.eq(community_id_))
|
||||||
@ -308,7 +278,7 @@ impl Followable for CommunityFollower {
|
|||||||
conn: &PgConnection,
|
conn: &PgConnection,
|
||||||
community_follower_form: &CommunityFollowerForm,
|
community_follower_form: &CommunityFollowerForm,
|
||||||
) -> Result<usize, Error> {
|
) -> Result<usize, Error> {
|
||||||
use lemmy_db_schema::schema::community_follower::dsl::*;
|
use crate::schema::community_follower::dsl::*;
|
||||||
diesel::delete(
|
diesel::delete(
|
||||||
community_follower
|
community_follower
|
||||||
.filter(community_id.eq(&community_follower_form.community_id))
|
.filter(community_id.eq(&community_follower_form.community_id))
|
||||||
@ -319,7 +289,7 @@ impl Followable for CommunityFollower {
|
|||||||
// TODO: this function name only makes sense if you call it with a remote community. for a local
|
// TODO: this function name only makes sense if you call it with a remote community. for a local
|
||||||
// community, it will also return true if only remote followers exist
|
// community, it will also return true if only remote followers exist
|
||||||
fn has_local_followers(conn: &PgConnection, community_id_: CommunityId) -> Result<bool, Error> {
|
fn has_local_followers(conn: &PgConnection, community_id_: CommunityId) -> Result<bool, Error> {
|
||||||
use lemmy_db_schema::schema::community_follower::dsl::*;
|
use crate::schema::community_follower::dsl::*;
|
||||||
diesel::select(exists(
|
diesel::select(exists(
|
||||||
community_follower.filter(community_id.eq(community_id_)),
|
community_follower.filter(community_id.eq(community_id_)),
|
||||||
))
|
))
|
||||||
@ -327,10 +297,66 @@ impl Followable for CommunityFollower {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl ApubObject for Community {
|
||||||
|
type DataType = PgConnection;
|
||||||
|
|
||||||
|
fn last_refreshed_at(&self) -> Option<NaiveDateTime> {
|
||||||
|
Some(self.last_refreshed_at)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn read_from_apub_id(conn: &PgConnection, object_id: Url) -> Result<Option<Self>, LemmyError> {
|
||||||
|
use crate::schema::community::dsl::*;
|
||||||
|
let object_id: DbUrl = object_id.into();
|
||||||
|
Ok(
|
||||||
|
community
|
||||||
|
.filter(actor_id.eq(object_id))
|
||||||
|
.first::<Self>(conn)
|
||||||
|
.ok(),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn delete(self, conn: &PgConnection) -> Result<(), LemmyError> {
|
||||||
|
use crate::schema::community::dsl::*;
|
||||||
|
diesel::update(community.find(self.id))
|
||||||
|
.set((deleted.eq(true), updated.eq(naive_now())))
|
||||||
|
.get_result::<Self>(conn)?;
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl ActorType for Community {
|
||||||
|
fn is_local(&self) -> bool {
|
||||||
|
self.local
|
||||||
|
}
|
||||||
|
fn actor_id(&self) -> Url {
|
||||||
|
self.actor_id.to_owned().into()
|
||||||
|
}
|
||||||
|
fn name(&self) -> String {
|
||||||
|
self.name.clone()
|
||||||
|
}
|
||||||
|
fn public_key(&self) -> Option<String> {
|
||||||
|
self.public_key.to_owned()
|
||||||
|
}
|
||||||
|
fn private_key(&self) -> Option<String> {
|
||||||
|
self.private_key.to_owned()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn inbox_url(&self) -> Url {
|
||||||
|
self.inbox_url.clone().into()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn shared_inbox_url(&self) -> Option<Url> {
|
||||||
|
self.shared_inbox_url.clone().map(|s| s.into_inner())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use crate::{establish_unpooled_connection, Bannable, Crud, Followable, Joinable};
|
use crate::{
|
||||||
use lemmy_db_schema::source::{community::*, person::*};
|
establish_unpooled_connection,
|
||||||
|
source::{community::*, person::*},
|
||||||
|
traits::{Bannable, Crud, Followable, Joinable},
|
||||||
|
};
|
||||||
use serial_test::serial;
|
use serial_test::serial;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
@ -1,11 +1,13 @@
|
|||||||
use crate::Blockable;
|
use crate::{
|
||||||
|
source::community_block::{CommunityBlock, CommunityBlockForm},
|
||||||
|
traits::Blockable,
|
||||||
|
};
|
||||||
use diesel::{dsl::*, result::Error, *};
|
use diesel::{dsl::*, result::Error, *};
|
||||||
use lemmy_db_schema::source::community_block::{CommunityBlock, CommunityBlockForm};
|
|
||||||
|
|
||||||
impl Blockable for CommunityBlock {
|
impl Blockable for CommunityBlock {
|
||||||
type Form = CommunityBlockForm;
|
type Form = CommunityBlockForm;
|
||||||
fn block(conn: &PgConnection, community_block_form: &Self::Form) -> Result<Self, Error> {
|
fn block(conn: &PgConnection, community_block_form: &Self::Form) -> Result<Self, Error> {
|
||||||
use lemmy_db_schema::schema::community_block::dsl::*;
|
use crate::schema::community_block::dsl::*;
|
||||||
insert_into(community_block)
|
insert_into(community_block)
|
||||||
.values(community_block_form)
|
.values(community_block_form)
|
||||||
.on_conflict((person_id, community_id))
|
.on_conflict((person_id, community_id))
|
||||||
@ -14,7 +16,7 @@ impl Blockable for CommunityBlock {
|
|||||||
.get_result::<Self>(conn)
|
.get_result::<Self>(conn)
|
||||||
}
|
}
|
||||||
fn unblock(conn: &PgConnection, community_block_form: &Self::Form) -> Result<usize, Error> {
|
fn unblock(conn: &PgConnection, community_block_form: &Self::Form) -> Result<usize, Error> {
|
||||||
use lemmy_db_schema::schema::community_block::dsl::*;
|
use crate::schema::community_block::dsl::*;
|
||||||
diesel::delete(
|
diesel::delete(
|
||||||
community_block
|
community_block
|
||||||
.filter(person_id.eq(community_block_form.person_id))
|
.filter(person_id.eq(community_block_form.person_id))
|
@ -1,16 +1,19 @@
|
|||||||
use crate::Crud;
|
use crate::{
|
||||||
use bcrypt::{hash, DEFAULT_COST};
|
|
||||||
use diesel::{dsl::*, result::Error, *};
|
|
||||||
use lemmy_db_schema::{
|
|
||||||
naive_now,
|
naive_now,
|
||||||
|
newtypes::LocalUserId,
|
||||||
schema::local_user::dsl::*,
|
schema::local_user::dsl::*,
|
||||||
source::local_user::{LocalUser, LocalUserForm},
|
source::local_user::{LocalUser, LocalUserForm},
|
||||||
LocalUserId,
|
traits::Crud,
|
||||||
};
|
};
|
||||||
|
use bcrypt::{hash, DEFAULT_COST};
|
||||||
|
use diesel::{dsl::*, result::Error, *};
|
||||||
|
|
||||||
mod safe_settings_type {
|
mod safe_settings_type {
|
||||||
use crate::ToSafeSettings;
|
use crate::{
|
||||||
use lemmy_db_schema::{schema::local_user::columns::*, source::local_user::LocalUser};
|
schema::local_user::columns::*,
|
||||||
|
source::local_user::LocalUser,
|
||||||
|
traits::ToSafeSettings,
|
||||||
|
};
|
||||||
|
|
||||||
type Columns = (
|
type Columns = (
|
||||||
id,
|
id,
|
||||||
@ -56,17 +59,8 @@ mod safe_settings_type {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub trait LocalUser_ {
|
impl LocalUser {
|
||||||
fn register(conn: &PgConnection, form: &LocalUserForm) -> Result<LocalUser, Error>;
|
pub fn register(conn: &PgConnection, form: &LocalUserForm) -> Result<Self, Error> {
|
||||||
fn update_password(
|
|
||||||
conn: &PgConnection,
|
|
||||||
local_user_id: LocalUserId,
|
|
||||||
new_password: &str,
|
|
||||||
) -> Result<LocalUser, Error>;
|
|
||||||
}
|
|
||||||
|
|
||||||
impl LocalUser_ for LocalUser {
|
|
||||||
fn register(conn: &PgConnection, form: &LocalUserForm) -> Result<Self, Error> {
|
|
||||||
let mut edited_user = form.clone();
|
let mut edited_user = form.clone();
|
||||||
let password_hash =
|
let password_hash =
|
||||||
hash(&form.password_encrypted, DEFAULT_COST).expect("Couldn't hash password");
|
hash(&form.password_encrypted, DEFAULT_COST).expect("Couldn't hash password");
|
||||||
@ -75,7 +69,7 @@ impl LocalUser_ for LocalUser {
|
|||||||
Self::create(conn, &edited_user)
|
Self::create(conn, &edited_user)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn update_password(
|
pub fn update_password(
|
||||||
conn: &PgConnection,
|
conn: &PgConnection,
|
||||||
local_user_id: LocalUserId,
|
local_user_id: LocalUserId,
|
||||||
new_password: &str,
|
new_password: &str,
|
@ -1,24 +1,23 @@
|
|||||||
use crate::Crud;
|
use crate::{source::moderator::*, traits::Crud};
|
||||||
use diesel::{dsl::*, result::Error, *};
|
use diesel::{dsl::*, result::Error, *};
|
||||||
use lemmy_db_schema::source::moderator::*;
|
|
||||||
|
|
||||||
impl Crud for ModRemovePost {
|
impl Crud for ModRemovePost {
|
||||||
type Form = ModRemovePostForm;
|
type Form = ModRemovePostForm;
|
||||||
type IdType = i32;
|
type IdType = i32;
|
||||||
fn read(conn: &PgConnection, from_id: i32) -> Result<Self, Error> {
|
fn read(conn: &PgConnection, from_id: i32) -> Result<Self, Error> {
|
||||||
use lemmy_db_schema::schema::mod_remove_post::dsl::*;
|
use crate::schema::mod_remove_post::dsl::*;
|
||||||
mod_remove_post.find(from_id).first::<Self>(conn)
|
mod_remove_post.find(from_id).first::<Self>(conn)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn create(conn: &PgConnection, form: &ModRemovePostForm) -> Result<Self, Error> {
|
fn create(conn: &PgConnection, form: &ModRemovePostForm) -> Result<Self, Error> {
|
||||||
use lemmy_db_schema::schema::mod_remove_post::dsl::*;
|
use crate::schema::mod_remove_post::dsl::*;
|
||||||
insert_into(mod_remove_post)
|
insert_into(mod_remove_post)
|
||||||
.values(form)
|
.values(form)
|
||||||
.get_result::<Self>(conn)
|
.get_result::<Self>(conn)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn update(conn: &PgConnection, from_id: i32, form: &ModRemovePostForm) -> Result<Self, Error> {
|
fn update(conn: &PgConnection, from_id: i32, form: &ModRemovePostForm) -> Result<Self, Error> {
|
||||||
use lemmy_db_schema::schema::mod_remove_post::dsl::*;
|
use crate::schema::mod_remove_post::dsl::*;
|
||||||
diesel::update(mod_remove_post.find(from_id))
|
diesel::update(mod_remove_post.find(from_id))
|
||||||
.set(form)
|
.set(form)
|
||||||
.get_result::<Self>(conn)
|
.get_result::<Self>(conn)
|
||||||
@ -29,19 +28,19 @@ impl Crud for ModLockPost {
|
|||||||
type Form = ModLockPostForm;
|
type Form = ModLockPostForm;
|
||||||
type IdType = i32;
|
type IdType = i32;
|
||||||
fn read(conn: &PgConnection, from_id: i32) -> Result<Self, Error> {
|
fn read(conn: &PgConnection, from_id: i32) -> Result<Self, Error> {
|
||||||
use lemmy_db_schema::schema::mod_lock_post::dsl::*;
|
use crate::schema::mod_lock_post::dsl::*;
|
||||||
mod_lock_post.find(from_id).first::<Self>(conn)
|
mod_lock_post.find(from_id).first::<Self>(conn)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn create(conn: &PgConnection, form: &ModLockPostForm) -> Result<Self, Error> {
|
fn create(conn: &PgConnection, form: &ModLockPostForm) -> Result<Self, Error> {
|
||||||
use lemmy_db_schema::schema::mod_lock_post::dsl::*;
|
use crate::schema::mod_lock_post::dsl::*;
|
||||||
insert_into(mod_lock_post)
|
insert_into(mod_lock_post)
|
||||||
.values(form)
|
.values(form)
|
||||||
.get_result::<Self>(conn)
|
.get_result::<Self>(conn)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn update(conn: &PgConnection, from_id: i32, form: &ModLockPostForm) -> Result<Self, Error> {
|
fn update(conn: &PgConnection, from_id: i32, form: &ModLockPostForm) -> Result<Self, Error> {
|
||||||
use lemmy_db_schema::schema::mod_lock_post::dsl::*;
|
use crate::schema::mod_lock_post::dsl::*;
|
||||||
diesel::update(mod_lock_post.find(from_id))
|
diesel::update(mod_lock_post.find(from_id))
|
||||||
.set(form)
|
.set(form)
|
||||||
.get_result::<Self>(conn)
|
.get_result::<Self>(conn)
|
||||||
@ -52,19 +51,19 @@ impl Crud for ModStickyPost {
|
|||||||
type Form = ModStickyPostForm;
|
type Form = ModStickyPostForm;
|
||||||
type IdType = i32;
|
type IdType = i32;
|
||||||
fn read(conn: &PgConnection, from_id: i32) -> Result<Self, Error> {
|
fn read(conn: &PgConnection, from_id: i32) -> Result<Self, Error> {
|
||||||
use lemmy_db_schema::schema::mod_sticky_post::dsl::*;
|
use crate::schema::mod_sticky_post::dsl::*;
|
||||||
mod_sticky_post.find(from_id).first::<Self>(conn)
|
mod_sticky_post.find(from_id).first::<Self>(conn)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn create(conn: &PgConnection, form: &ModStickyPostForm) -> Result<Self, Error> {
|
fn create(conn: &PgConnection, form: &ModStickyPostForm) -> Result<Self, Error> {
|
||||||
use lemmy_db_schema::schema::mod_sticky_post::dsl::*;
|
use crate::schema::mod_sticky_post::dsl::*;
|
||||||
insert_into(mod_sticky_post)
|
insert_into(mod_sticky_post)
|
||||||
.values(form)
|
.values(form)
|
||||||
.get_result::<Self>(conn)
|
.get_result::<Self>(conn)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn update(conn: &PgConnection, from_id: i32, form: &ModStickyPostForm) -> Result<Self, Error> {
|
fn update(conn: &PgConnection, from_id: i32, form: &ModStickyPostForm) -> Result<Self, Error> {
|
||||||
use lemmy_db_schema::schema::mod_sticky_post::dsl::*;
|
use crate::schema::mod_sticky_post::dsl::*;
|
||||||
diesel::update(mod_sticky_post.find(from_id))
|
diesel::update(mod_sticky_post.find(from_id))
|
||||||
.set(form)
|
.set(form)
|
||||||
.get_result::<Self>(conn)
|
.get_result::<Self>(conn)
|
||||||
@ -75,19 +74,19 @@ impl Crud for ModRemoveComment {
|
|||||||
type Form = ModRemoveCommentForm;
|
type Form = ModRemoveCommentForm;
|
||||||
type IdType = i32;
|
type IdType = i32;
|
||||||
fn read(conn: &PgConnection, from_id: i32) -> Result<Self, Error> {
|
fn read(conn: &PgConnection, from_id: i32) -> Result<Self, Error> {
|
||||||
use lemmy_db_schema::schema::mod_remove_comment::dsl::*;
|
use crate::schema::mod_remove_comment::dsl::*;
|
||||||
mod_remove_comment.find(from_id).first::<Self>(conn)
|
mod_remove_comment.find(from_id).first::<Self>(conn)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn create(conn: &PgConnection, form: &ModRemoveCommentForm) -> Result<Self, Error> {
|
fn create(conn: &PgConnection, form: &ModRemoveCommentForm) -> Result<Self, Error> {
|
||||||
use lemmy_db_schema::schema::mod_remove_comment::dsl::*;
|
use crate::schema::mod_remove_comment::dsl::*;
|
||||||
insert_into(mod_remove_comment)
|
insert_into(mod_remove_comment)
|
||||||
.values(form)
|
.values(form)
|
||||||
.get_result::<Self>(conn)
|
.get_result::<Self>(conn)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn update(conn: &PgConnection, from_id: i32, form: &ModRemoveCommentForm) -> Result<Self, Error> {
|
fn update(conn: &PgConnection, from_id: i32, form: &ModRemoveCommentForm) -> Result<Self, Error> {
|
||||||
use lemmy_db_schema::schema::mod_remove_comment::dsl::*;
|
use crate::schema::mod_remove_comment::dsl::*;
|
||||||
diesel::update(mod_remove_comment.find(from_id))
|
diesel::update(mod_remove_comment.find(from_id))
|
||||||
.set(form)
|
.set(form)
|
||||||
.get_result::<Self>(conn)
|
.get_result::<Self>(conn)
|
||||||
@ -98,12 +97,12 @@ impl Crud for ModRemoveCommunity {
|
|||||||
type Form = ModRemoveCommunityForm;
|
type Form = ModRemoveCommunityForm;
|
||||||
type IdType = i32;
|
type IdType = i32;
|
||||||
fn read(conn: &PgConnection, from_id: i32) -> Result<Self, Error> {
|
fn read(conn: &PgConnection, from_id: i32) -> Result<Self, Error> {
|
||||||
use lemmy_db_schema::schema::mod_remove_community::dsl::*;
|
use crate::schema::mod_remove_community::dsl::*;
|
||||||
mod_remove_community.find(from_id).first::<Self>(conn)
|
mod_remove_community.find(from_id).first::<Self>(conn)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn create(conn: &PgConnection, form: &ModRemoveCommunityForm) -> Result<Self, Error> {
|
fn create(conn: &PgConnection, form: &ModRemoveCommunityForm) -> Result<Self, Error> {
|
||||||
use lemmy_db_schema::schema::mod_remove_community::dsl::*;
|
use crate::schema::mod_remove_community::dsl::*;
|
||||||
insert_into(mod_remove_community)
|
insert_into(mod_remove_community)
|
||||||
.values(form)
|
.values(form)
|
||||||
.get_result::<Self>(conn)
|
.get_result::<Self>(conn)
|
||||||
@ -114,7 +113,7 @@ impl Crud for ModRemoveCommunity {
|
|||||||
from_id: i32,
|
from_id: i32,
|
||||||
form: &ModRemoveCommunityForm,
|
form: &ModRemoveCommunityForm,
|
||||||
) -> Result<Self, Error> {
|
) -> Result<Self, Error> {
|
||||||
use lemmy_db_schema::schema::mod_remove_community::dsl::*;
|
use crate::schema::mod_remove_community::dsl::*;
|
||||||
diesel::update(mod_remove_community.find(from_id))
|
diesel::update(mod_remove_community.find(from_id))
|
||||||
.set(form)
|
.set(form)
|
||||||
.get_result::<Self>(conn)
|
.get_result::<Self>(conn)
|
||||||
@ -125,12 +124,12 @@ impl Crud for ModBanFromCommunity {
|
|||||||
type Form = ModBanFromCommunityForm;
|
type Form = ModBanFromCommunityForm;
|
||||||
type IdType = i32;
|
type IdType = i32;
|
||||||
fn read(conn: &PgConnection, from_id: i32) -> Result<Self, Error> {
|
fn read(conn: &PgConnection, from_id: i32) -> Result<Self, Error> {
|
||||||
use lemmy_db_schema::schema::mod_ban_from_community::dsl::*;
|
use crate::schema::mod_ban_from_community::dsl::*;
|
||||||
mod_ban_from_community.find(from_id).first::<Self>(conn)
|
mod_ban_from_community.find(from_id).first::<Self>(conn)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn create(conn: &PgConnection, form: &ModBanFromCommunityForm) -> Result<Self, Error> {
|
fn create(conn: &PgConnection, form: &ModBanFromCommunityForm) -> Result<Self, Error> {
|
||||||
use lemmy_db_schema::schema::mod_ban_from_community::dsl::*;
|
use crate::schema::mod_ban_from_community::dsl::*;
|
||||||
insert_into(mod_ban_from_community)
|
insert_into(mod_ban_from_community)
|
||||||
.values(form)
|
.values(form)
|
||||||
.get_result::<Self>(conn)
|
.get_result::<Self>(conn)
|
||||||
@ -141,7 +140,7 @@ impl Crud for ModBanFromCommunity {
|
|||||||
from_id: i32,
|
from_id: i32,
|
||||||
form: &ModBanFromCommunityForm,
|
form: &ModBanFromCommunityForm,
|
||||||
) -> Result<Self, Error> {
|
) -> Result<Self, Error> {
|
||||||
use lemmy_db_schema::schema::mod_ban_from_community::dsl::*;
|
use crate::schema::mod_ban_from_community::dsl::*;
|
||||||
diesel::update(mod_ban_from_community.find(from_id))
|
diesel::update(mod_ban_from_community.find(from_id))
|
||||||
.set(form)
|
.set(form)
|
||||||
.get_result::<Self>(conn)
|
.get_result::<Self>(conn)
|
||||||
@ -152,17 +151,17 @@ impl Crud for ModBan {
|
|||||||
type Form = ModBanForm;
|
type Form = ModBanForm;
|
||||||
type IdType = i32;
|
type IdType = i32;
|
||||||
fn read(conn: &PgConnection, from_id: i32) -> Result<Self, Error> {
|
fn read(conn: &PgConnection, from_id: i32) -> Result<Self, Error> {
|
||||||
use lemmy_db_schema::schema::mod_ban::dsl::*;
|
use crate::schema::mod_ban::dsl::*;
|
||||||
mod_ban.find(from_id).first::<Self>(conn)
|
mod_ban.find(from_id).first::<Self>(conn)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn create(conn: &PgConnection, form: &ModBanForm) -> Result<Self, Error> {
|
fn create(conn: &PgConnection, form: &ModBanForm) -> Result<Self, Error> {
|
||||||
use lemmy_db_schema::schema::mod_ban::dsl::*;
|
use crate::schema::mod_ban::dsl::*;
|
||||||
insert_into(mod_ban).values(form).get_result::<Self>(conn)
|
insert_into(mod_ban).values(form).get_result::<Self>(conn)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn update(conn: &PgConnection, from_id: i32, form: &ModBanForm) -> Result<Self, Error> {
|
fn update(conn: &PgConnection, from_id: i32, form: &ModBanForm) -> Result<Self, Error> {
|
||||||
use lemmy_db_schema::schema::mod_ban::dsl::*;
|
use crate::schema::mod_ban::dsl::*;
|
||||||
diesel::update(mod_ban.find(from_id))
|
diesel::update(mod_ban.find(from_id))
|
||||||
.set(form)
|
.set(form)
|
||||||
.get_result::<Self>(conn)
|
.get_result::<Self>(conn)
|
||||||
@ -173,19 +172,19 @@ impl Crud for ModAddCommunity {
|
|||||||
type Form = ModAddCommunityForm;
|
type Form = ModAddCommunityForm;
|
||||||
type IdType = i32;
|
type IdType = i32;
|
||||||
fn read(conn: &PgConnection, from_id: i32) -> Result<Self, Error> {
|
fn read(conn: &PgConnection, from_id: i32) -> Result<Self, Error> {
|
||||||
use lemmy_db_schema::schema::mod_add_community::dsl::*;
|
use crate::schema::mod_add_community::dsl::*;
|
||||||
mod_add_community.find(from_id).first::<Self>(conn)
|
mod_add_community.find(from_id).first::<Self>(conn)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn create(conn: &PgConnection, form: &ModAddCommunityForm) -> Result<Self, Error> {
|
fn create(conn: &PgConnection, form: &ModAddCommunityForm) -> Result<Self, Error> {
|
||||||
use lemmy_db_schema::schema::mod_add_community::dsl::*;
|
use crate::schema::mod_add_community::dsl::*;
|
||||||
insert_into(mod_add_community)
|
insert_into(mod_add_community)
|
||||||
.values(form)
|
.values(form)
|
||||||
.get_result::<Self>(conn)
|
.get_result::<Self>(conn)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn update(conn: &PgConnection, from_id: i32, form: &ModAddCommunityForm) -> Result<Self, Error> {
|
fn update(conn: &PgConnection, from_id: i32, form: &ModAddCommunityForm) -> Result<Self, Error> {
|
||||||
use lemmy_db_schema::schema::mod_add_community::dsl::*;
|
use crate::schema::mod_add_community::dsl::*;
|
||||||
diesel::update(mod_add_community.find(from_id))
|
diesel::update(mod_add_community.find(from_id))
|
||||||
.set(form)
|
.set(form)
|
||||||
.get_result::<Self>(conn)
|
.get_result::<Self>(conn)
|
||||||
@ -196,12 +195,12 @@ impl Crud for ModTransferCommunity {
|
|||||||
type Form = ModTransferCommunityForm;
|
type Form = ModTransferCommunityForm;
|
||||||
type IdType = i32;
|
type IdType = i32;
|
||||||
fn read(conn: &PgConnection, from_id: i32) -> Result<Self, Error> {
|
fn read(conn: &PgConnection, from_id: i32) -> Result<Self, Error> {
|
||||||
use lemmy_db_schema::schema::mod_transfer_community::dsl::*;
|
use crate::schema::mod_transfer_community::dsl::*;
|
||||||
mod_transfer_community.find(from_id).first::<Self>(conn)
|
mod_transfer_community.find(from_id).first::<Self>(conn)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn create(conn: &PgConnection, form: &ModTransferCommunityForm) -> Result<Self, Error> {
|
fn create(conn: &PgConnection, form: &ModTransferCommunityForm) -> Result<Self, Error> {
|
||||||
use lemmy_db_schema::schema::mod_transfer_community::dsl::*;
|
use crate::schema::mod_transfer_community::dsl::*;
|
||||||
insert_into(mod_transfer_community)
|
insert_into(mod_transfer_community)
|
||||||
.values(form)
|
.values(form)
|
||||||
.get_result::<Self>(conn)
|
.get_result::<Self>(conn)
|
||||||
@ -212,7 +211,7 @@ impl Crud for ModTransferCommunity {
|
|||||||
from_id: i32,
|
from_id: i32,
|
||||||
form: &ModTransferCommunityForm,
|
form: &ModTransferCommunityForm,
|
||||||
) -> Result<Self, Error> {
|
) -> Result<Self, Error> {
|
||||||
use lemmy_db_schema::schema::mod_transfer_community::dsl::*;
|
use crate::schema::mod_transfer_community::dsl::*;
|
||||||
diesel::update(mod_transfer_community.find(from_id))
|
diesel::update(mod_transfer_community.find(from_id))
|
||||||
.set(form)
|
.set(form)
|
||||||
.get_result::<Self>(conn)
|
.get_result::<Self>(conn)
|
||||||
@ -223,17 +222,17 @@ impl Crud for ModAdd {
|
|||||||
type Form = ModAddForm;
|
type Form = ModAddForm;
|
||||||
type IdType = i32;
|
type IdType = i32;
|
||||||
fn read(conn: &PgConnection, from_id: i32) -> Result<Self, Error> {
|
fn read(conn: &PgConnection, from_id: i32) -> Result<Self, Error> {
|
||||||
use lemmy_db_schema::schema::mod_add::dsl::*;
|
use crate::schema::mod_add::dsl::*;
|
||||||
mod_add.find(from_id).first::<Self>(conn)
|
mod_add.find(from_id).first::<Self>(conn)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn create(conn: &PgConnection, form: &ModAddForm) -> Result<Self, Error> {
|
fn create(conn: &PgConnection, form: &ModAddForm) -> Result<Self, Error> {
|
||||||
use lemmy_db_schema::schema::mod_add::dsl::*;
|
use crate::schema::mod_add::dsl::*;
|
||||||
insert_into(mod_add).values(form).get_result::<Self>(conn)
|
insert_into(mod_add).values(form).get_result::<Self>(conn)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn update(conn: &PgConnection, from_id: i32, form: &ModAddForm) -> Result<Self, Error> {
|
fn update(conn: &PgConnection, from_id: i32, form: &ModAddForm) -> Result<Self, Error> {
|
||||||
use lemmy_db_schema::schema::mod_add::dsl::*;
|
use crate::schema::mod_add::dsl::*;
|
||||||
diesel::update(mod_add.find(from_id))
|
diesel::update(mod_add.find(from_id))
|
||||||
.set(form)
|
.set(form)
|
||||||
.get_result::<Self>(conn)
|
.get_result::<Self>(conn)
|
||||||
@ -242,8 +241,11 @@ impl Crud for ModAdd {
|
|||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use crate::{establish_unpooled_connection, Crud};
|
use crate::{
|
||||||
use lemmy_db_schema::source::{comment::*, community::*, moderator::*, person::*, post::*};
|
establish_unpooled_connection,
|
||||||
|
source::{comment::*, community::*, moderator::*, person::*, post::*},
|
||||||
|
traits::Crud,
|
||||||
|
};
|
||||||
use serial_test::serial;
|
use serial_test::serial;
|
||||||
|
|
||||||
// use Crud;
|
// use Crud;
|
@ -1,10 +1,10 @@
|
|||||||
use crate::Crud;
|
use crate::{
|
||||||
use diesel::{dsl::*, result::Error, PgConnection, *};
|
newtypes::LocalUserId,
|
||||||
use lemmy_db_schema::{
|
|
||||||
schema::password_reset_request::dsl::*,
|
schema::password_reset_request::dsl::*,
|
||||||
source::password_reset_request::*,
|
source::password_reset_request::*,
|
||||||
LocalUserId,
|
traits::Crud,
|
||||||
};
|
};
|
||||||
|
use diesel::{dsl::*, result::Error, PgConnection, *};
|
||||||
use sha2::{Digest, Sha256};
|
use sha2::{Digest, Sha256};
|
||||||
|
|
||||||
impl Crud for PasswordResetRequest {
|
impl Crud for PasswordResetRequest {
|
||||||
@ -31,17 +31,8 @@ impl Crud for PasswordResetRequest {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub trait PasswordResetRequest_ {
|
impl PasswordResetRequest {
|
||||||
fn create_token(
|
pub fn create_token(
|
||||||
conn: &PgConnection,
|
|
||||||
from_local_user_id: LocalUserId,
|
|
||||||
token: &str,
|
|
||||||
) -> Result<PasswordResetRequest, Error>;
|
|
||||||
fn read_from_token(conn: &PgConnection, token: &str) -> Result<PasswordResetRequest, Error>;
|
|
||||||
}
|
|
||||||
|
|
||||||
impl PasswordResetRequest_ for PasswordResetRequest {
|
|
||||||
fn create_token(
|
|
||||||
conn: &PgConnection,
|
conn: &PgConnection,
|
||||||
from_local_user_id: LocalUserId,
|
from_local_user_id: LocalUserId,
|
||||||
token: &str,
|
token: &str,
|
||||||
@ -57,7 +48,7 @@ impl PasswordResetRequest_ for PasswordResetRequest {
|
|||||||
|
|
||||||
Self::create(conn, &form)
|
Self::create(conn, &form)
|
||||||
}
|
}
|
||||||
fn read_from_token(conn: &PgConnection, token: &str) -> Result<PasswordResetRequest, Error> {
|
pub fn read_from_token(conn: &PgConnection, token: &str) -> Result<PasswordResetRequest, Error> {
|
||||||
let mut hasher = Sha256::new();
|
let mut hasher = Sha256::new();
|
||||||
hasher.update(token);
|
hasher.update(token);
|
||||||
let token_hash: String = bytes_to_hex(hasher.finalize().to_vec());
|
let token_hash: String = bytes_to_hex(hasher.finalize().to_vec());
|
||||||
@ -80,13 +71,12 @@ fn bytes_to_hex(bytes: Vec<u8>) -> String {
|
|||||||
mod tests {
|
mod tests {
|
||||||
use crate::{
|
use crate::{
|
||||||
establish_unpooled_connection,
|
establish_unpooled_connection,
|
||||||
source::password_reset_request::PasswordResetRequest_,
|
source::{
|
||||||
Crud,
|
local_user::{LocalUser, LocalUserForm},
|
||||||
};
|
password_reset_request::PasswordResetRequest,
|
||||||
use lemmy_db_schema::source::{
|
person::*,
|
||||||
local_user::{LocalUser, LocalUserForm},
|
},
|
||||||
password_reset_request::PasswordResetRequest,
|
traits::Crud,
|
||||||
person::*,
|
|
||||||
};
|
};
|
||||||
use serial_test::serial;
|
use serial_test::serial;
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user