1
0
Fork 0
mirror of https://github.com/Nutomic/ibis.git synced 2024-11-22 17:01:10 +00:00

create newtypes.rs

This commit is contained in:
Felix Ableitner 2024-11-11 23:08:42 +01:00
parent 53a89a51d3
commit 7d8954ecd1
6 changed files with 10 additions and 9 deletions

View file

@ -5,8 +5,9 @@ use crate::{
federation::activities::submit_article_update, federation::activities::submit_article_update,
utils::generate_article_version, 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 activitypub_federation::config::Data;
use diesel::{ use diesel::{
delete, delete,

View file

@ -4,13 +4,14 @@ use crate::{
error::MyResult, error::MyResult,
IbisData, IbisData,
}, },
common::{DbArticle, DbEdit, EditVersion, EditView, PersonId}, common::{DbArticle, DbEdit, EditVersion, EditView},
}; };
use activitypub_federation::fetch::object_id::ObjectId; use activitypub_federation::fetch::object_id::ObjectId;
use chrono::{DateTime, Utc}; use chrono::{DateTime, Utc};
use diesel::{insert_into, AsChangeset, ExpressionMethods, Insertable, QueryDsl, RunQueryDsl}; use diesel::{insert_into, AsChangeset, ExpressionMethods, Insertable, QueryDsl, RunQueryDsl};
use diffy::create_patch; use diffy::create_patch;
use std::ops::DerefMut; use std::ops::DerefMut;
use crate::common::newtypes::PersonId;
#[derive(Debug, Clone, Insertable, AsChangeset)] #[derive(Debug, Clone, Insertable, AsChangeset)]
#[diesel(table_name = edit, check_for_backend(diesel::pg::Pg))] #[diesel(table_name = edit, check_for_backend(diesel::pg::Pg))]

View file

@ -12,9 +12,9 @@ use crate::{
DbLocalUser, DbLocalUser,
DbPerson, DbPerson,
LocalUserView, LocalUserView,
PersonId,
}, },
}; };
use crate::common::newtypes::PersonId;
use activitypub_federation::{ use activitypub_federation::{
config::Data, config::Data,
fetch::object_id::ObjectId, fetch::object_id::ObjectId,

View file

@ -7,10 +7,11 @@ use crate::{
update_remote_article::UpdateRemoteArticle, update_remote_article::UpdateRemoteArticle,
}, },
}, },
common::{DbArticle, DbEdit, DbInstance, EditVersion, PersonId}, common::{DbArticle, DbEdit, DbInstance, EditVersion},
}; };
use activitypub_federation::config::Data; use activitypub_federation::config::Data;
use chrono::Utc; use chrono::Utc;
use crate::common::newtypes::PersonId;
pub mod accept; pub mod accept;
pub mod create_article; pub mod create_article;

View file

@ -46,7 +46,7 @@ pub fn generate_article_version(edits: &Vec<EditView>, version: &EditVersion) ->
#[cfg(test)] #[cfg(test)]
mod test { mod test {
use super::*; use super::*;
use crate::common::{DbEdit, DbPerson, PersonId}; use crate::common::{newtypes::PersonId, DbEdit, DbPerson};
use activitypub_federation::fetch::object_id::ObjectId; use activitypub_federation::fetch::object_id::ObjectId;
use chrono::Utc; use chrono::Utc;
use diffy::create_patch; use diffy::create_patch;

View file

@ -1,7 +1,9 @@
pub mod newtypes;
pub mod utils; pub mod utils;
pub mod validation; pub mod validation;
use chrono::{DateTime, Utc}; use chrono::{DateTime, Utc};
use newtypes::PersonId;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use sha2::{Digest, Sha256}; use sha2::{Digest, Sha256};
use url::Url; use url::Url;
@ -15,7 +17,6 @@ use {
}, },
activitypub_federation::fetch::{collection_id::CollectionId, object_id::ObjectId}, activitypub_federation::fetch::{collection_id::CollectionId, object_id::ObjectId},
diesel::{Identifiable, Queryable, Selectable}, diesel::{Identifiable, Queryable, Selectable},
diesel_derive_newtype::DieselNewType,
}; };
pub const MAIN_PAGE_NAME: &str = "Main_Page"; pub const MAIN_PAGE_NAME: &str = "Main_Page";
@ -150,9 +151,6 @@ pub struct DbLocalUser {
pub person_id: i32, pub person_id: i32,
pub admin: bool, 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. /// Federation related data from a local or remote user.
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)] #[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]