use vec newtype

This commit is contained in:
Namekuji 2023-06-01 00:18:50 -04:00
parent 6178593e22
commit 745384ff58
No known key found for this signature in database
GPG key ID: B541BD6E646CABC7
17 changed files with 76 additions and 38 deletions

View file

@ -2,6 +2,8 @@
use sea_orm::entity::prelude::*;
use super::newtype::StringVec;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "access_token")]
pub struct Model {
@ -22,7 +24,7 @@ pub struct Model {
pub description: Option<String>,
#[sea_orm(column_name = "iconUrl")]
pub icon_url: Option<String>,
pub permission: Vec<String>,
pub permission: StringVec,
pub fetched: bool,
}

View file

@ -2,6 +2,8 @@
use sea_orm::entity::prelude::*;
use super::newtype::StringVec;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "app")]
pub struct Model {
@ -14,7 +16,7 @@ pub struct Model {
pub secret: String,
pub name: String,
pub description: String,
pub permission: Vec<String>,
pub permission: StringVec,
#[sea_orm(column_name = "callbackUrl")]
pub callback_url: Option<String>,
}

View file

@ -2,6 +2,8 @@
use sea_orm::entity::prelude::*;
use super::newtype::StringVec;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "emoji")]
pub struct Model {
@ -15,7 +17,7 @@ pub struct Model {
pub original_url: String,
pub uri: Option<String>,
pub r#type: Option<String>,
pub aliases: Vec<String>,
pub aliases: StringVec,
pub category: Option<String>,
#[sea_orm(column_name = "publicUrl")]
pub public_url: String,

View file

@ -2,6 +2,8 @@
use sea_orm::entity::prelude::*;
use super::newtype::StringVec;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "gallery_post")]
pub struct Model {
@ -16,12 +18,12 @@ pub struct Model {
#[sea_orm(column_name = "userId")]
pub user_id: String,
#[sea_orm(column_name = "fileIds")]
pub file_ids: Vec<String>,
pub file_ids: StringVec,
#[sea_orm(column_name = "isSensitive")]
pub is_sensitive: bool,
#[sea_orm(column_name = "likedCount")]
pub liked_count: i32,
pub tags: Vec<String>,
pub tags: StringVec,
}
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]

View file

