CommunityPersonBanAdditionalInfo (partial)

pull/3755/head
dull b 2023-07-29 01:55:40 +00:00
parent 603aede7ce
commit 158f7f0cd9
8 changed files with 35 additions and 12 deletions

View File

@ -11,6 +11,7 @@ use crate::{
CommunityModerator,
CommunityModeratorForm,
CommunityPersonBan,
CommunityPersonBanAdditionalInfo,
CommunityPersonBanForm,
CommunityUpdateForm,
},
@ -214,6 +215,18 @@ impl Bannable for CommunityPersonBan {
}
}
impl CommunityPersonBanAdditionalInfo {
pub fn into_full(self, community_id: CommunityId, person_id: PersonId) -> CommunityPersonBan {
CommunityPersonBan {
id: self.id,
published: self.published,
expires: self.expires,
community_id,
person_id,
}
}
}
impl CommunityFollower {
pub fn to_subscribed_type(follower: &Option<Self>) -> SubscribedType {
match follower {

View File

@ -162,6 +162,16 @@ pub struct CommunityPersonBan {
pub expires: Option<chrono::NaiveDateTime>,
}
#[derive(PartialEq, Eq, Debug)]
#[cfg_attr(feature = "full", derive(Queryable, Selectable))]
#[cfg_attr(feature = "full", diesel(table_name = community_person_ban))]
/// Like `CommunityPersonBan` but without `community_id` and `person_id`, which are usually already known
pub struct CommunityPersonBanAdditionalInfo {
pub id: i32,
pub published: chrono::NaiveDateTime,
pub expires: Option<chrono::NaiveDateTime>,
}
#[derive(Clone)]
#[cfg_attr(feature = "full", derive(Insertable, AsChangeset))]
#[cfg_attr(feature = "full", diesel(table_name = community_person_ban))]

View File

@ -72,7 +72,7 @@ fn queries<'a>() -> Queries<
person::all_columns,
aliases::person1.fields(person::all_columns),
CommentAggregatesNotInComment::as_select(),
community_person_ban::all_columns.nullable(),
CommunityPersonBanAdditionalInfo::as_select().nullable(),
comment_like::score.nullable(),
aliases::person2.fields(person::all_columns).nullable(),
);
@ -229,7 +229,7 @@ impl JoinView for CommentReportView {
Person,
Person,
CommentAggregatesNotInComment,
Option<CommunityPersonBan>,
Option<CommunityPersonBanAdditionalInfo>,
Option<i16>,
Option<Person>,
);

View File

@ -48,7 +48,7 @@ type CommentViewTuple = (
Post,
Community,
CommentAggregatesNotInComment,
Option<CommunityPersonBan>,
Option<CommunityPersonBanAdditionalInfo>,
Option<CommunityFollower>,
Option<CommentSaved>,
Option<PersonBlock>,
@ -110,7 +110,7 @@ fn queries<'a>() -> Queries<
post::all_columns,
community::all_columns,
CommentAggregatesNotInComment::as_select(),
community_person_ban::all_columns.nullable(),
CommunityPersonBanAdditionalInfo::as_select().nullable(),
community_follower::all_columns.nullable(),
comment_saved::all_columns.nullable(),
person_block::all_columns.nullable(),

View File

@ -40,7 +40,7 @@ type PostReportViewTuple = (
Community,
Person,
Person,
Option<CommunityPersonBan>,
Option<CommunityPersonBanAdditionalInfo>,
Option<i16>,
PostAggregatesNotInPost,
Option<Person>,
@ -81,7 +81,7 @@ fn queries<'a>() -> Queries<
community::all_columns,
person::all_columns,
aliases::person1.fields(person::all_columns),
community_person_ban::all_columns.nullable(),
CommunityPersonBanAdditionalInfo::as_select().nullable(),
post_like::score.nullable(),
PostAggregatesNotInPost::as_select(),
aliases::person2.fields(person::all_columns.nullable()),

View File

@ -51,7 +51,7 @@ type PostViewTuple = (
Post,
Person,
Community,
Option<CommunityPersonBan>,
Option<CommunityPersonBanAdditionalInfo>,
PostAggregatesNotInPost,
Option<CommunityFollower>,
Option<PostSaved>,
@ -137,7 +137,7 @@ fn queries<'a>() -> Queries<
post::all_columns,
person::all_columns,
community::all_columns,
community_person_ban::all_columns.nullable(),
CommunityPersonBanAdditionalInfo::as_select().nullable(),
PostAggregatesNotInPost::as_select(),
community_follower::all_columns.nullable(),
post_saved::all_columns.nullable(),

View File

@ -48,7 +48,7 @@ type CommentReplyViewTuple = (
Community,
Person,
CommentAggregatesNotInComment,
Option<CommunityPersonBan>,
Option<CommunityPersonBanAdditionalInfo>,
Option<CommunityFollower>,
Option<CommentSaved>,
Option<PersonBlock>,
@ -113,7 +113,7 @@ fn queries<'a>() -> Queries<
community::all_columns,
aliases::person1.fields(person::all_columns),
CommentAggregatesNotInComment::as_select(),
community_person_ban::all_columns.nullable(),
CommunityPersonBanAdditionalInfo::as_select().nullable(),
community_follower::all_columns.nullable(),
comment_saved::all_columns.nullable(),
person_block::all_columns.nullable(),

View File

@ -49,7 +49,7 @@ type PersonMentionViewTuple = (
Community,
Person,
CommentAggregatesNotInComment,
Option<CommunityPersonBan>,
Option<CommunityPersonBanAdditionalInfo>,
Option<CommunityFollower>,
Option<CommentSaved>,
Option<PersonBlock>,
@ -109,7 +109,7 @@ fn queries<'a>() -> Queries<
community::all_columns,
aliases::person1.fields(person::all_columns),
CommentAggregatesNotInComment::as_select(),
community_person_ban::all_columns.nullable(),
CommunityPersonBanAdditionalInfo::as_select().nullable(),
community_follower::all_columns.nullable(),
comment_saved::all_columns.nullable(),
person_block::all_columns.nullable(),