Compare commits

...

5 commits

Author SHA1 Message Date
722b7ece8b
refactor: move fetchMeta() to native-utils 2024-01-20 13:45:08 +09:00
d7d60ffdb0
refactor: bring all internal functions into misc/native-utils.ts
Co-authored-by: sup39 <dev@sup39.dev>
2024-01-20 08:27:08 +09:00
93b7396990
refactor: make database models accesible to napi
Co-authored-by: sup39 <dev@sup39.dev>
2024-01-20 05:57:00 +09:00
3bc2b7bcfb
refactor (backend): drop timezone info from database
Co-authored-by: sup39 <dev@sup39.dev>
2024-01-20 04:26:13 +09:00
ea020e9f7c
refactor (client): organize CSS properties & improve RTL layout support
Co-authored-by: sup39 <dev@sup39.dev>
2024-01-20 03:04:08 +09:00
256 changed files with 1388 additions and 479 deletions

View file

@ -31,8 +31,11 @@ regenerate-entities:
cd packages/backend/native-utils && \
sea-orm-cli generate entity \
--output-dir='src/model/entity' \
--database-url='postgres://firefish:password@localhost:25432/firefish_db'
--database-url='postgres://firefish:password@localhost:25432/firefish_db' \
--date-time-crate='chrono' \
--model-extra-attributes='napi_derive::napi(object)'
sed -i 's/#\[derive(Debug, Clone, PartialEq, Eq, EnumIter, DeriveActiveEnum)\]/#[derive(Debug, PartialEq, Eq, EnumIter, DeriveActiveEnum)]\n#[napi_derive::napi]/' \
packages/backend/native-utils/src/model/entity/sea_orm_active_enums.rs
.PHONY: update-index-js
update-index-js:

View file

