refactor (backend-rs): rewrite id generator

Co-authored-by: sup39 <dev@sup39.dev>
This commit is contained in:
naskya 2024-04-02 19:08:32 +09:00
parent 186919aac3
commit f60ff2eaf4
No known key found for this signature in database
GPG key ID: 712D413B3A9FED5C
77 changed files with 115 additions and 137 deletions

View file

@ -310,7 +310,7 @@ if (!nativeBinding) {
throw new Error(`Failed to load native binding`) throw new Error(`Failed to load native binding`)
} }
const { AntennaSrcEnum, MutedNoteReasonEnum, NoteVisibilityEnum, NotificationTypeEnum, PageVisibilityEnum, PollNotevisibilityEnum, RelayStatusEnum, UserEmojimodpermEnum, UserProfileFfvisibilityEnum, UserProfileMutingnotificationtypesEnum, nativeRandomStr, IdConvertType, convertId, nativeGetTimestamp, nativeCreateId, nativeInitIdGenerator } = nativeBinding const { AntennaSrcEnum, MutedNoteReasonEnum, NoteVisibilityEnum, NotificationTypeEnum, PageVisibilityEnum, PollNotevisibilityEnum, RelayStatusEnum, UserEmojimodpermEnum, UserProfileFfvisibilityEnum, UserProfileMutingnotificationtypesEnum, secureRndstr, IdConvertType, convertId, getTimestamp, genId, initIdGenerator } = nativeBinding
module.exports.AntennaSrcEnum = AntennaSrcEnum module.exports.AntennaSrcEnum = AntennaSrcEnum
module.exports.MutedNoteReasonEnum = MutedNoteReasonEnum module.exports.MutedNoteReasonEnum = MutedNoteReasonEnum
@ -322,9 +322,9 @@ module.exports.RelayStatusEnum = RelayStatusEnum
module.exports.UserEmojimodpermEnum = UserEmojimodpermEnum module.exports.UserEmojimodpermEnum = UserEmojimodpermEnum
module.exports.UserProfileFfvisibilityEnum = UserProfileFfvisibilityEnum module.exports.UserProfileFfvisibilityEnum = UserProfileFfvisibilityEnum
module.exports.UserProfileMutingnotificationtypesEnum = UserProfileMutingnotificationtypesEnum module.exports.UserProfileMutingnotificationtypesEnum = UserProfileMutingnotificationtypesEnum
module.exports.nativeRandomStr = nativeRandomStr module.exports.secureRndstr = secureRndstr
module.exports.IdConvertType = IdConvertType module.exports.IdConvertType = IdConvertType
module.exports.convertId = convertId module.exports.convertId = convertId
module.exports.nativeGetTimestamp = nativeGetTimestamp module.exports.getTimestamp = getTimestamp
module.exports.nativeCreateId = nativeCreateId module.exports.genId = genId
module.exports.nativeInitIdGenerator = nativeInitIdGenerator module.exports.initIdGenerator = initIdGenerator

View file