@ -2,6 +2,8 @@
use sea_orm::entity::prelude::*;
use super::newtype::StringVec;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "hashtag")]
pub struct Model {
@ -9,27 +11,27 @@ pub struct Model {
pub id: String,
pub name: String,
#[sea_orm(column_name = "mentionedUserIds")]
pub mentioned_user_ids: Vec<String>,
pub mentioned_user_ids: StringVec,
#[sea_orm(column_name = "mentionedUsersCount")]
pub mentioned_users_count: i32,
#[sea_orm(column_name = "mentionedLocalUserIds")]
pub mentioned_local_user_ids: Vec<String>,
pub mentioned_local_user_ids: StringVec,
#[sea_orm(column_name = "mentionedLocalUsersCount")]
pub mentioned_local_users_count: i32,
#[sea_orm(column_name = "mentionedRemoteUserIds")]
pub mentioned_remote_user_ids: Vec<String>,
pub mentioned_remote_user_ids: StringVec,
#[sea_orm(column_name = "mentionedRemoteUsersCount")]
pub mentioned_remote_users_count: i32,
#[sea_orm(column_name = "attachedUserIds")]
pub attached_user_ids: Vec<String>,
pub attached_user_ids: StringVec,
#[sea_orm(column_name = "attachedUsersCount")]
pub attached_users_count: i32,
#[sea_orm(column_name = "attachedLocalUserIds")]
pub attached_local_user_ids: Vec<String>,
pub attached_local_user_ids: StringVec,
#[sea_orm(column_name = "attachedLocalUsersCount")]
pub attached_local_users_count: i32,
#[sea_orm(column_name = "attachedRemoteUserIds")]
pub attached_remote_user_ids: Vec<String>,
pub attached_remote_user_ids: StringVec,
#[sea_orm(column_name = "attachedRemoteUsersCount")]
pub attached_remote_users_count: i32,
}

View file

@ -2,6 +2,8 @@
use sea_orm::entity::prelude::*;
use super::newtype::StringVec;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "messaging_message")]
pub struct Model {
@ -20,7 +22,7 @@ pub struct Model {
pub file_id: Option<String>,
#[sea_orm(column_name = "groupId")]
pub group_id: Option<String>,
pub reads: Vec<String>,
pub reads: StringVec,
pub uri: Option<String>,
}

View file

@ -4,6 +4,8 @@ use super::sea_orm_active_enums::MetaSensitivemediadetectionEnum;
use super::sea_orm_active_enums::MetaSensitivemediadetectionsensitivityEnum;
use sea_orm::entity::prelude::*;
use super::newtype::StringVec;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "meta")]
pub struct Model {
@ -23,11 +25,11 @@ pub struct Model {
pub disable_global_timeline: bool,
#[sea_orm(column_name = "useStarForReactionFallback")]
pub use_star_for_reaction_fallback: bool,
pub langs: Vec<String>,
pub langs: StringVec,
#[sea_orm(column_name = "hiddenTags")]
pub hidden_tags: Vec<String>,
pub hidden_tags: StringVec,
#[sea_orm(column_name = "blockedHosts")]
pub blocked_hosts: Vec<String>,
pub blocked_hosts: StringVec,
#[sea_orm(column_name = "mascotImageUrl")]
pub mascot_image_url: Option<String>,
#[sea_orm(column_name = "bannerUrl")]
@ -88,7 +90,7 @@ pub struct Model {
#[sea_orm(column_name = "discordClientSecret")]
pub discord_client_secret: Option<String>,
#[sea_orm(column_name = "pinnedUsers")]
pub pinned_users: Vec<String>,
pub pinned_users: StringVec,
#[sea_orm(column_name = "ToSUrl")]
pub to_s_url: Option<String>,
#[sea_orm(column_name = "repositoryUrl")]
@ -128,7 +130,7 @@ pub struct Model {
#[sea_orm(column_name = "objectStorageSetPublicRead")]
pub object_storage_set_public_read: bool,
#[sea_orm(column_name = "pinnedPages")]
pub pinned_pages: Vec<String>,
pub pinned_pages: StringVec,
#[sea_orm(column_name = "backgroundImageUrl")]
pub background_image_url: Option<String>,
#[sea_orm(column_name = "logoImageUrl")]
@ -138,7 +140,7 @@ pub struct Model {
#[sea_orm(column_name = "objectStorageS3ForcePathStyle")]
pub object_storage_s3_force_path_style: bool,
#[sea_orm(column_name = "allowedHosts")]
pub allowed_hosts: Option<Vec<String>>,
pub allowed_hosts: Option<StringVec>,
#[sea_orm(column_name = "secureMode")]
pub secure_mode: Option<bool>,
#[sea_orm(column_name = "privateMode")]
@ -168,13 +170,13 @@ pub struct Model {
#[sea_orm(column_name = "enableActiveEmailValidation")]
pub enable_active_email_validation: bool,
#[sea_orm(column_name = "customMOTD")]
pub custom_motd: Vec<String>,
pub custom_motd: StringVec,
#[sea_orm(column_name = "customSplashIcons")]
pub custom_splash_icons: Vec<String>,
pub custom_splash_icons: StringVec,
#[sea_orm(column_name = "disableRecommendedTimeline")]
pub disable_recommended_timeline: bool,
#[sea_orm(column_name = "recommendedInstances")]
pub recommended_instances: Vec<String>,
pub recommended_instances: StringVec,
#[sea_orm(column_name = "enableGuestTimeline")]
pub enable_guest_timeline: bool,
#[sea_orm(column_name = "defaultReaction")]
@ -184,7 +186,7 @@ pub struct Model {
#[sea_orm(column_name = "libreTranslateApiKey")]
pub libre_translate_api_key: Option<String>,
#[sea_orm(column_name = "silencedHosts")]
pub silenced_hosts: Vec<String>,
pub silenced_hosts: StringVec,
#[sea_orm(column_name = "experimentalFeatures", column_type = "JsonBinary")]
pub experimental_features: Json,
}

View file

@ -15,10 +15,16 @@ impl_json_newtype!(JsonKeyword);
pub struct JsonStringVec(pub Vec<String>);
impl_json_newtype!(JsonStringVec);
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize, From, Into)]
pub struct JsonI32Vec(pub Vec<i32>);
impl_json_newtype!(JsonI32Vec);
cfg_if! {
if #[cfg(feature = "legacy")] {
pub type StringVec = Vec<String>;
pub type I32Vec = Vec<i32>;
} else {
pub type StringVec = JsonStringVec;
pub type I32Vec = JsonI32Vec;
}
}

View file

@ -3,6 +3,8 @@
use super::sea_orm_active_enums::NoteVisibilityEnum;
use sea_orm::entity::prelude::*;
use super::newtype::StringVec;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "note")]
pub struct Model {
@ -32,16 +34,16 @@ pub struct Model {
pub uri: Option<String>,
pub score: i32,
#[sea_orm(column_name = "fileIds")]
pub file_ids: Vec<String>,
pub file_ids: StringVec,
#[sea_orm(column_name = "attachedFileTypes")]
pub attached_file_types: Vec<String>,
pub attached_file_types: StringVec,
#[sea_orm(column_name = "visibleUserIds")]
pub visible_user_ids: Vec<String>,
pub mentions: Vec<String>,
pub visible_user_ids: StringVec,
pub mentions: StringVec,
#[sea_orm(column_name = "mentionedRemoteUsers", column_type = "Text")]
pub mentioned_remote_users: String,
pub emojis: Vec<String>,
pub tags: Vec<String>,
pub emojis: StringVec,
pub tags: StringVec,
#[sea_orm(column_name = "hasPoll")]
pub has_poll: bool,
#[sea_orm(column_name = "userHost")]

View file

@ -2,6 +2,8 @@
use sea_orm::entity::prelude::*;
use super::newtype::StringVec;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "note_edit")]
pub struct Model {
@ -13,7 +15,7 @@ pub struct Model {
pub text: Option<String>,
pub cw: Option<String>,
#[sea_orm(column_name = "fileIds")]
pub file_ids: Vec<String>,
pub file_ids: StringVec,
#[sea_orm(column_name = "updatedAt")]
pub updated_at: DateTimeWithTimeZone,
}

View file

@ -3,6 +3,8 @@
use super::sea_orm_active_enums::PageVisibilityEnum;
use sea_orm::entity::prelude::*;
use super::newtype::StringVec;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "page")]
pub struct Model {
@ -28,7 +30,7 @@ pub struct Model {
pub variables: Json,
pub visibility: PageVisibilityEnum,
#[sea_orm(column_name = "visibleUserIds")]
pub visible_user_ids: Vec<String>,
pub visible_user_ids: StringVec,
#[sea_orm(column_name = "likedCount")]
pub liked_count: i32,
#[sea_orm(column_name = "hideTitleWhenPinned")]

View file

@ -3,6 +3,8 @@
use super::sea_orm_active_enums::PollNotevisibilityEnum;
use sea_orm::entity::prelude::*;
use super::newtype::{I32Vec, StringVec};
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "poll")]
pub struct Model {
@ -11,8 +13,8 @@ pub struct Model {
#[sea_orm(column_name = "expiresAt")]
pub expires_at: Option<DateTimeWithTimeZone>,
pub multiple: bool,
pub choices: Vec<String>,
pub votes: Vec<i32>,
pub choices: StringVec,
pub votes: I32Vec,
#[sea_orm(column_name = "noteVisibility")]
pub note_visibility: PollNotevisibilityEnum,
#[sea_orm(column_name = "userId")]

View file

@ -2,6 +2,8 @@
use sea_orm::entity::prelude::*;
use super::newtype::StringVec;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "registry_item")]
pub struct Model {
@ -14,7 +16,7 @@ pub struct Model {
#[sea_orm(column_name = "userId")]
pub user_id: String,
pub key: String,
pub scope: Vec<String>,
pub scope: StringVec,
pub domain: Option<String>,
#[sea_orm(column_type = "JsonBinary", nullable)]
pub value: Option<Json>,

View file

@ -2,6 +2,8 @@
use sea_orm::entity::prelude::*;
use super::newtype::StringVec;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "reversi_game")]
pub struct Model {
@ -29,7 +31,7 @@ pub struct Model {
pub surrendered: Option<String>,
#[sea_orm(column_type = "JsonBinary")]
pub logs: Json,
pub map: Vec<String>,
pub map: StringVec,
pub bw: String,
#[sea_orm(column_name = "isLlotheo")]
pub is_llotheo: bool,

View file

@ -2,6 +2,8 @@
use sea_orm::entity::prelude::*;
use super::newtype::StringVec;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "user")]
pub struct Model {
@ -27,7 +29,7 @@ pub struct Model {
pub avatar_id: Option<String>,
#[sea_orm(column_name = "bannerId", unique)]
pub banner_id: Option<String>,
pub tags: Vec<String>,
pub tags: StringVec,
#[sea_orm(column_name = "isSuspended")]
pub is_suspended: bool,
#[sea_orm(column_name = "isSilenced")]
@ -42,7 +44,7 @@ pub struct Model {
pub is_admin: bool,
#[sea_orm(column_name = "isModerator")]
pub is_moderator: bool,
pub emojis: Vec<String>,
pub emojis: StringVec,
pub host: Option<String>,
pub inbox: Option<String>,
#[sea_orm(column_name = "sharedInbox")]

View file

@ -3,6 +3,8 @@
use super::sea_orm_active_enums::UserProfileFfvisibilityEnum;
use sea_orm::entity::prelude::*;
use super::newtype::StringVec;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "user_profile")]
pub struct Model {
@ -53,7 +55,7 @@ pub struct Model {
#[sea_orm(column_name = "mutedWords", column_type = "JsonBinary")]
pub muted_words: Json,
#[sea_orm(column_name = "mutingNotificationTypes")]
pub muting_notification_types: Vec<String>,
pub muting_notification_types: StringVec,
#[sea_orm(column_name = "noCrawle")]
pub no_crawle: bool,
#[sea_orm(column_name = "receiveAnnouncementEmail")]

View file

@ -2,6 +2,8 @@
use sea_orm::entity::prelude::*;
use super::newtype::StringVec;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "webhook")]
pub struct Model {
@ -12,7 +14,7 @@ pub struct Model {
#[sea_orm(column_name = "userId")]
pub user_id: String,
pub name: String,
pub on: Vec<String>,
pub on: StringVec,
pub url: String,
pub secret: String,
pub active: bool,