@ -269,6 +269,18 @@ const {
EnvConfig,
readEnvironmentConfig,
readServerConfig,
AntennaSrcEnum,
MetaSensitivemediadetectionEnum,
MetaSensitivemediadetectionsensitivityEnum,
MutedNoteReasonEnum,
NoteVisibilityEnum,
NotificationTypeEnum,
PageVisibilityEnum,
PollNotevisibilityEnum,
RelayStatusEnum,
UserEmojimodpermEnum,
UserProfileFfvisibilityEnum,
UserProfileMutingnotificationtypesEnum,
stringToAcct,
acctToString,
getFullApAccount,
@ -280,17 +292,32 @@ const {
sqlLikeEscape,
safeForSql,
formatMilliseconds,
nativeInitIdGenerator,
nativeCreateId,
nativeGetTimestamp,
genString,
IdConvertType,
convertId,
nativeGetTimestamp,
nativeCreateId,
nativeInitIdGenerator,
} = nativeBinding;
module.exports.EnvConfig = EnvConfig;
module.exports.readEnvironmentConfig = readEnvironmentConfig;
module.exports.readServerConfig = readServerConfig;
module.exports.AntennaSrcEnum = AntennaSrcEnum;
module.exports.MetaSensitivemediadetectionEnum =
MetaSensitivemediadetectionEnum;
module.exports.MetaSensitivemediadetectionsensitivityEnum =
MetaSensitivemediadetectionsensitivityEnum;
module.exports.MutedNoteReasonEnum = MutedNoteReasonEnum;
module.exports.NoteVisibilityEnum = NoteVisibilityEnum;
module.exports.NotificationTypeEnum = NotificationTypeEnum;
module.exports.PageVisibilityEnum = PageVisibilityEnum;
module.exports.PollNotevisibilityEnum = PollNotevisibilityEnum;
module.exports.RelayStatusEnum = RelayStatusEnum;
module.exports.UserEmojimodpermEnum = UserEmojimodpermEnum;
module.exports.UserProfileFfvisibilityEnum = UserProfileFfvisibilityEnum;
module.exports.UserProfileMutingnotificationtypesEnum =
UserProfileMutingnotificationtypesEnum;
module.exports.stringToAcct = stringToAcct;
module.exports.acctToString = acctToString;
module.exports.getFullApAccount = getFullApAccount;
@ -302,9 +329,9 @@ module.exports.convertToHiddenPost = convertToHiddenPost;
module.exports.sqlLikeEscape = sqlLikeEscape;
module.exports.safeForSql = safeForSql;
module.exports.formatMilliseconds = formatMilliseconds;
module.exports.nativeInitIdGenerator = nativeInitIdGenerator;
module.exports.nativeCreateId = nativeCreateId;
module.exports.nativeGetTimestamp = nativeGetTimestamp;
module.exports.genString = genString;
module.exports.IdConvertType = IdConvertType;
module.exports.convertId = convertId;
module.exports.nativeGetTimestamp = nativeGetTimestamp;
module.exports.nativeCreateId = nativeCreateId;
module.exports.nativeInitIdGenerator = nativeInitIdGenerator;

View file

@ -1,3 +1,80 @@
-- drop-time-zone
ALTER TABLE "webhook" ALTER "latestSentAt" TYPE timestamp with time zone;
ALTER TABLE "webhook" ALTER "createdAt" TYPE timestamp with time zone;
ALTER TABLE "user_security_key" ALTER "lastUsed" TYPE timestamp with time zone;
ALTER TABLE "user_pending" ALTER "createdAt" TYPE timestamp with time zone;
ALTER TABLE "user_note_pining" ALTER "createdAt" TYPE timestamp with time zone;
ALTER TABLE "user_list_joining" ALTER "createdAt" TYPE timestamp with time zone;
ALTER TABLE "user_list" ALTER "createdAt" TYPE timestamp with time zone;
ALTER TABLE "user_ip" ALTER "createdAt" TYPE timestamp with time zone;
ALTER TABLE "user_group_joining" ALTER "createdAt" TYPE timestamp with time zone;
ALTER TABLE "user_group_invite" ALTER "createdAt" TYPE timestamp with time zone;
ALTER TABLE "user_group_invitation" ALTER "createdAt" TYPE timestamp with time zone;
ALTER TABLE "user_group" ALTER "createdAt" TYPE timestamp with time zone;
ALTER TABLE "user" ALTER "updatedAt" TYPE timestamp with time zone;
ALTER TABLE "user" ALTER "lastFetchedAt" TYPE timestamp with time zone;
ALTER TABLE "user" ALTER "lastActiveDate" TYPE timestamp with time zone;
ALTER TABLE "user" ALTER "createdAt" TYPE timestamp with time zone;
ALTER TABLE "used_username" ALTER "createdAt" TYPE timestamp with time zone;
ALTER TABLE "sw_subscription" ALTER "createdAt" TYPE timestamp with time zone;
ALTER TABLE "signin" ALTER "createdAt" TYPE timestamp with time zone;
ALTER TABLE "reply_muting" ALTER "createdAt" TYPE timestamp with time zone;
ALTER TABLE "renote_muting" ALTER "createdAt" TYPE timestamp with time zone;
ALTER TABLE "registry_item" ALTER "updatedAt" TYPE timestamp with time zone;
ALTER TABLE "registry_item" ALTER "createdAt" TYPE timestamp with time zone;
ALTER TABLE "registration_ticket" ALTER "createdAt" TYPE timestamp with time zone;
ALTER TABLE "promo_read" ALTER "createdAt" TYPE timestamp with time zone;
ALTER TABLE "promo_note" ALTER "expiresAt" TYPE timestamp with time zone;
ALTER TABLE "poll_vote" ALTER "createdAt" TYPE timestamp with time zone;
ALTER TABLE "poll" ALTER "expiresAt" TYPE timestamp with time zone;
ALTER TABLE "password_reset_request" ALTER "createdAt" TYPE timestamp with time zone;
ALTER TABLE "page_like" ALTER "createdAt" TYPE timestamp with time zone;
ALTER TABLE "page" ALTER "updatedAt" TYPE timestamp with time zone;
ALTER TABLE "page" ALTER "createdAt" TYPE timestamp with time zone;
ALTER TABLE "notification" ALTER "createdAt" TYPE timestamp with time zone;
ALTER TABLE "note_watching" ALTER "createdAt" TYPE timestamp with time zone;
ALTER TABLE "note_thread_muting" ALTER "createdAt" TYPE timestamp with time zone;
ALTER TABLE "note_reaction" ALTER "createdAt" TYPE timestamp with time zone;
ALTER TABLE "note_favorite" ALTER "createdAt" TYPE timestamp with time zone;
ALTER TABLE "note_edit" ALTER "updatedAt" TYPE timestamp with time zone;
ALTER TABLE "note" ALTER "updatedAt" TYPE timestamp with time zone;
ALTER TABLE "note" ALTER "createdAt" TYPE timestamp with time zone;
ALTER TABLE "muting" ALTER "expiresAt" TYPE timestamp with time zone;
ALTER TABLE "muting" ALTER "createdAt" TYPE timestamp with time zone;
ALTER TABLE "moderation_log" ALTER "createdAt" TYPE timestamp with time zone;
ALTER TABLE "messaging_message" ALTER "createdAt" TYPE timestamp with time zone;
ALTER TABLE "instance" ALTER "latestRequestSentAt" TYPE timestamp with time zone;
ALTER TABLE "instance" ALTER "latestRequestReceivedAt" TYPE timestamp with time zone;
ALTER TABLE "instance" ALTER "lastCommunicatedAt" TYPE timestamp with time zone;
ALTER TABLE "instance" ALTER "infoUpdatedAt" TYPE timestamp with time zone;
ALTER TABLE "instance" ALTER "caughtAt" TYPE timestamp with time zone;
ALTER TABLE "gallery_post" ALTER "updatedAt" TYPE timestamp with time zone;
ALTER TABLE "gallery_post" ALTER "createdAt" TYPE timestamp with time zone;
ALTER TABLE "gallery_like" ALTER "createdAt" TYPE timestamp with time zone;
ALTER TABLE "follow_request" ALTER "createdAt" TYPE timestamp with time zone;
ALTER TABLE "following" ALTER "createdAt" TYPE timestamp with time zone;
ALTER TABLE "emoji" ALTER "updatedAt" TYPE timestamp with time zone;
ALTER TABLE "drive_folder" ALTER "createdAt" TYPE timestamp with time zone;
ALTER TABLE "drive_file" ALTER "createdAt" TYPE timestamp with time zone;
ALTER TABLE "clip" ALTER "createdAt" TYPE timestamp with time zone;
ALTER TABLE "channel_note_pining" ALTER "createdAt" TYPE timestamp with time zone;
ALTER TABLE "channel_following" ALTER "createdAt" TYPE timestamp with time zone;
ALTER TABLE "channel" ALTER "lastNotedAt" TYPE timestamp with time zone;
ALTER TABLE "channel" ALTER "createdAt" TYPE timestamp with time zone;
ALTER TABLE "blocking" ALTER "createdAt" TYPE timestamp with time zone;
ALTER TABLE "auth_session" ALTER "createdAt" TYPE timestamp with time zone;
ALTER TABLE "attestation_challenge" ALTER "createdAt" TYPE timestamp with time zone;
ALTER TABLE "app" ALTER "createdAt" TYPE timestamp with time zone;
ALTER TABLE "antenna" ALTER "createdAt" TYPE timestamp with time zone;
ALTER TABLE "announcement_read" ALTER "createdAt" TYPE timestamp with time zone;
ALTER TABLE "announcement" ALTER "updatedAt" TYPE timestamp with time zone;
ALTER TABLE "announcement" ALTER "createdAt" TYPE timestamp with time zone;
ALTER TABLE "ad" ALTER "expiresAt" TYPE timestamp with time zone;
ALTER TABLE "ad" ALTER "createdAt" TYPE timestamp with time zone;
ALTER TABLE "access_token" ALTER "lastUsedAt" TYPE timestamp with time zone;
ALTER TABLE "access_token" ALTER "createdAt" TYPE timestamp with time zone;
ALTER TABLE "abuse_user_report" ALTER "createdAt" TYPE timestamp with time zone;
-- reply-muting
DROP TABLE "reply_muting";

View file

@ -0,0 +1,459 @@
export class DropTimeZone1705691683091 {
name = "DropTimeZone1705691683091";
async up(queryRunner) {
await queryRunner.query(
`ALTER TABLE "abuse_user_report" ALTER "createdAt" TYPE timestamp without time zone`,
);
await queryRunner.query(
`ALTER TABLE "access_token" ALTER "createdAt" TYPE timestamp without time zone`,
);
await queryRunner.query(
`ALTER TABLE "access_token" ALTER "lastUsedAt" TYPE timestamp without time zone`,
);
await queryRunner.query(
`ALTER TABLE "ad" ALTER "createdAt" TYPE timestamp without time zone`,
);
await queryRunner.query(
`ALTER TABLE "ad" ALTER "expiresAt" TYPE timestamp without time zone`,
);
await queryRunner.query(
`ALTER TABLE "announcement" ALTER "createdAt" TYPE timestamp without time zone`,
);
await queryRunner.query(
`ALTER TABLE "announcement" ALTER "updatedAt" TYPE timestamp without time zone`,
);
await queryRunner.query(
`ALTER TABLE "announcement_read" ALTER "createdAt" TYPE timestamp without time zone`,
);
await queryRunner.query(
`ALTER TABLE "antenna" ALTER "createdAt" TYPE timestamp without time zone`,
);
await queryRunner.query(
`ALTER TABLE "app" ALTER "createdAt" TYPE timestamp without time zone`,
);
await queryRunner.query(
`ALTER TABLE "attestation_challenge" ALTER "createdAt" TYPE timestamp without time zone`,
);
await queryRunner.query(
`ALTER TABLE "auth_session" ALTER "createdAt" TYPE timestamp without time zone`,
);
await queryRunner.query(
`ALTER TABLE "blocking" ALTER "createdAt" TYPE timestamp without time zone`,
);
await queryRunner.query(
`ALTER TABLE "channel" ALTER "createdAt" TYPE timestamp without time zone`,
);
await queryRunner.query(
`ALTER TABLE "channel" ALTER "lastNotedAt" TYPE timestamp without time zone`,
);
await queryRunner.query(
`ALTER TABLE "channel_following" ALTER "createdAt" TYPE timestamp without time zone`,
);
await queryRunner.query(
`ALTER TABLE "channel_note_pining" ALTER "createdAt" TYPE timestamp without time zone`,
);
await queryRunner.query(
`ALTER TABLE "clip" ALTER "createdAt" TYPE timestamp without time zone`,
);
await queryRunner.query(
`ALTER TABLE "drive_file" ALTER "createdAt" TYPE timestamp without time zone`,
);
await queryRunner.query(
`ALTER TABLE "drive_folder" ALTER "createdAt" TYPE timestamp without time zone`,
);
await queryRunner.query(
`ALTER TABLE "emoji" ALTER "updatedAt" TYPE timestamp without time zone`,
);
await queryRunner.query(
`ALTER TABLE "following" ALTER "createdAt" TYPE timestamp without time zone`,
);
await queryRunner.query(
`ALTER TABLE "follow_request" ALTER "createdAt" TYPE timestamp without time zone`,
);
await queryRunner.query(
`ALTER TABLE "gallery_like" ALTER "createdAt" TYPE timestamp without time zone`,
);
await queryRunner.query(
`ALTER TABLE "gallery_post" ALTER "createdAt" TYPE timestamp without time zone`,
);
await queryRunner.query(
`ALTER TABLE "gallery_post" ALTER "updatedAt" TYPE timestamp without time zone`,
);
await queryRunner.query(
`ALTER TABLE "instance" ALTER "caughtAt" TYPE timestamp without time zone`,
);
await queryRunner.query(
`ALTER TABLE "instance" ALTER "infoUpdatedAt" TYPE timestamp without time zone`,
);
await queryRunner.query(
`ALTER TABLE "instance" ALTER "lastCommunicatedAt" TYPE timestamp without time zone`,
);
await queryRunner.query(
`ALTER TABLE "instance" ALTER "latestRequestReceivedAt" TYPE timestamp without time zone`,
);
await queryRunner.query(
`ALTER TABLE "instance" ALTER "latestRequestSentAt" TYPE timestamp without time zone`,
);
await queryRunner.query(
`ALTER TABLE "messaging_message" ALTER "createdAt" TYPE timestamp without time zone`,
);
await queryRunner.query(
`ALTER TABLE "moderation_log" ALTER "createdAt" TYPE timestamp without time zone`,
);
await queryRunner.query(
`ALTER TABLE "muting" ALTER "createdAt" TYPE timestamp without time zone`,
);
await queryRunner.query(
`ALTER TABLE "muting" ALTER "expiresAt" TYPE timestamp without time zone`,
);
await queryRunner.query(
`ALTER TABLE "note" ALTER "createdAt" TYPE timestamp without time zone`,
);
await queryRunner.query(
`ALTER TABLE "note" ALTER "updatedAt" TYPE timestamp without time zone`,
);
await queryRunner.query(
`ALTER TABLE "note_edit" ALTER "updatedAt" TYPE timestamp without time zone`,
);
await queryRunner.query(
`ALTER TABLE "note_favorite" ALTER "createdAt" TYPE timestamp without time zone`,
);
await queryRunner.query(
`ALTER TABLE "note_reaction" ALTER "createdAt" TYPE timestamp without time zone`,
);
await queryRunner.query(
`ALTER TABLE "note_thread_muting" ALTER "createdAt" TYPE timestamp without time zone`,
);
await queryRunner.query(
`ALTER TABLE "note_watching" ALTER "createdAt" TYPE timestamp without time zone`,
);
await queryRunner.query(
`ALTER TABLE "notification" ALTER "createdAt" TYPE timestamp without time zone`,
);
await queryRunner.query(
`ALTER TABLE "page" ALTER "createdAt" TYPE timestamp without time zone`,
);
await queryRunner.query(
`ALTER TABLE "page" ALTER "updatedAt" TYPE timestamp without time zone`,
);
await queryRunner.query(
`ALTER TABLE "page_like" ALTER "createdAt" TYPE timestamp without time zone`,
);
await queryRunner.query(
`ALTER TABLE "password_reset_request" ALTER "createdAt" TYPE timestamp without time zone`,
);
await queryRunner.query(
`ALTER TABLE "poll" ALTER "expiresAt" TYPE timestamp without time zone`,
);
await queryRunner.query(
`ALTER TABLE "poll_vote" ALTER "createdAt" TYPE timestamp without time zone`,
);
await queryRunner.query(
`ALTER TABLE "promo_note" ALTER "expiresAt" TYPE timestamp without time zone`,
);
await queryRunner.query(
`ALTER TABLE "promo_read" ALTER "createdAt" TYPE timestamp without time zone`,
);
await queryRunner.query(
`ALTER TABLE "registration_ticket" ALTER "createdAt" TYPE timestamp without time zone`,
);
await queryRunner.query(
`ALTER TABLE "registry_item" ALTER "createdAt" TYPE timestamp without time zone`,
);
await queryRunner.query(
`ALTER TABLE "registry_item" ALTER "updatedAt" TYPE timestamp without time zone`,
);
await queryRunner.query(
`ALTER TABLE "renote_muting" ALTER "createdAt" TYPE timestamp without time zone`,
);
await queryRunner.query(
`ALTER TABLE "reply_muting" ALTER "createdAt" TYPE timestamp without time zone`,
);
await queryRunner.query(
`ALTER TABLE "signin" ALTER "createdAt" TYPE timestamp without time zone`,
);
await queryRunner.query(
`ALTER TABLE "sw_subscription" ALTER "createdAt" TYPE timestamp without time zone`,
);
await queryRunner.query(
`ALTER TABLE "used_username" ALTER "createdAt" TYPE timestamp without time zone`,
);
await queryRunner.query(
`ALTER TABLE "user" ALTER "createdAt" TYPE timestamp without time zone`,
);
await queryRunner.query(
`ALTER TABLE "user" ALTER "lastActiveDate" TYPE timestamp without time zone`,
);
await queryRunner.query(
`ALTER TABLE "user" ALTER "lastFetchedAt" TYPE timestamp without time zone`,
);
await queryRunner.query(
`ALTER TABLE "user" ALTER "updatedAt" TYPE timestamp without time zone`,
);
await queryRunner.query(
`ALTER TABLE "user_group" ALTER "createdAt" TYPE timestamp without time zone`,
);
await queryRunner.query(
`ALTER TABLE "user_group_invitation" ALTER "createdAt" TYPE timestamp without time zone`,
);
await queryRunner.query(
`ALTER TABLE "user_group_invite" ALTER "createdAt" TYPE timestamp without time zone`,
);
await queryRunner.query(
`ALTER TABLE "user_group_joining" ALTER "createdAt" TYPE timestamp without time zone`,
);
await queryRunner.query(
`ALTER TABLE "user_ip" ALTER "createdAt" TYPE timestamp without time zone`,
);
await queryRunner.query(
`ALTER TABLE "user_list" ALTER "createdAt" TYPE timestamp without time zone`,
);
await queryRunner.query(
`ALTER TABLE "user_list_joining" ALTER "createdAt" TYPE timestamp without time zone`,
);
await queryRunner.query(
`ALTER TABLE "user_note_pining" ALTER "createdAt" TYPE timestamp without time zone`,
);
await queryRunner.query(
`ALTER TABLE "user_pending" ALTER "createdAt" TYPE timestamp without time zone`,
);
await queryRunner.query(
`ALTER TABLE "user_security_key" ALTER "lastUsed" TYPE timestamp without time zone`,
);
await queryRunner.query(
`ALTER TABLE "webhook" ALTER "createdAt" TYPE timestamp without time zone`,
);
await queryRunner.query(
`ALTER TABLE "webhook" ALTER "latestSentAt" TYPE timestamp without time zone`,
);
}
async down(queryRunner) {
await queryRunner.query(
`ALTER TABLE "webhook" ALTER "latestSentAt" TYPE timestamp with time zone`,
);
await queryRunner.query(
`ALTER TABLE "webhook" ALTER "createdAt" TYPE timestamp with time zone`,
);
await queryRunner.query(
`ALTER TABLE "user_security_key" ALTER "lastUsed" TYPE timestamp with time zone`,
);
await queryRunner.query(
`ALTER TABLE "user_pending" ALTER "createdAt" TYPE timestamp with time zone`,
);
await queryRunner.query(
`ALTER TABLE "user_note_pining" ALTER "createdAt" TYPE timestamp with time zone`,
);
await queryRunner.query(
`ALTER TABLE "user_list_joining" ALTER "createdAt" TYPE timestamp with time zone`,
);
await queryRunner.query(
`ALTER TABLE "user_list" ALTER "createdAt" TYPE timestamp with time zone`,
);
await queryRunner.query(
`ALTER TABLE "user_ip" ALTER "createdAt" TYPE timestamp with time zone`,
);
await queryRunner.query(
`ALTER TABLE "user_group_joining" ALTER "createdAt" TYPE timestamp with time zone`,
);
await queryRunner.query(
`ALTER TABLE "user_group_invite" ALTER "createdAt" TYPE timestamp with time zone`,
);
await queryRunner.query(
`ALTER TABLE "user_group_invitation" ALTER "createdAt" TYPE timestamp with time zone`,
);
await queryRunner.query(
`ALTER TABLE "user_group" ALTER "createdAt" TYPE timestamp with time zone`,
);
await queryRunner.query(
`ALTER TABLE "user" ALTER "updatedAt" TYPE timestamp with time zone`,
);
await queryRunner.query(
`ALTER TABLE "user" ALTER "lastFetchedAt" TYPE timestamp with time zone`,
);
await queryRunner.query(
`ALTER TABLE "user" ALTER "lastActiveDate" TYPE timestamp with time zone`,
);
await queryRunner.query(
`ALTER TABLE "user" ALTER "createdAt" TYPE timestamp with time zone`,
);
await queryRunner.query(
`ALTER TABLE "used_username" ALTER "createdAt" TYPE timestamp with time zone`,
);
await queryRunner.query(
`ALTER TABLE "sw_subscription" ALTER "createdAt" TYPE timestamp with time zone`,
);
await queryRunner.query(
`ALTER TABLE "signin" ALTER "createdAt" TYPE timestamp with time zone`,
);
await queryRunner.query(
`ALTER TABLE "reply_muting" ALTER "createdAt" TYPE timestamp with time zone`,
);
await queryRunner.query(
`ALTER TABLE "renote_muting" ALTER "createdAt" TYPE timestamp with time zone`,
);
await queryRunner.query(
`ALTER TABLE "registry_item" ALTER "updatedAt" TYPE timestamp with time zone`,
);
await queryRunner.query(
`ALTER TABLE "registry_item" ALTER "createdAt" TYPE timestamp with time zone`,
);
await queryRunner.query(
`ALTER TABLE "registration_ticket" ALTER "createdAt" TYPE timestamp with time zone`,
);
await queryRunner.query(
`ALTER TABLE "promo_read" ALTER "createdAt" TYPE timestamp with time zone`,
);
await queryRunner.query(
`ALTER TABLE "promo_note" ALTER "expiresAt" TYPE timestamp with time zone`,
);
await queryRunner.query(
`ALTER TABLE "poll_vote" ALTER "createdAt" TYPE timestamp with time zone`,
);
await queryRunner.query(
`ALTER TABLE "poll" ALTER "expiresAt" TYPE timestamp with time zone`,
);
await queryRunner.query(
`ALTER TABLE "password_reset_request" ALTER "createdAt" TYPE timestamp with time zone`,
);
await queryRunner.query(
`ALTER TABLE "page_like" ALTER "createdAt" TYPE timestamp with time zone`,
);
await queryRunner.query(
`ALTER TABLE "page" ALTER "updatedAt" TYPE timestamp with time zone`,
);
await queryRunner.query(
`ALTER TABLE "page" ALTER "createdAt" TYPE timestamp with time zone`,
);
await queryRunner.query(
`ALTER TABLE "notification" ALTER "createdAt" TYPE timestamp with time zone`,
);
await queryRunner.query(
`ALTER TABLE "note_watching" ALTER "createdAt" TYPE timestamp with time zone`,
);
await queryRunner.query(
`ALTER TABLE "note_thread_muting" ALTER "createdAt" TYPE timestamp with time zone`,
);
await queryRunner.query(
`ALTER TABLE "note_reaction" ALTER "createdAt" TYPE timestamp with time zone`,
);
await queryRunner.query(
`ALTER TABLE "note_favorite" ALTER "createdAt" TYPE timestamp with time zone`,
);
await queryRunner.query(
`ALTER TABLE "note_edit" ALTER "updatedAt" TYPE timestamp with time zone`,
);
await queryRunner.query(
`ALTER TABLE "note" ALTER "updatedAt" TYPE timestamp with time zone`,
);
await queryRunner.query(
`ALTER TABLE "note" ALTER "createdAt" TYPE timestamp with time zone`,
);
await queryRunner.query(
`ALTER TABLE "muting" ALTER "expiresAt" TYPE timestamp with time zone`,
);
await queryRunner.query(
`ALTER TABLE "muting" ALTER "createdAt" TYPE timestamp with time zone`,
);
await queryRunner.query(
`ALTER TABLE "moderation_log" ALTER "createdAt" TYPE timestamp with time zone`,
);
await queryRunner.query(
`ALTER TABLE "messaging_message" ALTER "createdAt" TYPE timestamp with time zone`,
);
await queryRunner.query(
`ALTER TABLE "instance" ALTER "latestRequestSentAt" TYPE timestamp with time zone`,
);
await queryRunner.query(
`ALTER TABLE "instance" ALTER "latestRequestReceivedAt" TYPE timestamp with time zone`,
);
await queryRunner.query(
`ALTER TABLE "instance" ALTER "lastCommunicatedAt" TYPE timestamp with time zone`,
);
await queryRunner.query(
`ALTER TABLE "instance" ALTER "infoUpdatedAt" TYPE timestamp with time zone`,
);
await queryRunner.query(
`ALTER TABLE "instance" ALTER "caughtAt" TYPE timestamp with time zone`,
);
await queryRunner.query(
`ALTER TABLE "gallery_post" ALTER "updatedAt" TYPE timestamp with time zone`,
);
await queryRunner.query(
`ALTER TABLE "gallery_post" ALTER "createdAt" TYPE timestamp with time zone`,
);
await queryRunner.query(
`ALTER TABLE "gallery_like" ALTER "createdAt" TYPE timestamp with time zone`,
);
await queryRunner.query(
`ALTER TABLE "follow_request" ALTER "createdAt" TYPE timestamp with time zone`,
);
await queryRunner.query(
`ALTER TABLE "following" ALTER "createdAt" TYPE timestamp with time zone`,
);
await queryRunner.query(
`ALTER TABLE "emoji" ALTER "updatedAt" TYPE timestamp with time zone`,
);
await queryRunner.query(
`ALTER TABLE "drive_folder" ALTER "createdAt" TYPE timestamp with time zone`,
);
await queryRunner.query(
`ALTER TABLE "drive_file" ALTER "createdAt" TYPE timestamp with time zone`,
);
await queryRunner.query(
`ALTER TABLE "clip" ALTER "createdAt" TYPE timestamp with time zone`,
);
await queryRunner.query(
`ALTER TABLE "channel_note_pining" ALTER "createdAt" TYPE timestamp with time zone`,
);
await queryRunner.query(
`ALTER TABLE "channel_following" ALTER "createdAt" TYPE timestamp with time zone`,
);
await queryRunner.query(
`ALTER TABLE "channel" ALTER "lastNotedAt" TYPE timestamp with time zone`,
);
await queryRunner.query(
`ALTER TABLE "channel" ALTER "createdAt" TYPE timestamp with time zone`,
);
await queryRunner.query(
`ALTER TABLE "blocking" ALTER "createdAt" TYPE timestamp with time zone`,
);
await queryRunner.query(
`ALTER TABLE "auth_session" ALTER "createdAt" TYPE timestamp with time zone`,
);
await queryRunner.query(
`ALTER TABLE "attestation_challenge" ALTER "createdAt" TYPE timestamp with time zone`,
);
await queryRunner.query(
`ALTER TABLE "app" ALTER "createdAt" TYPE timestamp with time zone`,
);
await queryRunner.query(
`ALTER TABLE "antenna" ALTER "createdAt" TYPE timestamp with time zone`,
);
await queryRunner.query(
`ALTER TABLE "announcement_read" ALTER "createdAt" TYPE timestamp with time zone`,
);
await queryRunner.query(
`ALTER TABLE "announcement" ALTER "updatedAt" TYPE timestamp with time zone`,
);
await queryRunner.query(
`ALTER TABLE "announcement" ALTER "createdAt" TYPE timestamp with time zone`,
);
await queryRunner.query(
`ALTER TABLE "ad" ALTER "expiresAt" TYPE timestamp with time zone`,
);
await queryRunner.query(
`ALTER TABLE "ad" ALTER "createdAt" TYPE timestamp with time zone`,
);
await queryRunner.query(
`ALTER TABLE "access_token" ALTER "lastUsedAt" TYPE timestamp with time zone`,
);
await queryRunner.query(
`ALTER TABLE "access_token" ALTER "createdAt" TYPE timestamp with time zone`,
);
await queryRunner.query(
`ALTER TABLE "abuse_user_report" ALTER "createdAt" TYPE timestamp with time zone`,
);
}
}

View file

@ -1351,10 +1351,13 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2fc1cb00cde484640da9f01a124edbb013576a6ae9843b23857c940936b76d91"
dependencies = [
"bitflags 2.4.2",
"chrono",
"ctor",
"napi-derive",
"napi-sys",
"once_cell",
"serde",
"serde_json",
"tokio",
]
@ -1428,6 +1431,7 @@ dependencies = [
"thiserror",
"tokio",
"url",
"urlencoding",
]
[[package]]

View file

@ -7,7 +7,7 @@ version = "0.0.0"
members = ["migration"]
[features]
default = []
default = ["napi"]
napi = ["dep:napi-derive"]
[lib]
@ -33,9 +33,10 @@ tokio = { version = "1.35.1", features = ["full"] }
url = "2.5.0"
# Default enable napi4 feature, see https://nodejs.org/api/n-api.html#node-api-version-matrix
napi = { version = "2.14.2", default-features = false, features = ["napi9", "tokio_rt"] }
napi = { version = "2.14.2", default-features = false, features = ["napi9", "tokio_rt", "chrono_date", "serde-json"] }
napi-derive = { version = "2.14.6", optional = true }
basen = "0.1.0"
urlencoding = "2.1.3"
[dev-dependencies]
pretty_assertions = "1.4.0"

View file

@ -1,6 +1,6 @@
use sea_orm::error::DbErr;
use crate::impl_into_napi_error;
use crate::impl_napi_error_from;
#[derive(thiserror::Error, Debug, PartialEq, Eq)]
pub enum Error {
@ -10,4 +10,13 @@ pub enum Error {
OrmError(#[from] DbErr),
}
impl_into_napi_error!(Error);
impl_napi_error_from!(Error);
pub trait NapiDbErrExt {
fn into(self) -> napi::Error;
}
impl NapiDbErrExt for DbErr {
fn into(self) -> napi::Error {
napi::Error::from_reason(self.to_string())
}
}

View file

@ -1,26 +1,44 @@
pub mod error;
pub use error::NapiDbErrExt;
use error::Error;
use crate::config::server::read_server_config;
use sea_orm::{Database, DbConn};
use urlencoding::encode;
static DB_CONN: once_cell::sync::OnceCell<DbConn> = once_cell::sync::OnceCell::new();
pub async fn init_database(conn_uri: impl Into<String>) -> Result<(), Error> {
let conn = Database::connect(conn_uri.into()).await?;
DB_CONN.get_or_init(move || conn);
Ok(())
#[napi_derive::napi]
pub struct JsDbConn {
inner: DbConn,
}
pub fn get_database() -> Result<&'static DbConn, Error> {
DB_CONN.get().ok_or(Error::Uninitialized)
}
#[cfg(test)]
mod unit_test {
use super::{error::Error, get_database};
#[test]
fn error_uninitialized() {
assert_eq!(get_database().unwrap_err(), Error::Uninitialized);
impl JsDbConn {
pub fn inner(&self) -> &DbConn {
&self.inner
}
}
#[napi_derive::napi]
pub async fn init_database() -> napi::Result<JsDbConn> {
let config = read_server_config().db;
let conn_uri = format!(
"postgres://{}:{}@{}:{}/{}",
config.user,
encode(&config.pass),
config.host,
config.port,
config.db,
);
let conn = Database::connect(conn_uri)
.await
.map_err(NapiDbErrExt::into)?;
Ok(JsDbConn { inner: conn })
}
// TODO
// #[cfg(test)]
// mod unit_test {
// use super::{error::Error, get_database};
//
// #[test]
// fn error_uninitialized() {
// assert_eq!(get_database().unwrap_err(), Error::Uninitialized);
// }
// }

View file

@ -4,5 +4,5 @@ pub mod macros;
pub mod model;
pub mod util;
#[cfg(feature = "napi")]
// #[cfg(feature = "napi")]
pub mod mastodon_api;

View file

@ -1,10 +1,10 @@
#[macro_export]
macro_rules! impl_into_napi_error {
macro_rules! impl_napi_error_from {
($a:ty) => {
#[cfg(feature = "napi")]
impl Into<napi::Error> for $a {
fn into(self) -> napi::Error {
napi::Error::from_reason(self.to_string())
impl From<$a> for napi::Error {
fn from(reason: $a) -> napi::Error {
napi::Error::from_reason(reason.to_string())
}
}
};

View file

@ -4,11 +4,12 @@ use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "abuse_user_report")]
#[napi_derive::napi(object)]
pub struct Model {
#[sea_orm(primary_key, auto_increment = false)]
pub id: String,
#[sea_orm(column_name = "createdAt")]
pub created_at: DateTimeWithTimeZone,
pub created_at: DateTime,
#[sea_orm(column_name = "targetUserId")]
pub target_user_id: String,
#[sea_orm(column_name = "reporterId")]

View file

@ -4,11 +4,12 @@ use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "access_token")]
#[napi_derive::napi(object)]
pub struct Model {
#[sea_orm(primary_key, auto_increment = false)]
pub id: String,
#[sea_orm(column_name = "createdAt")]
pub created_at: DateTimeWithTimeZone,
pub created_at: DateTime,
pub token: String,
pub hash: String,
#[sea_orm(column_name = "userId")]
@ -16,7 +17,7 @@ pub struct Model {
#[sea_orm(column_name = "appId")]
pub app_id: Option<String>,
#[sea_orm(column_name = "lastUsedAt")]
pub last_used_at: Option<DateTimeWithTimeZone>,
pub last_used_at: Option<DateTime>,
pub session: Option<String>,
pub name: Option<String>,
pub description: Option<String>,

View file

@ -4,13 +4,14 @@ use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "ad")]
#[napi_derive::napi(object)]
pub struct Model {
#[sea_orm(primary_key, auto_increment = false)]
pub id: String,
#[sea_orm(column_name = "createdAt")]
pub created_at: DateTimeWithTimeZone,
pub created_at: DateTime,
#[sea_orm(column_name = "expiresAt")]
pub expires_at: DateTimeWithTimeZone,
pub expires_at: DateTime,
pub place: String,
pub priority: String,
pub url: String,

View file

@ -4,17 +4,18 @@ use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "announcement")]
#[napi_derive::napi(object)]
pub struct Model {
#[sea_orm(primary_key, auto_increment = false)]
pub id: String,
#[sea_orm(column_name = "createdAt")]
pub created_at: DateTimeWithTimeZone,
pub created_at: DateTime,
pub text: String,
pub title: String,
#[sea_orm(column_name = "imageUrl")]
pub image_url: Option<String>,
#[sea_orm(column_name = "updatedAt")]
pub updated_at: Option<DateTimeWithTimeZone>,
pub updated_at: Option<DateTime>,
#[sea_orm(column_name = "showPopup")]
pub show_popup: bool,
#[sea_orm(column_name = "isGoodNews")]

View file

@ -4,6 +4,7 @@ use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "announcement_read")]
#[napi_derive::napi(object)]
pub struct Model {
#[sea_orm(primary_key, auto_increment = false)]
pub id: String,
@ -12,7 +13,7 @@ pub struct Model {
#[sea_orm(column_name = "announcementId")]
pub announcement_id: String,
#[sea_orm(column_name = "createdAt")]
pub created_at: DateTimeWithTimeZone,
pub created_at: DateTime,
}
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]

View file

@ -5,11 +5,12 @@ use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "antenna")]
#[napi_derive::napi(object)]
pub struct Model {
#[sea_orm(primary_key, auto_increment = false)]
pub id: String,
#[sea_orm(column_name = "createdAt")]
pub created_at: DateTimeWithTimeZone,
pub created_at: DateTime,
#[sea_orm(column_name = "userId")]
pub user_id: String,
pub name: String,

View file

@ -4,11 +4,12 @@ use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "app")]
#[napi_derive::napi(object)]
pub struct Model {
#[sea_orm(primary_key, auto_increment = false)]
pub id: String,
#[sea_orm(column_name = "createdAt")]
pub created_at: DateTimeWithTimeZone,
pub created_at: DateTime,
#[sea_orm(column_name = "userId")]
pub user_id: Option<String>,
pub secret: String,

View file

@ -4,6 +4,7 @@ use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "attestation_challenge")]
#[napi_derive::napi(object)]
pub struct Model {
#[sea_orm(primary_key, auto_increment = false)]
pub id: String,
@ -11,7 +12,7 @@ pub struct Model {
pub user_id: String,
pub challenge: String,
#[sea_orm(column_name = "createdAt")]
pub created_at: DateTimeWithTimeZone,
pub created_at: DateTime,
#[sea_orm(column_name = "registrationChallenge")]
pub registration_challenge: bool,
}

View file

@ -4,11 +4,12 @@ use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "auth_session")]
#[napi_derive::napi(object)]
pub struct Model {
#[sea_orm(primary_key, auto_increment = false)]
pub id: String,
#[sea_orm(column_name = "createdAt")]
pub created_at: DateTimeWithTimeZone,
pub created_at: DateTime,
pub token: String,
#[sea_orm(column_name = "userId")]
pub user_id: Option<String>,

View file

@ -4,11 +4,12 @@ use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "blocking")]
#[napi_derive::napi(object)]
pub struct Model {
#[sea_orm(primary_key, auto_increment = false)]
pub id: String,
#[sea_orm(column_name = "createdAt")]
pub created_at: DateTimeWithTimeZone,
pub created_at: DateTime,
#[sea_orm(column_name = "blockeeId")]
pub blockee_id: String,
#[sea_orm(column_name = "blockerId")]

View file

@ -4,13 +4,14 @@ use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "channel")]
#[napi_derive::napi(object)]
pub struct Model {
#[sea_orm(primary_key, auto_increment = false)]
pub id: String,
#[sea_orm(column_name = "createdAt")]
pub created_at: DateTimeWithTimeZone,
pub created_at: DateTime,
#[sea_orm(column_name = "lastNotedAt")]
pub last_noted_at: Option<DateTimeWithTimeZone>,
pub last_noted_at: Option<DateTime>,
#[sea_orm(column_name = "userId")]
pub user_id: Option<String>,
pub name: String,

View file

@ -4,11 +4,12 @@ use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "channel_following")]
#[napi_derive::napi(object)]
pub struct Model {
#[sea_orm(primary_key, auto_increment = false)]
pub id: String,
#[sea_orm(column_name = "createdAt")]
pub created_at: DateTimeWithTimeZone,
pub created_at: DateTime,
#[sea_orm(column_name = "followeeId")]
pub followee_id: String,
#[sea_orm(column_name = "followerId")]

View file

@ -4,11 +4,12 @@ use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "channel_note_pining")]
#[napi_derive::napi(object)]
pub struct Model {
#[sea_orm(primary_key, auto_increment = false)]
pub id: String,
#[sea_orm(column_name = "createdAt")]
pub created_at: DateTimeWithTimeZone,
pub created_at: DateTime,
#[sea_orm(column_name = "channelId")]
pub channel_id: String,
#[sea_orm(column_name = "noteId")]

View file

@ -4,11 +4,12 @@ use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "clip")]
#[napi_derive::napi(object)]
pub struct Model {
#[sea_orm(primary_key, auto_increment = false)]
pub id: String,
#[sea_orm(column_name = "createdAt")]
pub created_at: DateTimeWithTimeZone,
pub created_at: DateTime,
#[sea_orm(column_name = "userId")]
pub user_id: String,
pub name: String,

View file

@ -4,6 +4,7 @@ use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "clip_note")]
#[napi_derive::napi(object)]
pub struct Model {
#[sea_orm(primary_key, auto_increment = false)]
pub id: String,

View file

@ -4,11 +4,12 @@ use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "drive_file")]
#[napi_derive::napi(object)]
pub struct Model {
#[sea_orm(primary_key, auto_increment = false)]
pub id: String,
#[sea_orm(column_name = "createdAt")]
pub created_at: DateTimeWithTimeZone,
pub created_at: DateTime,
#[sea_orm(column_name = "userId")]
pub user_id: Option<String>,
#[sea_orm(column_name = "userHost")]

View file

@ -4,11 +4,12 @@ use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "drive_folder")]
#[napi_derive::napi(object)]
pub struct Model {
#[sea_orm(primary_key, auto_increment = false)]
pub id: String,
#[sea_orm(column_name = "createdAt")]
pub created_at: DateTimeWithTimeZone,
pub created_at: DateTime,
pub name: String,
#[sea_orm(column_name = "userId")]
pub user_id: Option<String>,

View file

@ -4,11 +4,12 @@ use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "emoji")]
#[napi_derive::napi(object)]
pub struct Model {
#[sea_orm(primary_key, auto_increment = false)]
pub id: String,
#[sea_orm(column_name = "updatedAt")]
pub updated_at: Option<DateTimeWithTimeZone>,
pub updated_at: Option<DateTime>,
pub name: String,
pub host: Option<String>,
#[sea_orm(column_name = "originalUrl")]

View file

@ -4,11 +4,12 @@ use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "follow_request")]
#[napi_derive::napi(object)]
pub struct Model {
#[sea_orm(primary_key, auto_increment = false)]
pub id: String,
#[sea_orm(column_name = "createdAt")]
pub created_at: DateTimeWithTimeZone,
pub created_at: DateTime,
#[sea_orm(column_name = "followeeId")]
pub followee_id: String,
#[sea_orm(column_name = "followerId")]

View file

@ -4,11 +4,12 @@ use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "following")]
#[napi_derive::napi(object)]
pub struct Model {
#[sea_orm(primary_key, auto_increment = false)]
pub id: String,
#[sea_orm(column_name = "createdAt")]
pub created_at: DateTimeWithTimeZone,
pub created_at: DateTime,
#[sea_orm(column_name = "followeeId")]
pub followee_id: String,
#[sea_orm(column_name = "followerId")]

View file

@ -4,11 +4,12 @@ use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "gallery_like")]
#[napi_derive::napi(object)]
pub struct Model {
#[sea_orm(primary_key, auto_increment = false)]
pub id: String,
#[sea_orm(column_name = "createdAt")]
pub created_at: DateTimeWithTimeZone,
pub created_at: DateTime,
#[sea_orm(column_name = "userId")]
pub user_id: String,
#[sea_orm(column_name = "postId")]

View file

@ -4,13 +4,14 @@ use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "gallery_post")]
#[napi_derive::napi(object)]
pub struct Model {
#[sea_orm(primary_key, auto_increment = false)]
pub id: String,
#[sea_orm(column_name = "createdAt")]
pub created_at: DateTimeWithTimeZone,
pub created_at: DateTime,
#[sea_orm(column_name = "updatedAt")]
pub updated_at: DateTimeWithTimeZone,
pub updated_at: DateTime,
pub title: String,
pub description: Option<String>,
#[sea_orm(column_name = "userId")]

View file

@ -4,6 +4,7 @@ use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "hashtag")]
#[napi_derive::napi(object)]
pub struct Model {
#[sea_orm(primary_key, auto_increment = false)]
pub id: String,

View file

@ -4,11 +4,12 @@ use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "instance")]
#[napi_derive::napi(object)]
pub struct Model {
#[sea_orm(primary_key, auto_increment = false)]
pub id: String,
#[sea_orm(column_name = "caughtAt")]
pub caught_at: DateTimeWithTimeZone,
pub caught_at: DateTime,
pub host: String,
#[sea_orm(column_name = "usersCount")]
pub users_count: i32,
@ -19,13 +20,13 @@ pub struct Model {
#[sea_orm(column_name = "followersCount")]
pub followers_count: i32,
#[sea_orm(column_name = "latestRequestSentAt")]
pub latest_request_sent_at: Option<DateTimeWithTimeZone>,
pub latest_request_sent_at: Option<DateTime>,
#[sea_orm(column_name = "latestStatus")]
pub latest_status: Option<i32>,
#[sea_orm(column_name = "latestRequestReceivedAt")]
pub latest_request_received_at: Option<DateTimeWithTimeZone>,
pub latest_request_received_at: Option<DateTime>,
#[sea_orm(column_name = "lastCommunicatedAt")]
pub last_communicated_at: DateTimeWithTimeZone,
pub last_communicated_at: DateTime,
#[sea_orm(column_name = "isNotResponding")]
pub is_not_responding: bool,
#[sea_orm(column_name = "softwareName")]
@ -41,7 +42,7 @@ pub struct Model {
#[sea_orm(column_name = "maintainerEmail")]
pub maintainer_email: Option<String>,
#[sea_orm(column_name = "infoUpdatedAt")]
pub info_updated_at: Option<DateTimeWithTimeZone>,
pub info_updated_at: Option<DateTime>,
#[sea_orm(column_name = "isSuspended")]
pub is_suspended: bool,
#[sea_orm(column_name = "iconUrl")]

View file

@ -4,11 +4,12 @@ use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "messaging_message")]
#[napi_derive::napi(object)]
pub struct Model {
#[sea_orm(primary_key, auto_increment = false)]
pub id: String,
#[sea_orm(column_name = "createdAt")]
pub created_at: DateTimeWithTimeZone,
pub created_at: DateTime,
#[sea_orm(column_name = "userId")]
pub user_id: String,
#[sea_orm(column_name = "recipientId")]

View file

@ -6,6 +6,7 @@ use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "meta")]
#[napi_derive::napi(object, js_name = "Meta")]
pub struct Model {
#[sea_orm(primary_key, auto_increment = false)]
pub id: String,

View file

@ -4,6 +4,7 @@ use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "migrations")]
#[napi_derive::napi(object)]
pub struct Model {
#[sea_orm(primary_key)]
pub id: i32,

View file

@ -4,11 +4,12 @@ use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "moderation_log")]
#[napi_derive::napi(object)]
pub struct Model {
#[sea_orm(primary_key, auto_increment = false)]
pub id: String,
#[sea_orm(column_name = "createdAt")]
pub created_at: DateTimeWithTimeZone,
pub created_at: DateTime,
#[sea_orm(column_name = "userId")]
pub user_id: String,
pub r#type: String,

View file

@ -5,6 +5,7 @@ use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "muted_note")]
#[napi_derive::napi(object)]
pub struct Model {
#[sea_orm(primary_key, auto_increment = false)]
pub id: String,

View file

@ -4,17 +4,18 @@ use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "muting")]
#[napi_derive::napi(object)]
pub struct Model {
#[sea_orm(primary_key, auto_increment = false)]
pub id: String,
#[sea_orm(column_name = "createdAt")]
pub created_at: DateTimeWithTimeZone,
pub created_at: DateTime,
#[sea_orm(column_name = "muteeId")]
pub mutee_id: String,
#[sea_orm(column_name = "muterId")]
pub muter_id: String,
#[sea_orm(column_name = "expiresAt")]
pub expires_at: Option<DateTimeWithTimeZone>,
pub expires_at: Option<DateTime>,
}
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]

