diff --git a/src/backend/database/conflict.rs b/src/backend/database/conflict.rs index 2badaa8..890db7a 100644 --- a/src/backend/database/conflict.rs +++ b/src/backend/database/conflict.rs @@ -5,8 +5,9 @@ use crate::{ federation::activities::submit_article_update, utils::generate_article_version, }, - common::{ApiConflict, DbArticle, DbEdit, DbPerson, EditVersion, PersonId}, + common::{ApiConflict, DbArticle, DbEdit, DbPerson, EditVersion}, }; +use crate::common::newtypes::PersonId; use activitypub_federation::config::Data; use diesel::{ delete, diff --git a/src/backend/database/edit.rs b/src/backend/database/edit.rs index aae3d5c..3e47319 100644 --- a/src/backend/database/edit.rs +++ b/src/backend/database/edit.rs @@ -4,13 +4,14 @@ use crate::{ error::MyResult, IbisData, }, - common::{DbArticle, DbEdit, EditVersion, EditView, PersonId}, + common::{DbArticle, DbEdit, EditVersion, EditView}, }; use activitypub_federation::fetch::object_id::ObjectId; use chrono::{DateTime, Utc}; use diesel::{insert_into, AsChangeset, ExpressionMethods, Insertable, QueryDsl, RunQueryDsl}; use diffy::create_patch; use std::ops::DerefMut; +use crate::common::newtypes::PersonId; #[derive(Debug, Clone, Insertable, AsChangeset)] #[diesel(table_name = edit, check_for_backend(diesel::pg::Pg))] diff --git a/src/backend/database/user.rs b/src/backend/database/user.rs index 966d09e..6328329 100644 --- a/src/backend/database/user.rs +++ b/src/backend/database/user.rs @@ -12,9 +12,9 @@ use crate::{ DbLocalUser, DbPerson, LocalUserView, - PersonId, }, }; +use crate::common::newtypes::PersonId; use activitypub_federation::{ config::Data, fetch::object_id::ObjectId, diff --git a/src/backend/federation/activities/mod.rs b/src/backend/federation/activities/mod.rs index c3614b3..ece2f96 100644 --- a/src/backend/federation/activities/mod.rs +++ b/src/backend/federation/activities/mod.rs @@ -7,10 +7,11 @@ use crate::{ update_remote_article::UpdateRemoteArticle, }, }, - common::{DbArticle, DbEdit, DbInstance, EditVersion, PersonId}, + common::{DbArticle, DbEdit, DbInstance, EditVersion}, }; use activitypub_federation::config::Data; use chrono::Utc; +use crate::common::newtypes::PersonId; pub mod accept; pub mod create_article; diff --git a/src/backend/utils.rs b/src/backend/utils.rs index 3f3531e..dbd489d 100644 --- a/src/backend/utils.rs +++ b/src/backend/utils.rs @@ -46,7 +46,7 @@ pub fn generate_article_version(edits: &Vec, version: &EditVersion) -> #[cfg(test)] mod test { use super::*; - use crate::common::{DbEdit, DbPerson, PersonId}; + use crate::common::{newtypes::PersonId, DbEdit, DbPerson}; use activitypub_federation::fetch::object_id::ObjectId; use chrono::Utc; use diffy::create_patch; diff --git a/src/common/mod.rs b/src/common/mod.rs index 9f61d8d..0405af5 100644 --- a/src/common/mod.rs +++ b/src/common/mod.rs @@ -1,7 +1,9 @@ +pub mod newtypes; pub mod utils; pub mod validation; use chrono::{DateTime, Utc}; +use newtypes::PersonId; use serde::{Deserialize, Serialize}; use sha2::{Digest, Sha256}; use url::Url; @@ -15,7 +17,6 @@ use { }, activitypub_federation::fetch::{collection_id::CollectionId, object_id::ObjectId}, diesel::{Identifiable, Queryable, Selectable}, - diesel_derive_newtype::DieselNewType, }; pub const MAIN_PAGE_NAME: &str = "Main_Page"; @@ -150,9 +151,6 @@ pub struct DbLocalUser { pub person_id: i32, pub admin: bool, } -#[derive(Debug, Copy, Clone, Hash, Eq, PartialEq, Default, Serialize, Deserialize)] -#[cfg_attr(feature = "ssr", derive(DieselNewType))] -pub struct PersonId(pub i32); /// Federation related data from a local or remote user. #[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]