1
0
Fork 1
mirror of https://example.com synced 2024-11-22 12:46:39 +09:00

chore: upgrade seaorm (wip)

This commit is contained in:
Namekuji 2023-09-06 23:16:00 -04:00 committed by naskya
parent e51a4a4e25
commit 3169301ddc
Signed by: naskya
GPG key ID: 712D413B3A9FED5C
28 changed files with 1271 additions and 1182 deletions

File diff suppressed because it is too large Load diff

View file

@ -8,7 +8,6 @@ members = ["migration"]
[features]
default = []
noarray = []
napi = ["dep:napi", "dep:napi-derive"]
[lib]
@ -25,7 +24,7 @@ once_cell = "1.17.1"
parse-display = "0.8.0"
rand = "0.8.5"
schemars = { version = "0.8.12", features = ["chrono"] }
sea-orm = { version = "0.11.3", features = ["sqlx-postgres", "postgres-array", "sqlx-sqlite", "runtime-tokio-rustls"] }
sea-orm = { version = "0.12.2", features = ["sqlx-postgres", "runtime-tokio-rustls"] }
serde = { version = "1.0.163", features = ["derive"] }
serde_json = "1.0.96"
thiserror = "1.0.40"

View file

@ -22,17 +22,16 @@ serde_yaml = "0.9.21"
serde = { version = "1.0.163", features = ["derive"] }
urlencoding = "2.1.2"
redis = { version = "0.23.0", features = ["tokio-rustls-comp"] }
sea-orm = "0.11.3"
sea-orm = "0.12.2"
url = { version = "2.4.0", features = ["serde"] }
basen = "0.1.0"
[dependencies.sea-orm-migration]
version = "0.11.0"
version = "0.12.0"
features = [
# Enable at least one `ASYNC_RUNTIME` and `DATABASE_DRIVER` feature if you want to run migration via CLI.
# View the list of supported features at https://www.sea-ql.org/SeaORM/docs/install-and-config/database-and-async-runtime.
# e.g.
"runtime-tokio-rustls", # `ASYNC_RUNTIME` feature
"sqlx-postgres", # `DATABASE_DRIVER` feature
"sqlx-sqlite",
]

View file

@ -41,7 +41,7 @@
"prepublishOnly": "napi prepublish -t npm",
"universal": "napi universal",
"version": "napi version",
"format": "cargo fmt --all --",
"lint": "cargo clippy --fix --allow-dirty --allow-staged && cargo fmt --all --"
"format": "cargo fmt --all -- --check",
"lint": "cargo clippy --fix --allow-dirty --allow-staged && cargo fmt --all -- --check"
}
}

View file

@ -32,7 +32,6 @@ pub mod migrations;
pub mod moderation_log;
pub mod muted_note;
pub mod muting;
pub mod newtype;
pub mod note;
pub mod note_edit;
pub mod note_favorite;

View file

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

View file