View file

@ -5,11 +5,12 @@ use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "note")]
#[napi_derive::napi(object)]
pub struct Model {
#[sea_orm(primary_key, auto_increment = false)]
pub id: String,
#[sea_orm(column_name = "createdAt")]
pub created_at: DateTimeWithTimeZone,
pub created_at: DateTime,
#[sea_orm(column_name = "replyId")]
pub reply_id: Option<String>,
#[sea_orm(column_name = "renoteId")]
@ -60,7 +61,7 @@ pub struct Model {
#[sea_orm(column_name = "threadId")]
pub thread_id: Option<String>,
#[sea_orm(column_name = "updatedAt")]
pub updated_at: Option<DateTimeWithTimeZone>,
pub updated_at: Option<DateTime>,
pub lang: Option<String>,
}

View file

@ -4,6 +4,7 @@ use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "note_edit")]
#[napi_derive::napi(object)]
pub struct Model {
#[sea_orm(primary_key, auto_increment = false)]
pub id: String,
@ -15,7 +16,7 @@ pub struct Model {
#[sea_orm(column_name = "fileIds")]
pub file_ids: Vec<String>,
#[sea_orm(column_name = "updatedAt")]
pub updated_at: DateTimeWithTimeZone,
pub updated_at: DateTime,
}
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]

