From 45e312f020fb173f09722c436c0fa04d75f26fed Mon Sep 17 00:00:00 2001 From: Dessalines Date: Fri, 10 Jan 2025 12:31:04 -0500 Subject: [PATCH] Revert "Adding strum and simplifying imports." This reverts commit 15f167110721429dd6e465f522250c8beb3d4dd7. --- Cargo.lock | 1 - crates/db_views_moderator/Cargo.toml | 1 - .../src/modlog_combined_view.rs | 51 +++++++++++-------- crates/db_views_moderator/src/structs.rs | 3 +- 4 files changed, 31 insertions(+), 25 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 4a4e98acf..3e37c1d39 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2742,7 +2742,6 @@ dependencies = [ "serde", "serde_with", "serial_test", - "strum", "tokio", "ts-rs", ] diff --git a/crates/db_views_moderator/Cargo.toml b/crates/db_views_moderator/Cargo.toml index c95661557..a7257c4f1 100644 --- a/crates/db_views_moderator/Cargo.toml +++ b/crates/db_views_moderator/Cargo.toml @@ -40,7 +40,6 @@ diesel-async = { workspace = true, features = [ serde = { workspace = true } serde_with = { workspace = true } ts-rs = { workspace = true, optional = true } -strum = { workspace = true } [dev-dependencies] serial_test = { workspace = true } diff --git a/crates/db_views_moderator/src/modlog_combined_view.rs b/crates/db_views_moderator/src/modlog_combined_view.rs index 52368573b..4c6e619ea 100644 --- a/crates/db_views_moderator/src/modlog_combined_view.rs +++ b/crates/db_views_moderator/src/modlog_combined_view.rs @@ -70,29 +70,38 @@ use lemmy_utils::error::LemmyResult; impl ModlogCombinedPaginationCursor { // get cursor for page that starts immediately after the given post pub fn after_post(view: &ModlogCombinedView) -> ModlogCombinedPaginationCursor { - let id = match view { - ModlogCombinedView::AdminAllowInstance(v) => v.admin_allow_instance.id.0, - ModlogCombinedView::AdminBlockInstance(v) => v.admin_block_instance.id.0, - ModlogCombinedView::AdminPurgeComment(v) => v.admin_purge_comment.id.0, - ModlogCombinedView::AdminPurgeCommunity(v) => v.admin_purge_community.id.0, - ModlogCombinedView::AdminPurgePerson(v) => v.admin_purge_person.id.0, - ModlogCombinedView::AdminPurgePost(v) => v.admin_purge_post.id.0, - ModlogCombinedView::ModAdd(v) => v.mod_add.id.0, - ModlogCombinedView::ModAddCommunity(v) => v.mod_add_community.id.0, - ModlogCombinedView::ModBan(v) => v.mod_ban.id.0, - ModlogCombinedView::ModBanFromCommunity(v) => v.mod_ban_from_community.id.0, - - ModlogCombinedView::ModFeaturePost(v) => v.mod_feature_post.id.0, - ModlogCombinedView::ModHideCommunity(v) => v.mod_hide_community.id.0, - ModlogCombinedView::ModLockPost(v) => v.mod_lock_post.id.0, - ModlogCombinedView::ModRemoveComment(v) => v.mod_remove_comment.id.0, - ModlogCombinedView::ModRemoveCommunity(v) => v.mod_remove_community.id.0, - - ModlogCombinedView::ModRemovePost(v) => v.mod_remove_post.id.0, - ModlogCombinedView::ModTransferCommunity(v) => v.mod_transfer_community.id.0, + let (prefix, id) = match view { + ModlogCombinedView::AdminAllowInstance(v) => { + ("AdminAllowInstance", v.admin_allow_instance.id.0) + } + ModlogCombinedView::AdminBlockInstance(v) => { + ("AdminBlockInstance", v.admin_block_instance.id.0) + } + ModlogCombinedView::AdminPurgeComment(v) => ("AdminPurgeComment", v.admin_purge_comment.id.0), + ModlogCombinedView::AdminPurgeCommunity(v) => { + ("AdminPurgeCommunity", v.admin_purge_community.id.0) + } + ModlogCombinedView::AdminPurgePerson(v) => ("AdminPurgePerson", v.admin_purge_person.id.0), + ModlogCombinedView::AdminPurgePost(v) => ("AdminPurgePost", v.admin_purge_post.id.0), + ModlogCombinedView::ModAdd(v) => ("ModAdd", v.mod_add.id.0), + ModlogCombinedView::ModAddCommunity(v) => ("ModAddCommunity", v.mod_add_community.id.0), + ModlogCombinedView::ModBan(v) => ("ModBan", v.mod_ban.id.0), + ModlogCombinedView::ModBanFromCommunity(v) => { + ("ModBanFromCommunity", v.mod_ban_from_community.id.0) + } + ModlogCombinedView::ModFeaturePost(v) => ("ModFeaturePost", v.mod_feature_post.id.0), + ModlogCombinedView::ModHideCommunity(v) => ("ModHideCommunity", v.mod_hide_community.id.0), + ModlogCombinedView::ModLockPost(v) => ("ModLockPost", v.mod_lock_post.id.0), + ModlogCombinedView::ModRemoveComment(v) => ("ModRemoveComment", v.mod_remove_comment.id.0), + ModlogCombinedView::ModRemoveCommunity(v) => { + ("ModRemoveCommunity", v.mod_remove_community.id.0) + } + ModlogCombinedView::ModRemovePost(v) => ("ModRemovePost", v.mod_remove_post.id.0), + ModlogCombinedView::ModTransferCommunity(v) => { + ("ModTransferCommunity", v.mod_transfer_community.id.0) + } }; // hex encoding to prevent ossification - let prefix = view.as_ref(); ModlogCombinedPaginationCursor(format!("{prefix}-{id:x}")) } diff --git a/crates/db_views_moderator/src/structs.rs b/crates/db_views_moderator/src/structs.rs index 3d76aa321..513a79705 100644 --- a/crates/db_views_moderator/src/structs.rs +++ b/crates/db_views_moderator/src/structs.rs @@ -32,7 +32,6 @@ use lemmy_db_schema::source::{ }; use serde::{Deserialize, Serialize}; use serde_with::skip_serializing_none; -use strum::AsRefStr; #[cfg(feature = "full")] use ts_rs::TS; @@ -307,7 +306,7 @@ pub struct ModlogCombinedViewInternal { pub comment: Option, } -#[derive(AsRefStr, Debug, PartialEq, Serialize, Deserialize, Clone)] +#[derive(Debug, PartialEq, Serialize, Deserialize, Clone)] #[cfg_attr(feature = "full", derive(TS))] #[cfg_attr(feature = "full", ts(export))] // Use serde's internal tagging, to work easier with javascript libraries