@ -1,6 +1,6 @@
//! `SeaORM` Entity. Generated by sea-orm-codegen 0.11.3
use super::{newtype, sea_orm_active_enums::AntennaSrcEnum};
use super::sea_orm_active_enums::AntennaSrcEnum;
use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Default)]
@ -17,7 +17,7 @@ pub struct Model {
#[sea_orm(column_name = "userListId")]
pub user_list_id: Option<String>,
#[sea_orm(column_type = "JsonBinary")]
pub keywords: newtype::JsonKeyword,
pub keywords: Json,
#[sea_orm(column_name = "withFile")]
pub with_file: bool,
pub expression: Option<String>,
@ -28,11 +28,11 @@ pub struct Model {
pub with_replies: bool,
#[sea_orm(column_name = "userGroupJoiningId")]
pub user_group_joining_id: Option<String>,
pub users: newtype::StringVec,
pub users: Vec<String>,
#[sea_orm(column_name = "excludeKeywords", column_type = "JsonBinary")]
pub exclude_keywords: newtype::JsonKeyword,
pub exclude_keywords: Json,
#[sea_orm(column_type = "JsonBinary")]
pub instances: newtype::JsonStringVec,
pub instances: Json,
}
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -4,8 +4,6 @@ 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, Default)]
#[sea_orm(table_name = "meta")]
pub struct Model {
@ -25,11 +23,11 @@ pub struct Model {
pub disable_global_timeline: bool,
#[sea_orm(column_name = "useStarForReactionFallback")]
pub use_star_for_reaction_fallback: bool,
pub langs: StringVec,
pub langs: Vec<String>,
#[sea_orm(column_name = "hiddenTags")]
pub hidden_tags: StringVec,
pub hidden_tags: Vec<String>,
#[sea_orm(column_name = "blockedHosts")]
pub blocked_hosts: StringVec,
pub blocked_hosts: Vec<String>,
#[sea_orm(column_name = "mascotImageUrl")]
pub mascot_image_url: Option<String>,
#[sea_orm(column_name = "bannerUrl")]
@ -72,7 +70,7 @@ pub struct Model {
#[sea_orm(column_name = "swPrivateKey")]
pub sw_private_key: Option<String>,
#[sea_orm(column_name = "pinnedUsers")]
pub pinned_users: StringVec,
pub pinned_users: Vec<String>,
#[sea_orm(column_name = "ToSUrl")]
pub to_s_url: Option<String>,
#[sea_orm(column_name = "moreUrls", column_type = "JsonBinary")]
@ -114,7 +112,7 @@ pub struct Model {
#[sea_orm(column_name = "objectStorageSetPublicRead")]
pub object_storage_set_public_read: bool,
#[sea_orm(column_name = "pinnedPages")]
pub pinned_pages: StringVec,
pub pinned_pages: Vec<String>,
#[sea_orm(column_name = "backgroundImageUrl")]
pub background_image_url: Option<String>,
#[sea_orm(column_name = "logoImageUrl")]
@ -124,7 +122,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<StringVec>,
pub allowed_hosts: Option<Vec<String>>,
#[sea_orm(column_name = "secureMode")]
pub secure_mode: Option<bool>,
#[sea_orm(column_name = "privateMode")]
@ -154,13 +152,13 @@ pub struct Model {
#[sea_orm(column_name = "enableActiveEmailValidation")]
pub enable_active_email_validation: bool,
#[sea_orm(column_name = "customMOTD")]
pub custom_motd: StringVec,
pub custom_motd: Vec<String>,
#[sea_orm(column_name = "customSplashIcons")]
pub custom_splash_icons: StringVec,
pub custom_splash_icons: Vec<String>,
#[sea_orm(column_name = "disableRecommendedTimeline")]
pub disable_recommended_timeline: bool,
#[sea_orm(column_name = "recommendedInstances")]
pub recommended_instances: StringVec,
pub recommended_instances: Vec<String>,
#[sea_orm(column_name = "enableGuestTimeline")]
pub enable_guest_timeline: bool,
#[sea_orm(column_name = "defaultReaction")]
@ -170,7 +168,7 @@ pub struct Model {
#[sea_orm(column_name = "libreTranslateApiKey")]
pub libre_translate_api_key: Option<String>,
#[sea_orm(column_name = "silencedHosts")]
pub silenced_hosts: StringVec,
pub silenced_hosts: Vec<String>,
#[sea_orm(column_name = "experimentalFeatures", column_type = "JsonBinary")]
pub experimental_features: Json,
#[sea_orm(column_name = "enableServerMachineStats")]

View file

@ -1,51 +0,0 @@
#[macro_export]
macro_rules! impl_json_newtype {
($a:tt) => {
impl From<$a> for Value {
fn from(source: $a) -> Self {
Value::Json(serde_json::to_value(source).ok().map(Box::new))
}
}
impl TryGetable for $a {
fn try_get_by<I: sea_orm::ColIdx>(
res: &QueryResult,
idx: I,
) -> Result<Self, TryGetError> {
let json_value: serde_json::Value =
res.try_get_by(idx).map_err(TryGetError::DbErr)?;
serde_json::from_value(json_value)
.map_err(|e| TryGetError::DbErr(DbErr::Json(e.to_string())))
}
}
impl sea_query::ValueType for $a {
fn try_from(v: Value) -> Result<Self, sea_query::ValueTypeErr> {
match v {
Value::Json(Some(x)) => Ok($a(
serde_json::from_value(*x).map_err(|_| sea_query::ValueTypeErr)?
)),
_ => Err(sea_query::ValueTypeErr),
}
}
fn type_name() -> String {
stringify!($a).to_owned()
}
fn array_type() -> sea_query::ArrayType {
sea_query::ArrayType::Json
}
fn column_type() -> sea_query::ColumnType {
sea_query::ColumnType::JsonBinary
}
}
impl sea_query::Nullable for $a {
fn null() -> Value {
Value::Json(None)
}
}
};
}

View file

@ -1,30 +0,0 @@
mod macros;
use cfg_if::cfg_if;
use derive_more::{From, Into};
use sea_orm::{sea_query, DbErr, QueryResult, TryGetError, TryGetable, Value};
use serde::{Deserialize, Serialize};
use crate::impl_json_newtype;
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize, From, Into, Default)]
pub struct JsonKeyword(pub Vec<Vec<String>>);
impl_json_newtype!(JsonKeyword);
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize, From, Into, Default)]
pub struct JsonStringVec(pub Vec<String>);
impl_json_newtype!(JsonStringVec);
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize, From, Into, Default)]
pub struct JsonI32Vec(pub Vec<i32>);
impl_json_newtype!(JsonI32Vec);
cfg_if! {
if #[cfg(feature = "noarray")] {
pub type StringVec = JsonStringVec;
pub type I32Vec = JsonI32Vec;
} else {
pub type StringVec = Vec<String>;
pub type I32Vec = Vec<i32>;
}
}

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -1,9 +1,12 @@
//! `SeaORM` Entity. Generated by sea-orm-codegen 0.11.3
use sea_orm::entity::prelude::*;
use parse_display::Display;
#[derive(Debug, Clone, PartialEq, Eq, EnumIter, DeriveActiveEnum, Default)]
#[derive(Debug, Clone, PartialEq, Eq, EnumIter, DeriveActiveEnum, Default, Display)]
#[sea_orm(rs_type = "String", db_type = "Enum", enum_name = "antenna_src_enum")]
#[display(style = "camelCase")]
#[display("'{}'")]
pub enum AntennaSrcEnum {
#[default]
#[sea_orm(string_value = "all")]

View file

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

View file

@ -3,8 +3,6 @@
use super::sea_orm_active_enums::UserProfileFfvisibilityEnum;
use sea_orm::entity::prelude::*;
use super::newtype::StringVec;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Default)]
#[sea_orm(table_name = "user_profile")]
pub struct Model {
@ -53,7 +51,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: StringVec,
pub muting_notification_types: Vec<String>,
#[sea_orm(column_name = "noCrawle")]
pub no_crawle: bool,
#[sea_orm(column_name = "receiveAnnouncementEmail")]

View file

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

View file

@ -1,4 +1,4 @@
pub mod entity;
pub mod error;
pub mod repository;
// pub mod repository;
pub mod schema;

View file

@ -1,5 +1,3 @@
pub mod antenna;
use async_trait::async_trait;
use schemars::JsonSchema;

View file

@ -1,56 +0,0 @@
use async_trait::async_trait;
use cfg_if::cfg_if;
use sea_orm::EntityTrait;
use crate::database;
use crate::model::entity::{antenna, user_group_joining};
use crate::model::error::Error;
use crate::model::schema::Antenna;
use super::macros::impl_pack_by_id;
use super::Repository;
#[async_trait]
impl Repository<Antenna> for antenna::Model {
async fn pack(self) -> Result<Antenna, Error> {
let db = database::get_database()?;
let user_group_joining = match self.user_group_joining_id {
None => None,
Some(id) => user_group_joining::Entity::find_by_id(id).one(db).await?,
};
let user_group_id = match user_group_joining {
None => None,
Some(m) => Some(m.user_group_id),
};
cfg_if! {
if #[cfg(feature = "napi")] {
let created_at: String = self.created_at.to_rfc3339();
} else {
let created_at: chrono::DateTime<chrono::Utc> = self.created_at.into();
}
}
Ok(Antenna {
id: self.id,
created_at,
name: self.name,
keywords: self.keywords.into(),
exclude_keywords: self.exclude_keywords.into(),
src: self.src.try_into()?,
user_list_id: self.user_list_id,
user_group_id,
users: self.users,
instances: self.instances.into(),
case_sensitive: self.case_sensitive,
notify: self.notify,
with_replies: self.with_replies,
with_file: self.with_file,
has_unread_note: false,
})
}
async fn pack_by_id(id: String) -> Result<Antenna, Error> {
impl_pack_by_id!(antenna::Entity, id)
}
}