View file

@ -4,11 +4,12 @@ use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "note_favorite")]
#[napi_derive::napi(object)]
pub struct Model {
#[sea_orm(primary_key, auto_increment = false)]
pub id: String,
#[sea_orm(column_name = "createdAt")]
pub created_at: DateTimeWithTimeZone,
pub created_at: DateTime,
#[sea_orm(column_name = "userId")]
pub user_id: String,
#[sea_orm(column_name = "noteId")]

View file

@ -4,11 +4,12 @@ use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "note_reaction")]
#[napi_derive::napi(object)]
pub struct Model {
#[sea_orm(primary_key, auto_increment = false)]
pub id: String,
#[sea_orm(column_name = "createdAt")]
pub created_at: DateTimeWithTimeZone,
pub created_at: DateTime,
#[sea_orm(column_name = "userId")]
pub user_id: String,
#[sea_orm(column_name = "noteId")]

View file

@ -4,11 +4,12 @@ use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "note_thread_muting")]
#[napi_derive::napi(object)]
pub struct Model {
#[sea_orm(primary_key, auto_increment = false)]
pub id: String,
#[sea_orm(column_name = "createdAt")]
pub created_at: DateTimeWithTimeZone,
pub created_at: DateTime,
#[sea_orm(column_name = "userId")]
pub user_id: String,
#[sea_orm(column_name = "threadId")]

View file

@ -4,6 +4,7 @@ use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "note_unread")]
#[napi_derive::napi(object)]
pub struct Model {
#[sea_orm(primary_key, auto_increment = false)]
pub id: String,

View file

@ -4,11 +4,12 @@ use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "note_watching")]
#[napi_derive::napi(object)]
pub struct Model {
#[sea_orm(primary_key, auto_increment = false)]
pub id: String,
#[sea_orm(column_name = "createdAt")]
pub created_at: DateTimeWithTimeZone,
pub created_at: DateTime,
#[sea_orm(column_name = "userId")]
pub user_id: String,
#[sea_orm(column_name = "noteId")]

View file

@ -5,11 +5,12 @@ use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "notification")]
#[napi_derive::napi(object)]
pub struct Model {
#[sea_orm(primary_key, auto_increment = false)]
pub id: String,
#[sea_orm(column_name = "createdAt")]
pub created_at: DateTimeWithTimeZone,
pub created_at: DateTime,
#[sea_orm(column_name = "notifieeId")]
pub notifiee_id: String,
#[sea_orm(column_name = "notifierId")]

View file

@ -5,13 +5,14 @@ use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "page")]
#[napi_derive::napi(object)]
pub struct Model {
#[sea_orm(primary_key, auto_increment = false)]
pub id: String,
#[sea_orm(column_name = "createdAt")]
pub created_at: DateTimeWithTimeZone,
pub created_at: DateTime,
#[sea_orm(column_name = "updatedAt")]
pub updated_at: DateTimeWithTimeZone,
pub updated_at: DateTime,
pub title: String,
pub name: String,
pub summary: Option<String>,

View file

@ -4,11 +4,12 @@ use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "page_like")]
#[napi_derive::napi(object)]
pub struct Model {
#[sea_orm(primary_key, auto_increment = false)]
pub id: String,
#[sea_orm(column_name = "createdAt")]
pub created_at: DateTimeWithTimeZone,
pub created_at: DateTime,
#[sea_orm(column_name = "userId")]
pub user_id: String,
#[sea_orm(column_name = "pageId")]

View file

@ -4,11 +4,12 @@ use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "password_reset_request")]
#[napi_derive::napi(object)]
pub struct Model {
#[sea_orm(primary_key, auto_increment = false)]
pub id: String,
#[sea_orm(column_name = "createdAt")]
pub created_at: DateTimeWithTimeZone,
pub created_at: DateTime,
pub token: String,
#[sea_orm(column_name = "userId")]
pub user_id: String,

View file

@ -5,11 +5,12 @@ use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "poll")]
#[napi_derive::napi(object)]
pub struct Model {
#[sea_orm(column_name = "noteId", primary_key, auto_increment = false, unique)]
pub note_id: String,
#[sea_orm(column_name = "expiresAt")]
pub expires_at: Option<DateTimeWithTimeZone>,
pub expires_at: Option<DateTime>,
pub multiple: bool,
pub choices: Vec<String>,
pub votes: Vec<i32>,

View file

@ -4,11 +4,12 @@ use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "poll_vote")]
#[napi_derive::napi(object)]
pub struct Model {
#[sea_orm(primary_key, auto_increment = false)]
pub id: String,
#[sea_orm(column_name = "createdAt")]
pub created_at: DateTimeWithTimeZone,
pub created_at: DateTime,
#[sea_orm(column_name = "userId")]
pub user_id: String,
#[sea_orm(column_name = "noteId")]

View file

@ -4,11 +4,12 @@ use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "promo_note")]
#[napi_derive::napi(object)]
pub struct Model {
#[sea_orm(column_name = "noteId", primary_key, auto_increment = false, unique)]
pub note_id: String,
#[sea_orm(column_name = "expiresAt")]
pub expires_at: DateTimeWithTimeZone,
pub expires_at: DateTime,
#[sea_orm(column_name = "userId")]
pub user_id: String,
}