@ -2,7 +2,7 @@
use basen::BASE36; use basen::BASE36;
use cfg_if::cfg_if; use cfg_if::cfg_if;
use chrono::Utc; use chrono::NaiveDateTime;
use once_cell::sync::OnceCell; use once_cell::sync::OnceCell;
use std::cmp; use std::cmp;
@ -33,20 +33,14 @@ pub fn init_id(length: u16, fingerprint: &str) {
/// Returns Cuid2 with the length specified by [init_id]. Must be called after /// Returns Cuid2 with the length specified by [init_id]. Must be called after
/// [init_id], otherwise returns [ErrorUninitialized]. /// [init_id], otherwise returns [ErrorUninitialized].
/// The current timestamp via [chrono::Utc] is used if `date_num` is `0`. pub fn create_id(datetime: &NaiveDateTime) -> Result<String, ErrorUninitialized> {
pub fn create_id(date_num: i64) -> Result<String, ErrorUninitialized> {
match GENERATOR.get() { match GENERATOR.get() {
None => Err(ErrorUninitialized), None => Err(ErrorUninitialized),
Some(gen) => { Some(gen) => {
let date_num = if date_num > 0 { let date_num = cmp::max(0, datetime.and_utc().timestamp_millis() - TIME_2000) as u64;
date_num
} else {
Utc::now().timestamp_millis()
};
let time = cmp::max(date_num - TIME_2000, 0);
Ok(format!( Ok(format!(
"{:0>8}{}", "{:0>8}{}",
BASE36.encode_var_len(&(time as u64)), BASE36.encode_var_len(&date_num),
gen.create_id() gen.create_id()
)) ))
} }
@ -64,20 +58,26 @@ pub fn get_timestamp(id: &str) -> i64 {
cfg_if! { cfg_if! {
if #[cfg(feature = "napi")] { if #[cfg(feature = "napi")] {
use napi_derive::napi; use napi_derive::napi;
use chrono::{DateTime, Utc};
/// Calls [init_id] inside. Must be called before [native_create_id]. /// Calls [init_id] inside. Must be called before [native_create_id].
#[napi] #[napi(js_name = "initIdGenerator")]
pub fn native_init_id_generator(length: u16, fingerprint: String) { pub fn native_init_id_generator(length: u16, fingerprint: String) {
init_id(length, &fingerprint); init_id(length, &fingerprint);
} }
/// Generates /// The generated ID results in the form of `[8 chars timestamp] + [cuid2]`.
/// The minimum and maximum lengths are 16 and 24, respectively.
/// With the length of 16, namely 8 for cuid2, roughly 1427399 IDs are needed
/// in the same millisecond to reach 50% chance of collision.
///
/// Ref: https://github.com/paralleldrive/cuid2#parameterized-length
#[napi] #[napi]
pub fn native_create_id(date_num: i64) -> String { pub fn gen_id(date: Option<DateTime<Utc>>) -> String {
create_id(date_num).unwrap() create_id(&date.unwrap_or_else(|| Utc::now()).naive_utc()).unwrap()
} }
#[napi] #[napi(js_name = "getTimestamp")]
pub fn native_get_timestamp(id: String) -> i64 { pub fn native_get_timestamp(id: String) -> i64 {
get_timestamp(&id) get_timestamp(&id)
} }
@ -92,18 +92,18 @@ mod unit_test {
use std::thread; use std::thread;
#[test] #[test]
fn can_create_and_decode() { fn can_create_and_decode_id() {
assert_eq!(id::create_id(0), Err(id::ErrorUninitialized)); let now = Utc::now().naive_utc();
assert_eq!(id::create_id(&now), Err(id::ErrorUninitialized));
id::init_id(16, ""); id::init_id(16, "");
assert_eq!(id::create_id(0).unwrap().len(), 16); assert_eq!(id::create_id(&now).unwrap().len(), 16);
assert_ne!(id::create_id(0).unwrap(), id::create_id(0).unwrap()); assert_ne!(id::create_id(&now).unwrap(), id::create_id(&now).unwrap());
let id1 = thread::spawn(|| id::create_id(0).unwrap()); let id1 = thread::spawn(move || id::create_id(&now).unwrap());
let id2 = thread::spawn(|| id::create_id(0).unwrap()); let id2 = thread::spawn(move || id::create_id(&now).unwrap());
assert_ne!(id1.join().unwrap(), id2.join().unwrap()); assert_ne!(id1.join().unwrap(), id2.join().unwrap());
let now = Utc::now().timestamp_millis(); let test_id = id::create_id(&now).unwrap();
let test_id = id::create_id(now).unwrap();
let timestamp = id::get_timestamp(&test_id); let timestamp = id::get_timestamp(&test_id);
assert_eq!(now, timestamp); assert_eq!(now.and_utc().timestamp_millis(), timestamp);
} }
} }

View file

@ -10,9 +10,9 @@ pub fn gen_string(length: u16) -> String {
} }
#[cfg(feature = "napi")] #[cfg(feature = "napi")]
#[napi_derive::napi] #[napi_derive::napi(js_name = "secureRndstr")]
pub fn native_random_str(length: u16) -> String { pub fn native_random_str(length: Option<u16>) -> String {
gen_string(length) gen_string(length.unwrap_or(32))
} }
#[cfg(test)] #[cfg(test)]

View file

@ -1,11 +1,17 @@
import cluster from "node:cluster"; import cluster from "node:cluster";
import config from "@/config/index.js";
import { initDb } from "@/db/postgre.js"; import { initDb } from "@/db/postgre.js";
import { initIdGenerator } from "backend-rs";
import os from "node:os"; import os from "node:os";
/** /**
* Init worker process * Init worker process
*/ */
export async function workerMain() { export async function workerMain() {
const length = Math.min(Math.max(config.cuid?.length ?? 16, 16), 24);
const fingerprint = config.cuid?.fingerprint ?? "";
initIdGenerator(length, fingerprint);
await initDb(); await initDb();
if (!process.env.mode || process.env.mode === "web") { if (!process.env.mode || process.env.mode === "web") {

View file

@ -1,26 +1,6 @@
import config from "@/config/index.js"; import config from "@/config/index.js";
import { import { initIdGenerator } from "backend-rs";
nativeCreateId,
nativeInitIdGenerator,
nativeGetTimestamp,
} from "backend-rs";
const length = Math.min(Math.max(config.cuid?.length ?? 16, 16), 24); const length = Math.min(Math.max(config.cuid?.length ?? 16, 16), 24);
const fingerprint = config.cuid?.fingerprint ?? ""; const fingerprint = config.cuid?.fingerprint ?? "";
nativeInitIdGenerator(length, fingerprint); initIdGenerator(length, fingerprint);
/**
* The generated ID results in the form of `[8 chars timestamp] + [cuid2]`.
* The minimum and maximum lengths are 16 and 24, respectively.
* With the length of 16, namely 8 for cuid2, roughly 1427399 IDs are needed
* in the same millisecond to reach 50% chance of collision.
*
* Ref: https://github.com/paralleldrive/cuid2#parameterized-length
*/
export function genId(date?: Date): string {
return nativeCreateId(date?.getTime() ?? Date.now());
}
export function getTimestamp(id: string): number {
return nativeGetTimestamp(id);
}

View file

@ -1,5 +0,0 @@
import { nativeRandomStr } from "backend-rs";
export function secureRndstr(length = 32, _ = true): string {
return nativeRandomStr(length);
}

View file

@ -8,7 +8,7 @@ import { downloadUrl } from "@/misc/download-url.js";
import { DriveFiles, Emojis } from "@/models/index.js"; import { DriveFiles, Emojis } from "@/models/index.js";
import type { DbUserImportJobData } from "@/queue/types.js"; import type { DbUserImportJobData } from "@/queue/types.js";
import { addFile } from "@/services/drive/add-file.js"; import { addFile } from "@/services/drive/add-file.js";
import { genId } from "@/misc/gen-id.js"; import { genId } from "backend-rs";
import { db } from "@/db/postgre.js"; import { db } from "@/db/postgre.js";
import probeImageSize from "probe-image-size"; import probeImageSize from "probe-image-size";
import * as path from "path"; import * as path from "path";

View file

@ -9,7 +9,7 @@ import type Bull from "bull";
import { createImportCkPostJob } from "@/queue/index.js"; import { createImportCkPostJob } from "@/queue/index.js";
import { Notes, NoteEdits } from "@/models/index.js"; import { Notes, NoteEdits } from "@/models/index.js";
import type { Note } from "@/models/entities/note.js"; import type { Note } from "@/models/entities/note.js";
import { genId } from "@/misc/gen-id.js"; import { genId } from "backend-rs";
const logger = queueLogger.createSubLogger("import-firefish-post"); const logger = queueLogger.createSubLogger("import-firefish-post");

View file

@ -9,7 +9,7 @@ import { uploadFromUrl } from "@/services/drive/upload-from-url.js";
import type { DriveFile } from "@/models/entities/drive-file.js"; import type { DriveFile } from "@/models/entities/drive-file.js";
import { Notes, NoteEdits } from "@/models/index.js"; import { Notes, NoteEdits } from "@/models/index.js";
import type { Note } from "@/models/entities/note.js"; import type { Note } from "@/models/entities/note.js";
import { genId } from "@/misc/gen-id.js"; import { genId } from "backend-rs";
const logger = queueLogger.createSubLogger("import-masto-post"); const logger = queueLogger.createSubLogger("import-masto-post");

View file

@ -8,7 +8,7 @@ import { isSelfHost, toPuny } from "@/misc/convert-host.js";
import { Users, DriveFiles, Mutings } from "@/models/index.js"; import { Users, DriveFiles, Mutings } from "@/models/index.js";
import type { DbUserImportJobData } from "@/queue/types.js"; import type { DbUserImportJobData } from "@/queue/types.js";
import type { User } from "@/models/entities/user.js"; import type { User } from "@/models/entities/user.js";
import { genId } from "@/misc/gen-id.js"; import { genId } from "backend-rs";
import { IsNull } from "typeorm"; import { IsNull } from "typeorm";
import { inspect } from "node:util"; import { inspect } from "node:util";

View file

@ -12,7 +12,7 @@ import {
UserLists, UserLists,
UserListJoinings, UserListJoinings,
} from "@/models/index.js"; } from "@/models/index.js";
import { genId } from "@/misc/gen-id.js"; import { genId } from "backend-rs";
import type { DbUserImportJobData } from "@/queue/types.js"; import type { DbUserImportJobData } from "@/queue/types.js";
import { IsNull } from "typeorm"; import { IsNull } from "typeorm";
import { inspect } from "node:util"; import { inspect } from "node:util";

View file

@ -4,7 +4,7 @@ import type { IFlag } from "../../type.js";
import { getApIds } from "../../type.js"; import { getApIds } from "../../type.js";
import { AbuseUserReports, Users } from "@/models/index.js"; import { AbuseUserReports, Users } from "@/models/index.js";
import { In } from "typeorm"; import { In } from "typeorm";
import { genId } from "@/misc/gen-id.js"; import { genId } from "backend-rs";
export default async ( export default async (
actor: CacheableRemoteUser, actor: CacheableRemoteUser,

View file

@ -33,7 +33,7 @@ import {
getApType, getApType,
} from "../type.js"; } from "../type.js";
import type { Emoji } from "@/models/entities/emoji.js"; import type { Emoji } from "@/models/entities/emoji.js";
import { genId } from "@/misc/gen-id.js"; import { genId } from "backend-rs";
import { getApLock } from "@/misc/app-lock.js"; import { getApLock } from "@/misc/app-lock.js";
import { createMessage } from "@/services/messages/create.js"; import { createMessage } from "@/services/messages/create.js";
import { parseAudience } from "../audience.js"; import { parseAudience } from "../audience.js";

View file

@ -16,7 +16,7 @@ import type { IRemoteUser, CacheableUser } from "@/models/entities/user.js";
import { User } from "@/models/entities/user.js"; import { User } from "@/models/entities/user.js";
import type { Emoji } from "@/models/entities/emoji.js"; import type { Emoji } from "@/models/entities/emoji.js";
import { UserNotePining } from "@/models/entities/user-note-pining.js"; import { UserNotePining } from "@/models/entities/user-note-pining.js";
import { genId } from "@/misc/gen-id.js"; import { genId } from "backend-rs";
import { UserPublickey } from "@/models/entities/user-publickey.js"; import { UserPublickey } from "@/models/entities/user-publickey.js";
import { isDuplicateKeyValueError } from "@/misc/is-duplicate-key-value-error.js"; import { isDuplicateKeyValueError } from "@/misc/is-duplicate-key-value-error.js";
import { isSameOrigin, toPuny } from "@/misc/convert-host.js"; import { isSameOrigin, toPuny } from "@/misc/convert-host.js";

View file

@ -1,3 +1,3 @@
import { secureRndstr } from "@/misc/secure-rndstr.js"; import { secureRndstr } from "backend-rs";
export default () => secureRndstr(16, true); export default () => secureRndstr(16);

View file

@ -3,7 +3,7 @@ import type Koa from "koa";
import config from "@/config/index.js"; import config from "@/config/index.js";
import type { ILocalUser } from "@/models/entities/user.js"; import type { ILocalUser } from "@/models/entities/user.js";
import { Signins } from "@/models/index.js"; import { Signins } from "@/models/index.js";
import { genId } from "@/misc/gen-id.js"; import { genId } from "backend-rs";
import { publishMainStream } from "@/services/stream.js"; import { publishMainStream } from "@/services/stream.js";
export default function (ctx: Koa.Context, user: ILocalUser, redirect = false) { export default function (ctx: Koa.Context, user: ILocalUser, redirect = false) {

View file

@ -4,7 +4,7 @@ import { User } from "@/models/entities/user.js";
import { Users, UsedUsernames } from "@/models/index.js"; import { Users, UsedUsernames } from "@/models/index.js";
import { UserProfile } from "@/models/entities/user-profile.js"; import { UserProfile } from "@/models/entities/user-profile.js";
import { IsNull } from "typeorm"; import { IsNull } from "typeorm";
import { genId } from "@/misc/gen-id.js"; import { genId } from "backend-rs";
import { toPunyNullable } from "@/misc/convert-host.js"; import { toPunyNullable } from "@/misc/convert-host.js";
import { UserKeypair } from "@/models/entities/user-keypair.js"; import { UserKeypair } from "@/models/entities/user-keypair.js";
import { UsedUsername } from "@/models/entities/used-username.js"; import { UsedUsername } from "@/models/entities/used-username.js";

View file

@ -1,6 +1,6 @@
import define from "@/server/api/define.js"; import define from "@/server/api/define.js";
import { Ads } from "@/models/index.js"; import { Ads } from "@/models/index.js";
import { genId } from "@/misc/gen-id.js"; import { genId } from "backend-rs";
export const meta = { export const meta = {
tags: ["admin"], tags: ["admin"],

View file

@ -1,6 +1,6 @@
import define from "@/server/api/define.js"; import define from "@/server/api/define.js";
import { Announcements } from "@/models/index.js"; import { Announcements } from "@/models/index.js";
import { genId } from "@/misc/gen-id.js"; import { genId } from "backend-rs";
export const meta = { export const meta = {
tags: ["admin"], tags: ["admin"],

View file

@ -1,6 +1,6 @@
import define from "@/server/api/define.js"; import define from "@/server/api/define.js";
import { Emojis, DriveFiles } from "@/models/index.js"; import { Emojis, DriveFiles } from "@/models/index.js";
import { genId } from "@/misc/gen-id.js"; import { genId } from "backend-rs";
import { insertModerationLog } from "@/services/insert-moderation-log.js"; import { insertModerationLog } from "@/services/insert-moderation-log.js";
import { ApiError } from "@/server/api/error.js"; import { ApiError } from "@/server/api/error.js";
import rndstr from "rndstr"; import rndstr from "rndstr";

View file

@ -1,6 +1,6 @@
import define from "@/server/api/define.js"; import define from "@/server/api/define.js";
import { Emojis } from "@/models/index.js"; import { Emojis } from "@/models/index.js";
import { genId } from "@/misc/gen-id.js"; import { genId } from "backend-rs";
import { ApiError } from "@/server/api/error.js"; import { ApiError } from "@/server/api/error.js";
import type { DriveFile } from "@/models/entities/drive-file.js"; import type { DriveFile } from "@/models/entities/drive-file.js";
import { uploadFromUrl } from "@/services/drive/upload-from-url.js"; import { uploadFromUrl } from "@/services/drive/upload-from-url.js";

View file

@ -1,7 +1,7 @@
import rndstr from "rndstr"; import rndstr from "rndstr";
import define from "@/server/api/define.js"; import define from "@/server/api/define.js";
import { RegistrationTickets } from "@/models/index.js"; import { RegistrationTickets } from "@/models/index.js";
import { genId } from "@/misc/gen-id.js"; import { genId } from "backend-rs";
export const meta = { export const meta = {
tags: ["admin"], tags: ["admin"],

View file

@ -1,5 +1,5 @@
import define from "@/server/api/define.js"; import define from "@/server/api/define.js";
import { genId } from "@/misc/gen-id.js"; import { genId } from "backend-rs";
import { Antennas, UserLists, UserGroupJoinings } from "@/models/index.js"; import { Antennas, UserLists, UserGroupJoinings } from "@/models/index.js";
import { ApiError } from "@/server/api/error.js"; import { ApiError } from "@/server/api/error.js";
import { publishInternalEvent } from "@/services/stream.js"; import { publishInternalEvent } from "@/services/stream.js";

View file

@ -2,7 +2,7 @@ import define from "@/server/api/define.js";
import readNote from "@/services/note/read.js"; import readNote from "@/services/note/read.js";
import { Antennas, Notes } from "@/models/index.js"; import { Antennas, Notes } from "@/models/index.js";
import { redisClient } from "@/db/redis.js"; import { redisClient } from "@/db/redis.js";
import { getTimestamp } from "@/misc/gen-id.js"; import { getTimestamp } from "backend-rs";
import { makePaginationQuery } from "@/server/api/common/make-pagination-query.js"; import { makePaginationQuery } from "@/server/api/common/make-pagination-query.js";
import { generateVisibilityQuery } from "@/server/api/common/generate-visibility-query.js"; import { generateVisibilityQuery } from "@/server/api/common/generate-visibility-query.js";
import { generateMutedUserQuery } from "@/server/api/common/generate-muted-user-query.js"; import { generateMutedUserQuery } from "@/server/api/common/generate-muted-user-query.js";

View file

@ -1,8 +1,7 @@
import define from "@/server/api/define.js"; import define from "@/server/api/define.js";
import { Apps } from "@/models/index.js"; import { Apps } from "@/models/index.js";
import { genId } from "@/misc/gen-id.js"; import { genId, secureRndstr } from "backend-rs";
import { unique } from "@/prelude/array.js"; import { unique } from "@/prelude/array.js";
import { secureRndstr } from "@/misc/secure-rndstr.js";
export const meta = { export const meta = {
tags: ["app"], tags: ["app"],
@ -41,7 +40,7 @@ export default define(meta, paramDef, async (ps, user) => {
includeSecret: true, includeSecret: true,
}); });
// Generate secret // Generate secret
const secret = secureRndstr(32, true); const secret = secureRndstr(32);
// for backward compatibility // for backward compatibility
const permission = unique( const permission = unique(

View file

@ -2,8 +2,7 @@ import * as crypto from "node:crypto";
import define from "@/server/api/define.js"; import define from "@/server/api/define.js";
import { ApiError } from "@/server/api/error.js"; import { ApiError } from "@/server/api/error.js";
import { AuthSessions, AccessTokens, Apps } from "@/models/index.js"; import { AuthSessions, AccessTokens, Apps } from "@/models/index.js";
import { genId } from "@/misc/gen-id.js"; import { genId, secureRndstr } from "backend-rs";
import { secureRndstr } from "@/misc/secure-rndstr.js";
export const meta = { export const meta = {
tags: ["auth"], tags: ["auth"],
@ -38,7 +37,7 @@ export default define(meta, paramDef, async (ps, user) => {
} }
// Generate access token // Generate access token
const accessToken = secureRndstr(32, true); const accessToken = secureRndstr(32);
// Fetch exist access token // Fetch exist access token
const exist = await AccessTokens.exist({ const exist = await AccessTokens.exist({

View file

@ -3,7 +3,7 @@ import config from "@/config/index.js";
import define from "@/server/api/define.js"; import define from "@/server/api/define.js";
import { ApiError } from "@/server/api/error.js"; import { ApiError } from "@/server/api/error.js";
import { Apps, AuthSessions } from "@/models/index.js"; import { Apps, AuthSessions } from "@/models/index.js";
import { genId } from "@/misc/gen-id.js"; import { genId } from "backend-rs";
export const meta = { export const meta = {
tags: ["auth"], tags: ["auth"],

View file

@ -2,7 +2,7 @@ import define from "@/server/api/define.js";
import { ApiError } from "@/server/api/error.js"; import { ApiError } from "@/server/api/error.js";
import { Channels, DriveFiles } from "@/models/index.js"; import { Channels, DriveFiles } from "@/models/index.js";
import type { Channel } from "@/models/entities/channel.js"; import type { Channel } from "@/models/entities/channel.js";
import { genId } from "@/misc/gen-id.js"; import { genId } from "backend-rs";
export const meta = { export const meta = {
tags: ["channels"], tags: ["channels"],

View file

@ -1,7 +1,7 @@
import define from "@/server/api/define.js"; import define from "@/server/api/define.js";
import { ApiError } from "@/server/api/error.js"; import { ApiError } from "@/server/api/error.js";
import { Channels, ChannelFollowings } from "@/models/index.js"; import { Channels, ChannelFollowings } from "@/models/index.js";
import { genId } from "@/misc/gen-id.js"; import { genId } from "backend-rs";
import { publishUserEvent } from "@/services/stream.js"; import { publishUserEvent } from "@/services/stream.js";
export const meta = { export const meta = {

View file

@ -1,7 +1,7 @@
import define from "@/server/api/define.js"; import define from "@/server/api/define.js";
import { ClipNotes, Clips } from "@/models/index.js"; import { ClipNotes, Clips } from "@/models/index.js";
import { ApiError } from "@/server/api/error.js"; import { ApiError } from "@/server/api/error.js";
import { genId } from "@/misc/gen-id.js"; import { genId } from "backend-rs";
import { getNote } from "@/server/api/common/getters.js"; import { getNote } from "@/server/api/common/getters.js";
export const meta = { export const meta = {

View file

@ -1,5 +1,5 @@
import define from "@/server/api/define.js"; import define from "@/server/api/define.js";
import { genId } from "@/misc/gen-id.js"; import { genId } from "backend-rs";
import { Clips } from "@/models/index.js"; import { Clips } from "@/models/index.js";
export const meta = { export const meta = {

View file

@ -2,7 +2,7 @@ import { publishDriveStream } from "@/services/stream.js";
import define from "@/server/api/define.js"; import define from "@/server/api/define.js";
import { ApiError } from "@/server/api/error.js"; import { ApiError } from "@/server/api/error.js";
import { DriveFolders } from "@/models/index.js"; import { DriveFolders } from "@/models/index.js";
import { genId } from "@/misc/gen-id.js"; import { genId } from "backend-rs";
export const meta = { export const meta = {
tags: ["drive"], tags: ["drive"],

View file

@ -1,6 +1,6 @@
import define from "@/server/api/define.js"; import define from "@/server/api/define.js";
import { DriveFiles, GalleryPosts } from "@/models/index.js"; import { DriveFiles, GalleryPosts } from "@/models/index.js";
import { genId } from "@/server/api/../../misc/gen-id.js"; import { genId } from "backend-rs";
import { GalleryPost } from "@/models/entities/gallery-post.js"; import { GalleryPost } from "@/models/entities/gallery-post.js";
import type { DriveFile } from "@/models/entities/drive-file.js"; import type { DriveFile } from "@/models/entities/drive-file.js";
import { HOUR } from "@/const.js"; import { HOUR } from "@/const.js";

View file

@ -1,7 +1,7 @@
import define from "@/server/api/define.js"; import define from "@/server/api/define.js";
import { ApiError } from "@/server/api/error.js"; import { ApiError } from "@/server/api/error.js";
import { GalleryPosts, GalleryLikes } from "@/models/index.js"; import { GalleryPosts, GalleryLikes } from "@/models/index.js";
import { genId } from "@/misc/gen-id.js"; import { genId } from "backend-rs";
export const meta = { export const meta = {
tags: ["gallery"], tags: ["gallery"],

View file

@ -2,7 +2,7 @@ import define from "@/server/api/define.js";
import { UserProfiles, AttestationChallenges } from "@/models/index.js"; import { UserProfiles, AttestationChallenges } from "@/models/index.js";
import { promisify } from "node:util"; import { promisify } from "node:util";
import * as crypto from "node:crypto"; import * as crypto from "node:crypto";
import { genId } from "@/misc/gen-id.js"; import { genId } from "backend-rs";
import { hash } from "@/server/api/2fa.js"; import { hash } from "@/server/api/2fa.js";
import { comparePassword } from "@/misc/password.js"; import { comparePassword } from "@/misc/password.js";

View file

@ -1,6 +1,6 @@
import define from "@/server/api/define.js"; import define from "@/server/api/define.js";
import { ApiError } from "@/server/api/error.js"; import { ApiError } from "@/server/api/error.js";
import { genId } from "@/misc/gen-id.js"; import { genId } from "backend-rs";
import { AnnouncementReads, Announcements, Users } from "@/models/index.js"; import { AnnouncementReads, Announcements, Users } from "@/models/index.js";
import { publishMainStream } from "@/services/stream.js"; import { publishMainStream } from "@/services/stream.js";

View file

@ -1,7 +1,7 @@
import { publishMainStream } from "@/services/stream.js"; import { publishMainStream } from "@/services/stream.js";
import define from "@/server/api/define.js"; import define from "@/server/api/define.js";
import { RegistryItems } from "@/models/index.js"; import { RegistryItems } from "@/models/index.js";
import { genId } from "@/misc/gen-id.js"; import { genId } from "backend-rs";
export const meta = { export const meta = {
requireCredential: true, requireCredential: true,

View file

@ -1,5 +1,5 @@
import define from "@/server/api/define.js"; import define from "@/server/api/define.js";
import { genId } from "@/misc/gen-id.js"; import { genId } from "backend-rs";
import { Webhooks } from "@/models/index.js"; import { Webhooks } from "@/models/index.js";
import { publishInternalEvent } from "@/services/stream.js"; import { publishInternalEvent } from "@/services/stream.js";
import { webhookEventTypes } from "@/models/entities/webhook.js"; import { webhookEventTypes } from "@/models/entities/webhook.js";

View file

@ -1,7 +1,6 @@
import define from "@/server/api/define.js"; import define from "@/server/api/define.js";
import { AccessTokens } from "@/models/index.js"; import { AccessTokens } from "@/models/index.js";
import { genId } from "@/misc/gen-id.js"; import { genId, secureRndstr } from "backend-rs";
import { secureRndstr } from "@/misc/secure-rndstr.js";
export const meta = { export const meta = {
tags: ["auth"], tags: ["auth"],
@ -44,7 +43,7 @@ export const paramDef = {
export default define(meta, paramDef, async (ps, user) => { export default define(meta, paramDef, async (ps, user) => {
// Generate access token // Generate access token
const accessToken = secureRndstr(32, true); const accessToken = secureRndstr(32);
const now = new Date(); const now = new Date();

View file

@ -1,7 +1,7 @@
import define from "@/server/api/define.js"; import define from "@/server/api/define.js";
import { ApiError } from "@/server/api/error.js"; import { ApiError } from "@/server/api/error.js";
import { getUser } from "@/server/api/common/getters.js"; import { getUser } from "@/server/api/common/getters.js";
import { genId } from "@/misc/gen-id.js"; import { genId } from "backend-rs";
import { Mutings, NoteWatchings } from "@/models/index.js"; import { Mutings, NoteWatchings } from "@/models/index.js";
import type { Muting } from "@/models/entities/muting.js"; import type { Muting } from "@/models/entities/muting.js";
import { publishUserEvent } from "@/services/stream.js"; import { publishUserEvent } from "@/services/stream.js";

View file

@ -26,7 +26,7 @@ import { concat } from "@/prelude/array.js";
import { extractHashtags } from "@/misc/extract-hashtags.js"; import { extractHashtags } from "@/misc/extract-hashtags.js";
import { extractCustomEmojisFromMfm } from "@/misc/extract-custom-emojis-from-mfm.js"; import { extractCustomEmojisFromMfm } from "@/misc/extract-custom-emojis-from-mfm.js";
import { extractMentionedUsers } from "@/services/note/create.js"; import { extractMentionedUsers } from "@/services/note/create.js";
import { genId } from "@/misc/gen-id.js"; import { genId } from "backend-rs";
import { publishNoteStream } from "@/services/stream.js"; import { publishNoteStream } from "@/services/stream.js";
import DeliverManager from "@/remote/activitypub/deliver-manager.js"; import DeliverManager from "@/remote/activitypub/deliver-manager.js";
import { renderActivity } from "@/remote/activitypub/renderer/index.js"; import { renderActivity } from "@/remote/activitypub/renderer/index.js";

View file

@ -1,5 +1,5 @@
import { NoteFavorites } from "@/models/index.js"; import { NoteFavorites } from "@/models/index.js";
import { genId } from "@/misc/gen-id.js"; import { genId } from "backend-rs";
import define from "@/server/api/define.js"; import define from "@/server/api/define.js";
import { ApiError } from "@/server/api/error.js"; import { ApiError } from "@/server/api/error.js";
import { getNote } from "@/server/api/common/getters.js"; import { getNote } from "@/server/api/common/getters.js";

View file

@ -12,7 +12,7 @@ import {
Blockings, Blockings,
} from "@/models/index.js"; } from "@/models/index.js";
import type { IRemoteUser } from "@/models/entities/user.js"; import type { IRemoteUser } from "@/models/entities/user.js";
import { genId } from "@/misc/gen-id.js"; import { genId } from "backend-rs";
import { getNote } from "@/server/api/common/getters.js"; import { getNote } from "@/server/api/common/getters.js";
import { ApiError } from "@/server/api/error.js"; import { ApiError } from "@/server/api/error.js";
import define from "@/server/api/define.js"; import define from "@/server/api/define.js";

View file

@ -1,5 +1,5 @@
import { Notes, NoteThreadMutings } from "@/models/index.js"; import { Notes, NoteThreadMutings } from "@/models/index.js";
import { genId } from "@/misc/gen-id.js"; import { genId } from "backend-rs";
import readNote from "@/services/note/read.js"; import readNote from "@/services/note/read.js";
import define from "@/server/api/define.js"; import define from "@/server/api/define.js";
import { getNote } from "@/server/api/common/getters.js"; import { getNote } from "@/server/api/common/getters.js";

View file

@ -1,5 +1,5 @@
import { Pages, DriveFiles } from "@/models/index.js"; import { Pages, DriveFiles } from "@/models/index.js";
import { genId } from "@/misc/gen-id.js"; import { genId } from "backend-rs";
import { Page } from "@/models/entities/page.js"; import { Page } from "@/models/entities/page.js";
import define from "@/server/api/define.js"; import define from "@/server/api/define.js";
import { ApiError } from "@/server/api/error.js"; import { ApiError } from "@/server/api/error.js";

View file

@ -1,5 +1,5 @@
import { Pages, PageLikes } from "@/models/index.js"; import { Pages, PageLikes } from "@/models/index.js";
import { genId } from "@/misc/gen-id.js"; import { genId } from "backend-rs";
import define from "@/server/api/define.js"; import define from "@/server/api/define.js";
import { ApiError } from "@/server/api/error.js"; import { ApiError } from "@/server/api/error.js";

View file

@ -1,5 +1,5 @@
import { PromoReads } from "@/models/index.js"; import { PromoReads } from "@/models/index.js";
import { genId } from "@/misc/gen-id.js"; import { genId } from "backend-rs";
import define from "@/server/api/define.js"; import define from "@/server/api/define.js";
import { ApiError } from "@/server/api/error.js"; import { ApiError } from "@/server/api/error.js";
import { getNote } from "@/server/api/common/getters.js"; import { getNote } from "@/server/api/common/getters.js";

View file

@ -1,4 +1,4 @@
import { genId } from "@/misc/gen-id.js"; import { genId } from "backend-rs";
import { RenoteMutings } from "@/models/index.js"; import { RenoteMutings } from "@/models/index.js";
import { RenoteMuting } from "@/models/entities/renote-muting.js"; import { RenoteMuting } from "@/models/entities/renote-muting.js";
import define from "@/server/api/define.js"; import define from "@/server/api/define.js";

View file

@ -1,4 +1,4 @@
import { genId } from "@/misc/gen-id.js"; import { genId } from "backend-rs";
import { ReplyMutings } from "@/models/index.js"; import { ReplyMutings } from "@/models/index.js";
import { ReplyMuting } from "@/models/entities/reply-muting.js"; import { ReplyMuting } from "@/models/entities/reply-muting.js";
import define from "@/server/api/define.js"; import define from "@/server/api/define.js";

View file

@ -3,7 +3,7 @@ import { IsNull } from "typeorm";
import config from "@/config/index.js"; import config from "@/config/index.js";
import { Users, UserProfiles, PasswordResetRequests } from "@/models/index.js"; import { Users, UserProfiles, PasswordResetRequests } from "@/models/index.js";
import { sendEmail } from "@/services/send-email.js"; import { sendEmail } from "@/services/send-email.js";
import { genId } from "@/misc/gen-id.js"; import { genId } from "backend-rs";
import define from "@/server/api/define.js"; import define from "@/server/api/define.js";
import { HOUR } from "@/const.js"; import { HOUR } from "@/const.js";

View file

@ -1,5 +1,5 @@
import { fetchMeta } from "@/misc/fetch-meta.js"; import { fetchMeta } from "@/misc/fetch-meta.js";
import { genId } from "@/misc/gen-id.js"; import { genId } from "backend-rs";
import { SwSubscriptions } from "@/models/index.js"; import { SwSubscriptions } from "@/models/index.js";
import define from "@/server/api/define.js"; import define from "@/server/api/define.js";

View file

@ -1,5 +1,5 @@
import { UserGroups, UserGroupJoinings } from "@/models/index.js"; import { UserGroups, UserGroupJoinings } from "@/models/index.js";
import { genId } from "@/misc/gen-id.js"; import { genId } from "backend-rs";
import type { UserGroup } from "@/models/entities/user-group.js"; import type { UserGroup } from "@/models/entities/user-group.js";
import type { UserGroupJoining } from "@/models/entities/user-group-joining.js"; import type { UserGroupJoining } from "@/models/entities/user-group-joining.js";
import define from "@/server/api/define.js"; import define from "@/server/api/define.js";

View file

@ -1,5 +1,5 @@
import { UserGroupJoinings, UserGroupInvitations } from "@/models/index.js"; import { UserGroupJoinings, UserGroupInvitations } from "@/models/index.js";
import { genId } from "@/misc/gen-id.js"; import { genId } from "backend-rs";
import type { UserGroupJoining } from "@/models/entities/user-group-joining.js"; import type { UserGroupJoining } from "@/models/entities/user-group-joining.js";
import { ApiError } from "@/server/api/error.js"; import { ApiError } from "@/server/api/error.js";
import define from "@/server/api/define.js"; import define from "@/server/api/define.js";

View file

@ -3,7 +3,7 @@ import {
UserGroupJoinings, UserGroupJoinings,
UserGroupInvitations, UserGroupInvitations,
} from "@/models/index.js"; } from "@/models/index.js";
import { genId } from "@/misc/gen-id.js"; import { genId } from "backend-rs";
import type { UserGroupInvitation } from "@/models/entities/user-group-invitation.js"; import type { UserGroupInvitation } from "@/models/entities/user-group-invitation.js";
import { createNotification } from "@/services/create-notification.js"; import { createNotification } from "@/services/create-notification.js";
import { getUser } from "@/server/api/common/getters.js"; import { getUser } from "@/server/api/common/getters.js";

View file

@ -1,5 +1,5 @@
import { UserLists } from "@/models/index.js"; import { UserLists } from "@/models/index.js";
import { genId } from "@/misc/gen-id.js"; import { genId } from "backend-rs";
import type { UserList } from "@/models/entities/user-list.js"; import type { UserList } from "@/models/entities/user-list.js";
import define from "@/server/api/define.js"; import define from "@/server/api/define.js";

View file

@ -2,7 +2,7 @@ import * as mfm from "mfm-js";
import sanitizeHtml from "sanitize-html"; import sanitizeHtml from "sanitize-html";
import { publishAdminStream } from "@/services/stream.js"; import { publishAdminStream } from "@/services/stream.js";
import { AbuseUserReports, UserProfiles, Users } from "@/models/index.js"; import { AbuseUserReports, UserProfiles, Users } from "@/models/index.js";
import { genId } from "@/misc/gen-id.js"; import { genId } from "backend-rs";
import { sendEmail } from "@/services/send-email.js"; import { sendEmail } from "@/services/send-email.js";
import { fetchMeta } from "@/misc/fetch-meta.js"; import { fetchMeta } from "@/misc/fetch-meta.js";
import { getUser } from "@/server/api/common/getters.js"; import { getUser } from "@/server/api/common/getters.js";

View file

@ -10,7 +10,7 @@ import {
AttestationChallenges, AttestationChallenges,
} from "@/models/index.js"; } from "@/models/index.js";
import type { ILocalUser } from "@/models/entities/user.js"; import type { ILocalUser } from "@/models/entities/user.js";
import { genId } from "@/misc/gen-id.js"; import { genId } from "backend-rs";
import { import {
comparePassword, comparePassword,
hashPassword, hashPassword,

View file

@ -6,7 +6,7 @@ import { Users, RegistrationTickets, UserPendings } from "@/models/index.js";
import { signup } from "@/server/api/common/signup.js"; import { signup } from "@/server/api/common/signup.js";
import config from "@/config/index.js"; import config from "@/config/index.js";
import { sendEmail } from "@/services/send-email.js"; import { sendEmail } from "@/services/send-email.js";
import { genId } from "@/misc/gen-id.js"; import { genId } from "backend-rs";
import { validateEmailForAccount } from "@/services/validate-email-for-account.js"; import { validateEmailForAccount } from "@/services/validate-email-for-account.js";
import { hashPassword } from "@/misc/password.js"; import { hashPassword } from "@/misc/password.js";
import { inspect } from "node:util"; import { inspect } from "node:util";

View file

@ -1,6 +1,6 @@
import type { Antenna } from "@/models/entities/antenna.js"; import type { Antenna } from "@/models/entities/antenna.js";
import type { Note } from "@/models/entities/note.js"; import type { Note } from "@/models/entities/note.js";
import { getTimestamp } from "@/misc/gen-id.js"; import { getTimestamp } from "backend-rs";
import { redisClient } from "@/db/redis.js"; import { redisClient } from "@/db/redis.js";
import { publishAntennaStream } from "@/services/stream.js"; import { publishAntennaStream } from "@/services/stream.js";
import type { User } from "@/models/entities/user.js"; import type { User } from "@/models/entities/user.js";

View file

@ -15,7 +15,7 @@ import {
UserListJoinings, UserListJoinings,
UserLists, UserLists,
} from "@/models/index.js"; } from "@/models/index.js";
import { genId } from "@/misc/gen-id.js"; import { genId } from "backend-rs";
import { getActiveWebhooks } from "@/misc/webhook-cache.js"; import { getActiveWebhooks } from "@/misc/webhook-cache.js";
import { webhookDeliver } from "@/queue/index.js"; import { webhookDeliver } from "@/queue/index.js";

View file

@ -8,7 +8,7 @@ import {
Users, Users,
Followings, Followings,
} from "@/models/index.js"; } from "@/models/index.js";
import { genId } from "@/misc/gen-id.js"; import { genId } from "backend-rs";
import type { User } from "@/models/entities/user.js"; import type { User } from "@/models/entities/user.js";
import type { Notification } from "@/models/entities/notification.js"; import type { Notification } from "@/models/entities/notification.js";
import { sendEmailNotification } from "./send-email-notification.js"; import { sendEmailNotification } from "./send-email-notification.js";

View file

@ -4,7 +4,7 @@ import { genRsaKeyPair } from "@/misc/gen-key-pair.js";
import { User } from "@/models/entities/user.js"; import { User } from "@/models/entities/user.js";
import { UserProfile } from "@/models/entities/user-profile.js"; import { UserProfile } from "@/models/entities/user-profile.js";
import { IsNull } from "typeorm"; import { IsNull } from "typeorm";
import { genId } from "@/misc/gen-id.js"; import { genId } from "backend-rs";
import { UserKeypair } from "@/models/entities/user-keypair.js"; import { UserKeypair } from "@/models/entities/user-keypair.js";
import { UsedUsername } from "@/models/entities/used-username.js"; import { UsedUsername } from "@/models/entities/used-username.js";
import { db } from "@/db/postgre.js"; import { db } from "@/db/postgre.js";

View file

@ -17,7 +17,7 @@ import {
} from "@/models/index.js"; } from "@/models/index.js";
import { DriveFile } from "@/models/entities/drive-file.js"; import { DriveFile } from "@/models/entities/drive-file.js";
import type { IRemoteUser, User } from "@/models/entities/user.js"; import type { IRemoteUser, User } from "@/models/entities/user.js";
import { genId } from "@/misc/gen-id.js"; import { genId } from "backend-rs";
import { isDuplicateKeyValueError } from "@/misc/is-duplicate-key-value-error.js"; import { isDuplicateKeyValueError } from "@/misc/is-duplicate-key-value-error.js";
import { FILE_TYPE_BROWSERSAFE } from "@/const.js"; import { FILE_TYPE_BROWSERSAFE } from "@/const.js";
import { IdentifiableError } from "@/misc/identifiable-error.js"; import { IdentifiableError } from "@/misc/identifiable-error.js";

View file

@ -17,7 +17,7 @@ import {
Instances, Instances,
UserProfiles, UserProfiles,
} from "@/models/index.js"; } from "@/models/index.js";
import { genId } from "@/misc/gen-id.js"; import { genId } from "backend-rs";
import { createNotification } from "@/services/create-notification.js"; import { createNotification } from "@/services/create-notification.js";
import { isDuplicateKeyValueError } from "@/misc/is-duplicate-key-value-error.js"; import { isDuplicateKeyValueError } from "@/misc/is-duplicate-key-value-error.js";
import type { Packed } from "@/misc/schema.js"; import type { Packed } from "@/misc/schema.js";

View file

@ -4,7 +4,7 @@ import renderFollow from "@/remote/activitypub/renderer/follow.js";
import { deliver } from "@/queue/index.js"; import { deliver } from "@/queue/index.js";
import type { User } from "@/models/entities/user.js"; import type { User } from "@/models/entities/user.js";
import { Blockings, FollowRequests, Users } from "@/models/index.js"; import { Blockings, FollowRequests, Users } from "@/models/index.js";
import { genId } from "@/misc/gen-id.js"; import { genId } from "backend-rs";
import { createNotification } from "@/services/create-notification.js"; import { createNotification } from "@/services/create-notification.js";
import config from "@/config/index.js"; import config from "@/config/index.js";

View file

@ -7,7 +7,7 @@ import type { User } from "@/models/entities/user.js";
import type { Note } from "@/models/entities/note.js"; import type { Note } from "@/models/entities/note.js";
import { Notes, UserNotePinings, Users } from "@/models/index.js"; import { Notes, UserNotePinings, Users } from "@/models/index.js";
import type { UserNotePining } from "@/models/entities/user-note-pining.js"; import type { UserNotePining } from "@/models/entities/user-note-pining.js";
import { genId } from "@/misc/gen-id.js"; import { genId } from "backend-rs";
import { deliverToFollowers } from "@/remote/activitypub/deliver-manager.js"; import { deliverToFollowers } from "@/remote/activitypub/deliver-manager.js";
import { deliverToRelays } from "@/services/relay.js"; import { deliverToRelays } from "@/services/relay.js";

View file

@ -1,5 +1,5 @@
import { ModerationLogs } from "@/models/index.js"; import { ModerationLogs } from "@/models/index.js";
import { genId } from "@/misc/gen-id.js"; import { genId } from "backend-rs";
import type { User } from "@/models/entities/user.js"; import type { User } from "@/models/entities/user.js";
export async function insertModerationLog( export async function insertModerationLog(

View file

@ -7,7 +7,7 @@ import {
Mutings, Mutings,
Users, Users,
} from "@/models/index.js"; } from "@/models/index.js";
import { genId } from "@/misc/gen-id.js"; import { genId } from "backend-rs";
import type { MessagingMessage } from "@/models/entities/messaging-message.js"; import type { MessagingMessage } from "@/models/entities/messaging-message.js";
import { import {
publishMessagingStream, publishMessagingStream,

View file

@ -37,7 +37,7 @@ import type { DriveFile } from "@/models/entities/drive-file.js";
import type { App } from "@/models/entities/app.js"; import type { App } from "@/models/entities/app.js";
import { Not, In } from "typeorm"; import { Not, In } from "typeorm";
import type { User, ILocalUser, IRemoteUser } from "@/models/entities/user.js"; import type { User, ILocalUser, IRemoteUser } from "@/models/entities/user.js";
import { genId } from "@/misc/gen-id.js"; import { genId } from "backend-rs";
import { activeUsersChart } from "@/services/chart/index.js"; import { activeUsersChart } from "@/services/chart/index.js";
import type { IPoll } from "@/models/entities/poll.js"; import type { IPoll } from "@/models/entities/poll.js";
import { Poll } from "@/models/entities/poll.js"; import { Poll } from "@/models/entities/poll.js";

View file

@ -3,7 +3,7 @@ import type { CacheableUser } from "@/models/entities/user.js";
import type { Note } from "@/models/entities/note.js"; import type { Note } from "@/models/entities/note.js";
import { PollVotes, NoteWatchings, Polls, Blockings } from "@/models/index.js"; import { PollVotes, NoteWatchings, Polls, Blockings } from "@/models/index.js";
import { Not } from "typeorm"; import { Not } from "typeorm";
import { genId } from "@/misc/gen-id.js"; import { genId } from "backend-rs";
import { createNotification } from "@/services/create-notification.js"; import { createNotification } from "@/services/create-notification.js";
export default async function ( export default async function (

View file

@ -14,7 +14,7 @@ import {
Blockings, Blockings,
} from "@/models/index.js"; } from "@/models/index.js";
import { IsNull, Not } from "typeorm"; import { IsNull, Not } from "typeorm";
import { genId } from "@/misc/gen-id.js"; import { genId } from "backend-rs";
import { createNotification } from "@/services/create-notification.js"; import { createNotification } from "@/services/create-notification.js";
import deleteReaction from "./delete.js"; import deleteReaction from "./delete.js";
import { isDuplicateKeyValueError } from "@/misc/is-duplicate-key-value-error.js"; import { isDuplicateKeyValueError } from "@/misc/is-duplicate-key-value-error.js";

View file

@ -2,7 +2,7 @@ import type { Note } from "@/models/entities/note.js";
import { publishMainStream } from "@/services/stream.js"; import { publishMainStream } from "@/services/stream.js";
import type { User } from "@/models/entities/user.js"; import type { User } from "@/models/entities/user.js";
import { Mutings, NoteThreadMutings, NoteUnreads } from "@/models/index.js"; import { Mutings, NoteThreadMutings, NoteUnreads } from "@/models/index.js";
import { genId } from "@/misc/gen-id.js"; import { genId } from "backend-rs";
export async function insertNoteUnread( export async function insertNoteUnread(
userId: User["id"], userId: User["id"],

View file

@ -1,7 +1,7 @@
import type { User } from "@/models/entities/user.js"; import type { User } from "@/models/entities/user.js";
import type { Note } from "@/models/entities/note.js"; import type { Note } from "@/models/entities/note.js";
import { NoteWatchings } from "@/models/index.js"; import { NoteWatchings } from "@/models/index.js";
import { genId } from "@/misc/gen-id.js"; import { genId } from "backend-rs";
import type { NoteWatching } from "@/models/entities/note-watching.js"; import type { NoteWatching } from "@/models/entities/note-watching.js";
export default async (me: User["id"], note: Note) => { export default async (me: User["id"], note: Note) => {

View file

@ -3,7 +3,7 @@ import {
MAX_LENGTH_INSTANCE, MAX_LENGTH_INSTANCE,
} from "@/models/entities/instance.js"; } from "@/models/entities/instance.js";
import { Instances } from "@/models/index.js"; import { Instances } from "@/models/index.js";
import { genId } from "@/misc/gen-id.js"; import { genId } from "backend-rs";
import { toPuny } from "@/misc/convert-host.js"; import { toPuny } from "@/misc/convert-host.js";
import { Cache } from "@/misc/cache.js"; import { Cache } from "@/misc/cache.js";
import Logger from "@/services/logger.js"; import Logger from "@/services/logger.js";

View file

@ -8,7 +8,7 @@ import renderUndo from "@/remote/activitypub/renderer/undo.js";
import { deliver } from "@/queue/index.js"; import { deliver } from "@/queue/index.js";
import type { ILocalUser, User } from "@/models/entities/user.js"; import type { ILocalUser, User } from "@/models/entities/user.js";
import { Users, Relays } from "@/models/index.js"; import { Users, Relays } from "@/models/index.js";
import { genId } from "@/misc/gen-id.js"; import { genId } from "backend-rs";
import { Cache } from "@/misc/cache.js"; import { Cache } from "@/misc/cache.js";
import type { Relay } from "@/models/entities/relay.js"; import type { Relay } from "@/models/entities/relay.js";
import { createSystemUser } from "@/services/create-system-user.js"; import { createSystemUser } from "@/services/create-system-user.js";

View file

@ -1,6 +1,6 @@
import type { User } from "@/models/entities/user.js"; import type { User } from "@/models/entities/user.js";
import { Hashtags, Users } from "@/models/index.js"; import { Hashtags, Users } from "@/models/index.js";
import { genId } from "@/misc/gen-id.js"; import { genId } from "backend-rs";
import type { Hashtag } from "@/models/entities/hashtag.js"; import type { Hashtag } from "@/models/entities/hashtag.js";
import { normalizeForSearch } from "@/misc/normalize-for-search.js"; import { normalizeForSearch } from "@/misc/normalize-for-search.js";

View file

@ -3,7 +3,7 @@ import type { User } from "@/models/entities/user.js";
import type { UserList } from "@/models/entities/user-list.js"; import type { UserList } from "@/models/entities/user-list.js";
import { UserListJoinings, Users } from "@/models/index.js"; import { UserListJoinings, Users } from "@/models/index.js";
import type { UserListJoining } from "@/models/entities/user-list-joining.js"; import type { UserListJoining } from "@/models/entities/user-list-joining.js";
import { genId } from "@/misc/gen-id.js"; import { genId } from "backend-rs";
import { fetchProxyAccount } from "@/misc/fetch-proxy-account.js"; import { fetchProxyAccount } from "@/misc/fetch-proxy-account.js";
import createFollowing from "@/services/following/create.js"; import createFollowing from "@/services/following/create.js";