View file

@ -1,14 +1,33 @@
import { db } from "@/db/postgre.js";
import { Antenna } from "@/models/entities/antenna.js";
import {
NativeAntennaSchema,
nativePackAntennaById,
} from "native-utils/built/index.js";
import type { Packed } from "@/misc/schema.js";
import { UserGroupJoinings } from "@/models/index.js";
export const AntennaRepository = db.getRepository(Antenna).extend({
async pack(src: Antenna["id"] | Antenna): Promise<NativeAntennaSchema> {
const id = typeof src === "object" ? src.id : src;
async pack(src: Antenna["id"] | Antenna): Promise<Packed<"Antenna">> {
const antenna =
typeof src === "object" ? src : await this.findOneByOrFail({ id: src });
return await nativePackAntennaById(id);
const userGroupJoining = antenna.userGroupJoiningId
? await UserGroupJoinings.findOneBy({ id: antenna.userGroupJoiningId })
: null;
return {
id: antenna.id,
createdAt: antenna.createdAt.toISOString(),
name: antenna.name,
keywords: antenna.keywords,
excludeKeywords: antenna.excludeKeywords,
src: antenna.src,
userListId: antenna.userListId,
userGroupId: userGroupJoining ? userGroupJoining.userGroupId : null,
users: antenna.users,
instances: antenna.instances,
caseSensitive: antenna.caseSensitive,
notify: antenna.notify,
withReplies: antenna.withReplies,
withFile: antenna.withFile,
hasUnreadNote: false,
};
},
});