diff --git a/packages/backend-rs/index.d.ts b/packages/backend-rs/index.d.ts index fca4394501..c0f0406e74 100644 --- a/packages/backend-rs/index.d.ts +++ b/packages/backend-rs/index.d.ts @@ -3,6 +3,21 @@ /* auto-generated by NAPI-RS */ +export const SECOND: number +export const MINUTE: number +export const HOUR: number +export const DAY: number +export const USER_ONLINE_THRESHOLD: number +export const USER_ACTIVE_THRESHOLD: number +/** + * List of file types allowed to be viewed directly in the browser + * Anything not included here will be responded as application/octet-stream + * SVG is not allowed because it generates XSS <- we need to fix this and later allow it to be viewed directly + * https://github.com/sindresorhus/file-type/blob/main/supported.js + * https://github.com/sindresorhus/file-type/blob/main/core.js + * https://developer.mozilla.org/en-US/docs/Web/Media/Formats/Containers + */ +export const FILE_TYPE_BROWSERSAFE: string[] export interface EnvConfig { onlyQueue: boolean onlyServer: boolean @@ -160,8 +175,8 @@ export interface Config { reservedUsernames?: Array maxUserSignups?: number isManagedHosting?: boolean - maxNoteLength?: number - maxCaptionLength?: number + maxNoteLength: number + maxCaptionLength: number deepl?: DeepLConfig libreTranslate?: LibreTranslateConfig email?: EmailConfig diff --git a/packages/backend-rs/index.js b/packages/backend-rs/index.js index 430e799430..1c3a2f4195 100644 --- a/packages/backend-rs/index.js +++ b/packages/backend-rs/index.js @@ -310,8 +310,15 @@ if (!nativeBinding) { throw new Error(`Failed to load native binding`) } -const { loadEnv, loadConfig, stringToAcct, acctToString, addNoteToAntenna, isBlockedServer, isSilencedServer, isAllowedServer, checkWordMute, getFullApAccount, isSelfHost, isSameOrigin, extractHost, toPuny, isUnicodeEmoji, sqlLikeEscape, safeForSql, formatMilliseconds, getNoteSummary, toMastodonId, fromMastodonId, fetchMeta, metaToPugArgs, nyaify, hashPassword, verifyPassword, isOldPasswordAlgorithm, decodeReaction, countReactions, toDbReaction, removeOldAttestationChallenges, AntennaSrcEnum, DriveFileUsageHintEnum, MutedNoteReasonEnum, NoteVisibilityEnum, NotificationTypeEnum, PageVisibilityEnum, PollNotevisibilityEnum, RelayStatusEnum, UserEmojimodpermEnum, UserProfileFfvisibilityEnum, UserProfileMutingnotificationtypesEnum, initializeRustLogger, watchNote, unwatchNote, ChatEvent, publishToChatStream, getTimestamp, genId, genIdAt, secureRndstr } = nativeBinding +const { SECOND, MINUTE, HOUR, DAY, USER_ONLINE_THRESHOLD, USER_ACTIVE_THRESHOLD, FILE_TYPE_BROWSERSAFE, loadEnv, loadConfig, stringToAcct, acctToString, addNoteToAntenna, isBlockedServer, isSilencedServer, isAllowedServer, checkWordMute, getFullApAccount, isSelfHost, isSameOrigin, extractHost, toPuny, isUnicodeEmoji, sqlLikeEscape, safeForSql, formatMilliseconds, getNoteSummary, toMastodonId, fromMastodonId, fetchMeta, metaToPugArgs, nyaify, hashPassword, verifyPassword, isOldPasswordAlgorithm, decodeReaction, countReactions, toDbReaction, removeOldAttestationChallenges, AntennaSrcEnum, DriveFileUsageHintEnum, MutedNoteReasonEnum, NoteVisibilityEnum, NotificationTypeEnum, PageVisibilityEnum, PollNotevisibilityEnum, RelayStatusEnum, UserEmojimodpermEnum, UserProfileFfvisibilityEnum, UserProfileMutingnotificationtypesEnum, initializeRustLogger, watchNote, unwatchNote, ChatEvent, publishToChatStream, getTimestamp, genId, genIdAt, secureRndstr } = nativeBinding +module.exports.SECOND = SECOND +module.exports.MINUTE = MINUTE +module.exports.HOUR = HOUR +module.exports.DAY = DAY +module.exports.USER_ONLINE_THRESHOLD = USER_ONLINE_THRESHOLD +module.exports.USER_ACTIVE_THRESHOLD = USER_ACTIVE_THRESHOLD +module.exports.FILE_TYPE_BROWSERSAFE = FILE_TYPE_BROWSERSAFE module.exports.loadEnv = loadEnv module.exports.loadConfig = loadConfig module.exports.stringToAcct = stringToAcct diff --git a/packages/backend-rs/src/config/constant.rs b/packages/backend-rs/src/config/constant.rs new file mode 100644 index 0000000000..46fe189aca --- /dev/null +++ b/packages/backend-rs/src/config/constant.rs @@ -0,0 +1,67 @@ +#[crate::export] +pub const SECOND: i32 = 1000; +#[crate::export] +pub const MINUTE: i32 = 60 * SECOND; +#[crate::export] +pub const HOUR: i32 = 60 * MINUTE; +#[crate::export] +pub const DAY: i32 = 24 * HOUR; + +#[crate::export] +pub const USER_ONLINE_THRESHOLD: i32 = 10 * MINUTE; +#[crate::export] +pub const USER_ACTIVE_THRESHOLD: i32 = 3 * DAY; + +/// List of file types allowed to be viewed directly in the browser +/// Anything not included here will be responded as application/octet-stream +/// SVG is not allowed because it generates XSS <- we need to fix this and later allow it to be viewed directly +/// https://github.com/sindresorhus/file-type/blob/main/supported.js +/// https://github.com/sindresorhus/file-type/blob/main/core.js +/// https://developer.mozilla.org/en-US/docs/Web/Media/Formats/Containers +#[crate::export] +pub const FILE_TYPE_BROWSERSAFE: [&str; 41] = [ + // Images + "image/png", + "image/gif", // TODO: deprecated, but still used by old posts, new gifs should be converted to webp in the future + "image/jpeg", + "image/webp", // TODO: make this the default image format + "image/apng", + "image/bmp", + "image/tiff", + "image/x-icon", + "image/avif", // not as good supported now, but its good to introduce initial support for the future + // OggS + "audio/opus", + "video/ogg", + "audio/ogg", + "application/ogg", + // ISO/IEC base media file format + "video/quicktime", + "video/mp4", // TODO: we need to check for av1 later + "video/vnd.avi", // also av1 + "audio/mp4", + "video/x-m4v", + "audio/x-m4a", + "video/3gpp", + "video/3gpp2", + "video/3gp2", + "audio/3gpp", + "audio/3gpp2", + "audio/3gp2", + "video/mpeg", + "audio/mpeg", + "video/webm", + "audio/webm", + "audio/aac", + "audio/x-flac", + "audio/flac", + "audio/vnd.wave", + "audio/mod", + "audio/x-mod", + "audio/s3m", + "audio/x-s3m", + "audio/xm", + "audio/x-xm", + "audio/it", + "audio/x-it", +]; diff --git a/packages/backend-rs/src/config/mod.rs b/packages/backend-rs/src/config/mod.rs index 6155f15e54..1bc5eaeb7e 100644 --- a/packages/backend-rs/src/config/mod.rs +++ b/packages/backend-rs/src/config/mod.rs @@ -1,4 +1,5 @@ pub use server::CONFIG; +pub mod constant; pub mod environment; pub mod server; diff --git a/packages/backend-rs/src/config/server.rs b/packages/backend-rs/src/config/server.rs index 3cba6722cd..6bc5a0a0eb 100644 --- a/packages/backend-rs/src/config/server.rs +++ b/packages/backend-rs/src/config/server.rs @@ -200,8 +200,10 @@ pub struct Config { pub inbox_job_per_sec: Option, pub deliver_job_max_attempts: Option, pub inbox_job_max_attempts: Option, + /// deprecated pub log_level: Option>, + pub max_log_level: Option, pub syslog: Option, pub proxy_remote_files: Option, @@ -210,8 +212,8 @@ pub struct Config { pub reserved_usernames: Option>, pub max_user_signups: Option, pub is_managed_hosting: Option, - pub max_note_length: Option, - pub max_caption_length: Option, + pub max_note_length: u32, + pub max_caption_length: u32, pub deepl: Option, pub libre_translate: Option, pub email: Option, @@ -359,8 +361,8 @@ fn load_config() -> Config { reserved_usernames: server_config.reserved_usernames, max_user_signups: server_config.max_user_signups, is_managed_hosting: server_config.is_managed_hosting, - max_note_length: server_config.max_note_length, - max_caption_length: server_config.max_caption_length, + max_note_length: server_config.max_note_length.unwrap_or(3000), + max_caption_length: server_config.max_caption_length.unwrap_or(1500), deepl: server_config.deepl, libre_translate: server_config.libre_translate, email: server_config.email, diff --git a/packages/backend/src/const.ts b/packages/backend/src/const.ts deleted file mode 100644 index 2c52e2b009..0000000000 --- a/packages/backend/src/const.ts +++ /dev/null @@ -1,83 +0,0 @@ -import { config } from "@/config.js"; -import { - DB_MAX_IMAGE_COMMENT_LENGTH, - DB_MAX_NOTE_TEXT_LENGTH, -} from "@/misc/hard-limits.js"; - -export const MAX_NOTE_TEXT_LENGTH = Math.min( - config.maxNoteLength ?? 3000, - DB_MAX_NOTE_TEXT_LENGTH, -); -export const MAX_CAPTION_TEXT_LENGTH = Math.min( - config.maxCaptionLength ?? 1500, - DB_MAX_IMAGE_COMMENT_LENGTH, -); - -export const SECOND = 1000; -export const MINUTE = 60 * SECOND; -export const HOUR = 60 * MINUTE; -export const DAY = 24 * HOUR; - -export const USER_ONLINE_THRESHOLD = 10 * MINUTE; -export const USER_ACTIVE_THRESHOLD = 3 * DAY; - -// List of file types allowed to be viewed directly in the browser -// Anything not included here will be responded as application/octet-stream -// SVG is not allowed because it generates XSS <- we need to fix this and later allow it to be viewed directly -export const FILE_TYPE_BROWSERSAFE = [ - // Images - "image/png", - "image/gif", // TODO: deprecated, but still used by old notes, new gifs should be converted to webp in the future - "image/jpeg", - "image/webp", // TODO: make this the default image format - "image/apng", - "image/bmp", - "image/tiff", - "image/x-icon", - "image/avif", // not as good supported now, but its good to introduce initial support for the future - - // OggS - "audio/opus", - "video/ogg", - "audio/ogg", - "application/ogg", - - // ISO/IEC base media file format - "video/quicktime", - "video/mp4", // TODO: we need to check for av1 later - "video/vnd.avi", // also av1 - "audio/mp4", - "video/x-m4v", - "audio/x-m4a", - "video/3gpp", - "video/3gpp2", - "video/3gp2", - "audio/3gpp", - "audio/3gpp2", - "audio/3gp2", - - "video/mpeg", - "audio/mpeg", - - "video/webm", - "audio/webm", - - "audio/aac", - "audio/x-flac", - "audio/flac", - "audio/vnd.wave", - - "audio/mod", - "audio/x-mod", - "audio/s3m", - "audio/x-s3m", - "audio/xm", - "audio/x-xm", - "audio/it", - "audio/x-it", -]; -/* -https://github.com/sindresorhus/file-type/blob/main/supported.js -https://github.com/sindresorhus/file-type/blob/main/core.js -https://developer.mozilla.org/en-US/docs/Web/Media/Formats/Containers -*/ diff --git a/packages/backend/src/misc/emoji-meta.ts b/packages/backend/src/misc/emoji-meta.ts index 539a034817..f970658f8e 100644 --- a/packages/backend/src/misc/emoji-meta.ts +++ b/packages/backend/src/misc/emoji-meta.ts @@ -1,7 +1,7 @@ import probeImageSize from "probe-image-size"; import { Mutex } from "redis-semaphore"; -import { FILE_TYPE_BROWSERSAFE } from "@/const.js"; +import { FILE_TYPE_BROWSERSAFE } from "backend-rs"; import Logger from "@/services/logger.js"; import { Cache } from "./cache.js"; import { redisClient } from "@/db/redis.js"; diff --git a/packages/backend/src/misc/hard-limits.ts b/packages/backend/src/misc/hard-limits.ts deleted file mode 100644 index 5ce3e0ac9a..0000000000 --- a/packages/backend/src/misc/hard-limits.ts +++ /dev/null @@ -1,18 +0,0 @@ -// If you change DB_* values, you must also change the DB schema. - -/** - * Maximum note text length that can be stored in DB. - * Surrogate pairs count as one - * - * NOTE: this can hypothetically be pushed further - * (up to 250000000), but will likely cause truncations - * and incompatibilities with other servers, - * as well as potential performance issues. - */ -export const DB_MAX_NOTE_TEXT_LENGTH = 100000; - -/** - * Maximum image description length that can be stored in DB. - * Surrogate pairs count as one - */ -export const DB_MAX_IMAGE_COMMENT_LENGTH = 8192; diff --git a/packages/backend/src/misc/is-mime-image.ts b/packages/backend/src/misc/is-mime-image.ts index a8ba62ec20..83fdae442e 100644 --- a/packages/backend/src/misc/is-mime-image.ts +++ b/packages/backend/src/misc/is-mime-image.ts @@ -1,4 +1,4 @@ -import { FILE_TYPE_BROWSERSAFE } from "@/const.js"; +import { FILE_TYPE_BROWSERSAFE } from "backend-rs"; const dictionary = { "safe-file": FILE_TYPE_BROWSERSAFE, diff --git a/packages/backend/src/misc/skipped-instances.ts b/packages/backend/src/misc/skipped-instances.ts index 0c87a524f6..1d2ed1702e 100644 --- a/packages/backend/src/misc/skipped-instances.ts +++ b/packages/backend/src/misc/skipped-instances.ts @@ -2,7 +2,7 @@ import { Brackets } from "typeorm"; import { isBlockedServer } from "backend-rs"; import { Instances } from "@/models/index.js"; import type { Instance } from "@/models/entities/instance.js"; -import { DAY } from "@/const.js"; +import { DAY } from "backend-rs"; // Threshold from last contact after which an instance will be considered // "dead" and should no longer get activities delivered to it. diff --git a/packages/backend/src/models/entities/drive-file.ts b/packages/backend/src/models/entities/drive-file.ts index 81f564115f..c81d5d7622 100644 --- a/packages/backend/src/models/entities/drive-file.ts +++ b/packages/backend/src/models/entities/drive-file.ts @@ -13,7 +13,6 @@ import { id } from "../id.js"; import { Note } from "./note.js"; import { User } from "./user.js"; import { DriveFolder } from "./drive-folder.js"; -import { DB_MAX_IMAGE_COMMENT_LENGTH } from "@/misc/hard-limits.js"; import { NoteFile } from "./note-file.js"; export type DriveFileUsageHint = "userAvatar" | "userBanner" | null; @@ -73,7 +72,7 @@ export class DriveFile { @Index() // USING pgroonga pgroonga_varchar_full_text_search_ops_v2 @Column("varchar", { - length: DB_MAX_IMAGE_COMMENT_LENGTH, + length: 8192, nullable: true, comment: "The comment of the DriveFile.", }) diff --git a/packages/backend/src/models/repositories/user.ts b/packages/backend/src/models/repositories/user.ts index 040106b410..a5a8771645 100644 --- a/packages/backend/src/models/repositories/user.ts +++ b/packages/backend/src/models/repositories/user.ts @@ -7,7 +7,7 @@ import type { Packed } from "@/misc/schema.js"; import type { Promiseable } from "@/prelude/await-all.js"; import { awaitAll } from "@/prelude/await-all.js"; import { populateEmojis } from "@/misc/populate-emojis.js"; -import { USER_ACTIVE_THRESHOLD, USER_ONLINE_THRESHOLD } from "@/const.js"; +import { USER_ACTIVE_THRESHOLD, USER_ONLINE_THRESHOLD } from "backend-rs"; import { Cache } from "@/misc/cache.js"; import { db } from "@/db/postgre.js"; import { isActor, getApId } from "@/remote/activitypub/type.js"; diff --git a/packages/backend/src/remote/activitypub/models/image.ts b/packages/backend/src/remote/activitypub/models/image.ts index 0858f48e7b..5fb261488f 100644 --- a/packages/backend/src/remote/activitypub/models/image.ts +++ b/packages/backend/src/remote/activitypub/models/image.ts @@ -9,7 +9,7 @@ import type { } from "@/models/entities/drive-file.js"; import { DriveFiles } from "@/models/index.js"; import { truncate } from "@/misc/truncate.js"; -import { DB_MAX_IMAGE_COMMENT_LENGTH } from "@/misc/hard-limits.js"; +import { config } from "@/config.js"; /** * create an Image. @@ -44,7 +44,7 @@ export async function createImage( uri: image.url, sensitive: image.sensitive, isLink: !instance.cacheRemoteFiles, - comment: truncate(image.name, DB_MAX_IMAGE_COMMENT_LENGTH), + comment: truncate(image.name, config.maxCaptionLength), usageHint: usage, }); diff --git a/packages/backend/src/remote/activitypub/models/note.ts b/packages/backend/src/remote/activitypub/models/note.ts index 7f0951246e..a7be3e9846 100644 --- a/packages/backend/src/remote/activitypub/models/note.ts +++ b/packages/backend/src/remote/activitypub/models/note.ts @@ -44,7 +44,7 @@ import { publishNoteStream } from "@/services/stream.js"; import { extractHashtags } from "@/misc/extract-hashtags.js"; import { UserProfiles } from "@/models/index.js"; import { In } from "typeorm"; -import { DB_MAX_IMAGE_COMMENT_LENGTH } from "@/misc/hard-limits.js"; +import { config } from "@/config.js"; import { truncate } from "@/misc/truncate.js"; import { type Size, getEmojiSize } from "@/misc/emoji-meta.js"; import { langmap } from "@/misc/langmap.js"; @@ -622,7 +622,7 @@ export async function updateNote(value: string | IObject, resolver?: Resolver) { const file = await resolveImage(actor, x, null); const update: Partial = {}; - const altText = truncate(x.name, DB_MAX_IMAGE_COMMENT_LENGTH); + const altText = truncate(x.name, config.maxCaptionLength); if (file.comment !== altText) { update.comment = altText; } diff --git a/packages/backend/src/server/api/endpoints/admin/meta.ts b/packages/backend/src/server/api/endpoints/admin/meta.ts index ecfed950d3..9e41e58c0a 100644 --- a/packages/backend/src/server/api/endpoints/admin/meta.ts +++ b/packages/backend/src/server/api/endpoints/admin/meta.ts @@ -1,6 +1,5 @@ import { config } from "@/config.js"; import { fetchMeta } from "backend-rs"; -import { MAX_NOTE_TEXT_LENGTH, MAX_CAPTION_TEXT_LENGTH } from "@/const.js"; import define from "@/server/api/define.js"; export const meta = { @@ -506,8 +505,8 @@ export default define(meta, paramDef, async () => { iconUrl: instance.iconUrl, backgroundImageUrl: instance.backgroundImageUrl, logoImageUrl: instance.logoImageUrl, - maxNoteTextLength: MAX_NOTE_TEXT_LENGTH, // 後方互換性のため - maxCaptionTextLength: MAX_CAPTION_TEXT_LENGTH, + maxNoteTextLength: config.maxNoteLength, // for backward compatibility + maxCaptionTextLength: config.maxCaptionLength, defaultLightTheme: instance.defaultLightTheme, defaultDarkTheme: instance.defaultDarkTheme, enableEmail: instance.enableEmail, diff --git a/packages/backend/src/server/api/endpoints/ap/get.ts b/packages/backend/src/server/api/endpoints/ap/get.ts index 5159ce3b4a..72baadb676 100644 --- a/packages/backend/src/server/api/endpoints/ap/get.ts +++ b/packages/backend/src/server/api/endpoints/ap/get.ts @@ -1,6 +1,6 @@ import define from "@/server/api/define.js"; import Resolver from "@/remote/activitypub/resolver.js"; -import { HOUR } from "@/const.js"; +import { HOUR } from "backend-rs"; export const meta = { tags: ["federation"], diff --git a/packages/backend/src/server/api/endpoints/ap/show.ts b/packages/backend/src/server/api/endpoints/ap/show.ts index 56307311b2..a24654b2dd 100644 --- a/packages/backend/src/server/api/endpoints/ap/show.ts +++ b/packages/backend/src/server/api/endpoints/ap/show.ts @@ -4,13 +4,12 @@ import { createNote } from "@/remote/activitypub/models/note.js"; import DbResolver from "@/remote/activitypub/db-resolver.js"; import Resolver from "@/remote/activitypub/resolver.js"; import { ApiError } from "@/server/api/error.js"; -import { extractHost, isBlockedServer } from "backend-rs"; +import { MINUTE, extractHost, isBlockedServer } from "backend-rs"; import { Users, Notes } from "@/models/index.js"; import type { Note } from "@/models/entities/note.js"; import type { CacheableLocalUser, User } from "@/models/entities/user.js"; import { isActor, isPost, getApId } from "@/remote/activitypub/type.js"; import type { SchemaType } from "@/misc/schema.js"; -import { MINUTE } from "@/const.js"; import { updateQuestion } from "@/remote/activitypub/models/question.js"; import { populatePoll } from "@/models/repositories/note.js"; import { redisClient } from "@/db/redis.js"; diff --git a/packages/backend/src/server/api/endpoints/blocking/create.ts b/packages/backend/src/server/api/endpoints/blocking/create.ts index 50154dd6cc..85ac239f35 100644 --- a/packages/backend/src/server/api/endpoints/blocking/create.ts +++ b/packages/backend/src/server/api/endpoints/blocking/create.ts @@ -3,7 +3,7 @@ import define from "@/server/api/define.js"; import { ApiError } from "@/server/api/error.js"; import { getUser } from "@/server/api/common/getters.js"; import { Blockings, NoteWatchings, Users } from "@/models/index.js"; -import { HOUR } from "@/const.js"; +import { HOUR } from "backend-rs"; export const meta = { tags: ["account"], diff --git a/packages/backend/src/server/api/endpoints/blocking/delete.ts b/packages/backend/src/server/api/endpoints/blocking/delete.ts index addf4bbd19..ce1a717d13 100644 --- a/packages/backend/src/server/api/endpoints/blocking/delete.ts +++ b/packages/backend/src/server/api/endpoints/blocking/delete.ts @@ -3,7 +3,7 @@ import define from "@/server/api/define.js"; import { ApiError } from "@/server/api/error.js"; import { getUser } from "@/server/api/common/getters.js"; import { Blockings, Users } from "@/models/index.js"; -import { HOUR } from "@/const.js"; +import { HOUR } from "backend-rs"; export const meta = { tags: ["account"], diff --git a/packages/backend/src/server/api/endpoints/compatibility/custom-emojis.ts b/packages/backend/src/server/api/endpoints/compatibility/custom-emojis.ts index f6c5573af7..2ab190ed0b 100644 --- a/packages/backend/src/server/api/endpoints/compatibility/custom-emojis.ts +++ b/packages/backend/src/server/api/endpoints/compatibility/custom-emojis.ts @@ -1,7 +1,7 @@ import { Emojis } from "@/models/index.js"; import type { Emoji } from "@/models/entities/emoji.js"; import { IsNull, In } from "typeorm"; -import { FILE_TYPE_BROWSERSAFE } from "@/const.js"; +import { FILE_TYPE_BROWSERSAFE } from "backend-rs"; import define from "@/server/api/define.js"; export const meta = { diff --git a/packages/backend/src/server/api/endpoints/drive/files/create.ts b/packages/backend/src/server/api/endpoints/drive/files/create.ts index 44e388a9bd..5b2a70bb94 100644 --- a/packages/backend/src/server/api/endpoints/drive/files/create.ts +++ b/packages/backend/src/server/api/endpoints/drive/files/create.ts @@ -1,9 +1,8 @@ import { addFile } from "@/services/drive/add-file.js"; import { DriveFiles } from "@/models/index.js"; -import { DB_MAX_IMAGE_COMMENT_LENGTH } from "@/misc/hard-limits.js"; +import { config } from "@/config.js"; import { IdentifiableError } from "@/misc/identifiable-error.js"; -import { fetchMeta } from "backend-rs"; -import { MINUTE } from "@/const.js"; +import { MINUTE, fetchMeta } from "backend-rs"; import define from "@/server/api/define.js"; import { apiLogger } from "@/server/api/logger.js"; import { ApiError } from "@/server/api/error.js"; @@ -68,7 +67,7 @@ export const paramDef = { comment: { type: "string", nullable: true, - maxLength: DB_MAX_IMAGE_COMMENT_LENGTH, + maxLength: config.maxCaptionLength, default: null, }, isSensitive: { type: "boolean", default: false }, diff --git a/packages/backend/src/server/api/endpoints/drive/files/update.ts b/packages/backend/src/server/api/endpoints/drive/files/update.ts index bde81e007e..4d9567a838 100644 --- a/packages/backend/src/server/api/endpoints/drive/files/update.ts +++ b/packages/backend/src/server/api/endpoints/drive/files/update.ts @@ -1,6 +1,6 @@ import { publishDriveStream } from "@/services/stream.js"; -import { DriveFiles, DriveFolders, Users } from "@/models/index.js"; -import { DB_MAX_IMAGE_COMMENT_LENGTH } from "@/misc/hard-limits.js"; +import { DriveFiles, DriveFolders } from "@/models/index.js"; +import { config } from "@/config.js"; import define from "@/server/api/define.js"; import { ApiError } from "@/server/api/error.js"; @@ -57,7 +57,7 @@ export const paramDef = { comment: { type: "string", nullable: true, - maxLength: DB_MAX_IMAGE_COMMENT_LENGTH, + maxLength: config.maxCaptionLength, }, }, required: ["fileId"], diff --git a/packages/backend/src/server/api/endpoints/drive/files/upload-from-url.ts b/packages/backend/src/server/api/endpoints/drive/files/upload-from-url.ts index cdfcb03089..fea6bf8a3a 100644 --- a/packages/backend/src/server/api/endpoints/drive/files/upload-from-url.ts +++ b/packages/backend/src/server/api/endpoints/drive/files/upload-from-url.ts @@ -2,7 +2,7 @@ import { uploadFromUrl } from "@/services/drive/upload-from-url.js"; import define from "@/server/api/define.js"; import { DriveFiles } from "@/models/index.js"; import { publishMainStream } from "@/services/stream.js"; -import { HOUR } from "@/const.js"; +import { HOUR } from "backend-rs"; export const meta = { tags: ["drive"], diff --git a/packages/backend/src/server/api/endpoints/export-custom-emojis.ts b/packages/backend/src/server/api/endpoints/export-custom-emojis.ts index ca013314e1..8ff6afa320 100644 --- a/packages/backend/src/server/api/endpoints/export-custom-emojis.ts +++ b/packages/backend/src/server/api/endpoints/export-custom-emojis.ts @@ -1,6 +1,6 @@ import { createExportCustomEmojisJob } from "@/queue/index.js"; import define from "@/server/api/define.js"; -import { HOUR } from "@/const.js"; +import { HOUR } from "backend-rs"; export const meta = { secure: true, diff --git a/packages/backend/src/server/api/endpoints/following/create.ts b/packages/backend/src/server/api/endpoints/following/create.ts index f6e341ad73..956dc14f6f 100644 --- a/packages/backend/src/server/api/endpoints/following/create.ts +++ b/packages/backend/src/server/api/endpoints/following/create.ts @@ -4,7 +4,7 @@ import { ApiError } from "@/server/api/error.js"; import { getUser } from "@/server/api/common/getters.js"; import { Followings, Users } from "@/models/index.js"; import { IdentifiableError } from "@/misc/identifiable-error.js"; -import { HOUR } from "@/const.js"; +import { HOUR } from "backend-rs"; export const meta = { tags: ["following", "users"], diff --git a/packages/backend/src/server/api/endpoints/following/delete.ts b/packages/backend/src/server/api/endpoints/following/delete.ts index 3ef031eb20..740ef5fd93 100644 --- a/packages/backend/src/server/api/endpoints/following/delete.ts +++ b/packages/backend/src/server/api/endpoints/following/delete.ts @@ -3,7 +3,7 @@ import define from "@/server/api/define.js"; import { ApiError } from "@/server/api/error.js"; import { getUser } from "@/server/api/common/getters.js"; import { Followings, Users } from "@/models/index.js"; -import { HOUR } from "@/const.js"; +import { HOUR } from "backend-rs"; export const meta = { tags: ["following", "users"], diff --git a/packages/backend/src/server/api/endpoints/following/invalidate.ts b/packages/backend/src/server/api/endpoints/following/invalidate.ts index 7559062c0f..682e7d963b 100644 --- a/packages/backend/src/server/api/endpoints/following/invalidate.ts +++ b/packages/backend/src/server/api/endpoints/following/invalidate.ts @@ -3,7 +3,7 @@ import define from "@/server/api/define.js"; import { ApiError } from "@/server/api/error.js"; import { getUser } from "@/server/api/common/getters.js"; import { Followings, Users } from "@/models/index.js"; -import { HOUR } from "@/const.js"; +import { HOUR } from "backend-rs"; export const meta = { tags: ["following", "users"], diff --git a/packages/backend/src/server/api/endpoints/gallery/posts/create.ts b/packages/backend/src/server/api/endpoints/gallery/posts/create.ts index 7cf1d9f7c0..01c772bc3c 100644 --- a/packages/backend/src/server/api/endpoints/gallery/posts/create.ts +++ b/packages/backend/src/server/api/endpoints/gallery/posts/create.ts @@ -1,9 +1,8 @@ import define from "@/server/api/define.js"; import { DriveFiles, GalleryPosts } from "@/models/index.js"; -import { genId } from "backend-rs"; +import { HOUR, genId } from "backend-rs"; import { GalleryPost } from "@/models/entities/gallery-post.js"; import type { DriveFile } from "@/models/entities/drive-file.js"; -import { HOUR } from "@/const.js"; export const meta = { tags: ["gallery"], diff --git a/packages/backend/src/server/api/endpoints/gallery/posts/update.ts b/packages/backend/src/server/api/endpoints/gallery/posts/update.ts index 16c629706c..a8a3d46890 100644 --- a/packages/backend/src/server/api/endpoints/gallery/posts/update.ts +++ b/packages/backend/src/server/api/endpoints/gallery/posts/update.ts @@ -1,7 +1,7 @@ import define from "@/server/api/define.js"; import { DriveFiles, GalleryPosts } from "@/models/index.js"; import type { DriveFile } from "@/models/entities/drive-file.js"; -import { HOUR } from "@/const.js"; +import { HOUR } from "backend-rs"; export const meta = { tags: ["gallery"], diff --git a/packages/backend/src/server/api/endpoints/get-online-users-count.ts b/packages/backend/src/server/api/endpoints/get-online-users-count.ts index 633e75335a..d6cfa14ece 100644 --- a/packages/backend/src/server/api/endpoints/get-online-users-count.ts +++ b/packages/backend/src/server/api/endpoints/get-online-users-count.ts @@ -1,5 +1,5 @@ import { MoreThan } from "typeorm"; -import { USER_ONLINE_THRESHOLD } from "@/const.js"; +import { USER_ONLINE_THRESHOLD } from "backend-rs"; import { Users } from "@/models/index.js"; import define from "@/server/api/define.js"; diff --git a/packages/backend/src/server/api/endpoints/i/export-blocking.ts b/packages/backend/src/server/api/endpoints/i/export-blocking.ts index 30e74ab2f5..68c875aa00 100644 --- a/packages/backend/src/server/api/endpoints/i/export-blocking.ts +++ b/packages/backend/src/server/api/endpoints/i/export-blocking.ts @@ -1,6 +1,6 @@ import define from "@/server/api/define.js"; import { createExportBlockingJob } from "@/queue/index.js"; -import { HOUR } from "@/const.js"; +import { HOUR } from "backend-rs"; export const meta = { secure: true, diff --git a/packages/backend/src/server/api/endpoints/i/export-following.ts b/packages/backend/src/server/api/endpoints/i/export-following.ts index 07d2997a18..5bce16f0ef 100644 --- a/packages/backend/src/server/api/endpoints/i/export-following.ts +++ b/packages/backend/src/server/api/endpoints/i/export-following.ts @@ -1,6 +1,6 @@ import define from "@/server/api/define.js"; import { createExportFollowingJob } from "@/queue/index.js"; -import { HOUR } from "@/const.js"; +import { HOUR } from "backend-rs"; export const meta = { secure: true, diff --git a/packages/backend/src/server/api/endpoints/i/export-mute.ts b/packages/backend/src/server/api/endpoints/i/export-mute.ts index 7d22a073e6..1b1fcf7241 100644 --- a/packages/backend/src/server/api/endpoints/i/export-mute.ts +++ b/packages/backend/src/server/api/endpoints/i/export-mute.ts @@ -1,6 +1,6 @@ import define from "@/server/api/define.js"; import { createExportMuteJob } from "@/queue/index.js"; -import { HOUR } from "@/const.js"; +import { HOUR } from "backend-rs"; export const meta = { secure: true, diff --git a/packages/backend/src/server/api/endpoints/i/export-notes.ts b/packages/backend/src/server/api/endpoints/i/export-notes.ts index f167bb83cb..9984c7656b 100644 --- a/packages/backend/src/server/api/endpoints/i/export-notes.ts +++ b/packages/backend/src/server/api/endpoints/i/export-notes.ts @@ -1,6 +1,6 @@ import define from "@/server/api/define.js"; import { createExportNotesJob } from "@/queue/index.js"; -import { DAY } from "@/const.js"; +import { DAY } from "backend-rs"; export const meta = { secure: true, diff --git a/packages/backend/src/server/api/endpoints/i/export-user-lists.ts b/packages/backend/src/server/api/endpoints/i/export-user-lists.ts index b68d889dcd..e3b30d2d98 100644 --- a/packages/backend/src/server/api/endpoints/i/export-user-lists.ts +++ b/packages/backend/src/server/api/endpoints/i/export-user-lists.ts @@ -1,6 +1,6 @@ import define from "@/server/api/define.js"; import { createExportUserListsJob } from "@/queue/index.js"; -import { MINUTE } from "@/const.js"; +import { MINUTE } from "backend-rs"; export const meta = { secure: true, diff --git a/packages/backend/src/server/api/endpoints/i/import-blocking.ts b/packages/backend/src/server/api/endpoints/i/import-blocking.ts index 58314aced3..b7cb6e6518 100644 --- a/packages/backend/src/server/api/endpoints/i/import-blocking.ts +++ b/packages/backend/src/server/api/endpoints/i/import-blocking.ts @@ -2,7 +2,7 @@ import define from "@/server/api/define.js"; import { createImportBlockingJob } from "@/queue/index.js"; import { ApiError } from "@/server/api/error.js"; import { DriveFiles } from "@/models/index.js"; -import { HOUR } from "@/const.js"; +import { HOUR } from "backend-rs"; export const meta = { secure: true, diff --git a/packages/backend/src/server/api/endpoints/i/import-following.ts b/packages/backend/src/server/api/endpoints/i/import-following.ts index b7c475698c..8c20ff3591 100644 --- a/packages/backend/src/server/api/endpoints/i/import-following.ts +++ b/packages/backend/src/server/api/endpoints/i/import-following.ts @@ -2,7 +2,7 @@ import define from "@/server/api/define.js"; import { createImportFollowingJob } from "@/queue/index.js"; import { ApiError } from "@/server/api/error.js"; import { DriveFiles } from "@/models/index.js"; -import { HOUR } from "@/const.js"; +import { HOUR } from "backend-rs"; export const meta = { secure: true, diff --git a/packages/backend/src/server/api/endpoints/i/import-muting.ts b/packages/backend/src/server/api/endpoints/i/import-muting.ts index 494fb0d420..5ff4c94a29 100644 --- a/packages/backend/src/server/api/endpoints/i/import-muting.ts +++ b/packages/backend/src/server/api/endpoints/i/import-muting.ts @@ -2,7 +2,7 @@ import define from "@/server/api/define.js"; import { createImportMutingJob } from "@/queue/index.js"; import { ApiError } from "@/server/api/error.js"; import { DriveFiles } from "@/models/index.js"; -import { HOUR } from "@/const.js"; +import { HOUR } from "backend-rs"; export const meta = { secure: true, diff --git a/packages/backend/src/server/api/endpoints/i/import-posts.ts b/packages/backend/src/server/api/endpoints/i/import-posts.ts index 225306ebc5..c81b443608 100644 --- a/packages/backend/src/server/api/endpoints/i/import-posts.ts +++ b/packages/backend/src/server/api/endpoints/i/import-posts.ts @@ -2,7 +2,7 @@ import define from "@/server/api/define.js"; import { createImportPostsJob } from "@/queue/index.js"; import { ApiError } from "@/server/api/error.js"; import { DriveFiles } from "@/models/index.js"; -import { DAY } from "@/const.js"; +import { DAY } from "backend-rs"; import { fetchMeta } from "backend-rs"; export const meta = { diff --git a/packages/backend/src/server/api/endpoints/i/import-user-lists.ts b/packages/backend/src/server/api/endpoints/i/import-user-lists.ts index ed82a96054..03aa14ac2b 100644 --- a/packages/backend/src/server/api/endpoints/i/import-user-lists.ts +++ b/packages/backend/src/server/api/endpoints/i/import-user-lists.ts @@ -2,7 +2,7 @@ import define from "@/server/api/define.js"; import { createImportUserListsJob } from "@/queue/index.js"; import { ApiError } from "@/server/api/error.js"; import { DriveFiles } from "@/models/index.js"; -import { HOUR } from "@/const.js"; +import { HOUR } from "backend-rs"; export const meta = { secure: true, diff --git a/packages/backend/src/server/api/endpoints/i/known-as.ts b/packages/backend/src/server/api/endpoints/i/known-as.ts index 9eaeedb39f..1411d9418a 100644 --- a/packages/backend/src/server/api/endpoints/i/known-as.ts +++ b/packages/backend/src/server/api/endpoints/i/known-as.ts @@ -4,7 +4,7 @@ import { resolveUser } from "@/remote/resolve-user.js"; import acceptAllFollowRequests from "@/services/following/requests/accept-all.js"; import { publishToFollowers } from "@/services/i/update.js"; import { publishMainStream } from "@/services/stream.js"; -import { DAY } from "@/const.js"; +import { DAY } from "backend-rs"; import { apiLogger } from "@/server/api/logger.js"; import define from "@/server/api/define.js"; import { ApiError } from "@/server/api/error.js"; diff --git a/packages/backend/src/server/api/endpoints/i/move.ts b/packages/backend/src/server/api/endpoints/i/move.ts index 381bb1dea9..ef6d0c9b35 100644 --- a/packages/backend/src/server/api/endpoints/i/move.ts +++ b/packages/backend/src/server/api/endpoints/i/move.ts @@ -1,6 +1,6 @@ import type { User } from "@/models/entities/user.js"; import { resolveUser } from "@/remote/resolve-user.js"; -import { DAY } from "@/const.js"; +import { DAY } from "backend-rs"; import DeliverManager from "@/remote/activitypub/deliver-manager.js"; import { renderActivity } from "@/remote/activitypub/renderer/index.js"; import define from "@/server/api/define.js"; diff --git a/packages/backend/src/server/api/endpoints/i/update-email.ts b/packages/backend/src/server/api/endpoints/i/update-email.ts index 185d1c8dc9..393a358545 100644 --- a/packages/backend/src/server/api/endpoints/i/update-email.ts +++ b/packages/backend/src/server/api/endpoints/i/update-email.ts @@ -6,8 +6,7 @@ import { Users, UserProfiles } from "@/models/index.js"; import { sendEmail } from "@/services/send-email.js"; import { ApiError } from "@/server/api/error.js"; import { validateEmailForAccount } from "@/services/validate-email-for-account.js"; -import { HOUR } from "@/const.js"; -import { verifyPassword } from "backend-rs"; +import { HOUR, verifyPassword } from "backend-rs"; export const meta = { requireCredential: true, diff --git a/packages/backend/src/server/api/endpoints/messaging/messages/delete.ts b/packages/backend/src/server/api/endpoints/messaging/messages/delete.ts index 76691dd34d..1b9734c85c 100644 --- a/packages/backend/src/server/api/endpoints/messaging/messages/delete.ts +++ b/packages/backend/src/server/api/endpoints/messaging/messages/delete.ts @@ -2,7 +2,7 @@ import define from "@/server/api/define.js"; import { ApiError } from "@/server/api/error.js"; import { MessagingMessages } from "@/models/index.js"; import { deleteMessage } from "@/services/messages/delete.js"; -import { SECOND, HOUR } from "@/const.js"; +import { SECOND, HOUR } from "backend-rs"; export const meta = { tags: ["messaging"], diff --git a/packages/backend/src/server/api/endpoints/meta.ts b/packages/backend/src/server/api/endpoints/meta.ts index f35ae9cc6b..d4a4172426 100644 --- a/packages/backend/src/server/api/endpoints/meta.ts +++ b/packages/backend/src/server/api/endpoints/meta.ts @@ -3,7 +3,6 @@ import { IsNull, MoreThan } from "typeorm"; import { config } from "@/config.js"; import { fetchMeta } from "backend-rs"; import { Ads, Emojis, Users } from "@/models/index.js"; -import { MAX_NOTE_TEXT_LENGTH, MAX_CAPTION_TEXT_LENGTH } from "@/const.js"; import define from "@/server/api/define.js"; export const meta = { @@ -464,8 +463,8 @@ export default define(meta, paramDef, async (ps, me) => { iconUrl: instance.iconUrl, backgroundImageUrl: instance.backgroundImageUrl, logoImageUrl: instance.logoImageUrl, - maxNoteTextLength: MAX_NOTE_TEXT_LENGTH, // 後方互換性のため - maxCaptionTextLength: MAX_CAPTION_TEXT_LENGTH, + maxNoteTextLength: config.maxNoteLength, // for backward compatibility + maxCaptionTextLength: config.maxCaptionLength, emojis: instance.privateMode && !me ? [] : await Emojis.packMany(emojis), // クライアントの手間を減らすためあらかじめJSONに変換しておく defaultLightTheme: instance.defaultLightTheme diff --git a/packages/backend/src/server/api/endpoints/notes/create.ts b/packages/backend/src/server/api/endpoints/notes/create.ts index c2302f4c8d..eb4d9ca5a2 100644 --- a/packages/backend/src/server/api/endpoints/notes/create.ts +++ b/packages/backend/src/server/api/endpoints/notes/create.ts @@ -11,11 +11,11 @@ import { import type { DriveFile } from "@/models/entities/drive-file.js"; import type { Note } from "@/models/entities/note.js"; import type { Channel } from "@/models/entities/channel.js"; -import { MAX_NOTE_TEXT_LENGTH } from "@/const.js"; +import { config } from "@/config.js"; import { noteVisibilities } from "@/types.js"; import { ApiError } from "@/server/api/error.js"; import define from "@/server/api/define.js"; -import { HOUR } from "@/const.js"; +import { HOUR } from "backend-rs"; import { getNote } from "@/server/api/common/getters.js"; import { langmap } from "@/misc/langmap.js"; @@ -108,13 +108,13 @@ export const paramDef = { format: "misskey:id", }, }, - text: { type: "string", maxLength: MAX_NOTE_TEXT_LENGTH, nullable: true }, + text: { type: "string", maxLength: config.maxNoteLength, nullable: true }, lang: { type: "string", enum: Object.keys(langmap), nullable: true, }, - cw: { type: "string", nullable: true, maxLength: MAX_NOTE_TEXT_LENGTH }, + cw: { type: "string", nullable: true, maxLength: config.maxNoteLength }, localOnly: { type: "boolean", default: false }, noExtractMentions: { type: "boolean", default: false }, noExtractHashtags: { type: "boolean", default: false }, @@ -164,7 +164,7 @@ export const paramDef = { text: { type: "string", minLength: 1, - maxLength: MAX_NOTE_TEXT_LENGTH, + maxLength: config.maxNoteLength, nullable: false, }, }, diff --git a/packages/backend/src/server/api/endpoints/notes/delete.ts b/packages/backend/src/server/api/endpoints/notes/delete.ts index 54aad1ebad..b5a77af094 100644 --- a/packages/backend/src/server/api/endpoints/notes/delete.ts +++ b/packages/backend/src/server/api/endpoints/notes/delete.ts @@ -3,7 +3,7 @@ import { Users } from "@/models/index.js"; import define from "@/server/api/define.js"; import { getNote } from "@/server/api/common/getters.js"; import { ApiError } from "@/server/api/error.js"; -import { SECOND, HOUR } from "@/const.js"; +import { SECOND, HOUR } from "backend-rs"; export const meta = { tags: ["notes"], diff --git a/packages/backend/src/server/api/endpoints/notes/edit.ts b/packages/backend/src/server/api/endpoints/notes/edit.ts index 60d5258ce9..238c01420d 100644 --- a/packages/backend/src/server/api/endpoints/notes/edit.ts +++ b/packages/backend/src/server/api/endpoints/notes/edit.ts @@ -14,11 +14,11 @@ import { import type { DriveFile } from "@/models/entities/drive-file.js"; import type { IMentionedRemoteUsers, Note } from "@/models/entities/note.js"; import type { Channel } from "@/models/entities/channel.js"; -import { MAX_NOTE_TEXT_LENGTH } from "@/const.js"; +import { config } from "@/config.js"; import { noteVisibilities } from "@/types.js"; import { ApiError } from "@/server/api/error.js"; import define from "@/server/api/define.js"; -import { HOUR } from "@/const.js"; +import { HOUR } from "backend-rs"; import { getNote } from "@/server/api/common/getters.js"; import { Poll } from "@/models/entities/poll.js"; import * as mfm from "mfm-js"; @@ -168,7 +168,7 @@ export const paramDef = { format: "misskey:id", }, }, - text: { type: "string", maxLength: MAX_NOTE_TEXT_LENGTH, nullable: true }, + text: { type: "string", maxLength: config.maxNoteLength, nullable: true }, lang: { type: "string", enum: Object.keys(langmap), @@ -224,7 +224,7 @@ export const paramDef = { text: { type: "string", minLength: 1, - maxLength: MAX_NOTE_TEXT_LENGTH, + maxLength: config.maxNoteLength, nullable: false, }, }, diff --git a/packages/backend/src/server/api/endpoints/notes/make-private.ts b/packages/backend/src/server/api/endpoints/notes/make-private.ts index 5ddf1f3bf1..795863b003 100644 --- a/packages/backend/src/server/api/endpoints/notes/make-private.ts +++ b/packages/backend/src/server/api/endpoints/notes/make-private.ts @@ -3,7 +3,7 @@ import { Notes } from "@/models/index.js"; import define from "@/server/api/define.js"; import { getNote } from "@/server/api/common/getters.js"; import { ApiError } from "@/server/api/error.js"; -import { SECOND, HOUR } from "@/const.js"; +import { SECOND, HOUR } from "backend-rs"; import { publishNoteStream } from "@/services/stream.js"; export const meta = { diff --git a/packages/backend/src/server/api/endpoints/notes/reactions/delete.ts b/packages/backend/src/server/api/endpoints/notes/reactions/delete.ts index f135bd7ffa..b5f942f650 100644 --- a/packages/backend/src/server/api/endpoints/notes/reactions/delete.ts +++ b/packages/backend/src/server/api/endpoints/notes/reactions/delete.ts @@ -2,7 +2,7 @@ import deleteReaction from "@/services/note/reaction/delete.js"; import define from "@/server/api/define.js"; import { getNote } from "@/server/api/common/getters.js"; import { ApiError } from "@/server/api/error.js"; -import { SECOND, HOUR } from "@/const.js"; +import { SECOND, HOUR } from "backend-rs"; export const meta = { tags: ["reactions", "notes"], diff --git a/packages/backend/src/server/api/endpoints/notes/unrenote.ts b/packages/backend/src/server/api/endpoints/notes/unrenote.ts index 3f6f260eeb..1b8f544f7b 100644 --- a/packages/backend/src/server/api/endpoints/notes/unrenote.ts +++ b/packages/backend/src/server/api/endpoints/notes/unrenote.ts @@ -3,7 +3,7 @@ import { Notes, Users } from "@/models/index.js"; import define from "@/server/api/define.js"; import { getNote } from "@/server/api/common/getters.js"; import { ApiError } from "@/server/api/error.js"; -import { SECOND, HOUR } from "@/const.js"; +import { SECOND, HOUR } from "backend-rs"; export const meta = { tags: ["notes"], diff --git a/packages/backend/src/server/api/endpoints/pages/create.ts b/packages/backend/src/server/api/endpoints/pages/create.ts index 35ab2d0450..3b56836d4e 100644 --- a/packages/backend/src/server/api/endpoints/pages/create.ts +++ b/packages/backend/src/server/api/endpoints/pages/create.ts @@ -3,7 +3,7 @@ import { genId } from "backend-rs"; import { Page } from "@/models/entities/page.js"; import define from "@/server/api/define.js"; import { ApiError } from "@/server/api/error.js"; -import { HOUR } from "@/const.js"; +import { HOUR } from "backend-rs"; export const meta = { tags: ["pages"], diff --git a/packages/backend/src/server/api/endpoints/pages/update.ts b/packages/backend/src/server/api/endpoints/pages/update.ts index 9509ebfb81..7a4c47a81d 100644 --- a/packages/backend/src/server/api/endpoints/pages/update.ts +++ b/packages/backend/src/server/api/endpoints/pages/update.ts @@ -2,7 +2,7 @@ import { Not } from "typeorm"; import { Pages, DriveFiles } from "@/models/index.js"; import define from "@/server/api/define.js"; import { ApiError } from "@/server/api/error.js"; -import { HOUR } from "@/const.js"; +import { HOUR } from "backend-rs"; export const meta = { tags: ["pages"], diff --git a/packages/backend/src/server/api/endpoints/request-reset-password.ts b/packages/backend/src/server/api/endpoints/request-reset-password.ts index 00936c9d22..58beb94a88 100644 --- a/packages/backend/src/server/api/endpoints/request-reset-password.ts +++ b/packages/backend/src/server/api/endpoints/request-reset-password.ts @@ -3,9 +3,8 @@ import { IsNull } from "typeorm"; import { config } from "@/config.js"; import { Users, UserProfiles, PasswordResetRequests } from "@/models/index.js"; import { sendEmail } from "@/services/send-email.js"; -import { genId } from "backend-rs"; +import { HOUR, genId } from "backend-rs"; import define from "@/server/api/define.js"; -import { HOUR } from "@/const.js"; export const meta = { tags: ["reset password"], diff --git a/packages/backend/src/server/api/endpoints/users/recommendation.ts b/packages/backend/src/server/api/endpoints/users/recommendation.ts index 4ea0d618ed..1ff242b097 100644 --- a/packages/backend/src/server/api/endpoints/users/recommendation.ts +++ b/packages/backend/src/server/api/endpoints/users/recommendation.ts @@ -5,7 +5,7 @@ import { generateBlockedUserQuery, generateBlockQueryForUsers, } from "@/server/api/common/generate-block-query.js"; -import { DAY } from "@/const.js"; +import { DAY } from "backend-rs"; export const meta = { tags: ["users"], diff --git a/packages/backend/src/server/api/mastodon/endpoints/meta.ts b/packages/backend/src/server/api/mastodon/endpoints/meta.ts index 862310fb3e..69a1822892 100644 --- a/packages/backend/src/server/api/mastodon/endpoints/meta.ts +++ b/packages/backend/src/server/api/mastodon/endpoints/meta.ts @@ -1,9 +1,8 @@ -import { Entity } from "megalodon"; +import type { Entity } from "megalodon"; import { config } from "@/config.js"; -import { fetchMeta } from "backend-rs"; +import { FILE_TYPE_BROWSERSAFE, fetchMeta } from "backend-rs"; import { Users, Notes } from "@/models/index.js"; import { IsNull } from "typeorm"; -import { MAX_NOTE_TEXT_LENGTH, FILE_TYPE_BROWSERSAFE } from "@/const.js"; export async function getInstance( response: Entity.Instance, @@ -41,7 +40,7 @@ export async function getInstance( max_featured_tags: 20, }, statuses: { - max_characters: MAX_NOTE_TEXT_LENGTH, + max_characters: config.maxNoteLength, max_media_attachments: 16, characters_reserved_per_url: response.uri.length, }, diff --git a/packages/backend/src/server/file/send-drive-file.ts b/packages/backend/src/server/file/send-drive-file.ts index cef94d2659..4cfe6095cd 100644 --- a/packages/backend/src/server/file/send-drive-file.ts +++ b/packages/backend/src/server/file/send-drive-file.ts @@ -15,7 +15,7 @@ import { convertToWebp } from "@/services/drive/image-processor.js"; import { GenerateVideoThumbnail } from "@/services/drive/generate-video-thumbnail.js"; import { StatusError } from "@/misc/fetch.js"; import { ByteRangeReadable } from "./byte-range-readable.js"; -import { FILE_TYPE_BROWSERSAFE } from "@/const.js"; +import { FILE_TYPE_BROWSERSAFE } from "backend-rs"; import { inspect } from "node:util"; const _filename = fileURLToPath(import.meta.url); diff --git a/packages/backend/src/server/nodeinfo.ts b/packages/backend/src/server/nodeinfo.ts index 91e5fd8034..73189b73d9 100644 --- a/packages/backend/src/server/nodeinfo.ts +++ b/packages/backend/src/server/nodeinfo.ts @@ -3,7 +3,6 @@ import { config } from "@/config.js"; import { fetchMeta } from "backend-rs"; import { Users, Notes } from "@/models/index.js"; import { IsNull, MoreThan } from "typeorm"; -import { MAX_NOTE_TEXT_LENGTH, MAX_CAPTION_TEXT_LENGTH } from "@/const.js"; import { Cache } from "@/misc/cache.js"; const router = new Router(); @@ -86,8 +85,8 @@ const nodeinfo2 = async () => { postImports: meta.experimentalFeatures?.postImports || false, enableHcaptcha: meta.enableHcaptcha, enableRecaptcha: meta.enableRecaptcha, - maxNoteTextLength: MAX_NOTE_TEXT_LENGTH, - maxCaptionTextLength: MAX_CAPTION_TEXT_LENGTH, + maxNoteTextLength: config.maxNoteLength, + maxCaptionTextLength: config.maxCaptionLength, enableEmail: meta.enableEmail, enableServiceWorker: meta.enableServiceWorker, proxyAccountName: proxyAccount ? proxyAccount.username : null, @@ -113,6 +112,7 @@ router.get(nodeinfo2_0path, async (ctx) => { // @ts-ignore base.software.repository = undefined; + // @ts-ignore base.software.homepage = undefined; ctx.body = { version: "2.0", ...base }; diff --git a/packages/backend/src/server/proxy/proxy-media.ts b/packages/backend/src/server/proxy/proxy-media.ts index bb43c21f83..4ede3d4bdb 100644 --- a/packages/backend/src/server/proxy/proxy-media.ts +++ b/packages/backend/src/server/proxy/proxy-media.ts @@ -9,7 +9,7 @@ import { createTemp } from "@/misc/create-temp.js"; import { downloadUrl } from "@/misc/download-url.js"; import { detectType } from "@/misc/get-file-info.js"; import { StatusError } from "@/misc/fetch.js"; -import { FILE_TYPE_BROWSERSAFE } from "@/const.js"; +import { FILE_TYPE_BROWSERSAFE } from "backend-rs"; import { serverLogger } from "../index.js"; import { isMimeImage } from "@/misc/is-mime-image.js"; import { inspect } from "node:util"; diff --git a/packages/backend/src/server/web/index.ts b/packages/backend/src/server/web/index.ts index b0687f084f..f79eba64e6 100644 --- a/packages/backend/src/server/web/index.ts +++ b/packages/backend/src/server/web/index.ts @@ -15,7 +15,14 @@ import { BullAdapter } from "@bull-board/api/bullAdapter.js"; import { KoaAdapter } from "@bull-board/koa"; import { In, IsNull } from "typeorm"; -import { fetchMeta, metaToPugArgs } from "backend-rs"; +import { + MINUTE, + DAY, + getNoteSummary, + stringToAcct, + fetchMeta, + metaToPugArgs, +} from "backend-rs"; import { config } from "@/config.js"; import { Users, @@ -27,13 +34,11 @@ import { Emojis, GalleryPosts, } from "@/models/index.js"; -import { getNoteSummary, stringToAcct } from "backend-rs"; import { queues } from "@/queue/queues.js"; import { genOpenapiSpec } from "../api/openapi/gen-spec.js"; import { urlPreviewHandler } from "./url-preview.js"; import { manifestHandler } from "./manifest.js"; import packFeed from "./feed.js"; -import { MINUTE, DAY } from "@/const.js"; const _filename = fileURLToPath(import.meta.url); const _dirname = dirname(_filename); diff --git a/packages/backend/src/services/drive/add-file.ts b/packages/backend/src/services/drive/add-file.ts index 6a28a90b80..9d28112c1d 100644 --- a/packages/backend/src/services/drive/add-file.ts +++ b/packages/backend/src/services/drive/add-file.ts @@ -6,7 +6,7 @@ import type S3 from "aws-sdk/clients/s3.js"; // TODO: migrate to SDK v3 import sharp from "sharp"; import { IsNull } from "typeorm"; import { publishMainStream, publishDriveStream } from "@/services/stream.js"; -import { fetchMeta } from "backend-rs"; +import { FILE_TYPE_BROWSERSAFE, fetchMeta, genId } from "backend-rs"; import { contentDisposition } from "@/misc/content-disposition.js"; import { getFileInfo } from "@/misc/get-file-info.js"; import { @@ -18,9 +18,7 @@ import { import { DriveFile } from "@/models/entities/drive-file.js"; import type { DriveFileUsageHint } from "@/models/entities/drive-file.js"; import type { IRemoteUser, User } from "@/models/entities/user.js"; -import { genId } from "backend-rs"; import { isDuplicateKeyValueError } from "@/misc/is-duplicate-key-value-error.js"; -import { FILE_TYPE_BROWSERSAFE } from "@/const.js"; import { IdentifiableError } from "@/misc/identifiable-error.js"; import { getS3 } from "./s3.js"; import { InternalStorage } from "./internal-storage.js";