Derive default for api request structs, move type enums (#2245)

* Derive default for api request structs, move type enums

* Simplify api by using enum types directly, instead of string

* Add default and clone for most api structs
This commit is contained in:
Nutomic 2022-05-06 20:55:07 +00:00 committed by GitHub
parent 3aa3d75a1e
commit 3053e14be7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
26 changed files with 223 additions and 220 deletions

View file

@ -4,7 +4,6 @@ use lemmy_api_common::{
person::{GetPersonMentions, GetPersonMentionsResponse},
utils::{blocking, get_local_user_view_from_jwt},
};
use lemmy_db_schema::utils::{from_opt_str_to_opt_enum, SortType};
use lemmy_db_views_actor::person_mention_view::PersonMentionQueryBuilder;
use lemmy_utils::{ConnectionId, LemmyError};
use lemmy_websocket::LemmyContext;
@ -23,8 +22,7 @@ impl Perform for GetPersonMentions {
let local_user_view =
get_local_user_view_from_jwt(&data.auth, context.pool(), context.secret()).await?;
let sort: Option<SortType> = from_opt_str_to_opt_enum(&data.sort);
let sort = data.sort;
let page = data.page;
let limit = data.limit;
let unread_only = data.unread_only;

View file

@ -4,7 +4,6 @@ use lemmy_api_common::{
person::{GetReplies, GetRepliesResponse},
utils::{blocking, get_local_user_view_from_jwt},
};
use lemmy_db_schema::utils::{from_opt_str_to_opt_enum, SortType};
use lemmy_db_views::comment_view::CommentQueryBuilder;
use lemmy_utils::{ConnectionId, LemmyError};
use lemmy_websocket::LemmyContext;
@ -23,8 +22,7 @@ impl Perform for GetReplies {
let local_user_view =
get_local_user_view_from_jwt(&data.auth, context.pool(), context.secret()).await?;
let sort: Option<SortType> = from_opt_str_to_opt_enum(&data.sort);
let sort = data.sort;
let page = data.page;
let limit = data.limit;
let unread_only = data.unread_only;

View file

@ -5,11 +5,7 @@ use lemmy_api_common::{
utils::{blocking, check_private_instance, get_local_user_view_from_jwt_opt},
};
use lemmy_apub::{fetcher::resolve_actor_identifier, objects::community::ApubCommunity};
use lemmy_db_schema::{
source::community::Community,
traits::DeleteableOrRemoveable,
utils::{from_opt_str_to_opt_enum, ListingType, SearchType, SortType},
};
use lemmy_db_schema::{source::community::Community, traits::DeleteableOrRemoveable, SearchType};
use lemmy_db_views::{comment_view::CommentQueryBuilder, post_view::PostQueryBuilder};
use lemmy_db_views_actor::{
community_view::CommunityQueryBuilder,
@ -56,9 +52,9 @@ impl Perform for Search {
let q = data.q.to_owned();
let page = data.page;
let limit = data.limit;
let sort: Option<SortType> = from_opt_str_to_opt_enum(&data.sort);
let listing_type: Option<ListingType> = from_opt_str_to_opt_enum(&data.listing_type);
let search_type: SearchType = from_opt_str_to_opt_enum(&data.type_).unwrap_or(SearchType::All);
let sort = data.sort;
let listing_type = data.listing_type;
let search_type = data.type_.unwrap_or(SearchType::All);
let community_id = data.community_id;
let community_actor_id = if let Some(name) = &data.community_name {
resolve_actor_identifier::<ApubCommunity, Community>(name, context)

View file

@ -1,9 +1,13 @@
use crate::sensitive::Sensitive;
use lemmy_db_schema::newtypes::{CommentId, CommentReportId, CommunityId, LocalUserId, PostId};
use lemmy_db_schema::{
newtypes::{CommentId, CommentReportId, CommunityId, LocalUserId, PostId},
ListingType,
SortType,
};
use lemmy_db_views::structs::{CommentReportView, CommentView};
use serde::{Deserialize, Serialize};
#[derive(Debug, Serialize, Deserialize)]
#[derive(Debug, Serialize, Deserialize, Clone, Default)]
pub struct CreateComment {
pub content: String,
pub post_id: PostId,
@ -12,13 +16,13 @@ pub struct CreateComment {
pub auth: Sensitive<String>,
}
#[derive(Debug, Serialize, Deserialize)]
#[derive(Debug, Serialize, Deserialize, Clone, Default)]
pub struct GetComment {
pub id: CommentId,
pub auth: Option<Sensitive<String>>,
}
#[derive(Debug, Serialize, Deserialize)]
#[derive(Debug, Serialize, Deserialize, Clone, Default)]
pub struct EditComment {
pub content: String,
pub comment_id: CommentId,
@ -26,14 +30,14 @@ pub struct EditComment {
pub auth: Sensitive<String>,
}
#[derive(Debug, Serialize, Deserialize)]
#[derive(Debug, Serialize, Deserialize, Clone, Default)]
pub struct DeleteComment {
pub comment_id: CommentId,
pub deleted: bool,
pub auth: Sensitive<String>,
}
#[derive(Debug, Serialize, Deserialize)]
#[derive(Debug, Serialize, Deserialize, Clone, Default)]
pub struct RemoveComment {
pub comment_id: CommentId,
pub removed: bool,
@ -41,14 +45,14 @@ pub struct RemoveComment {
pub auth: Sensitive<String>,
}
#[derive(Debug, Serialize, Deserialize)]
#[derive(Debug, Serialize, Deserialize, Clone, Default)]
pub struct MarkCommentAsRead {
pub comment_id: CommentId,
pub read: bool,
pub auth: Sensitive<String>,
}
#[derive(Debug, Serialize, Deserialize)]
#[derive(Debug, Serialize, Deserialize, Clone, Default)]
pub struct SaveComment {
pub comment_id: CommentId,
pub save: bool,
@ -62,17 +66,17 @@ pub struct CommentResponse {
pub form_id: Option<String>, // An optional front end ID, to tell which is coming back
}
#[derive(Debug, Serialize, Deserialize)]
#[derive(Debug, Serialize, Deserialize, Clone, Default)]
pub struct CreateCommentLike {
pub comment_id: CommentId,
pub score: i16,
pub auth: Sensitive<String>,
}
#[derive(Debug, Serialize, Deserialize)]
#[derive(Debug, Serialize, Deserialize, Clone, Default)]
pub struct GetComments {
pub type_: Option<String>,
pub sort: Option<String>,
pub type_: Option<ListingType>,
pub sort: Option<SortType>,
pub page: Option<i64>,
pub limit: Option<i64>,
pub community_id: Option<CommunityId>,
@ -81,12 +85,12 @@ pub struct GetComments {
pub auth: Option<Sensitive<String>>,
}
#[derive(Debug, Serialize, Deserialize)]
#[derive(Debug, Serialize, Deserialize, Clone)]
pub struct GetCommentsResponse {
pub comments: Vec<CommentView>,
}
#[derive(Debug, Serialize, Deserialize)]
#[derive(Debug, Serialize, Deserialize, Clone, Default)]
pub struct CreateCommentReport {
pub comment_id: CommentId,
pub reason: String,
@ -98,14 +102,14 @@ pub struct CommentReportResponse {
pub comment_report_view: CommentReportView,
}
#[derive(Debug, Serialize, Deserialize)]
#[derive(Debug, Serialize, Deserialize, Clone, Default)]
pub struct ResolveCommentReport {
pub report_id: CommentReportId,
pub resolved: bool,
pub auth: Sensitive<String>,
}
#[derive(Debug, Serialize, Deserialize)]
#[derive(Debug, Serialize, Deserialize, Clone, Default)]
pub struct ListCommentReports {
pub page: Option<i64>,
pub limit: Option<i64>,
@ -116,7 +120,7 @@ pub struct ListCommentReports {
pub auth: Sensitive<String>,
}
#[derive(Debug, Serialize, Deserialize)]
#[derive(Debug, Serialize, Deserialize, Clone)]
pub struct ListCommentReportsResponse {
pub comment_reports: Vec<CommentReportView>,
}

View file

@ -2,11 +2,13 @@ use crate::sensitive::Sensitive;
use lemmy_db_schema::{
newtypes::{CommunityId, PersonId},
source::site::Site,
ListingType,
SortType,
};
use lemmy_db_views_actor::structs::{CommunityModeratorView, CommunityView, PersonViewSafe};
use serde::{Deserialize, Serialize};
#[derive(Debug, Serialize, Deserialize)]
#[derive(Debug, Serialize, Deserialize, Clone, Default)]
pub struct GetCommunity {
pub id: Option<CommunityId>,
/// Example: star_trek , or star_trek@xyz.tld
@ -14,7 +16,7 @@ pub struct GetCommunity {
pub auth: Option<Sensitive<String>>,
}
#[derive(Debug, Serialize, Deserialize)]
#[derive(Debug, Serialize, Deserialize, Clone)]
pub struct GetCommunityResponse {
pub community_view: CommunityView,
pub site: Option<Site>,
@ -22,7 +24,7 @@ pub struct GetCommunityResponse {
pub online: usize,
}
#[derive(Debug, Serialize, Deserialize)]
#[derive(Debug, Serialize, Deserialize, Clone, Default)]
pub struct CreateCommunity {
pub name: String,
pub title: String,
@ -39,21 +41,21 @@ pub struct CommunityResponse {
pub community_view: CommunityView,
}
#[derive(Serialize, Deserialize, Debug)]
#[derive(Debug, Serialize, Deserialize, Clone, Default)]
pub struct ListCommunities {
pub type_: Option<String>,
pub sort: Option<String>,
pub type_: Option<ListingType>,
pub sort: Option<SortType>,
pub page: Option<i64>,
pub limit: Option<i64>,
pub auth: Option<Sensitive<String>>,
}
#[derive(Serialize, Deserialize, Debug)]
#[derive(Debug, Serialize, Deserialize, Clone)]
pub struct ListCommunitiesResponse {
pub communities: Vec<CommunityView>,
}
#[derive(Debug, Serialize, Deserialize, Clone)]
#[derive(Debug, Serialize, Deserialize, Clone, Default)]
pub struct BanFromCommunity {
pub community_id: CommunityId,
pub person_id: PersonId,
@ -70,7 +72,7 @@ pub struct BanFromCommunityResponse {
pub banned: bool,
}
#[derive(Debug, Serialize, Deserialize)]
#[derive(Debug, Serialize, Deserialize, Clone, Default)]
pub struct AddModToCommunity {
pub community_id: CommunityId,
pub person_id: PersonId,
@ -83,7 +85,7 @@ pub struct AddModToCommunityResponse {
pub moderators: Vec<CommunityModeratorView>,
}
#[derive(Debug, Serialize, Deserialize)]
#[derive(Debug, Serialize, Deserialize, Clone, Default)]
pub struct EditCommunity {
pub community_id: CommunityId,
pub title: Option<String>,
@ -95,7 +97,7 @@ pub struct EditCommunity {
pub auth: Sensitive<String>,
}
#[derive(Debug, Serialize, Deserialize)]
#[derive(Debug, Serialize, Deserialize, Clone, Default)]
pub struct HideCommunity {
pub community_id: CommunityId,
pub hidden: bool,
@ -103,14 +105,14 @@ pub struct HideCommunity {
pub auth: Sensitive<String>,
}
#[derive(Debug, Serialize, Deserialize)]
#[derive(Debug, Serialize, Deserialize, Clone, Default)]
pub struct DeleteCommunity {
pub community_id: CommunityId,
pub deleted: bool,
pub auth: Sensitive<String>,
}
#[derive(Debug, Serialize, Deserialize)]
#[derive(Debug, Serialize, Deserialize, Clone, Default)]
pub struct RemoveCommunity {
pub community_id: CommunityId,
pub removed: bool,
@ -119,14 +121,14 @@ pub struct RemoveCommunity {
pub auth: Sensitive<String>,
}
#[derive(Debug, Serialize, Deserialize)]
#[derive(Debug, Serialize, Deserialize, Clone, Default)]
pub struct FollowCommunity {
pub community_id: CommunityId,
pub follow: bool,
pub auth: Sensitive<String>,
}
#[derive(Debug, Serialize, Deserialize)]
#[derive(Debug, Serialize, Deserialize, Clone, Default)]
pub struct BlockCommunity {
pub community_id: CommunityId,
pub block: bool,
@ -139,7 +141,7 @@ pub struct BlockCommunityResponse {
pub blocked: bool,
}
#[derive(Debug, Serialize, Deserialize)]
#[derive(Debug, Serialize, Deserialize, Clone, Default)]
pub struct TransferCommunity {
pub community_id: CommunityId,
pub person_id: PersonId,

View file

@ -4,7 +4,7 @@ pub mod person;
pub mod post;
#[cfg(feature = "full")]
pub mod request;
mod sensitive;
pub mod sensitive;
pub mod site;
#[cfg(feature = "full")]
pub mod utils;

View file

@ -3,14 +3,17 @@ use lemmy_db_views::structs::{CommentView, PostView, PrivateMessageView};
use lemmy_db_views_actor::structs::{CommunityModeratorView, PersonMentionView, PersonViewSafe};
use serde::{Deserialize, Serialize};
#[derive(Debug, Serialize, Deserialize)]
#[derive(Debug, Serialize, Deserialize, Clone, Default)]
pub struct Login {
pub username_or_email: Sensitive<String>,
pub password: Sensitive<String>,
}
use lemmy_db_schema::newtypes::{CommunityId, PersonId, PersonMentionId, PrivateMessageId};
use lemmy_db_schema::{
newtypes::{CommunityId, PersonId, PersonMentionId, PrivateMessageId},
SortType,
};
#[derive(Debug, Serialize, Deserialize)]
#[derive(Debug, Serialize, Deserialize, Clone, Default)]
pub struct Register {
pub username: String,
pub password: Sensitive<String>,
@ -25,22 +28,22 @@ pub struct Register {
pub answer: Option<String>,
}
#[derive(Debug, Serialize, Deserialize)]
#[derive(Debug, Serialize, Deserialize, Clone, Default)]
pub struct GetCaptcha {}
#[derive(Debug, Serialize, Deserialize)]
#[derive(Debug, Serialize, Deserialize, Clone)]
pub struct GetCaptchaResponse {
pub ok: Option<CaptchaResponse>, // Will be None if captchas are disabled
}
#[derive(Debug, Serialize, Deserialize)]
#[derive(Debug, Serialize, Deserialize, Clone)]
pub struct CaptchaResponse {
pub png: String, // A Base64 encoded png
pub wav: String, // A Base64 encoded wav audio
pub uuid: String,
}
#[derive(Debug, Serialize, Deserialize)]
#[derive(Debug, Serialize, Deserialize, Clone, Default)]
pub struct SaveUserSettings {
pub show_nsfw: Option<bool>,
pub show_scores: Option<bool>,
@ -63,7 +66,7 @@ pub struct SaveUserSettings {
pub auth: Sensitive<String>,
}
#[derive(Debug, Serialize, Deserialize)]
#[derive(Debug, Serialize, Deserialize, Clone, Default)]
pub struct ChangePassword {
pub new_password: Sensitive<String>,
pub new_password_verify: Sensitive<String>,
@ -71,7 +74,7 @@ pub struct ChangePassword {
pub auth: Sensitive<String>,
}
#[derive(Debug, Serialize, Deserialize)]
#[derive(Debug, Serialize, Deserialize, Clone)]
pub struct LoginResponse {
/// This is None in response to `Register` if email verification is enabled, or the server requires registration applications.
pub jwt: Option<Sensitive<String>>,
@ -79,12 +82,12 @@ pub struct LoginResponse {
pub verify_email_sent: bool,
}
#[derive(Debug, Serialize, Deserialize)]
#[derive(Debug, Serialize, Deserialize, Clone, Default)]
pub struct GetPersonDetails {
pub person_id: Option<PersonId>, // One of these two are required
/// Example: dessalines , or dessalines@xyz.tld
pub username: Option<String>,
pub sort: Option<String>,
pub sort: Option<SortType>,
pub page: Option<i64>,
pub limit: Option<i64>,
pub community_id: Option<CommunityId>,
@ -92,7 +95,7 @@ pub struct GetPersonDetails {
pub auth: Option<Sensitive<String>>,
}
#[derive(Debug, Serialize, Deserialize)]
#[derive(Debug, Serialize, Deserialize, Clone)]
pub struct GetPersonDetailsResponse {
pub person_view: PersonViewSafe,
pub comments: Vec<CommentView>,
@ -100,22 +103,22 @@ pub struct GetPersonDetailsResponse {
pub moderates: Vec<CommunityModeratorView>,
}
#[derive(Debug, Serialize, Deserialize)]
#[derive(Debug, Serialize, Deserialize, Clone, Default)]
pub struct GetRepliesResponse {
pub replies: Vec<CommentView>,
}
#[derive(Debug, Serialize, Deserialize)]
#[derive(Debug, Serialize, Deserialize, Clone)]
pub struct GetPersonMentionsResponse {
pub mentions: Vec<PersonMentionView>,
}
#[derive(Debug, Serialize, Deserialize)]
#[derive(Debug, Serialize, Deserialize, Clone, Default)]
pub struct MarkAllAsRead {
pub auth: Sensitive<String>,
}
#[derive(Debug, Serialize, Deserialize)]
#[derive(Debug, Serialize, Deserialize, Clone, Default)]
pub struct AddAdmin {
pub person_id: PersonId,
pub added: bool,
@ -127,7 +130,7 @@ pub struct AddAdminResponse {
pub admins: Vec<PersonViewSafe>,
}
#[derive(Debug, Serialize, Deserialize)]
#[derive(Debug, Serialize, Deserialize, Clone, Default)]
pub struct BanPerson {
pub person_id: PersonId,
pub ban: bool,
@ -137,12 +140,12 @@ pub struct BanPerson {
pub auth: Sensitive<String>,
}
#[derive(Debug, Serialize, Deserialize)]
#[derive(Debug, Serialize, Deserialize, Clone, Default)]
pub struct GetBannedPersons {
pub auth: String,
}
#[derive(Debug, Serialize, Deserialize)]
#[derive(Debug, Serialize, Deserialize, Clone)]
pub struct BannedPersonsResponse {
pub banned: Vec<PersonViewSafe>,
}
@ -153,7 +156,7 @@ pub struct BanPersonResponse {
pub banned: bool,
}
#[derive(Debug, Serialize, Deserialize)]
#[derive(Debug, Serialize, Deserialize, Clone, Default)]
pub struct BlockPerson {
pub person_id: PersonId,
pub block: bool,
@ -166,25 +169,25 @@ pub struct BlockPersonResponse {
pub blocked: bool,
}
#[derive(Debug, Serialize, Deserialize)]
#[derive(Debug, Serialize, Deserialize, Clone, Default)]
pub struct GetReplies {
pub sort: Option<String>,
pub sort: Option<SortType>,
pub page: Option<i64>,
pub limit: Option<i64>,
pub unread_only: Option<bool>,
pub auth: Sensitive<String>,
}
#[derive(Debug, Serialize, Deserialize)]
#[derive(Debug, Serialize, Deserialize, Clone, Default)]
pub struct GetPersonMentions {
pub sort: Option<String>,
pub sort: Option<SortType>,
pub page: Option<i64>,
pub limit: Option<i64>,
pub unread_only: Option<bool>,
pub auth: Sensitive<String>,
}
#[derive(Debug, Serialize, Deserialize)]
#[derive(Debug, Serialize, Deserialize, Clone, Default)]
pub struct MarkPersonMentionAsRead {
pub person_mention_id: PersonMentionId,
pub read: bool,
@ -196,7 +199,7 @@ pub struct PersonMentionResponse {
pub person_mention_view: PersonMentionView,
}
#[derive(Debug, Serialize, Deserialize)]
#[derive(Debug, Serialize, Deserialize, Clone, Default)]
pub struct DeleteAccount {
pub password: Sensitive<String>,
pub auth: Sensitive<String>,
@ -205,7 +208,7 @@ pub struct DeleteAccount {
#[derive(Debug, Serialize, Deserialize, Clone)]
pub struct DeleteAccountResponse {}
#[derive(Debug, Serialize, Deserialize)]
#[derive(Debug, Serialize, Deserialize, Clone, Default)]
pub struct PasswordReset {
pub email: Sensitive<String>,
}
@ -213,42 +216,42 @@ pub struct PasswordReset {
#[derive(Debug, Serialize, Deserialize, Clone)]
pub struct PasswordResetResponse {}
#[derive(Debug, Serialize, Deserialize)]
#[derive(Debug, Serialize, Deserialize, Clone, Default)]
pub struct PasswordChangeAfterReset {
pub token: Sensitive<String>,
pub password: Sensitive<String>,
pub password_verify: Sensitive<String>,
}
#[derive(Debug, Serialize, Deserialize)]
#[derive(Debug, Serialize, Deserialize, Clone, Default)]
pub struct CreatePrivateMessage {
pub content: String,
pub recipient_id: PersonId,
pub auth: Sensitive<String>,
}
#[derive(Debug, Serialize, Deserialize)]
#[derive(Debug, Serialize, Deserialize, Clone, Default)]
pub struct EditPrivateMessage {
pub private_message_id: PrivateMessageId,
pub content: String,
pub auth: Sensitive<String>,
}
#[derive(Debug, Serialize, Deserialize)]
#[derive(Debug, Serialize, Deserialize, Clone, Default)]
pub struct DeletePrivateMessage {
pub private_message_id: PrivateMessageId,
pub deleted: bool,
pub auth: Sensitive<String>,
}
#[derive(Debug, Serialize, Deserialize)]
#[derive(Debug, Serialize, Deserialize, Clone, Default)]
pub struct MarkPrivateMessageAsRead {
pub private_message_id: PrivateMessageId,
pub read: bool,
pub auth: Sensitive<String>,
}
#[derive(Debug, Serialize, Deserialize)]
#[derive(Debug, Serialize, Deserialize, Clone, Default)]
pub struct GetPrivateMessages {
pub unread_only: Option<bool>,
pub page: Option<i64>,
@ -266,7 +269,7 @@ pub struct PrivateMessageResponse {
pub private_message_view: PrivateMessageView,
}
#[derive(Debug, Serialize, Deserialize)]
#[derive(Debug, Serialize, Deserialize, Clone, Default)]
pub struct GetReportCount {
pub community_id: Option<CommunityId>,
pub auth: Sensitive<String>,
@ -279,7 +282,7 @@ pub struct GetReportCountResponse {
pub post_reports: i64,
}
#[derive(Debug, Serialize, Deserialize)]
#[derive(Debug, Serialize, Deserialize, Clone, Default)]
pub struct GetUnreadCount {
pub auth: Sensitive<String>,
}
@ -291,7 +294,7 @@ pub struct GetUnreadCountResponse {
pub private_messages: i64,
}
#[derive(Serialize, Deserialize)]
#[derive(Serialize, Deserialize, Clone, Default)]
pub struct VerifyEmail {
pub token: String,
}

View file

@ -1,11 +1,15 @@
use crate::sensitive::Sensitive;
use lemmy_db_schema::newtypes::{CommunityId, PostId, PostReportId};
use lemmy_db_schema::{
newtypes::{CommunityId, PostId, PostReportId},
ListingType,
SortType,
};
use lemmy_db_views::structs::{CommentView, PostReportView, PostView};
use lemmy_db_views_actor::structs::{CommunityModeratorView, CommunityView};
use serde::{Deserialize, Serialize};
use url::Url;
#[derive(Serialize, Deserialize, Debug)]
#[derive(Debug, Serialize, Deserialize, Clone, Default)]
pub struct CreatePost {
pub name: String,
pub community_id: CommunityId,
@ -21,13 +25,13 @@ pub struct PostResponse {
pub post_view: PostView,
}
#[derive(Debug, Serialize, Deserialize)]
#[derive(Debug, Serialize, Deserialize, Clone, Default)]
pub struct GetPost {
pub id: PostId,
pub auth: Option<Sensitive<String>>,
}
#[derive(Debug, Serialize, Deserialize)]
#[derive(Debug, Serialize, Deserialize, Clone)]
pub struct GetPostResponse {
pub post_view: PostView,
pub community_view: CommunityView,
@ -36,10 +40,10 @@ pub struct GetPostResponse {
pub online: usize,
}
#[derive(Serialize, Deserialize, Debug)]
#[derive(Serialize, Deserialize, Debug, Clone, Default)]
pub struct GetPosts {
pub type_: Option<String>,
pub sort: Option<String>,
pub type_: Option<ListingType>,
pub sort: Option<SortType>,
pub page: Option<i64>,
pub limit: Option<i64>,
pub community_id: Option<CommunityId>,
@ -48,19 +52,19 @@ pub struct GetPosts {
pub auth: Option<Sensitive<String>>,
}
#[derive(Serialize, Deserialize, Debug)]
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct GetPostsResponse {
pub posts: Vec<PostView>,
}
#[derive(Debug, Serialize, Deserialize)]
#[derive(Debug, Serialize, Deserialize, Clone, Default)]
pub struct CreatePostLike {
pub post_id: PostId,
pub score: i16,
pub auth: Sensitive<String>,
}
#[derive(Debug, Serialize, Deserialize)]
#[derive(Debug, Serialize, Deserialize, Clone, Default)]
pub struct EditPost {
pub post_id: PostId,
pub name: Option<String>,
@ -70,14 +74,14 @@ pub struct EditPost {
pub auth: Sensitive<String>,
}
#[derive(Debug, Serialize, Deserialize)]
#[derive(Debug, Serialize, Deserialize, Clone, Default)]
pub struct DeletePost {
pub post_id: PostId,
pub deleted: bool,
pub auth: Sensitive<String>,
}
#[derive(Debug, Serialize, Deserialize)]
#[derive(Debug, Serialize, Deserialize, Clone, Default)]
pub struct RemovePost {
pub post_id: PostId,
pub removed: bool,
@ -85,35 +89,35 @@ pub struct RemovePost {
pub auth: Sensitive<String>,
}
#[derive(Debug, Serialize, Deserialize)]
#[derive(Debug, Serialize, Deserialize, Clone, Default)]
pub struct MarkPostAsRead {
pub post_id: PostId,
pub read: bool,
pub auth: Sensitive<String>,
}
#[derive(Debug, Serialize, Deserialize)]
#[derive(Debug, Serialize, Deserialize, Clone, Default)]
pub struct LockPost {
pub post_id: PostId,
pub locked: bool,
pub auth: Sensitive<String>,
}
#[derive(Debug, Serialize, Deserialize)]
#[derive(Debug, Serialize, Deserialize, Clone, Default)]
pub struct StickyPost {
pub post_id: PostId,
pub stickied: bool,
pub auth: Sensitive<String>,
}
#[derive(Debug, Serialize, Deserialize)]
#[derive(Debug, Serialize, Deserialize, Clone, Default)]
pub struct SavePost {
pub post_id: PostId,
pub save: bool,
pub auth: Sensitive<String>,
}
#[derive(Debug, Serialize, Deserialize)]
#[derive(Debug, Serialize, Deserialize, Clone, Default)]
pub struct CreatePostReport {
pub post_id: PostId,
pub reason: String,
@ -125,14 +129,14 @@ pub struct PostReportResponse {
pub post_report_view: PostReportView,
}
#[derive(Debug, Serialize, Deserialize)]
#[derive(Debug, Serialize, Deserialize, Clone, Default)]
pub struct ResolvePostReport {
pub report_id: PostReportId,
pub resolved: bool,
pub auth: Sensitive<String>,
}
#[derive(Debug, Serialize, Deserialize)]
#[derive(Debug, Serialize, Deserialize, Clone, Default)]
pub struct ListPostReports {
pub page: Option<i64>,
pub limit: Option<i64>,
@ -143,22 +147,22 @@ pub struct ListPostReports {
pub auth: Sensitive<String>,
}
#[derive(Debug, Serialize, Deserialize)]
#[derive(Debug, Serialize, Deserialize, Clone)]
pub struct ListPostReportsResponse {
pub post_reports: Vec<PostReportView>,
}
#[derive(Serialize, Deserialize, Debug)]
#[derive(Debug, Serialize, Deserialize, Clone)]
pub struct GetSiteMetadata {
pub url: Url,
}
#[derive(Serialize, Deserialize, Clone, Debug)]
#[derive(Debug, Serialize, Deserialize, Clone)]
pub struct GetSiteMetadataResponse {
pub metadata: SiteMetadata,
}
#[derive(Deserialize, Serialize, Debug, PartialEq, Clone)]
#[derive(Debug, Deserialize, Serialize, PartialEq, Clone)]
pub struct SiteMetadata {
pub title: Option<String>,
pub description: Option<String>,

View file

@ -4,7 +4,7 @@ use std::{
ops::{Deref, DerefMut},
};
#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Deserialize, Serialize)]
#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Deserialize, Serialize, Default)]
#[serde(transparent)]
pub struct Sensitive<T>(T);

View file

@ -1,5 +1,10 @@
use crate::sensitive::Sensitive;
use lemmy_db_schema::newtypes::{CommunityId, PersonId};
use lemmy_db_schema::{
newtypes::{CommunityId, PersonId},
ListingType,
SearchType,
SortType,
};
use lemmy_db_views::structs::{
CommentView,
LocalUserSettingsView,
@ -30,21 +35,21 @@ use lemmy_db_views_moderator::structs::{
};
use serde::{Deserialize, Serialize};
#[derive(Serialize, Deserialize, Debug)]
#[derive(Debug, Serialize, Deserialize, Clone, Default)]
pub struct Search {
pub q: String,
pub community_id: Option<CommunityId>,
pub community_name: Option<String>,
pub creator_id: Option<PersonId>,
pub type_: Option<String>,
pub sort: Option<String>,
pub listing_type: Option<String>,
pub type_: Option<SearchType>,
pub sort: Option<SortType>,
pub listing_type: Option<ListingType>,
pub page: Option<i64>,
pub limit: Option<i64>,
pub auth: Option<Sensitive<String>>,
}
#[derive(Serialize, Deserialize, Debug)]
#[derive(Debug, Serialize, Deserialize, Clone)]
pub struct SearchResponse {
pub type_: String,
pub comments: Vec<CommentView>,
@ -53,7 +58,7 @@ pub struct SearchResponse {
pub users: Vec<PersonViewSafe>,
}
#[derive(Serialize, Deserialize, Debug)]
#[derive(Debug, Serialize, Deserialize, Clone, Default)]
pub struct ResolveObject {
pub q: String,
pub auth: Option<Sensitive<String>>,
@ -67,7 +72,7 @@ pub struct ResolveObjectResponse {
pub person: Option<PersonViewSafe>,
}
#[derive(Debug, Serialize, Deserialize)]
#[derive(Debug, Serialize, Deserialize, Clone, Default)]
pub struct GetModlog {
pub mod_person_id: Option<PersonId>,
pub community_id: Option<CommunityId>,
@ -76,7 +81,7 @@ pub struct GetModlog {
pub auth: Option<Sensitive<String>>,
}
#[derive(Debug, Serialize, Deserialize)]
#[derive(Debug, Serialize, Deserialize, Clone)]
pub struct GetModlogResponse {
pub removed_posts: Vec<ModRemovePostView>,
pub locked_posts: Vec<ModLockPostView>,
@ -91,7 +96,7 @@ pub struct GetModlogResponse {
pub hidden_communities: Vec<ModHideCommunityView>,
}
#[derive(Debug, Serialize, Deserialize)]
#[derive(Debug, Serialize, Deserialize, Clone, Default)]
pub struct CreateSite {
pub name: String,
pub sidebar: Option<String>,
@ -111,7 +116,7 @@ pub struct CreateSite {
pub auth: Sensitive<String>,
}
#[derive(Debug, Serialize, Deserialize)]
#[derive(Debug, Serialize, Deserialize, Clone, Default)]
pub struct EditSite {
pub name: Option<String>,
pub sidebar: Option<String>,
@ -131,7 +136,7 @@ pub struct EditSite {
pub auth: Sensitive<String>,
}
#[derive(Debug, Serialize, Deserialize)]
#[derive(Debug, Serialize, Deserialize, Clone, Default)]
pub struct GetSite {
pub auth: Option<Sensitive<String>>,
}
@ -141,7 +146,7 @@ pub struct SiteResponse {
pub site_view: SiteView,
}
#[derive(Debug, Serialize, Deserialize)]
#[derive(Debug, Serialize, Deserialize, Clone)]
pub struct GetSiteResponse {
pub site_view: Option<SiteView>, // Because the site might not be set up yet
pub admins: Vec<PersonViewSafe>,
@ -151,7 +156,7 @@ pub struct GetSiteResponse {
pub federated_instances: Option<FederatedInstances>, // Federation may be disabled
}
#[derive(Debug, Serialize, Deserialize)]
#[derive(Debug, Serialize, Deserialize, Clone)]
pub struct MyUserInfo {
pub local_user_view: LocalUserSettingsView,
pub follows: Vec<CommunityFollowerView>,
@ -160,35 +165,35 @@ pub struct MyUserInfo {
pub person_blocks: Vec<PersonBlockView>,
}
#[derive(Debug, Serialize, Deserialize)]
#[derive(Debug, Serialize, Deserialize, Clone)]
pub struct LeaveAdmin {
pub auth: Sensitive<String>,
}
#[derive(Debug, Serialize, Deserialize)]
#[derive(Debug, Serialize, Deserialize, Clone)]
pub struct GetSiteConfig {
pub auth: Sensitive<String>,
}
#[derive(Debug, Serialize, Deserialize)]
#[derive(Debug, Serialize, Deserialize, Clone)]
pub struct GetSiteConfigResponse {
pub config_hjson: String,
}
#[derive(Debug, Serialize, Deserialize)]
#[derive(Debug, Serialize, Deserialize, Clone)]
pub struct SaveSiteConfig {
pub config_hjson: String,
pub auth: Sensitive<String>,
}
#[derive(Debug, Serialize, Deserialize)]
#[derive(Debug, Serialize, Deserialize, Clone)]
pub struct FederatedInstances {
pub linked: Vec<String>,
pub allowed: Option<Vec<String>>,
pub blocked: Option<Vec<String>>,
}
#[derive(Serialize, Deserialize)]
#[derive(Debug, Serialize, Deserialize, Clone, Default)]
pub struct ListRegistrationApplications {
/// Only shows the unread applications (IE those without an admin actor)
pub unread_only: Option<bool>,
@ -197,12 +202,12 @@ pub struct ListRegistrationApplications {
pub auth: String,
}
#[derive(Serialize, Deserialize)]
#[derive(Debug, Serialize, Deserialize, Clone)]
pub struct ListRegistrationApplicationsResponse {
pub registration_applications: Vec<RegistrationApplicationView>,
}
#[derive(Serialize, Deserialize)]
#[derive(Debug, Serialize, Deserialize, Clone, Default)]
pub struct ApproveRegistrationApplication {
pub id: i32,
pub approve: bool,
@ -210,17 +215,17 @@ pub struct ApproveRegistrationApplication {
pub auth: String,
}
#[derive(Serialize, Deserialize)]
#[derive(Debug, Serialize, Deserialize, Clone)]
pub struct RegistrationApplicationResponse {
pub registration_application: RegistrationApplicationView,
}
#[derive(Serialize, Deserialize)]
#[derive(Debug, Serialize, Deserialize, Clone)]
pub struct GetUnreadRegistrationApplicationCount {
pub auth: String,
}
#[derive(Serialize, Deserialize, Clone)]
#[derive(Debug, Serialize, Deserialize, Clone)]
pub struct GetUnreadRegistrationApplicationCountResponse {
pub registration_applications: i64,
}

View file

@ -2,7 +2,7 @@ use crate::sensitive::Sensitive;
use lemmy_db_schema::newtypes::{CommunityId, PostId};
use serde::{Deserialize, Serialize};
#[derive(Serialize, Deserialize, Debug)]
#[derive(Debug, Serialize, Deserialize, Clone)]
pub struct UserJoin {
pub auth: Sensitive<String>,
}
@ -12,7 +12,7 @@ pub struct UserJoinResponse {
pub joined: bool,
}
#[derive(Serialize, Deserialize, Debug)]
#[derive(Debug, Serialize, Deserialize, Clone)]
pub struct CommunityJoin {
pub community_id: CommunityId,
}
@ -22,7 +22,7 @@ pub struct CommunityJoinResponse {
pub joined: bool,
}
#[derive(Serialize, Deserialize, Debug)]
#[derive(Debug, Serialize, Deserialize, Clone)]
pub struct ModJoin {
pub community_id: CommunityId,
}
@ -32,7 +32,7 @@ pub struct ModJoinResponse {
pub joined: bool,
}
#[derive(Serialize, Deserialize, Debug)]
#[derive(Debug, Serialize, Deserialize, Clone)]
pub struct PostJoin {
pub post_id: PostId,
}

View file

@ -5,11 +5,7 @@ use lemmy_api_common::{
utils::{blocking, check_private_instance, get_local_user_view_from_jwt_opt},
};
use lemmy_apub::{fetcher::resolve_actor_identifier, objects::community::ApubCommunity};
use lemmy_db_schema::{
source::community::Community,
traits::DeleteableOrRemoveable,
utils::{from_opt_str_to_opt_enum, ListingType, SortType},
};
use lemmy_db_schema::{source::community::Community, traits::DeleteableOrRemoveable};
use lemmy_db_views::comment_view::CommentQueryBuilder;
use lemmy_utils::{ConnectionId, LemmyError};
use lemmy_websocket::LemmyContext;
@ -36,9 +32,6 @@ impl PerformCrud for GetComments {
.map(|t| t.local_user.show_bot_accounts);
let person_id = local_user_view.map(|u| u.person.id);
let sort: Option<SortType> = from_opt_str_to_opt_enum(&data.sort);
let listing_type: Option<ListingType> = from_opt_str_to_opt_enum(&data.type_);
let community_id = data.community_id;
let community_actor_id = if let Some(name) = &data.community_name {
resolve_actor_identifier::<ApubCommunity, Community>(name, context)
@ -48,6 +41,8 @@ impl PerformCrud for GetComments {
} else {
None
};
let sort = data.sort;
let listing_type = data.type_;
let saved_only = data.saved_only;
let page = data.page;
let limit = data.limit;

View file

@ -4,10 +4,7 @@ use lemmy_api_common::{
community::{ListCommunities, ListCommunitiesResponse},
utils::{blocking, check_private_instance, get_local_user_view_from_jwt_opt},
};
use lemmy_db_schema::{
traits::DeleteableOrRemoveable,
utils::{from_opt_str_to_opt_enum, ListingType, SortType},
};
use lemmy_db_schema::traits::DeleteableOrRemoveable;
use lemmy_db_views_actor::community_view::CommunityQueryBuilder;
use lemmy_utils::{ConnectionId, LemmyError};
use lemmy_websocket::LemmyContext;
@ -37,9 +34,8 @@ impl PerformCrud for ListCommunities {
None => false,
};
let sort: Option<SortType> = from_opt_str_to_opt_enum(&data.sort);
let listing_type: Option<ListingType> = from_opt_str_to_opt_enum(&data.type_);
let sort = data.sort;
let listing_type = data.type_;
let page = data.page;
let limit = data.limit;
let mut communities = blocking(context.pool(), move |conn| {

View file

@ -8,7 +8,7 @@ use lemmy_apub::{fetcher::resolve_actor_identifier, objects::community::ApubComm
use lemmy_db_schema::{
source::{community::Community, site::Site},
traits::DeleteableOrRemoveable,
utils::{from_opt_str_to_opt_enum, ListingType, SortType},
ListingType,
};
use lemmy_db_views::post_view::PostQueryBuilder;
use lemmy_utils::{ConnectionId, LemmyError};
@ -42,15 +42,14 @@ impl PerformCrud for GetPosts {
.as_ref()
.map(|t| t.local_user.show_read_posts);
let sort: Option<SortType> = from_opt_str_to_opt_enum(&data.sort);
let listing_type: ListingType = match from_opt_str_to_opt_enum(&data.type_) {
let sort = data.sort;
let listing_type: ListingType = match data.type_ {
Some(l) => l,
None => {
let site = blocking(context.pool(), Site::read_local_site).await??;
ListingType::from_str(&site.default_post_listing_type)?
}
};
let page = data.page;
let limit = data.limit;
let community_id = data.community_id;

View file

@ -16,7 +16,8 @@ use lemmy_db_schema::{
site::{Site, SiteForm},
},
traits::Crud,
utils::{diesel_option_overwrite, diesel_option_overwrite_to_url, naive_now, ListingType},
utils::{diesel_option_overwrite, diesel_option_overwrite_to_url, naive_now},
ListingType,
};
use lemmy_db_views::structs::SiteView;
use lemmy_utils::{utils::check_slurs_opt, ConnectionId, LemmyError};

View file

@ -5,10 +5,7 @@ use lemmy_api_common::{
utils::{blocking, check_private_instance, get_local_user_view_from_jwt_opt},
};
use lemmy_apub::{fetcher::resolve_actor_identifier, objects::person::ApubPerson};
use lemmy_db_schema::{
source::person::Person,
utils::{from_opt_str_to_opt_enum, SortType},
};
use lemmy_db_schema::source::person::Person;
use lemmy_db_views::{comment_view::CommentQueryBuilder, post_view::PostQueryBuilder};
use lemmy_db_views_actor::structs::{CommunityModeratorView, PersonViewSafe};
use lemmy_utils::{ConnectionId, LemmyError};
@ -39,8 +36,6 @@ impl PerformCrud for GetPersonDetails {
.as_ref()
.map(|t| t.local_user.show_read_posts);
let sort: Option<SortType> = from_opt_str_to_opt_enum(&data.sort);
let person_details_id = match data.person_id {
Some(id) => id,
None => {
@ -66,6 +61,7 @@ impl PerformCrud for GetPersonDetails {
})
.await??;
let sort = data.sort;
let page = data.page;
let limit = data.limit;
let saved_only = data.saved_only;

View file

@ -14,12 +14,14 @@ doctest = false
[features]
full = ["diesel", "diesel-derive-newtype", "diesel_migrations", "bcrypt", "lemmy_utils",
"lemmy_apub_lib", "strum", "strum_macros", "sha2", "regex", "once_cell", "serde_json"]
"lemmy_apub_lib", "sha2", "regex", "once_cell", "serde_json"]
[dependencies]
chrono = { version = "0.4.19", features = ["serde"], default-features = false }
serde = { version = "1.0.136", features = ["derive"] }
url = { version = "2.2.2", features = ["serde"] }
strum = "0.24.0"
strum_macros = "0.24.0"
serde_json = { version = "1.0.79", features = ["preserve_order"], optional = true }
lemmy_apub_lib = { version = "=0.16.3", path = "../apub_lib", optional = true }
lemmy_utils = { version = "=0.16.3", path = "../utils", optional = true }
@ -27,8 +29,6 @@ bcrypt = { version = "0.12.1", optional = true }
diesel = { version = "1.4.8", features = ["postgres","chrono","r2d2","serde_json"], optional = true }
diesel-derive-newtype = { version = "0.1.2", optional = true }
diesel_migrations = { version = "1.4.0", optional = true }
strum = { version = "0.24.0", optional = true }
strum_macros = { version = "0.24.0", optional = true }
sha2 = { version = "0.10.2", optional = true }
regex = { version = "1.5.5", optional = true }
once_cell = { version = "1.10.0", optional = true }

View file

@ -1,8 +1,5 @@
#[cfg(feature = "full")]
#[macro_use]
extern crate strum_macros;
#[cfg(feature = "full")]
#[macro_use]
extern crate diesel;
#[cfg(feature = "full")]
#[macro_use]
@ -24,3 +21,38 @@ pub mod source;
pub mod traits;
#[cfg(feature = "full")]
pub mod utils;
use serde::{Deserialize, Serialize};
use strum_macros::{Display, EnumString};
#[derive(EnumString, Display, Debug, Serialize, Deserialize, Clone, Copy)]
pub enum SortType {
Active,
Hot,
New,
TopDay,
TopWeek,
TopMonth,
TopYear,
TopAll,
MostComments,
NewComments,
}
#[derive(EnumString, Display, Debug, Serialize, Deserialize, Clone, Copy, PartialEq)]
pub enum ListingType {
All,
Local,
Subscribed,
Community,
}
#[derive(EnumString, Display, Debug, Serialize, Deserialize, Clone, Copy)]
pub enum SearchType {
All,
Comments,
Posts,
Communities,
Users,
Url,
}

View file

@ -20,7 +20,7 @@ impl fmt::Display for PostId {
#[cfg_attr(feature = "full", derive(DieselNewType))]
pub struct PersonId(pub i32);
#[derive(Debug, Copy, Clone, Hash, Eq, PartialEq, Serialize, Deserialize)]
#[derive(Debug, Copy, Clone, Hash, Eq, PartialEq, Serialize, Deserialize, Default)]
#[cfg_attr(feature = "full", derive(DieselNewType))]
pub struct CommentId(pub i32);
@ -38,7 +38,7 @@ pub struct CommunityId(pub i32);
#[cfg_attr(feature = "full", derive(DieselNewType))]
pub struct LocalUserId(pub i32);
#[derive(Debug, Copy, Clone, Hash, Eq, PartialEq, Serialize, Deserialize)]
#[derive(Debug, Copy, Clone, Hash, Eq, PartialEq, Serialize, Deserialize, Default)]
#[cfg_attr(feature = "full", derive(DieselNewType))]
pub struct PrivateMessageId(i32);
@ -48,23 +48,23 @@ impl fmt::Display for PrivateMessageId {
}
}
#[derive(Debug, Copy, Clone, Hash, Eq, PartialEq, Serialize, Deserialize)]
#[derive(Debug, Copy, Clone, Hash, Eq, PartialEq, Serialize, Deserialize, Default)]
#[cfg_attr(feature = "full", derive(DieselNewType))]
pub struct PersonMentionId(i32);
#[derive(Debug, Copy, Clone, Hash, Eq, PartialEq, Serialize, Deserialize)]
#[derive(Debug, Copy, Clone, Hash, Eq, PartialEq, Serialize, Deserialize, Default)]
#[cfg_attr(feature = "full", derive(DieselNewType))]
pub struct PersonBlockId(i32);
#[derive(Debug, Copy, Clone, Hash, Eq, PartialEq, Serialize, Deserialize)]
#[derive(Debug, Copy, Clone, Hash, Eq, PartialEq, Serialize, Deserialize, Default)]
#[cfg_attr(feature = "full", derive(DieselNewType))]
pub struct CommunityBlockId(i32);
#[derive(Debug, Copy, Clone, Hash, Eq, PartialEq, Serialize, Deserialize)]
#[derive(Debug, Copy, Clone, Hash, Eq, PartialEq, Serialize, Deserialize, Default)]
#[cfg_attr(feature = "full", derive(DieselNewType))]
pub struct CommentReportId(i32);
#[derive(Debug, Copy, Clone, Hash, Eq, PartialEq, Serialize, Deserialize)]
#[derive(Debug, Copy, Clone, Hash, Eq, PartialEq, Serialize, Deserialize, Default)]
#[cfg_attr(feature = "full", derive(DieselNewType))]
pub struct PostReportId(i32);

View file

@ -12,7 +12,6 @@ use lemmy_apub_lib::{object_id::ObjectId, traits::ApubObject};
use lemmy_utils::LemmyError;
use once_cell::sync::Lazy;
use regex::Regex;
use serde::{Deserialize, Serialize};
use std::{env, env::VarError, io::Write};
use url::Url;
@ -22,42 +21,6 @@ pub fn get_database_url_from_env() -> Result<String, VarError> {
env::var("LEMMY_DATABASE_URL")
}
#[derive(EnumString, Display, Debug, Serialize, Deserialize, Clone, Copy)]
pub enum SortType {
Active,
Hot,
New,
TopDay,
TopWeek,
TopMonth,
TopYear,
TopAll,
MostComments,
NewComments,
}
#[derive(EnumString, Display, Debug, Serialize, Deserialize, Clone, Copy, PartialEq)]
pub enum ListingType {
All,
Local,
Subscribed,
Community,
}
#[derive(EnumString, Display, 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().and_then(|t| T::from_str(t).ok())
}
pub fn fuzzy_search(q: &str) -> String {
let replaced = q.replace('%', "\\%").replace('_', "\\_").replace(' ', "%");
format!("%{}%", replaced)

View file

@ -26,7 +26,9 @@ use lemmy_db_schema::{
post::Post,
},
traits::{MaybeOptional, ToSafe, ViewToVec},
utils::{functions::hot_rank, fuzzy_search, limit_and_offset, ListingType, SortType},
utils::{functions::hot_rank, fuzzy_search, limit_and_offset},
ListingType,
SortType,
};
type CommentViewTuple = (

View file

@ -23,7 +23,9 @@ use lemmy_db_schema::{
post::{Post, PostRead, PostSaved},
},
traits::{MaybeOptional, ToSafe, ViewToVec},
utils::{functions::hot_rank, fuzzy_search, limit_and_offset, ListingType, SortType},
utils::{functions::hot_rank, fuzzy_search, limit_and_offset},
ListingType,
SortType,
};
use tracing::debug;
@ -505,7 +507,9 @@ mod tests {
post::*,
},
traits::{Blockable, Crud, Likeable},
utils::{establish_unpooled_connection, ListingType, SortType},
utils::establish_unpooled_connection,
ListingType,
SortType,
};
use serial_test::serial;

View file

@ -9,7 +9,9 @@ use lemmy_db_schema::{
community_block::CommunityBlock,
},
traits::{MaybeOptional, ToSafe, ViewToVec},
utils::{functions::hot_rank, fuzzy_search, limit_and_offset, ListingType, SortType},
utils::{functions::hot_rank, fuzzy_search, limit_and_offset},
ListingType,
SortType,
};
type CommunityViewTuple = (

View file

@ -26,7 +26,8 @@ use lemmy_db_schema::{
post::Post,
},
traits::{MaybeOptional, ToSafe, ViewToVec},
utils::{functions::hot_rank, limit_and_offset, SortType},
utils::{functions::hot_rank, limit_and_offset},
SortType,
};
type PersonMentionViewTuple = (

View file

@ -6,7 +6,8 @@ use lemmy_db_schema::{
schema::{person, person_aggregates},
source::person::{Person, PersonSafe},
traits::{MaybeOptional, ToSafe, ViewToVec},
utils::{fuzzy_search, limit_and_offset, SortType},
utils::{fuzzy_search, limit_and_offset},
SortType,
};
type PersonViewSafeTuple = (PersonSafe, PersonAggregates);

View file

@ -7,7 +7,8 @@ use lemmy_db_schema::{
newtypes::LocalUserId,
source::{community::Community, local_user::LocalUser, person::Person},
traits::{ApubActor, Crud},
utils::{ListingType, SortType},
ListingType,
SortType,
};
use lemmy_db_views::{
comment_view::CommentQueryBuilder,