View file

@ -4,11 +4,12 @@ use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "promo_read")]
#[napi_derive::napi(object)]
pub struct Model {
#[sea_orm(primary_key, auto_increment = false)]
pub id: String,
#[sea_orm(column_name = "createdAt")]
pub created_at: DateTimeWithTimeZone,
pub created_at: DateTime,
#[sea_orm(column_name = "userId")]
pub user_id: String,
#[sea_orm(column_name = "noteId")]

View file

@ -4,11 +4,12 @@ use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "registration_ticket")]
#[napi_derive::napi(object)]
pub struct Model {
#[sea_orm(primary_key, auto_increment = false)]
pub id: String,
#[sea_orm(column_name = "createdAt")]
pub created_at: DateTimeWithTimeZone,
pub created_at: DateTime,
pub code: String,
}

View file

@ -4,13 +4,14 @@ use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "registry_item")]
#[napi_derive::napi(object)]
pub struct Model {
#[sea_orm(primary_key, auto_increment = false)]
pub id: String,
#[sea_orm(column_name = "createdAt")]
pub created_at: DateTimeWithTimeZone,
pub created_at: DateTime,
#[sea_orm(column_name = "updatedAt")]
pub updated_at: DateTimeWithTimeZone,
pub updated_at: DateTime,
#[sea_orm(column_name = "userId")]
pub user_id: String,
pub key: String,

View file

@ -5,6 +5,7 @@ use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "relay")]
#[napi_derive::napi(object)]
pub struct Model {
#[sea_orm(primary_key, auto_increment = false)]
pub id: String,

View file

@ -4,11 +4,12 @@ use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "renote_muting")]
#[napi_derive::napi(object)]
pub struct Model {
#[sea_orm(primary_key, auto_increment = false)]
pub id: String,
#[sea_orm(column_name = "createdAt")]
pub created_at: DateTimeWithTimeZone,
pub created_at: DateTime,
#[sea_orm(column_name = "muteeId")]
pub mutee_id: String,
#[sea_orm(column_name = "muterId")]

View file

@ -4,11 +4,12 @@ use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "reply_muting")]
#[napi_derive::napi(object)]
pub struct Model {
#[sea_orm(primary_key, auto_increment = false)]
pub id: String,
#[sea_orm(column_name = "createdAt")]
pub created_at: DateTimeWithTimeZone,
pub created_at: DateTime,
#[sea_orm(column_name = "muteeId")]
pub mutee_id: String,
#[sea_orm(column_name = "muterId")]

View file

@ -2,7 +2,8 @@
use sea_orm::entity::prelude::*;
#[derive(Debug, Clone, PartialEq, Eq, EnumIter, DeriveActiveEnum)]
#[derive(Debug, PartialEq, Eq, EnumIter, DeriveActiveEnum)]
#[napi_derive::napi]
#[sea_orm(rs_type = "String", db_type = "Enum", enum_name = "antenna_src_enum")]
pub enum AntennaSrcEnum {
#[sea_orm(string_value = "all")]
@ -18,7 +19,8 @@ pub enum AntennaSrcEnum {
#[sea_orm(string_value = "users")]
Users,
}
#[derive(Debug, Clone, PartialEq, Eq, EnumIter, DeriveActiveEnum)]
#[derive(Debug, PartialEq, Eq, EnumIter, DeriveActiveEnum)]
#[napi_derive::napi]
#[sea_orm(
rs_type = "String",
db_type = "Enum",
@ -34,7 +36,8 @@ pub enum MetaSensitivemediadetectionEnum {
#[sea_orm(string_value = "remote")]
Remote,
}
#[derive(Debug, Clone, PartialEq, Eq, EnumIter, DeriveActiveEnum)]
#[derive(Debug, PartialEq, Eq, EnumIter, DeriveActiveEnum)]
#[napi_derive::napi]
#[sea_orm(
rs_type = "String",
db_type = "Enum",
@ -52,7 +55,8 @@ pub enum MetaSensitivemediadetectionsensitivityEnum {
#[sea_orm(string_value = "veryLow")]
VeryLow,
}
#[derive(Debug, Clone, PartialEq, Eq, EnumIter, DeriveActiveEnum)]
#[derive(Debug, PartialEq, Eq, EnumIter, DeriveActiveEnum)]
#[napi_derive::napi]
#[sea_orm(
rs_type = "String",
db_type = "Enum",
@ -68,7 +72,8 @@ pub enum MutedNoteReasonEnum {
#[sea_orm(string_value = "word")]
Word,
}
#[derive(Debug, Clone, PartialEq, Eq, EnumIter, DeriveActiveEnum)]
#[derive(Debug, PartialEq, Eq, EnumIter, DeriveActiveEnum)]
#[napi_derive::napi]
#[sea_orm(
rs_type = "String",
db_type = "Enum",
@ -86,7 +91,8 @@ pub enum NoteVisibilityEnum {
#[sea_orm(string_value = "specified")]
Specified,
}
#[derive(Debug, Clone, PartialEq, Eq, EnumIter, DeriveActiveEnum)]
#[derive(Debug, PartialEq, Eq, EnumIter, DeriveActiveEnum)]
#[napi_derive::napi]
#[sea_orm(
rs_type = "String",
db_type = "Enum",
@ -118,7 +124,8 @@ pub enum NotificationTypeEnum {
#[sea_orm(string_value = "reply")]
Reply,
}
#[derive(Debug, Clone, PartialEq, Eq, EnumIter, DeriveActiveEnum)]
#[derive(Debug, PartialEq, Eq, EnumIter, DeriveActiveEnum)]
#[napi_derive::napi]
#[sea_orm(
rs_type = "String",
db_type = "Enum",
@ -132,7 +139,8 @@ pub enum PageVisibilityEnum {
#[sea_orm(string_value = "specified")]
Specified,
}
#[derive(Debug, Clone, PartialEq, Eq, EnumIter, DeriveActiveEnum)]
#[derive(Debug, PartialEq, Eq, EnumIter, DeriveActiveEnum)]
#[napi_derive::napi]
#[sea_orm(
rs_type = "String",
db_type = "Enum",
@ -148,7 +156,8 @@ pub enum PollNotevisibilityEnum {
#[sea_orm(string_value = "specified")]
Specified,
}
#[derive(Debug, Clone, PartialEq, Eq, EnumIter, DeriveActiveEnum)]
#[derive(Debug, PartialEq, Eq, EnumIter, DeriveActiveEnum)]
#[napi_derive::napi]
#[sea_orm(rs_type = "String", db_type = "Enum", enum_name = "relay_status_enum")]
pub enum RelayStatusEnum {
#[sea_orm(string_value = "accepted")]
@ -158,7 +167,8 @@ pub enum RelayStatusEnum {
#[sea_orm(string_value = "requesting")]
Requesting,
}
#[derive(Debug, Clone, PartialEq, Eq, EnumIter, DeriveActiveEnum)]
#[derive(Debug, PartialEq, Eq, EnumIter, DeriveActiveEnum)]
#[napi_derive::napi]
#[sea_orm(
rs_type = "String",
db_type = "Enum",
@ -174,7 +184,8 @@ pub enum UserEmojimodpermEnum {
#[sea_orm(string_value = "unauthorized")]
Unauthorized,
}
#[derive(Debug, Clone, PartialEq, Eq, EnumIter, DeriveActiveEnum)]
#[derive(Debug, PartialEq, Eq, EnumIter, DeriveActiveEnum)]
#[napi_derive::napi]
#[sea_orm(
rs_type = "String",
db_type = "Enum",
@ -188,7 +199,8 @@ pub enum UserProfileFfvisibilityEnum {
#[sea_orm(string_value = "public")]
Public,
}
#[derive(Debug, Clone, PartialEq, Eq, EnumIter, DeriveActiveEnum)]
#[derive(Debug, PartialEq, Eq, EnumIter, DeriveActiveEnum)]
#[napi_derive::napi]
#[sea_orm(
rs_type = "String",
db_type = "Enum",

View file

@ -4,11 +4,12 @@ use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "signin")]
#[napi_derive::napi(object)]
pub struct Model {
#[sea_orm(primary_key, auto_increment = false)]
pub id: String,
#[sea_orm(column_name = "createdAt")]
pub created_at: DateTimeWithTimeZone,
pub created_at: DateTime,
#[sea_orm(column_name = "userId")]
pub user_id: String,
pub ip: String,

View file

@ -4,11 +4,12 @@ use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "sw_subscription")]
#[napi_derive::napi(object)]
pub struct Model {
#[sea_orm(primary_key, auto_increment = false)]
pub id: String,
#[sea_orm(column_name = "createdAt")]
pub created_at: DateTimeWithTimeZone,
pub created_at: DateTime,
#[sea_orm(column_name = "userId")]
pub user_id: String,
pub endpoint: String,

View file

@ -4,11 +4,12 @@ use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "used_username")]
#[napi_derive::napi(object)]
pub struct Model {
#[sea_orm(primary_key, auto_increment = false)]
pub username: String,
#[sea_orm(column_name = "createdAt")]
pub created_at: DateTimeWithTimeZone,
pub created_at: DateTime,
}
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]

