mirror of
https://github.com/LemmyNet/lemmy.git
synced 2025-01-10 12:05:57 +00:00
Changing modded_person to other_person.
This commit is contained in:
parent
43179177a0
commit
0723ef2055
4 changed files with 71 additions and 70 deletions
|
@ -36,7 +36,7 @@ pub async fn get_mod_log(
|
|||
} else {
|
||||
data.mod_person_id
|
||||
};
|
||||
let modded_person_id = data.modded_person_id;
|
||||
let other_person_id = data.other_person_id;
|
||||
let post_id = data.post_id;
|
||||
let comment_id = data.comment_id;
|
||||
|
||||
|
@ -52,7 +52,7 @@ pub async fn get_mod_log(
|
|||
type_,
|
||||
community_id,
|
||||
mod_person_id,
|
||||
modded_person_id,
|
||||
other_person_id,
|
||||
post_id,
|
||||
comment_id,
|
||||
hide_modlog_names: Some(hide_modlog_names),
|
||||
|
|
|
@ -133,7 +133,7 @@ pub struct GetModlog {
|
|||
#[cfg_attr(feature = "full", ts(optional))]
|
||||
pub type_: Option<ModlogActionType>,
|
||||
#[cfg_attr(feature = "full", ts(optional))]
|
||||
pub modded_person_id: Option<PersonId>,
|
||||
pub other_person_id: Option<PersonId>,
|
||||
#[cfg_attr(feature = "full", ts(optional))]
|
||||
pub post_id: Option<PostId>,
|
||||
#[cfg_attr(feature = "full", ts(optional))]
|
||||
|
|
|
@ -142,7 +142,7 @@ pub struct ModlogCombinedQuery {
|
|||
pub community_id: Option<CommunityId>,
|
||||
pub hide_modlog_names: Option<bool>,
|
||||
pub mod_person_id: Option<PersonId>,
|
||||
pub modded_person_id: Option<PersonId>,
|
||||
pub other_person_id: Option<PersonId>,
|
||||
pub page_after: Option<PaginationCursorData>,
|
||||
pub page_back: Option<bool>,
|
||||
}
|
||||
|
@ -155,7 +155,8 @@ impl ModlogCombinedQuery {
|
|||
let show_mod_names = !(self.hide_modlog_names.unwrap_or_default());
|
||||
let show_mod_names_expr = show_mod_names.as_sql::<diesel::sql_types::Bool>();
|
||||
|
||||
let modded_person = aliases::person1.field(person::id);
|
||||
// The modded / other person
|
||||
let other_person = aliases::person1.field(person::id);
|
||||
|
||||
// The query for the admin / mod person
|
||||
// It needs an OR condition to every mod table
|
||||
|
@ -181,33 +182,33 @@ impl ModlogCombinedQuery {
|
|||
.or(mod_transfer_community::mod_person_id.eq(person::id)),
|
||||
);
|
||||
|
||||
let modded_person_join = mod_add::other_person_id
|
||||
.eq(modded_person)
|
||||
.or(mod_add_community::other_person_id.eq(modded_person))
|
||||
.or(mod_ban::other_person_id.eq(modded_person))
|
||||
.or(mod_ban_from_community::other_person_id.eq(modded_person))
|
||||
// Some tables don't have the modded_person_id directly, so you need to join
|
||||
let other_person_join = mod_add::other_person_id
|
||||
.eq(other_person)
|
||||
.or(mod_add_community::other_person_id.eq(other_person))
|
||||
.or(mod_ban::other_person_id.eq(other_person))
|
||||
.or(mod_ban_from_community::other_person_id.eq(other_person))
|
||||
// Some tables don't have the other_person_id directly, so you need to join
|
||||
.or(
|
||||
mod_feature_post::id
|
||||
.is_not_null()
|
||||
.and(post::creator_id.eq(modded_person)),
|
||||
.and(post::creator_id.eq(other_person)),
|
||||
)
|
||||
.or(
|
||||
mod_lock_post::id
|
||||
.is_not_null()
|
||||
.and(post::creator_id.eq(modded_person)),
|
||||
.and(post::creator_id.eq(other_person)),
|
||||
)
|
||||
.or(
|
||||
mod_remove_comment::id
|
||||
.is_not_null()
|
||||
.and(comment::creator_id.eq(modded_person)),
|
||||
.and(comment::creator_id.eq(other_person)),
|
||||
)
|
||||
.or(
|
||||
mod_remove_post::id
|
||||
.is_not_null()
|
||||
.and(post::creator_id.eq(modded_person)),
|
||||
.and(post::creator_id.eq(other_person)),
|
||||
)
|
||||
.or(mod_transfer_community::other_person_id.eq(modded_person));
|
||||
.or(mod_transfer_community::other_person_id.eq(other_person));
|
||||
|
||||
let comment_join = mod_remove_comment::comment_id.eq(comment::id);
|
||||
|
||||
|
@ -282,8 +283,8 @@ impl ModlogCombinedQuery {
|
|||
.left_join(community::table.on(community_join))
|
||||
// The instance
|
||||
.left_join(instance::table.on(instance_join))
|
||||
// The modded person
|
||||
.left_join(aliases::person1.on(modded_person_join))
|
||||
// The other / modded person
|
||||
.left_join(aliases::person1.on(other_person_join))
|
||||
.select((
|
||||
admin_allow_instance::all_columns.nullable(),
|
||||
admin_block_instance::all_columns.nullable(),
|
||||
|
@ -316,8 +317,8 @@ impl ModlogCombinedQuery {
|
|||
query = query.filter(person::id.eq(mod_person_id));
|
||||
};
|
||||
|
||||
if let Some(modded_person_id) = self.modded_person_id {
|
||||
query = query.filter(modded_person.eq(modded_person_id));
|
||||
if let Some(other_person_id) = self.other_person_id {
|
||||
query = query.filter(other_person.eq(other_person_id));
|
||||
};
|
||||
|
||||
if let Some(community_id) = self.community_id {
|
||||
|
@ -443,52 +444,52 @@ impl InternalToCombinedView for ModlogCombinedViewInternal {
|
|||
admin: v.moderator,
|
||||
community,
|
||||
}))
|
||||
} else if let (Some(mod_add), Some(modded_person)) = (v.mod_add, v.modded_person.clone()) {
|
||||
} else if let (Some(mod_add), Some(other_person)) = (v.mod_add, v.other_person.clone()) {
|
||||
Some(ModlogCombinedView::ModAdd(ModAddView {
|
||||
mod_add,
|
||||
moderator: v.moderator,
|
||||
modded_person,
|
||||
other_person,
|
||||
}))
|
||||
} else if let (Some(mod_add_community), Some(modded_person), Some(community)) = (
|
||||
} else if let (Some(mod_add_community), Some(other_person), Some(community)) = (
|
||||
v.mod_add_community,
|
||||
v.modded_person.clone(),
|
||||
v.other_person.clone(),
|
||||
v.community.clone(),
|
||||
) {
|
||||
Some(ModlogCombinedView::ModAddCommunity(ModAddCommunityView {
|
||||
mod_add_community,
|
||||
moderator: v.moderator,
|
||||
modded_person,
|
||||
other_person,
|
||||
community,
|
||||
}))
|
||||
} else if let (Some(mod_ban), Some(modded_person)) = (v.mod_ban, v.modded_person.clone()) {
|
||||
} else if let (Some(mod_ban), Some(other_person)) = (v.mod_ban, v.other_person.clone()) {
|
||||
Some(ModlogCombinedView::ModBan(ModBanView {
|
||||
mod_ban,
|
||||
moderator: v.moderator,
|
||||
modded_person,
|
||||
other_person,
|
||||
}))
|
||||
} else if let (Some(mod_ban_from_community), Some(modded_person), Some(community)) = (
|
||||
} else if let (Some(mod_ban_from_community), Some(other_person), Some(community)) = (
|
||||
v.mod_ban_from_community,
|
||||
v.modded_person.clone(),
|
||||
v.other_person.clone(),
|
||||
v.community.clone(),
|
||||
) {
|
||||
Some(ModlogCombinedView::ModBanFromCommunity(
|
||||
ModBanFromCommunityView {
|
||||
mod_ban_from_community,
|
||||
moderator: v.moderator,
|
||||
modded_person,
|
||||
other_person,
|
||||
community,
|
||||
},
|
||||
))
|
||||
} else if let (Some(mod_feature_post), Some(modded_person), Some(community), Some(post)) = (
|
||||
} else if let (Some(mod_feature_post), Some(other_person), Some(community), Some(post)) = (
|
||||
v.mod_feature_post,
|
||||
v.modded_person.clone(),
|
||||
v.other_person.clone(),
|
||||
v.community.clone(),
|
||||
v.post.clone(),
|
||||
) {
|
||||
Some(ModlogCombinedView::ModFeaturePost(ModFeaturePostView {
|
||||
mod_feature_post,
|
||||
moderator: v.moderator,
|
||||
modded_person,
|
||||
other_person,
|
||||
community,
|
||||
post,
|
||||
}))
|
||||
|
@ -500,28 +501,28 @@ impl InternalToCombinedView for ModlogCombinedViewInternal {
|
|||
admin: v.moderator,
|
||||
community,
|
||||
}))
|
||||
} else if let (Some(mod_lock_post), Some(modded_person), Some(community), Some(post)) = (
|
||||
} else if let (Some(mod_lock_post), Some(other_person), Some(community), Some(post)) = (
|
||||
v.mod_lock_post,
|
||||
v.modded_person.clone(),
|
||||
v.other_person.clone(),
|
||||
v.community.clone(),
|
||||
v.post.clone(),
|
||||
) {
|
||||
Some(ModlogCombinedView::ModLockPost(ModLockPostView {
|
||||
mod_lock_post,
|
||||
moderator: v.moderator,
|
||||
modded_person,
|
||||
other_person,
|
||||
community,
|
||||
post,
|
||||
}))
|
||||
} else if let (
|
||||
Some(mod_remove_comment),
|
||||
Some(modded_person),
|
||||
Some(other_person),
|
||||
Some(community),
|
||||
Some(post),
|
||||
Some(comment),
|
||||
) = (
|
||||
v.mod_remove_comment,
|
||||
v.modded_person.clone(),
|
||||
v.other_person.clone(),
|
||||
v.community.clone(),
|
||||
v.post.clone(),
|
||||
v.comment,
|
||||
|
@ -529,7 +530,7 @@ impl InternalToCombinedView for ModlogCombinedViewInternal {
|
|||
Some(ModlogCombinedView::ModRemoveComment(ModRemoveCommentView {
|
||||
mod_remove_comment,
|
||||
moderator: v.moderator,
|
||||
modded_person,
|
||||
other_person,
|
||||
community,
|
||||
post,
|
||||
comment,
|
||||
|
@ -544,29 +545,29 @@ impl InternalToCombinedView for ModlogCombinedViewInternal {
|
|||
community,
|
||||
},
|
||||
))
|
||||
} else if let (Some(mod_remove_post), Some(modded_person), Some(community), Some(post)) = (
|
||||
} else if let (Some(mod_remove_post), Some(other_person), Some(community), Some(post)) = (
|
||||
v.mod_remove_post,
|
||||
v.modded_person.clone(),
|
||||
v.other_person.clone(),
|
||||
v.community.clone(),
|
||||
v.post.clone(),
|
||||
) {
|
||||
Some(ModlogCombinedView::ModRemovePost(ModRemovePostView {
|
||||
mod_remove_post,
|
||||
moderator: v.moderator,
|
||||
modded_person,
|
||||
other_person,
|
||||
community,
|
||||
post,
|
||||
}))
|
||||
} else if let (Some(mod_transfer_community), Some(modded_person), Some(community)) = (
|
||||
} else if let (Some(mod_transfer_community), Some(other_person), Some(community)) = (
|
||||
v.mod_transfer_community,
|
||||
v.modded_person.clone(),
|
||||
v.other_person.clone(),
|
||||
v.community.clone(),
|
||||
) {
|
||||
Some(ModlogCombinedView::ModTransferCommunity(
|
||||
ModTransferCommunityView {
|
||||
mod_transfer_community,
|
||||
moderator: v.moderator,
|
||||
modded_person,
|
||||
other_person,
|
||||
community,
|
||||
},
|
||||
))
|
||||
|
@ -1051,7 +1052,7 @@ mod tests {
|
|||
data.jessica.id,
|
||||
v.moderator.as_ref().map(|a| a.id).unwrap_or(PersonId(-1))
|
||||
);
|
||||
assert_eq!(data.jessica.id, v.modded_person.id);
|
||||
assert_eq!(data.jessica.id, v.other_person.id);
|
||||
} else {
|
||||
panic!("wrong type");
|
||||
}
|
||||
|
@ -1065,7 +1066,7 @@ mod tests {
|
|||
data.jessica.id,
|
||||
v.moderator.as_ref().map(|a| a.id).unwrap_or(PersonId(-1))
|
||||
);
|
||||
assert_eq!(data.sara.id, v.modded_person.id);
|
||||
assert_eq!(data.sara.id, v.other_person.id);
|
||||
} else {
|
||||
panic!("wrong type");
|
||||
}
|
||||
|
@ -1077,7 +1078,7 @@ mod tests {
|
|||
data.jessica.id,
|
||||
v.moderator.as_ref().map(|a| a.id).unwrap_or(PersonId(-1))
|
||||
);
|
||||
assert_eq!(data.sara.id, v.modded_person.id);
|
||||
assert_eq!(data.sara.id, v.other_person.id);
|
||||
} else {
|
||||
panic!("wrong type");
|
||||
}
|
||||
|
@ -1089,7 +1090,7 @@ mod tests {
|
|||
data.timmy.id,
|
||||
v.moderator.as_ref().map(|a| a.id).unwrap_or(PersonId(-1))
|
||||
);
|
||||
assert_eq!(data.jessica.id, v.modded_person.id);
|
||||
assert_eq!(data.jessica.id, v.other_person.id);
|
||||
} else {
|
||||
panic!("wrong type");
|
||||
}
|
||||
|
@ -1103,7 +1104,7 @@ mod tests {
|
|||
data.timmy.id,
|
||||
v.moderator.as_ref().map(|a| a.id).unwrap_or(PersonId(-1))
|
||||
);
|
||||
assert_eq!(data.timmy.id, v.modded_person.id);
|
||||
assert_eq!(data.timmy.id, v.other_person.id);
|
||||
} else {
|
||||
panic!("wrong type");
|
||||
}
|
||||
|
@ -1128,7 +1129,7 @@ mod tests {
|
|||
data.timmy.id,
|
||||
v.moderator.as_ref().map(|a| a.id).unwrap_or(PersonId(-1))
|
||||
);
|
||||
assert_eq!(data.timmy.id, v.modded_person.id);
|
||||
assert_eq!(data.timmy.id, v.other_person.id);
|
||||
} else {
|
||||
panic!("wrong type");
|
||||
}
|
||||
|
@ -1143,7 +1144,7 @@ mod tests {
|
|||
data.timmy.id,
|
||||
v.moderator.as_ref().map(|a| a.id).unwrap_or(PersonId(-1))
|
||||
);
|
||||
assert_eq!(data.timmy.id, v.modded_person.id);
|
||||
assert_eq!(data.timmy.id, v.other_person.id);
|
||||
} else {
|
||||
panic!("wrong type");
|
||||
}
|
||||
|
@ -1158,7 +1159,7 @@ mod tests {
|
|||
data.timmy.id,
|
||||
v.moderator.as_ref().map(|a| a.id).unwrap_or(PersonId(-1))
|
||||
);
|
||||
assert_eq!(data.timmy.id, v.modded_person.id);
|
||||
assert_eq!(data.timmy.id, v.other_person.id);
|
||||
} else {
|
||||
panic!("wrong type");
|
||||
}
|
||||
|
@ -1170,7 +1171,7 @@ mod tests {
|
|||
data.timmy.id,
|
||||
v.moderator.as_ref().map(|a| a.id).unwrap_or(PersonId(-1))
|
||||
);
|
||||
assert_eq!(data.jessica.id, v.modded_person.id);
|
||||
assert_eq!(data.jessica.id, v.other_person.id);
|
||||
} else {
|
||||
panic!("wrong type");
|
||||
}
|
||||
|
@ -1180,7 +1181,7 @@ mod tests {
|
|||
data.timmy.id,
|
||||
v.moderator.as_ref().map(|a| a.id).unwrap_or(PersonId(-1))
|
||||
);
|
||||
assert_eq!(data.jessica.id, v.modded_person.id);
|
||||
assert_eq!(data.jessica.id, v.other_person.id);
|
||||
} else {
|
||||
panic!("wrong type");
|
||||
}
|
||||
|
@ -1192,7 +1193,7 @@ mod tests {
|
|||
data.timmy.id,
|
||||
v.moderator.as_ref().map(|a| a.id).unwrap_or(PersonId(-1))
|
||||
);
|
||||
assert_eq!(data.jessica.id, v.modded_person.id);
|
||||
assert_eq!(data.jessica.id, v.other_person.id);
|
||||
} else {
|
||||
panic!("wrong type");
|
||||
}
|
||||
|
@ -1202,7 +1203,7 @@ mod tests {
|
|||
data.timmy.id,
|
||||
v.moderator.as_ref().map(|a| a.id).unwrap_or(PersonId(-1))
|
||||
);
|
||||
assert_eq!(data.jessica.id, v.modded_person.id);
|
||||
assert_eq!(data.jessica.id, v.other_person.id);
|
||||
} else {
|
||||
panic!("wrong type");
|
||||
}
|
||||
|
@ -1229,7 +1230,7 @@ mod tests {
|
|||
// you have to go into the item to see who created it.
|
||||
|
||||
let modlog_modded_timmy_filter = ModlogCombinedQuery {
|
||||
modded_person_id: Some(data.timmy.id),
|
||||
other_person_id: Some(data.timmy.id),
|
||||
..Default::default()
|
||||
}
|
||||
.list(pool)
|
||||
|
@ -1237,7 +1238,7 @@ mod tests {
|
|||
assert_eq!(4, modlog_modded_timmy_filter.len());
|
||||
|
||||
let modlog_modded_jessica_filter = ModlogCombinedQuery {
|
||||
modded_person_id: Some(data.jessica.id),
|
||||
other_person_id: Some(data.jessica.id),
|
||||
..Default::default()
|
||||
}
|
||||
.list(pool)
|
||||
|
@ -1245,7 +1246,7 @@ mod tests {
|
|||
assert_eq!(6, modlog_modded_jessica_filter.len());
|
||||
|
||||
let modlog_modded_sara_filter = ModlogCombinedQuery {
|
||||
modded_person_id: Some(data.sara.id),
|
||||
other_person_id: Some(data.sara.id),
|
||||
..Default::default()
|
||||
}
|
||||
.list(pool)
|
||||
|
|
|
@ -47,7 +47,7 @@ pub struct ModAddCommunityView {
|
|||
#[cfg_attr(feature = "full", ts(optional))]
|
||||
pub moderator: Option<Person>,
|
||||
pub community: Community,
|
||||
pub modded_person: Person,
|
||||
pub other_person: Person,
|
||||
}
|
||||
|
||||
#[skip_serializing_none]
|
||||
|
@ -60,7 +60,7 @@ pub struct ModAddView {
|
|||
pub mod_add: ModAdd,
|
||||
#[cfg_attr(feature = "full", ts(optional))]
|
||||
pub moderator: Option<Person>,
|
||||
pub modded_person: Person,
|
||||
pub other_person: Person,
|
||||
}
|
||||
|
||||
#[skip_serializing_none]
|
||||
|
@ -74,7 +74,7 @@ pub struct ModBanFromCommunityView {
|
|||
#[cfg_attr(feature = "full", ts(optional))]
|
||||
pub moderator: Option<Person>,
|
||||
pub community: Community,
|
||||
pub modded_person: Person,
|
||||
pub other_person: Person,
|
||||
}
|
||||
|
||||
#[skip_serializing_none]
|
||||
|
@ -87,7 +87,7 @@ pub struct ModBanView {
|
|||
pub mod_ban: ModBan,
|
||||
#[cfg_attr(feature = "full", ts(optional))]
|
||||
pub moderator: Option<Person>,
|
||||
pub modded_person: Person,
|
||||
pub other_person: Person,
|
||||
}
|
||||
|
||||
#[skip_serializing_none]
|
||||
|
@ -113,7 +113,7 @@ pub struct ModLockPostView {
|
|||
pub mod_lock_post: ModLockPost,
|
||||
#[cfg_attr(feature = "full", ts(optional))]
|
||||
pub moderator: Option<Person>,
|
||||
pub modded_person: Person,
|
||||
pub other_person: Person,
|
||||
pub post: Post,
|
||||
pub community: Community,
|
||||
}
|
||||
|
@ -128,7 +128,7 @@ pub struct ModRemoveCommentView {
|
|||
pub mod_remove_comment: ModRemoveComment,
|
||||
#[cfg_attr(feature = "full", ts(optional))]
|
||||
pub moderator: Option<Person>,
|
||||
pub modded_person: Person,
|
||||
pub other_person: Person,
|
||||
pub comment: Comment,
|
||||
pub post: Post,
|
||||
pub community: Community,
|
||||
|
@ -157,7 +157,7 @@ pub struct ModRemovePostView {
|
|||
pub mod_remove_post: ModRemovePost,
|
||||
#[cfg_attr(feature = "full", ts(optional))]
|
||||
pub moderator: Option<Person>,
|
||||
pub modded_person: Person,
|
||||
pub other_person: Person,
|
||||
pub post: Post,
|
||||
pub community: Community,
|
||||
}
|
||||
|
@ -172,7 +172,7 @@ pub struct ModFeaturePostView {
|
|||
pub mod_feature_post: ModFeaturePost,
|
||||
#[cfg_attr(feature = "full", ts(optional))]
|
||||
pub moderator: Option<Person>,
|
||||
pub modded_person: Person,
|
||||
pub other_person: Person,
|
||||
pub post: Post,
|
||||
pub community: Community,
|
||||
}
|
||||
|
@ -188,7 +188,7 @@ pub struct ModTransferCommunityView {
|
|||
#[cfg_attr(feature = "full", ts(optional))]
|
||||
pub moderator: Option<Person>,
|
||||
pub community: Community,
|
||||
pub modded_person: Person,
|
||||
pub other_person: Person,
|
||||
}
|
||||
|
||||
#[skip_serializing_none]
|
||||
|
@ -300,7 +300,7 @@ pub struct ModlogCombinedViewInternal {
|
|||
|
||||
// Shared
|
||||
pub moderator: Option<Person>,
|
||||
pub modded_person: Option<Person>,
|
||||
pub other_person: Option<Person>,
|
||||
pub instance: Option<Instance>,
|
||||
pub community: Option<Community>,
|
||||
pub post: Option<Post>,
|
||||
|
|
Loading…
Reference in a new issue