Skip to content

Commit

Permalink
Add default and clone for most api structs
Browse files Browse the repository at this point in the history
  • Loading branch information
Nutomic committed May 6, 2022
1 parent f62f030 commit b4a3ac5
Show file tree
Hide file tree
Showing 7 changed files with 112 additions and 112 deletions.
28 changes: 14 additions & 14 deletions crates/api_common/src/comment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use lemmy_db_schema::{
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,
Expand All @@ -16,43 +16,43 @@ 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,
pub form_id: Option<String>,
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,
pub reason: Option<String>,
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,
Expand All @@ -66,14 +66,14 @@ 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, Default)]
#[derive(Debug, Serialize, Deserialize, Clone, Default)]
pub struct GetComments {
pub type_: Option<ListingType>,
pub sort: Option<SortType>,
Expand All @@ -85,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,
Expand All @@ -102,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, Default)]
#[derive(Debug, Serialize, Deserialize, Clone, Default)]
pub struct ListCommentReports {
pub page: Option<i64>,
pub limit: Option<i64>,
Expand All @@ -120,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>,
}
28 changes: 14 additions & 14 deletions crates/api_common/src/community.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,23 @@ use lemmy_db_schema::{
use lemmy_db_views_actor::structs::{CommunityModeratorView, CommunityView, PersonViewSafe};
use serde::{Deserialize, Serialize};

#[derive(Debug, Serialize, Deserialize, Default)]
#[derive(Debug, Serialize, Deserialize, Clone, Default)]
pub struct GetCommunity {
pub id: Option<CommunityId>,
/// Example: star_trek , or star_trek@xyz.tld
pub name: Option<String>,
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>,
pub moderators: Vec<CommunityModeratorView>,
pub online: usize,
}

#[derive(Debug, Serialize, Deserialize)]
#[derive(Debug, Serialize, Deserialize, Clone, Default)]
pub struct CreateCommunity {
pub name: String,
pub title: String,
Expand All @@ -41,7 +41,7 @@ pub struct CommunityResponse {
pub community_view: CommunityView,
}

#[derive(Serialize, Deserialize, Debug, Default)]
#[derive(Debug, Serialize, Deserialize, Clone, Default)]
pub struct ListCommunities {
pub type_: Option<ListingType>,
pub sort: Option<SortType>,
Expand All @@ -50,12 +50,12 @@ pub struct ListCommunities {
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,
Expand All @@ -72,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,
Expand All @@ -85,7 +85,7 @@ pub struct AddModToCommunityResponse {
pub moderators: Vec<CommunityModeratorView>,
}

#[derive(Debug, Serialize, Deserialize, Default)]
#[derive(Debug, Serialize, Deserialize, Clone, Default)]
pub struct EditCommunity {
pub community_id: CommunityId,
pub title: Option<String>,
Expand All @@ -97,22 +97,22 @@ 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,
pub reason: Option<String>,
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,
Expand All @@ -121,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,
Expand All @@ -141,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,
Expand Down
Loading

0 comments on commit b4a3ac5

Please sign in to comment.