View file

@ -5,15 +5,16 @@ use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "user")]
#[napi_derive::napi(object)]
pub struct Model {
#[sea_orm(primary_key, auto_increment = false)]
pub id: String,
#[sea_orm(column_name = "createdAt")]
pub created_at: DateTimeWithTimeZone,
pub created_at: DateTime,
#[sea_orm(column_name = "updatedAt")]
pub updated_at: Option<DateTimeWithTimeZone>,
pub updated_at: Option<DateTime>,
#[sea_orm(column_name = "lastFetchedAt")]
pub last_fetched_at: Option<DateTimeWithTimeZone>,
pub last_fetched_at: Option<DateTime>,
pub username: String,
#[sea_orm(column_name = "usernameLower")]
pub username_lower: String,
@ -57,7 +58,7 @@ pub struct Model {
#[sea_orm(column_name = "followersUri")]
pub followers_uri: Option<String>,
#[sea_orm(column_name = "lastActiveDate")]
pub last_active_date: Option<DateTimeWithTimeZone>,
pub last_active_date: Option<DateTime>,
#[sea_orm(column_name = "hideOnlineStatus")]
pub hide_online_status: bool,
#[sea_orm(column_name = "isDeleted")]

View file

@ -4,11 +4,12 @@ use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "user_group")]
#[napi_derive::napi(object)]
pub struct Model {
#[sea_orm(primary_key, auto_increment = false)]
pub id: String,
#[sea_orm(column_name = "createdAt")]
pub created_at: DateTimeWithTimeZone,
pub created_at: DateTime,
pub name: String,
#[sea_orm(column_name = "userId")]
pub user_id: String,

View file

@ -4,11 +4,12 @@ use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "user_group_invitation")]
#[napi_derive::napi(object)]
pub struct Model {
#[sea_orm(primary_key, auto_increment = false)]
pub id: String,
#[sea_orm(column_name = "createdAt")]
pub created_at: DateTimeWithTimeZone,
pub created_at: DateTime,
#[sea_orm(column_name = "userId")]
pub user_id: String,
#[sea_orm(column_name = "userGroupId")]

View file

@ -4,11 +4,12 @@ use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "user_group_invite")]
#[napi_derive::napi(object)]
pub struct Model {
#[sea_orm(primary_key, auto_increment = false)]
pub id: String,
#[sea_orm(column_name = "createdAt")]
pub created_at: DateTimeWithTimeZone,
pub created_at: DateTime,
#[sea_orm(column_name = "userId")]
pub user_id: String,
#[sea_orm(column_name = "userGroupId")]

View file

@ -4,11 +4,12 @@ use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "user_group_joining")]
#[napi_derive::napi(object)]
pub struct Model {
#[sea_orm(primary_key, auto_increment = false)]
pub id: String,
#[sea_orm(column_name = "createdAt")]
pub created_at: DateTimeWithTimeZone,
pub created_at: DateTime,
#[sea_orm(column_name = "userId")]
pub user_id: String,
#[sea_orm(column_name = "userGroupId")]

View file

@ -4,11 +4,12 @@ use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "user_ip")]
#[napi_derive::napi(object)]
pub struct Model {
#[sea_orm(primary_key)]
pub id: i32,
#[sea_orm(column_name = "createdAt")]
pub created_at: DateTimeWithTimeZone,
pub created_at: DateTime,
#[sea_orm(column_name = "userId")]
pub user_id: String,
pub ip: String,

View file

@ -4,6 +4,7 @@ use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "user_keypair")]
#[napi_derive::napi(object)]
pub struct Model {
#[sea_orm(column_name = "userId", primary_key, auto_increment = false, unique)]
pub user_id: String,

View file

@ -4,11 +4,12 @@ use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "user_list")]
#[napi_derive::napi(object)]
pub struct Model {
#[sea_orm(primary_key, auto_increment = false)]
pub id: String,
#[sea_orm(column_name = "createdAt")]
pub created_at: DateTimeWithTimeZone,
pub created_at: DateTime,
#[sea_orm(column_name = "userId")]
pub user_id: String,
pub name: String,

View file

@ -4,11 +4,12 @@ use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "user_list_joining")]
#[napi_derive::napi(object)]
pub struct Model {
#[sea_orm(primary_key, auto_increment = false)]
pub id: String,
#[sea_orm(column_name = "createdAt")]
pub created_at: DateTimeWithTimeZone,
pub created_at: DateTime,
#[sea_orm(column_name = "userId")]
pub user_id: String,
#[sea_orm(column_name = "userListId")]

View file

@ -4,11 +4,12 @@ use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "user_note_pining")]
#[napi_derive::napi(object)]
pub struct Model {
#[sea_orm(primary_key, auto_increment = false)]
pub id: String,
#[sea_orm(column_name = "createdAt")]
pub created_at: DateTimeWithTimeZone,
pub created_at: DateTime,
#[sea_orm(column_name = "userId")]
pub user_id: String,
#[sea_orm(column_name = "noteId")]

View file

@ -4,11 +4,12 @@ use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "user_pending")]
#[napi_derive::napi(object)]
pub struct Model {
#[sea_orm(primary_key, auto_increment = false)]
pub id: String,
#[sea_orm(column_name = "createdAt")]
pub created_at: DateTimeWithTimeZone,
pub created_at: DateTime,
pub code: String,
pub username: String,
pub email: String,

View file

@ -6,6 +6,7 @@ use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "user_profile")]
#[napi_derive::napi(object)]
pub struct Model {
#[sea_orm(column_name = "userId", primary_key, auto_increment = false, unique)]
pub user_id: String,

View file

@ -4,6 +4,7 @@ use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "user_publickey")]
#[napi_derive::napi(object)]
pub struct Model {
#[sea_orm(column_name = "userId", primary_key, auto_increment = false, unique)]
pub user_id: String,

View file

@ -4,6 +4,7 @@ use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "user_security_key")]
#[napi_derive::napi(object)]
pub struct Model {
#[sea_orm(primary_key, auto_increment = false)]
pub id: String,
@ -12,7 +13,7 @@ pub struct Model {
#[sea_orm(column_name = "publicKey")]
pub public_key: String,
#[sea_orm(column_name = "lastUsed")]
pub last_used: DateTimeWithTimeZone,
pub last_used: DateTime,
pub name: String,
}

View file

@ -4,11 +4,12 @@ use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "webhook")]
#[napi_derive::napi(object)]
pub struct Model {
#[sea_orm(primary_key, auto_increment = false)]
pub id: String,
#[sea_orm(column_name = "createdAt")]
pub created_at: DateTimeWithTimeZone,
pub created_at: DateTime,
#[sea_orm(column_name = "userId")]
pub user_id: String,
pub name: String,
@ -17,7 +18,7 @@ pub struct Model {
pub secret: String,
pub active: bool,
#[sea_orm(column_name = "latestSentAt")]
pub latest_sent_at: Option<DateTimeWithTimeZone>,
pub latest_sent_at: Option<DateTime>,
#[sea_orm(column_name = "latestStatus")]
pub latest_status: Option<i32>,
}

View file

@ -1,4 +1,4 @@
use crate::impl_into_napi_error;
use crate::impl_napi_error_from;
#[derive(thiserror::Error, Debug, PartialEq, Eq)]
pub enum Error {
@ -12,4 +12,4 @@ pub enum Error {
NotFound,
}
impl_into_napi_error!(Error);
impl_napi_error_from!(Error);

View file

@ -1,10 +1,10 @@
#[cfg_attr(feature = "napi", napi_derive::napi(object))]
#[napi_derive::napi(object)]
pub struct Acct {
pub username: String,
pub host: Option<String>,
}
#[cfg_attr(feature = "napi", napi_derive::napi)]
#[napi_derive::napi]
pub fn string_to_acct(acct: String) -> Acct {
let split: Vec<&str> = if let Some(stripped) = acct.strip_prefix('@') {
stripped
@ -24,7 +24,7 @@ pub fn string_to_acct(acct: String) -> Acct {
}
}
#[cfg_attr(feature = "napi", napi_derive::napi)]
#[napi_derive::napi]
pub fn acct_to_string(acct: Acct) -> String {
match acct.host {
Some(host) => format!("{}@{}", acct.username, host),

View file

@ -1,26 +1,30 @@
use crate::config::server::read_server_config;
use crate::config::server::ServerConfig;
use idna;
use url::Url;
#[cfg_attr(feature = "napi", napi_derive::napi)]
pub fn get_full_ap_account(username: String, host: Option<String>) -> String {
#[napi_derive::napi]
pub fn get_full_ap_account(
server_config: ServerConfig,
username: String,
host: Option<String>,
) -> String {
if host.is_none() {
format!("{}@{}", username, extract_host(read_server_config().url))
format!("{}@{}", username, extract_host(server_config.url))
} else {
format!("{}@{}", username, to_puny(host.unwrap()))
}
}
#[cfg_attr(feature = "napi", napi_derive::napi)]
pub fn is_self_host(host: Option<String>) -> bool {
#[napi_derive::napi]
pub fn is_self_host(server_config: ServerConfig, host: Option<String>) -> bool {
if let Some(x) = host {
extract_host(read_server_config().url) == to_puny(x)
extract_host(server_config.url) == to_puny(x)
} else {
true
}
}
#[cfg_attr(feature = "napi", napi_derive::napi)]
#[napi_derive::napi]
pub fn extract_host(uri: String) -> String {
to_puny(
Url::parse(uri.as_str())
@ -31,12 +35,12 @@ pub fn extract_host(uri: String) -> String {
)
}
#[cfg_attr(feature = "napi", napi_derive::napi)]
#[napi_derive::napi]
pub fn to_puny(host: String) -> String {
idna::domain_to_ascii(&host).expect("Failed to encode the host to punycode")
}
#[cfg_attr(feature = "napi", napi_derive::napi)]
#[napi_derive::napi]
pub fn to_puny_optional(host: Option<String>) -> Option<String> {
host.map(to_puny)
}

View file

@ -1,6 +1,6 @@
use napi;
#[cfg_attr(feature = "napi", napi_derive::napi(object))]
#[napi_derive::napi(object)]
pub struct Post {
pub text: Option<String>,
pub cw: Option<String>,
@ -10,7 +10,7 @@ pub struct Post {
pub visibility: String,
}
#[cfg_attr(feature = "napi", napi_derive::napi)]
#[napi_derive::napi]
pub fn convert_to_hidden_post(original_post: Post) -> Post {
Post {
text: match original_post.text {

View file

@ -1,9 +1,9 @@
#[cfg_attr(feature = "napi", napi_derive::napi)]
#[napi_derive::napi]
pub fn sql_like_escape(src: String) -> String {
src.replace('%', r"\%").replace('_', r"\_")
}
#[cfg_attr(feature = "napi", napi_derive::napi)]
#[napi_derive::napi]
pub fn safe_for_sql(src: String) -> bool {
!src.contains([
'\0', '\x08', '\x09', '\x1a', '\n', '\r', '"', '\'', '\\', '%',

View file

@ -0,0 +1,47 @@
use sea_orm::{prelude::*, ActiveValue};
use std::sync::Mutex;
// use sea_orm::{ActiveValue, prelude::*, sea_query::OnConflict};
use crate::database::{JsDbConn, NapiDbErrExt};
use crate::model::entity::meta;
type Meta = meta::Model;
static CACHE: Mutex<Option<Meta>> = Mutex::new(None);
fn update_cache(meta: &Meta) {
let _ = CACHE.lock().map(|mut cache| *cache = Some(meta.clone()));
}
#[napi_derive::napi]
pub async fn fetch_meta(conn: &JsDbConn, invalidate_cache: bool) -> napi::Result<Meta> {
// try using cache
if !invalidate_cache {
if let Some(cache) = CACHE.lock().ok().and_then(|cache| cache.clone()) {
return Ok(cache);
}
}
// try fetching from db
let db = conn.inner();
let meta = meta::Entity::find()
.one(db)
.await
.map_err(NapiDbErrExt::into)?;
if let Some(meta) = meta {
update_cache(&meta);
return Ok(meta);
}
// create a new meta object and insert into db
let meta = meta::Entity::insert(meta::ActiveModel {
id: ActiveValue::Set("x".to_owned()),
..Default::default()
})
// FIXME handle on conflict
// .on_conflict(OnConflict::column(meta::Column::Id).do_nothing().to_owned())
// .do_nothing()
.exec_with_returning(db)
.await
.map_err(NapiDbErrExt::into)?;
update_cache(&meta);
Ok(meta)
}

View file

@ -1,5 +1,5 @@
/// Convert milliseconds to human readable string
#[cfg_attr(feature = "napi", napi_derive::napi)]
#[napi_derive::napi]
pub fn format_milliseconds(milliseconds: i32) -> String {
let mut seconds = milliseconds / 1000;
let mut minutes = seconds / 60;

View file

@ -1,18 +1,18 @@
//! ID generation utility based on [cuid2]
use basen::BASE36;
use cfg_if::cfg_if;
// use cfg_if::cfg_if;
use chrono::Utc;
use once_cell::sync::OnceCell;
use std::cmp;
use crate::impl_into_napi_error;
use crate::impl_napi_error_from;
#[derive(thiserror::Error, Debug, PartialEq, Eq)]
#[error("ID generator has not been initialized yet")]
pub struct ErrorUninitialized;
impl_into_napi_error!(ErrorUninitialized);
impl_napi_error_from!(ErrorUninitialized);
static FINGERPRINT: OnceCell<String> = OnceCell::new();
static GENERATOR: OnceCell<cuid2::CuidConstructor> = OnceCell::new();
@ -61,29 +61,29 @@ pub fn get_timestamp(id: &str) -> i64 {
}
}
cfg_if! {
if #[cfg(feature = "napi")] {
use napi_derive::napi;
// cfg_if! {
// if #[cfg(feature = "napi")] {
use napi_derive::napi;
/// Calls [init_id] inside. Must be called before [native_create_id].
#[napi]
pub fn native_init_id_generator(length: u16, fingerprint: String) {
init_id(length, &fingerprint);
}
/// Generates
#[napi]
pub fn native_create_id(date_num: i64) -> String {
create_id(date_num).unwrap()
}
#[napi]
pub fn native_get_timestamp(id: String) -> i64 {
get_timestamp(&id)
}
}
/// Calls [init_id] inside. Must be called before [native_create_id].
#[napi]
pub fn native_init_id_generator(length: u16, fingerprint: String) {
init_id(length, &fingerprint);
}
/// Generates
#[napi]
pub fn native_create_id(date_num: i64) -> String {
create_id(date_num).unwrap()
}
#[napi]
pub fn native_get_timestamp(id: String) -> i64 {
get_timestamp(&id)
}
// }
// }
#[cfg(test)]
mod unit_test {
use crate::util::id;

View file

@ -2,6 +2,7 @@ pub mod acct;
pub mod convert_host;
pub mod convert_to_hidden_post;
pub mod escape_sql;
pub mod fetch_meta;
pub mod format_milliseconds;
pub mod id;
pub mod random;

View file

@ -1,7 +1,7 @@
use rand::{distributions::Alphanumeric, thread_rng, Rng};
/// Generate random string based on [thread_rng] and [Alphanumeric].
#[cfg_attr(feature = "napi", napi_derive::napi)]
#[napi_derive::napi]
pub fn gen_string(length: u16) -> String {
thread_rng()
.sample_iter(Alphanumeric)

View file

@ -3,7 +3,7 @@ import chalk from "chalk";
import Xev from "xev";
import Logger from "@/services/logger.js";
import { envOption } from "@/config/index.js";
import { envConfig } from "@/misc/native-utils.js";
// for typeorm
import "reflect-metadata";
@ -26,14 +26,14 @@ export default async function () {
const type = cluster.isPrimary ? "(master)" : "(worker)";
process.title = `Firefish ${mode} ${type}`;
if (cluster.isPrimary || envOption.disableClustering) {
if (cluster.isPrimary || envConfig.disableClustering) {
await masterMain();
if (cluster.isPrimary) {
ev.mount();
}
}
if (cluster.isWorker || envOption.disableClustering) {
if (cluster.isWorker || envConfig.disableClustering) {
await workerMain();
}
@ -75,7 +75,7 @@ cluster.on("exit", (worker) => {
});
// Display detail of unhandled promise rejection
if (!envOption.quiet) {
if (!envConfig.quiet) {
process.on("unhandledRejection", console.dir);
}

View file

@ -10,7 +10,7 @@ import semver from "semver";
import Logger from "@/services/logger.js";
import loadConfig from "@/config/load.js";
import type { Config } from "@/config/types.js";
import { envOption } from "@/config/index.js";
import { envConfig } from "@/misc/native-utils.js";
import { showMachineInfo } from "@/misc/show-machine-info.js";
import { db, initDb } from "@/db/postgre.js";
@ -27,7 +27,7 @@ const bootLogger = logger.createSubLogger("boot", "magenta", false);
const themeColor = chalk.hex("#31748f");
function greet() {
if (!envOption.quiet) {
if (!envConfig.quiet) {
//#region Firefish logo
console.log(
themeColor(
@ -109,7 +109,7 @@ export async function masterMain() {
bootLogger.succ("Firefish initialized");
if (!envOption.disableClustering) {
if (!envConfig.disableClustering) {
await spawnWorkers(config.clusterLimits);
}
@ -120,7 +120,7 @@ export async function masterMain() {
);
if (
!envOption.noDaemons &&
!envConfig.noDaemons &&
config.clusterLimits?.web &&
config.clusterLimits?.web >= 1
) {

View file

@ -1,5 +1,2 @@
import load from "./load.js";
import { readEnvironmentConfig } from "native-utils/built/index.js";
export default load();
export const envOption = readEnvironmentConfig();

View file

@ -2,7 +2,8 @@ import type { Antenna } from "@/models/entities/antenna.js";
import type { Note } from "@/models/entities/note.js";
import type { User } from "@/models/entities/user.js";
import { Blockings, Followings, UserProfiles } from "@/models/index.js";
import { getFullApAccount, stringToAcct } from "native-utils/built/index.js";
import { getFullApAccount } from "@/misc/native-utils.js";
import { stringToAcct } from "native-utils/built/index.js";
import type { Packed } from "@/misc/schema.js";
import { Cache } from "@/misc/cache.js";
import { getWordHardMute } from "@/misc/check-word-mute.js";
@ -25,7 +26,7 @@ export async function checkHitAntenna(
if (antenna.src === "users") {
const accts = antenna.users.map((x) => {
const { username, host } = stringToAcct(x);
return getFullApAccount(username, host ?? null).toLowerCase();
return getFullApAccount(username, host).toLowerCase();
});
if (
!accts.includes(

View file

@ -1,12 +1,10 @@
import { db } from "@/db/postgre.js";
import { Meta } from "@/models/entities/meta.js";
let cache: Meta;
import type { Meta } from "native-utils/built/index.js";
import { fetchMeta } from "@/misc/native-utils.js";
export function metaToPugArgs(meta: Meta): object {
let motd = ["Loading..."];
if (meta.customMOTD.length > 0) {
motd = meta.customMOTD;
if (meta.customMotd.length > 0) {
motd = meta.customMotd;
}
let splashIconUrl = meta.iconUrl;
if (meta.customSplashIcons.length > 0) {
@ -29,44 +27,7 @@ export function metaToPugArgs(meta: Meta): object {
};
}
export async function fetchMeta(noCache = false): Promise<Meta> {
if (!noCache && cache) return cache;
export { fetchMeta } from "@/misc/native-utils.js";
return await db.transaction(async (transactionalEntityManager) => {
// New IDs are prioritized because multiple records may have been created due to past bugs.
const metas = await transactionalEntityManager.find(Meta, {
order: {
id: "DESC",
},
});
const meta = metas[0];
if (meta) {
cache = meta;
return meta;
} else {
// If fetchMeta is called at the same time when meta is empty, this part may be called at the same time, so use fail-safe upsert.
const saved = await transactionalEntityManager
.upsert(
Meta,
{
id: "x",
},
["id"],
)
.then((x) =>
transactionalEntityManager.findOneByOrFail(Meta, x.identifiers[0]),
);
cache = saved;
return saved;
}
});
}
setInterval(() => {
fetchMeta(true).then((meta) => {
cache = meta;
});
}, 1000 * 10);
// refresh cache
setInterval(() => fetchMeta(true), 1000 * 10);

View file

@ -0,0 +1,28 @@
import {
readServerConfig,
readEnvironmentConfig,
initDatabase,
fetchMeta as fetchMetaImpl,
getFullApAccount as getFullApAccountImpl,
isSelfHost as isSelfHostImpl,
} from "native-utils/built/index.js";
export const serverConfig = readServerConfig();
export const envConfig = readEnvironmentConfig();
const dbPromise = initDatabase();
type Option<T> = T | null | undefined;
export const fetchMeta = (invalidateCache = false) =>
dbPromise.then((db) => fetchMetaImpl(db, invalidateCache));
export function getFullApAccount(
username: string,
host: Option<string>,
): string {
return getFullApAccountImpl(serverConfig, username, host);
}
export function isSelfHost(host: Option<string>): boolean {
return isSelfHostImpl(serverConfig, host);
}

View file

@ -3,7 +3,8 @@ import { Emojis } from "@/models/index.js";
import type { Emoji } from "@/models/entities/emoji.js";
import type { Note } from "@/models/entities/note.js";
import { Cache } from "./cache.js";
import { isSelfHost, toPunyOptional } from "native-utils/built/index.js";
import { toPunyOptional } from "native-utils/built/index.js";
import { isSelfHost } from "@/misc/native-utils.js";
import { decodeReaction } from "./reaction-lib.js";
import config from "@/config/index.js";
import { query } from "@/prelude/url.js";

View file

@ -15,7 +15,7 @@ export class AbuseUserReport {
public id: string;
@Index()
@Column("timestamp with time zone", {
@Column("timestamp without time zone", {
comment: "The created date of the AbuseUserReport.",
})
public createdAt: Date;

View file

@ -15,12 +15,12 @@ export class AccessToken {
@PrimaryColumn(id())
public id: string;
@Column("timestamp with time zone", {
@Column("timestamp without time zone", {
comment: "The created date of the AccessToken.",
})
public createdAt: Date;
@Column("timestamp with time zone", {
@Column("timestamp without time zone", {
nullable: true,
})
public lastUsedAt: Date | null;

View file

@ -7,13 +7,13 @@ export class Ad {
public id: string;
@Index()
@Column("timestamp with time zone", {
@Column("timestamp without time zone", {
comment: "The created date of the Ad.",
})
public createdAt: Date;
@Index()
@Column("timestamp with time zone", {
@Column("timestamp without time zone", {
comment: "The expired date of the Ad.",
})
public expiresAt: Date;

View file

@ -16,7 +16,7 @@ export class AnnouncementRead {
@PrimaryColumn(id())
public id: string;
@Column("timestamp with time zone", {
@Column("timestamp without time zone", {
comment: "The created date of the AnnouncementRead.",
})
public createdAt: Date;

Some files were not shown because too many files have changed in this diff Show more