From 79af7b0eae062c099694ae0f6b5fe079f46c7b03 Mon Sep 17 00:00:00 2001 From: sup39 Date: Tue, 23 Jan 2024 18:20:05 +0900 Subject: [PATCH] refactor: move misc/fetch-meta.ts to backend-rs --- neko/index.js | 6 +- packages/backend-rs/Cargo.lock | 1 + packages/backend-rs/Cargo.toml | 1 + packages/backend-rs/src/database/error.rs | 9 ++ packages/backend-rs/src/database/mod.rs | 50 ++++++++--- packages/backend-rs/src/util/meta.rs | 87 +++++++++++++++++++ packages/backend-rs/src/util/mod.rs | 1 + packages/backend/src/daemons/server-stats.ts | 2 +- packages/backend/src/misc/backend-rs.ts | 11 +++ packages/backend/src/misc/fetch-meta.ts | 72 --------------- .../backend/src/misc/fetch-proxy-account.ts | 2 +- packages/backend/src/misc/reaction-lib.ts | 2 +- .../backend/src/misc/should-block-instance.ts | 2 +- .../backend/src/misc/skipped-instances.ts | 2 +- packages/backend/src/misc/translate.ts | 2 +- .../backend/src/queue/processors/inbox.ts | 2 +- .../src/remote/activitypub/check-fetch.ts | 2 +- .../src/remote/activitypub/models/image.ts | 2 +- .../src/remote/activitypub/renderer/like.ts | 1 - .../src/remote/activitypub/resolver.ts | 2 +- packages/backend/src/server/activitypub.ts | 2 +- .../src/server/activitypub/featured.ts | 2 +- .../src/server/activitypub/followers.ts | 2 +- .../src/server/activitypub/following.ts | 2 +- .../backend/src/server/activitypub/outbox.ts | 2 +- .../backend/src/server/api/api-handler.ts | 2 +- packages/backend/src/server/api/call.ts | 2 +- .../api/endpoints/admin/accounts/hosted.ts | 3 + .../src/server/api/endpoints/admin/meta.ts | 2 +- .../server/api/endpoints/admin/update-meta.ts | 3 + .../src/server/api/endpoints/custom-motd.ts | 2 +- .../api/endpoints/custom-splash-icons.ts | 2 +- .../backend/src/server/api/endpoints/drive.ts | 2 +- .../api/endpoints/drive/files/create.ts | 2 +- .../api/endpoints/federation/instances.ts | 2 +- .../server/api/endpoints/hashtags/trend.ts | 2 +- .../server/api/endpoints/i/import-posts.ts | 2 +- .../backend/src/server/api/endpoints/meta.ts | 2 +- .../api/endpoints/notes/global-timeline.ts | 2 +- .../api/endpoints/notes/hybrid-timeline.ts | 2 +- .../api/endpoints/notes/local-timeline.ts | 2 +- .../endpoints/notes/recommended-timeline.ts | 2 +- .../src/server/api/endpoints/pinned-users.ts | 2 +- .../api/endpoints/recommended-instances.ts | 2 +- .../src/server/api/endpoints/server-info.ts | 2 +- .../src/server/api/endpoints/sw/register.ts | 2 +- .../api/endpoints/users/report-abuse.ts | 2 +- .../src/server/api/mastodon/endpoints/meta.ts | 2 +- .../server/api/mastodon/endpoints/status.ts | 2 +- .../backend/src/server/api/private/signup.ts | 2 +- .../api/stream/channels/global-timeline.ts | 2 +- .../api/stream/channels/hybrid-timeline.ts | 2 +- .../api/stream/channels/local-timeline.ts | 2 +- .../stream/channels/recommended-timeline.ts | 2 +- packages/backend/src/server/index.ts | 2 +- packages/backend/src/server/nodeinfo.ts | 2 +- packages/backend/src/server/web/index.ts | 3 +- packages/backend/src/server/web/manifest.ts | 2 +- .../backend/src/server/web/url-preview.ts | 2 +- .../backend/src/server/web/views/base.pug | 4 +- .../backend/src/services/drive/add-file.ts | 2 +- .../backend/src/services/drive/delete-file.ts | 2 +- .../backend/src/services/push-notification.ts | 2 +- packages/backend/src/services/send-email.ts | 2 +- .../services/validate-email-for-account.ts | 2 +- 65 files changed, 213 insertions(+), 141 deletions(-) create mode 100644 packages/backend-rs/src/util/meta.rs delete mode 100644 packages/backend/src/misc/fetch-meta.ts diff --git a/neko/index.js b/neko/index.js index 9e6aa70da..d4c647553 100644 --- a/neko/index.js +++ b/neko/index.js @@ -295,11 +295,13 @@ if (!nativeBinding) { throw new Error(`Failed to load native binding`) } -const { EnvConfig, readEnvironmentConfig, readServerConfig, AntennaSrcEnum, MutedNoteReasonEnum, NoteVisibilityEnum, NotificationTypeEnum, PageVisibilityEnum, PollNotevisibilityEnum, RelayStatusEnum, UserEmojimodpermEnum, UserProfileFfvisibilityEnum, UserProfileMutingnotificationtypesEnum, stringToAcct, acctToString, getFullApAccount, isSelfHost, extractHost, toPuny, toPunyOptional, convertToHiddenPost, sqlLikeEscape, safeForSql, formatMilliseconds, nativeInitIdGenerator, nativeCreateId, nativeGetTimestamp, genString, IdConvertType, convertId } = nativeBinding +const { EnvConfig, readEnvironmentConfig, readServerConfig, JsDbConn, connectToDatabase, AntennaSrcEnum, MutedNoteReasonEnum, NoteVisibilityEnum, NotificationTypeEnum, PageVisibilityEnum, PollNotevisibilityEnum, RelayStatusEnum, UserEmojimodpermEnum, UserProfileFfvisibilityEnum, UserProfileMutingnotificationtypesEnum, stringToAcct, acctToString, getFullApAccount, isSelfHost, extractHost, toPuny, toPunyOptional, convertToHiddenPost, sqlLikeEscape, safeForSql, formatMilliseconds, nativeInitIdGenerator, nativeCreateId, nativeGetTimestamp, fetchMeta, metaToPugArgs, genString, IdConvertType, convertId } = nativeBinding module.exports.EnvConfig = EnvConfig module.exports.readEnvironmentConfig = readEnvironmentConfig module.exports.readServerConfig = readServerConfig +module.exports.JsDbConn = JsDbConn +module.exports.connectToDatabase = connectToDatabase module.exports.AntennaSrcEnum = AntennaSrcEnum module.exports.MutedNoteReasonEnum = MutedNoteReasonEnum module.exports.NoteVisibilityEnum = NoteVisibilityEnum @@ -324,6 +326,8 @@ module.exports.formatMilliseconds = formatMilliseconds module.exports.nativeInitIdGenerator = nativeInitIdGenerator module.exports.nativeCreateId = nativeCreateId module.exports.nativeGetTimestamp = nativeGetTimestamp +module.exports.fetchMeta = fetchMeta +module.exports.metaToPugArgs = metaToPugArgs module.exports.genString = genString module.exports.IdConvertType = IdConvertType module.exports.convertId = convertId diff --git a/packages/backend-rs/Cargo.lock b/packages/backend-rs/Cargo.lock index 172bc62d1..7c939254a 100644 --- a/packages/backend-rs/Cargo.lock +++ b/packages/backend-rs/Cargo.lock @@ -222,6 +222,7 @@ dependencies = [ "thiserror", "tokio", "url", + "urlencoding", ] [[package]] diff --git a/packages/backend-rs/Cargo.toml b/packages/backend-rs/Cargo.toml index 0d7e003e9..4bab77cdc 100644 --- a/packages/backend-rs/Cargo.toml +++ b/packages/backend-rs/Cargo.toml @@ -33,6 +33,7 @@ url = "2.5.0" napi = { version = "2.14.4", default-features = false, features = ["napi9", "tokio_rt", "chrono_date", "serde-json"] } napi-derive = { version = "2.14.6", optional = true } basen = "0.1.0" +urlencoding = "2.1.3" [dev-dependencies] pretty_assertions = "1.4.0" diff --git a/packages/backend-rs/src/database/error.rs b/packages/backend-rs/src/database/error.rs index f180870fa..beb9f3636 100644 --- a/packages/backend-rs/src/database/error.rs +++ b/packages/backend-rs/src/database/error.rs @@ -11,3 +11,12 @@ pub enum Error { } impl_napi_error_from!(Error); + +pub trait NapiDbErrExt { + fn into(self) -> napi::Error; +} +impl NapiDbErrExt for DbErr { + fn into(self) -> napi::Error { + napi::Error::from_reason(self.to_string()) + } +} diff --git a/packages/backend-rs/src/database/mod.rs b/packages/backend-rs/src/database/mod.rs index 739f39bb6..574b27bfa 100644 --- a/packages/backend-rs/src/database/mod.rs +++ b/packages/backend-rs/src/database/mod.rs @@ -1,26 +1,50 @@ pub mod error; +pub use error::NapiDbErrExt; -use error::Error; +use crate::config::server::DbConfig; use sea_orm::{Database, DbConn}; +use urlencoding::encode; -static DB_CONN: once_cell::sync::OnceCell = once_cell::sync::OnceCell::new(); - -pub async fn init_database(conn_uri: impl Into) -> Result<(), Error> { - let conn = Database::connect(conn_uri.into()).await?; - DB_CONN.get_or_init(move || conn); - Ok(()) +#[napi_derive::napi] +pub struct JsDbConn { + inner: DbConn, +} +impl JsDbConn { + pub fn inner(&self) -> &DbConn { + &self.inner + } } -pub fn get_database() -> Result<&'static DbConn, Error> { - DB_CONN.get().ok_or(Error::Uninitialized) +#[napi_derive::napi] +pub async fn connect_to_database(config: DbConfig) -> napi::Result { + let conn_uri = format!( + "postgres://{}:{}@{}:{}/{}", + config.user, + encode(&config.pass), + config.host, + config.port, + config.db, + ); + let conn = Database::connect(conn_uri) + .await + .map_err(NapiDbErrExt::into)?; + Ok(JsDbConn { inner: conn }) } #[cfg(test)] mod unit_test { - use super::{error::Error, get_database}; + use super::connect_to_database; + use crate::config::server::read_server_config; - #[test] - fn error_uninitialized() { - assert_eq!(get_database().unwrap_err(), Error::Uninitialized); + #[tokio::test] + async fn connect_with_server_config() { + assert!(connect_to_database(read_server_config().db).await.is_ok()); + } + + #[tokio::test] + async fn connect_with_incorrect_password() { + let mut config = read_server_config().db; + config.pass.push('.'); // password should be incorrect now + assert!(connect_to_database(config).await.is_err()); } } diff --git a/packages/backend-rs/src/util/meta.rs b/packages/backend-rs/src/util/meta.rs new file mode 100644 index 000000000..04e1096e0 --- /dev/null +++ b/packages/backend-rs/src/util/meta.rs @@ -0,0 +1,87 @@ +use crate::database::{JsDbConn, NapiDbErrExt}; +use crate::model::entity::meta; +use rand::prelude::*; +use sea_orm::{prelude::*, ActiveValue}; +use std::sync::Mutex; + +type Meta = meta::Model; + +static CACHE: Mutex> = Mutex::new(None); +fn update_cache(meta: &Meta) { + let _ = CACHE.lock().map(|mut cache| *cache = Some(meta.clone())); +} + +#[napi_derive::napi] +pub async fn fetch_meta(conn: &JsDbConn, invalidate_cache: Option) -> napi::Result { + // try using cache + if invalidate_cache == Some(true) { + if let Some(cache) = CACHE.lock().ok().and_then(|cache| cache.clone()) { + return Ok(cache); + } + } + + // try fetching from db + let db = conn.inner(); + let meta = meta::Entity::find() + .one(db) + .await + .map_err(NapiDbErrExt::into)?; + if let Some(meta) = meta { + update_cache(&meta); + return Ok(meta); + } + + // create a new meta object and insert into db + let meta = meta::Entity::insert(meta::ActiveModel { + id: ActiveValue::Set("x".to_owned()), + ..Default::default() + }) + .exec_with_returning(db) + .await + .map_err(NapiDbErrExt::into)?; + update_cache(&meta); + Ok(meta) +} + +#[napi_derive::napi(object)] +pub struct PugArgs { + pub img: Option, + pub title: String, + pub instance_name: String, + pub desc: Option, + pub icon: Option, + pub splash_icon: Option, + pub theme_color: Option, + pub random_motd: String, + pub private_mode: Option, +} + +#[napi_derive::napi] +pub fn meta_to_pug_args(meta: Meta) -> PugArgs { + let mut rng = rand::thread_rng(); + + let splash_icon = meta + .custom_splash_icons + .choose(&mut rng) + .map(|s| s.to_owned()) + .or_else(|| meta.icon_url.to_owned()); + + let random_motd = meta + .custom_motd + .choose(&mut rng) + .map(|s| s.to_owned()) + .unwrap_or_else(|| "Loading...".to_owned()); + + let name = meta.name.unwrap_or_else(|| "Firefish".to_owned()); + PugArgs { + img: meta.banner_url, + title: name.clone(), + instance_name: name.clone(), + desc: meta.description, + icon: meta.icon_url, + splash_icon, + theme_color: meta.theme_color, + random_motd, + private_mode: meta.private_mode, + } +} diff --git a/packages/backend-rs/src/util/mod.rs b/packages/backend-rs/src/util/mod.rs index 79c10c951..bdbd2e451 100644 --- a/packages/backend-rs/src/util/mod.rs +++ b/packages/backend-rs/src/util/mod.rs @@ -4,4 +4,5 @@ pub mod convert_to_hidden_post; pub mod escape_sql; pub mod format_milliseconds; pub mod id; +pub mod meta; pub mod random; diff --git a/packages/backend/src/daemons/server-stats.ts b/packages/backend/src/daemons/server-stats.ts index 28c92fe98..f637f5d54 100644 --- a/packages/backend/src/daemons/server-stats.ts +++ b/packages/backend/src/daemons/server-stats.ts @@ -1,7 +1,7 @@ import si from "systeminformation"; import Xev from "xev"; import * as osUtils from "os-utils"; -import { fetchMeta } from "@/misc/fetch-meta.js"; +import { fetchMeta } from "@/misc/backend-rs.js"; // import meilisearch from "@/db/meilisearch.js"; const ev = new Xev(); diff --git a/packages/backend/src/misc/backend-rs.ts b/packages/backend/src/misc/backend-rs.ts index 80fb979ba..4bd382df8 100644 --- a/packages/backend/src/misc/backend-rs.ts +++ b/packages/backend/src/misc/backend-rs.ts @@ -1,15 +1,26 @@ import { readServerConfig, readEnvironmentConfig, + connectToDatabase, + fetchMeta as fetchMetaImpl, getFullApAccount as getFullApAccountImpl, isSelfHost as isSelfHostImpl, + JsDbConn, } from "backend-rs"; export const serverConfig = readServerConfig(); export const envConfig = readEnvironmentConfig(); +const dbPromise = connectToDatabase(serverConfig.db); type Option = T | null | undefined; +const curryDb = +

(f: (db: JsDbConn, ...args: P) => Promise) => + (...args: P) => + dbPromise.then((db) => f(db, ...args)); + +export const fetchMeta = curryDb(fetchMetaImpl); + export function getFullApAccount( username: string, host: Option, diff --git a/packages/backend/src/misc/fetch-meta.ts b/packages/backend/src/misc/fetch-meta.ts deleted file mode 100644 index fdc978b5a..000000000 --- a/packages/backend/src/misc/fetch-meta.ts +++ /dev/null @@ -1,72 +0,0 @@ -import { db } from "@/db/postgre.js"; -import { Meta } from "@/models/entities/meta.js"; - -let cache: Meta; - -export function metaToPugArgs(meta: Meta): object { - let motd = ["Loading..."]; - if (meta.customMotd.length > 0) { - motd = meta.customMotd; - } - let splashIconUrl = meta.iconUrl; - if (meta.customSplashIcons.length > 0) { - splashIconUrl = - meta.customSplashIcons[ - Math.floor(Math.random() * meta.customSplashIcons.length) - ]; - } - - return { - img: meta.bannerUrl, - title: meta.name || "Firefish", - instanceName: meta.name || "Firefish", - desc: meta.description, - icon: meta.iconUrl, - splashIcon: splashIconUrl, - themeColor: meta.themeColor, - randomMOTD: motd[Math.floor(Math.random() * motd.length)], - privateMode: meta.privateMode, - }; -} - -export async function fetchMeta(noCache = false): Promise { - if (!noCache && cache) return cache; - - return await db.transaction(async (transactionalEntityManager) => { - // New IDs are prioritized because multiple records may have been created due to past bugs. - const metas = await transactionalEntityManager.find(Meta, { - order: { - id: "DESC", - }, - }); - - const meta = metas[0]; - - if (meta) { - cache = meta; - return meta; - } else { - // If fetchMeta is called at the same time when meta is empty, this part may be called at the same time, so use fail-safe upsert. - const saved = await transactionalEntityManager - .upsert( - Meta, - { - id: "x", - }, - ["id"], - ) - .then((x) => - transactionalEntityManager.findOneByOrFail(Meta, x.identifiers[0]), - ); - - cache = saved; - return saved; - } - }); -} - -setInterval(() => { - fetchMeta(true).then((meta) => { - cache = meta; - }); -}, 1000 * 10); diff --git a/packages/backend/src/misc/fetch-proxy-account.ts b/packages/backend/src/misc/fetch-proxy-account.ts index a277db6fb..c3b5f2569 100644 --- a/packages/backend/src/misc/fetch-proxy-account.ts +++ b/packages/backend/src/misc/fetch-proxy-account.ts @@ -1,4 +1,4 @@ -import { fetchMeta } from "./fetch-meta.js"; +import { fetchMeta } from "@/misc/backend-rs.js"; import type { ILocalUser } from "@/models/entities/user.js"; import { Users } from "@/models/index.js"; diff --git a/packages/backend/src/misc/reaction-lib.ts b/packages/backend/src/misc/reaction-lib.ts index 85c9d1500..fbdf16ecb 100644 --- a/packages/backend/src/misc/reaction-lib.ts +++ b/packages/backend/src/misc/reaction-lib.ts @@ -1,5 +1,5 @@ import { emojiRegex } from "./emoji-regex.js"; -import { fetchMeta } from "./fetch-meta.js"; +import { fetchMeta } from "@/misc/backend-rs.js"; import { Emojis } from "@/models/index.js"; import { toPunyOptional } from "backend-rs"; import { IsNull } from "typeorm"; diff --git a/packages/backend/src/misc/should-block-instance.ts b/packages/backend/src/misc/should-block-instance.ts index 35ed30793..d0fcb8289 100644 --- a/packages/backend/src/misc/should-block-instance.ts +++ b/packages/backend/src/misc/should-block-instance.ts @@ -1,4 +1,4 @@ -import { fetchMeta } from "@/misc/fetch-meta.js"; +import { fetchMeta } from "@/misc/backend-rs.js"; import type { Instance } from "@/models/entities/instance.js"; import type { Meta } from "@/models/entities/meta.js"; diff --git a/packages/backend/src/misc/skipped-instances.ts b/packages/backend/src/misc/skipped-instances.ts index 785393022..b62e10fde 100644 --- a/packages/backend/src/misc/skipped-instances.ts +++ b/packages/backend/src/misc/skipped-instances.ts @@ -1,5 +1,5 @@ import { Brackets } from "typeorm"; -import { fetchMeta } from "@/misc/fetch-meta.js"; +import { fetchMeta } from "@/misc/backend-rs.js"; import { Instances } from "@/models/index.js"; import type { Instance } from "@/models/entities/instance.js"; import { DAY } from "@/const.js"; diff --git a/packages/backend/src/misc/translate.ts b/packages/backend/src/misc/translate.ts index 07f5ff2b0..7d45bf31b 100644 --- a/packages/backend/src/misc/translate.ts +++ b/packages/backend/src/misc/translate.ts @@ -1,7 +1,7 @@ import fetch from "node-fetch"; import { Converter } from "opencc-js"; import { getAgentByUrl } from "@/misc/fetch.js"; -import { fetchMeta } from "@/misc/fetch-meta.js"; +import { fetchMeta } from "@/misc/backend-rs.js"; import type { Language } from "@/misc/langmap"; import * as deepl from "deepl-node"; diff --git a/packages/backend/src/queue/processors/inbox.ts b/packages/backend/src/queue/processors/inbox.ts index 3cb3b9857..c5cb0bfde 100644 --- a/packages/backend/src/queue/processors/inbox.ts +++ b/packages/backend/src/queue/processors/inbox.ts @@ -5,7 +5,7 @@ import perform from "@/remote/activitypub/perform.js"; import Logger from "@/services/logger.js"; import { registerOrFetchInstanceDoc } from "@/services/register-or-fetch-instance-doc.js"; import { Instances } from "@/models/index.js"; -import { fetchMeta } from "@/misc/fetch-meta.js"; +import { fetchMeta } from "@/misc/backend-rs.js"; import { toPuny, extractHost } from "backend-rs"; import { getApId } from "@/remote/activitypub/type.js"; import { fetchInstanceMetadata } from "@/services/fetch-instance-metadata.js"; diff --git a/packages/backend/src/remote/activitypub/check-fetch.ts b/packages/backend/src/remote/activitypub/check-fetch.ts index c0d40278e..060884203 100644 --- a/packages/backend/src/remote/activitypub/check-fetch.ts +++ b/packages/backend/src/remote/activitypub/check-fetch.ts @@ -1,7 +1,7 @@ import { URL } from "url"; import httpSignature, { IParsedSignature } from "@peertube/http-signature"; import config from "@/config/index.js"; -import { fetchMeta } from "@/misc/fetch-meta.js"; +import { fetchMeta } from "@/misc/backend-rs.js"; import { toPuny } from "backend-rs"; import DbResolver from "@/remote/activitypub/db-resolver.js"; import { 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 2cf0c6c15..1f6d3a5d4 100644 --- a/packages/backend/src/remote/activitypub/models/image.ts +++ b/packages/backend/src/remote/activitypub/models/image.ts @@ -1,7 +1,7 @@ import { uploadFromUrl } from "@/services/drive/upload-from-url.js"; import type { CacheableRemoteUser } from "@/models/entities/user.js"; import Resolver from "../resolver.js"; -import { fetchMeta } from "@/misc/fetch-meta.js"; +import { fetchMeta } from "@/misc/backend-rs.js"; import { apLogger } from "../logger.js"; import type { DriveFile } from "@/models/entities/drive-file.js"; import { DriveFiles } from "@/models/index.js"; diff --git a/packages/backend/src/remote/activitypub/renderer/like.ts b/packages/backend/src/remote/activitypub/renderer/like.ts index 060b34ad0..6f810cd20 100644 --- a/packages/backend/src/remote/activitypub/renderer/like.ts +++ b/packages/backend/src/remote/activitypub/renderer/like.ts @@ -4,7 +4,6 @@ import type { NoteReaction } from "@/models/entities/note-reaction.js"; import type { Note } from "@/models/entities/note.js"; import { Emojis } from "@/models/index.js"; import renderEmoji from "./emoji.js"; -import { fetchMeta } from "@/misc/fetch-meta.js"; export const renderLike = async (noteReaction: NoteReaction, note: Note) => { const reaction = noteReaction.reaction; diff --git a/packages/backend/src/remote/activitypub/resolver.ts b/packages/backend/src/remote/activitypub/resolver.ts index c8580b2ba..d3cd9eeb8 100644 --- a/packages/backend/src/remote/activitypub/resolver.ts +++ b/packages/backend/src/remote/activitypub/resolver.ts @@ -2,7 +2,7 @@ import config from "@/config/index.js"; import { getJson } from "@/misc/fetch.js"; import type { ILocalUser } from "@/models/entities/user.js"; import { getInstanceActor } from "@/services/instance-actor.js"; -import { fetchMeta } from "@/misc/fetch-meta.js"; +import { fetchMeta } from "@/misc/backend-rs.js"; import { extractHost } from "backend-rs"; import { isSelfHost } from "@/misc/backend-rs.js"; import { signedGet } from "./request.js"; diff --git a/packages/backend/src/server/activitypub.ts b/packages/backend/src/server/activitypub.ts index 5fdcb621c..70a307ab2 100644 --- a/packages/backend/src/server/activitypub.ts +++ b/packages/backend/src/server/activitypub.ts @@ -25,7 +25,7 @@ import { getSignatureUser, } from "@/remote/activitypub/check-fetch.js"; import { getInstanceActor } from "@/services/instance-actor.js"; -import { fetchMeta } from "@/misc/fetch-meta.js"; +import { fetchMeta } from "@/misc/backend-rs.js"; import renderFollow from "@/remote/activitypub/renderer/follow.js"; import Featured from "./activitypub/featured.js"; import Following from "./activitypub/following.js"; diff --git a/packages/backend/src/server/activitypub/featured.ts b/packages/backend/src/server/activitypub/featured.ts index bd4923b7c..030d42530 100644 --- a/packages/backend/src/server/activitypub/featured.ts +++ b/packages/backend/src/server/activitypub/featured.ts @@ -5,7 +5,7 @@ import renderOrderedCollection from "@/remote/activitypub/renderer/ordered-colle import renderNote from "@/remote/activitypub/renderer/note.js"; import { Users, Notes, UserNotePinings } from "@/models/index.js"; import { checkFetch } from "@/remote/activitypub/check-fetch.js"; -import { fetchMeta } from "@/misc/fetch-meta.js"; +import { fetchMeta } from "@/misc/backend-rs.js"; import { setResponseType } from "../activitypub.js"; import type Router from "@koa/router"; diff --git a/packages/backend/src/server/activitypub/followers.ts b/packages/backend/src/server/activitypub/followers.ts index 146ca5192..bf1771a5b 100644 --- a/packages/backend/src/server/activitypub/followers.ts +++ b/packages/backend/src/server/activitypub/followers.ts @@ -8,7 +8,7 @@ import renderFollowUser from "@/remote/activitypub/renderer/follow-user.js"; import { Users, Followings, UserProfiles } from "@/models/index.js"; import type { Following } from "@/models/entities/following.js"; import { checkFetch } from "@/remote/activitypub/check-fetch.js"; -import { fetchMeta } from "@/misc/fetch-meta.js"; +import { fetchMeta } from "@/misc/backend-rs.js"; import { setResponseType } from "../activitypub.js"; import type { FindOptionsWhere } from "typeorm"; import type Router from "@koa/router"; diff --git a/packages/backend/src/server/activitypub/following.ts b/packages/backend/src/server/activitypub/following.ts index eab513ce6..345983e29 100644 --- a/packages/backend/src/server/activitypub/following.ts +++ b/packages/backend/src/server/activitypub/following.ts @@ -8,7 +8,7 @@ import renderFollowUser from "@/remote/activitypub/renderer/follow-user.js"; import { Users, Followings, UserProfiles } from "@/models/index.js"; import type { Following } from "@/models/entities/following.js"; import { checkFetch } from "@/remote/activitypub/check-fetch.js"; -import { fetchMeta } from "@/misc/fetch-meta.js"; +import { fetchMeta } from "@/misc/backend-rs.js"; import { setResponseType } from "../activitypub.js"; import type { FindOptionsWhere } from "typeorm"; import type Router from "@koa/router"; diff --git a/packages/backend/src/server/activitypub/outbox.ts b/packages/backend/src/server/activitypub/outbox.ts index e0a380ffb..969d2fc6f 100644 --- a/packages/backend/src/server/activitypub/outbox.ts +++ b/packages/backend/src/server/activitypub/outbox.ts @@ -11,7 +11,7 @@ import * as url from "@/prelude/url.js"; import { Users, Notes } from "@/models/index.js"; import type { Note } from "@/models/entities/note.js"; import { checkFetch } from "@/remote/activitypub/check-fetch.js"; -import { fetchMeta } from "@/misc/fetch-meta.js"; +import { fetchMeta } from "@/misc/backend-rs.js"; import { makePaginationQuery } from "../api/common/make-pagination-query.js"; import { setResponseType } from "../activitypub.js"; import type Router from "@koa/router"; diff --git a/packages/backend/src/server/api/api-handler.ts b/packages/backend/src/server/api/api-handler.ts index b9e6a3e06..af3239392 100644 --- a/packages/backend/src/server/api/api-handler.ts +++ b/packages/backend/src/server/api/api-handler.ts @@ -2,7 +2,7 @@ import type Koa from "koa"; import type { User } from "@/models/entities/user.js"; import { UserIps } from "@/models/index.js"; -import { fetchMeta } from "@/misc/fetch-meta.js"; +import { fetchMeta } from "@/misc/backend-rs.js"; import type { IEndpoint } from "./endpoints.js"; import authenticate, { AuthenticationError } from "./authenticate.js"; import call from "./call.js"; diff --git a/packages/backend/src/server/api/call.ts b/packages/backend/src/server/api/call.ts index 4cb4a51a9..2fe89762e 100644 --- a/packages/backend/src/server/api/call.ts +++ b/packages/backend/src/server/api/call.ts @@ -9,7 +9,7 @@ import endpoints from "./endpoints.js"; import compatibility from "./compatibility.js"; import { ApiError } from "./error.js"; import { apiLogger } from "./logger.js"; -import { fetchMeta } from "@/misc/fetch-meta.js"; +import { fetchMeta } from "@/misc/backend-rs.js"; const accessDenied = { message: "Access denied.", diff --git a/packages/backend/src/server/api/endpoints/admin/accounts/hosted.ts b/packages/backend/src/server/api/endpoints/admin/accounts/hosted.ts index fd4ad9401..c5b4783cd 100644 --- a/packages/backend/src/server/api/endpoints/admin/accounts/hosted.ts +++ b/packages/backend/src/server/api/endpoints/admin/accounts/hosted.ts @@ -2,6 +2,7 @@ import config from "@/config/index.js"; import { Meta } from "@/models/entities/meta.js"; import { insertModerationLog } from "@/services/insert-moderation-log.js"; import { db } from "@/db/postgre.js"; +import { fetchMeta } from "@/misc/backend-rs.js"; import define from "@/server/api/define.js"; export const meta = { @@ -120,6 +121,8 @@ export default define(meta, paramDef, async (ps, me) => { } else { await transactionalEntityManager.save(Meta, set); } + // update meta cache + fetchMeta(true); }); insertModerationLog(me, "updateMeta"); } diff --git a/packages/backend/src/server/api/endpoints/admin/meta.ts b/packages/backend/src/server/api/endpoints/admin/meta.ts index e3cb3a09d..4727647c9 100644 --- a/packages/backend/src/server/api/endpoints/admin/meta.ts +++ b/packages/backend/src/server/api/endpoints/admin/meta.ts @@ -1,5 +1,5 @@ import config from "@/config/index.js"; -import { fetchMeta } from "@/misc/fetch-meta.js"; +import { fetchMeta } from "@/misc/backend-rs.js"; import { MAX_NOTE_TEXT_LENGTH, MAX_CAPTION_TEXT_LENGTH } from "@/const.js"; import define from "@/server/api/define.js"; diff --git a/packages/backend/src/server/api/endpoints/admin/update-meta.ts b/packages/backend/src/server/api/endpoints/admin/update-meta.ts index f0e831924..ce803bb35 100644 --- a/packages/backend/src/server/api/endpoints/admin/update-meta.ts +++ b/packages/backend/src/server/api/endpoints/admin/update-meta.ts @@ -1,6 +1,7 @@ import { Meta } from "@/models/entities/meta.js"; import { insertModerationLog } from "@/services/insert-moderation-log.js"; import { db } from "@/db/postgre.js"; +import { fetchMeta } from "@/misc/backend-rs.js"; import define from "@/server/api/define.js"; export const meta = { @@ -571,6 +572,8 @@ export default define(meta, paramDef, async (ps, me) => { } else { await transactionalEntityManager.save(Meta, set); } + // update meta cache + fetchMeta(true); }); insertModerationLog(me, "updateMeta"); diff --git a/packages/backend/src/server/api/endpoints/custom-motd.ts b/packages/backend/src/server/api/endpoints/custom-motd.ts index 2939355b9..5bfe6446e 100644 --- a/packages/backend/src/server/api/endpoints/custom-motd.ts +++ b/packages/backend/src/server/api/endpoints/custom-motd.ts @@ -1,5 +1,5 @@ // import { IsNull } from 'typeorm'; -import { fetchMeta } from "@/misc/fetch-meta.js"; +import { fetchMeta } from "@/misc/backend-rs.js"; import define from "@/server/api/define.js"; export const meta = { diff --git a/packages/backend/src/server/api/endpoints/custom-splash-icons.ts b/packages/backend/src/server/api/endpoints/custom-splash-icons.ts index f63a1b960..45d138260 100644 --- a/packages/backend/src/server/api/endpoints/custom-splash-icons.ts +++ b/packages/backend/src/server/api/endpoints/custom-splash-icons.ts @@ -1,5 +1,5 @@ // import { IsNull } from 'typeorm'; -import { fetchMeta } from "@/misc/fetch-meta.js"; +import { fetchMeta } from "@/misc/backend-rs.js"; import define from "@/server/api/define.js"; export const meta = { diff --git a/packages/backend/src/server/api/endpoints/drive.ts b/packages/backend/src/server/api/endpoints/drive.ts index 164e7b8f9..fc7074d88 100644 --- a/packages/backend/src/server/api/endpoints/drive.ts +++ b/packages/backend/src/server/api/endpoints/drive.ts @@ -1,4 +1,4 @@ -import { fetchMeta } from "@/misc/fetch-meta.js"; +import { fetchMeta } from "@/misc/backend-rs.js"; import { DriveFiles } from "@/models/index.js"; import define from "@/server/api/define.js"; 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 54ca5f8d1..a59e8dcaa 100644 --- a/packages/backend/src/server/api/endpoints/drive/files/create.ts +++ b/packages/backend/src/server/api/endpoints/drive/files/create.ts @@ -2,7 +2,7 @@ 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 { IdentifiableError } from "@/misc/identifiable-error.js"; -import { fetchMeta } from "@/misc/fetch-meta.js"; +import { fetchMeta } from "@/misc/backend-rs.js"; import { MINUTE } from "@/const.js"; import define from "@/server/api/define.js"; import { apiLogger } from "@/server/api/logger.js"; diff --git a/packages/backend/src/server/api/endpoints/federation/instances.ts b/packages/backend/src/server/api/endpoints/federation/instances.ts index 615920d41..873695d51 100644 --- a/packages/backend/src/server/api/endpoints/federation/instances.ts +++ b/packages/backend/src/server/api/endpoints/federation/instances.ts @@ -1,6 +1,6 @@ import define from "@/server/api/define.js"; import { Instances } from "@/models/index.js"; -import { fetchMeta } from "@/misc/fetch-meta.js"; +import { fetchMeta } from "@/misc/backend-rs.js"; import { sqlLikeEscape } from "backend-rs"; export const meta = { diff --git a/packages/backend/src/server/api/endpoints/hashtags/trend.ts b/packages/backend/src/server/api/endpoints/hashtags/trend.ts index f123131cc..eef7a6639 100644 --- a/packages/backend/src/server/api/endpoints/hashtags/trend.ts +++ b/packages/backend/src/server/api/endpoints/hashtags/trend.ts @@ -1,6 +1,6 @@ import { Brackets } from "typeorm"; import define from "@/server/api/define.js"; -import { fetchMeta } from "@/misc/fetch-meta.js"; +import { fetchMeta } from "@/misc/backend-rs.js"; import { Notes } from "@/models/index.js"; import type { Note } from "@/models/entities/note.js"; import { safeForSql } from "backend-rs"; 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 b8b52be98..34e54aee8 100644 --- a/packages/backend/src/server/api/endpoints/i/import-posts.ts +++ b/packages/backend/src/server/api/endpoints/i/import-posts.ts @@ -3,7 +3,7 @@ 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 { fetchMeta } from "@/misc/fetch-meta.js"; +import { fetchMeta } from "@/misc/backend-rs.js"; export const meta = { secure: true, diff --git a/packages/backend/src/server/api/endpoints/meta.ts b/packages/backend/src/server/api/endpoints/meta.ts index e0e839671..7b164be09 100644 --- a/packages/backend/src/server/api/endpoints/meta.ts +++ b/packages/backend/src/server/api/endpoints/meta.ts @@ -1,7 +1,7 @@ import JSON5 from "json5"; import { IsNull, MoreThan } from "typeorm"; import config from "@/config/index.js"; -import { fetchMeta } from "@/misc/fetch-meta.js"; +import { fetchMeta } from "@/misc/backend-rs.js"; 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"; diff --git a/packages/backend/src/server/api/endpoints/notes/global-timeline.ts b/packages/backend/src/server/api/endpoints/notes/global-timeline.ts index 018bfb724..7d8eb69ff 100644 --- a/packages/backend/src/server/api/endpoints/notes/global-timeline.ts +++ b/packages/backend/src/server/api/endpoints/notes/global-timeline.ts @@ -1,4 +1,4 @@ -import { fetchMeta } from "@/misc/fetch-meta.js"; +import { fetchMeta } from "@/misc/backend-rs.js"; import { Notes } from "@/models/index.js"; import { activeUsersChart } from "@/services/chart/index.js"; import define from "@/server/api/define.js"; diff --git a/packages/backend/src/server/api/endpoints/notes/hybrid-timeline.ts b/packages/backend/src/server/api/endpoints/notes/hybrid-timeline.ts index c9800f2e1..4ee4cf813 100644 --- a/packages/backend/src/server/api/endpoints/notes/hybrid-timeline.ts +++ b/packages/backend/src/server/api/endpoints/notes/hybrid-timeline.ts @@ -1,5 +1,5 @@ import { Brackets } from "typeorm"; -import { fetchMeta } from "@/misc/fetch-meta.js"; +import { fetchMeta } from "@/misc/backend-rs.js"; import { Followings, Notes } from "@/models/index.js"; import { activeUsersChart } from "@/services/chart/index.js"; import define from "@/server/api/define.js"; diff --git a/packages/backend/src/server/api/endpoints/notes/local-timeline.ts b/packages/backend/src/server/api/endpoints/notes/local-timeline.ts index 64ca37756..f037e6dd2 100644 --- a/packages/backend/src/server/api/endpoints/notes/local-timeline.ts +++ b/packages/backend/src/server/api/endpoints/notes/local-timeline.ts @@ -1,5 +1,5 @@ import { Brackets } from "typeorm"; -import { fetchMeta } from "@/misc/fetch-meta.js"; +import { fetchMeta } from "@/misc/backend-rs.js"; import { Notes } from "@/models/index.js"; import { activeUsersChart } from "@/services/chart/index.js"; import define from "@/server/api/define.js"; diff --git a/packages/backend/src/server/api/endpoints/notes/recommended-timeline.ts b/packages/backend/src/server/api/endpoints/notes/recommended-timeline.ts index 6840fa1a6..1ab6ba796 100644 --- a/packages/backend/src/server/api/endpoints/notes/recommended-timeline.ts +++ b/packages/backend/src/server/api/endpoints/notes/recommended-timeline.ts @@ -1,5 +1,5 @@ import { Brackets } from "typeorm"; -import { fetchMeta } from "@/misc/fetch-meta.js"; +import { fetchMeta } from "@/misc/backend-rs.js"; import { Notes } from "@/models/index.js"; import { activeUsersChart } from "@/services/chart/index.js"; import define from "@/server/api/define.js"; diff --git a/packages/backend/src/server/api/endpoints/pinned-users.ts b/packages/backend/src/server/api/endpoints/pinned-users.ts index 6d6519e47..afbd1dd0f 100644 --- a/packages/backend/src/server/api/endpoints/pinned-users.ts +++ b/packages/backend/src/server/api/endpoints/pinned-users.ts @@ -1,6 +1,6 @@ import { IsNull } from "typeorm"; import { Users } from "@/models/index.js"; -import { fetchMeta } from "@/misc/fetch-meta.js"; +import { fetchMeta } from "@/misc/backend-rs.js"; import { stringToAcct } from "backend-rs"; import type { User } from "@/models/entities/user.js"; import define from "@/server/api/define.js"; diff --git a/packages/backend/src/server/api/endpoints/recommended-instances.ts b/packages/backend/src/server/api/endpoints/recommended-instances.ts index b23567842..a33b93f86 100644 --- a/packages/backend/src/server/api/endpoints/recommended-instances.ts +++ b/packages/backend/src/server/api/endpoints/recommended-instances.ts @@ -1,5 +1,5 @@ // import { IsNull } from 'typeorm'; -import { fetchMeta } from "@/misc/fetch-meta.js"; +import { fetchMeta } from "@/misc/backend-rs.js"; import define from "@/server/api/define.js"; export const meta = { diff --git a/packages/backend/src/server/api/endpoints/server-info.ts b/packages/backend/src/server/api/endpoints/server-info.ts index 66208a12b..97ef2eb5b 100644 --- a/packages/backend/src/server/api/endpoints/server-info.ts +++ b/packages/backend/src/server/api/endpoints/server-info.ts @@ -2,7 +2,7 @@ import * as os from "node:os"; import si from "systeminformation"; import define from "@/server/api/define.js"; // import meilisearch from "@/db/meilisearch.js"; -import { fetchMeta } from "@/misc/fetch-meta.js"; +import { fetchMeta } from "@/misc/backend-rs.js"; export const meta = { requireCredential: false, diff --git a/packages/backend/src/server/api/endpoints/sw/register.ts b/packages/backend/src/server/api/endpoints/sw/register.ts index ee6b3bbf4..6dc5c7034 100644 --- a/packages/backend/src/server/api/endpoints/sw/register.ts +++ b/packages/backend/src/server/api/endpoints/sw/register.ts @@ -1,4 +1,4 @@ -import { fetchMeta } from "@/misc/fetch-meta.js"; +import { fetchMeta } from "@/misc/backend-rs.js"; import { genId } from "@/misc/gen-id.js"; import { SwSubscriptions } from "@/models/index.js"; import define from "@/server/api/define.js"; diff --git a/packages/backend/src/server/api/endpoints/users/report-abuse.ts b/packages/backend/src/server/api/endpoints/users/report-abuse.ts index 7e9ba7238..43f0ef816 100644 --- a/packages/backend/src/server/api/endpoints/users/report-abuse.ts +++ b/packages/backend/src/server/api/endpoints/users/report-abuse.ts @@ -4,7 +4,7 @@ import { publishAdminStream } from "@/services/stream.js"; import { AbuseUserReports, UserProfiles, Users } from "@/models/index.js"; import { genId } from "@/misc/gen-id.js"; import { sendEmail } from "@/services/send-email.js"; -import { fetchMeta } from "@/misc/fetch-meta.js"; +import { fetchMeta } from "@/misc/backend-rs.js"; import { getUser } from "@/server/api/common/getters.js"; import { ApiError } from "@/server/api/error.js"; import define from "@/server/api/define.js"; diff --git a/packages/backend/src/server/api/mastodon/endpoints/meta.ts b/packages/backend/src/server/api/mastodon/endpoints/meta.ts index c458798d5..868e216a2 100644 --- a/packages/backend/src/server/api/mastodon/endpoints/meta.ts +++ b/packages/backend/src/server/api/mastodon/endpoints/meta.ts @@ -1,6 +1,6 @@ import { Entity } from "megalodon"; import config from "@/config/index.js"; -import { fetchMeta } from "@/misc/fetch-meta.js"; +import { fetchMeta } from "@/misc/backend-rs.js"; import { MAX_NOTE_TEXT_LENGTH, FILE_TYPE_BROWSERSAFE } from "@/const.js"; export async function getInstance( diff --git a/packages/backend/src/server/api/mastodon/endpoints/status.ts b/packages/backend/src/server/api/mastodon/endpoints/status.ts index 801682873..c85a62bac 100644 --- a/packages/backend/src/server/api/mastodon/endpoints/status.ts +++ b/packages/backend/src/server/api/mastodon/endpoints/status.ts @@ -11,7 +11,7 @@ import { convertPoll, convertStatus, } from "../converters.js"; -import { fetchMeta } from "@/misc/fetch-meta.js"; +import { fetchMeta } from "@/misc/backend-rs.js"; function normalizeQuery(data: any) { const str = querystring.stringify(data); diff --git a/packages/backend/src/server/api/private/signup.ts b/packages/backend/src/server/api/private/signup.ts index b6e903b82..ea80badc0 100644 --- a/packages/backend/src/server/api/private/signup.ts +++ b/packages/backend/src/server/api/private/signup.ts @@ -1,6 +1,6 @@ import type Koa from "koa"; import rndstr from "rndstr"; -import { fetchMeta } from "@/misc/fetch-meta.js"; +import { fetchMeta } from "@/misc/backend-rs.js"; import { verifyHcaptcha, verifyRecaptcha } from "@/misc/captcha.js"; import { Users, RegistrationTickets, UserPendings } from "@/models/index.js"; import { signup } from "@/server/api/common/signup.js"; diff --git a/packages/backend/src/server/api/stream/channels/global-timeline.ts b/packages/backend/src/server/api/stream/channels/global-timeline.ts index 0bc82d094..3042f6423 100644 --- a/packages/backend/src/server/api/stream/channels/global-timeline.ts +++ b/packages/backend/src/server/api/stream/channels/global-timeline.ts @@ -1,5 +1,5 @@ import Channel from "../channel.js"; -import { fetchMeta } from "@/misc/fetch-meta.js"; +import { fetchMeta } from "@/misc/backend-rs.js"; import { getWordHardMute } from "@/misc/check-word-mute.js"; import { isInstanceMuted } from "@/misc/is-instance-muted.js"; import { isUserRelated } from "@/misc/is-user-related.js"; diff --git a/packages/backend/src/server/api/stream/channels/hybrid-timeline.ts b/packages/backend/src/server/api/stream/channels/hybrid-timeline.ts index 306b22ad2..83c01846c 100644 --- a/packages/backend/src/server/api/stream/channels/hybrid-timeline.ts +++ b/packages/backend/src/server/api/stream/channels/hybrid-timeline.ts @@ -1,5 +1,5 @@ import Channel from "../channel.js"; -import { fetchMeta } from "@/misc/fetch-meta.js"; +import { fetchMeta } from "@/misc/backend-rs.js"; import { getWordHardMute } from "@/misc/check-word-mute.js"; import { isUserRelated } from "@/misc/is-user-related.js"; import { isInstanceMuted } from "@/misc/is-instance-muted.js"; diff --git a/packages/backend/src/server/api/stream/channels/local-timeline.ts b/packages/backend/src/server/api/stream/channels/local-timeline.ts index 9ae116991..e3e484a9a 100644 --- a/packages/backend/src/server/api/stream/channels/local-timeline.ts +++ b/packages/backend/src/server/api/stream/channels/local-timeline.ts @@ -1,5 +1,5 @@ import Channel from "../channel.js"; -import { fetchMeta } from "@/misc/fetch-meta.js"; +import { fetchMeta } from "@/misc/backend-rs.js"; import { getWordHardMute } from "@/misc/check-word-mute.js"; import { isUserRelated } from "@/misc/is-user-related.js"; import type { Packed } from "@/misc/schema.js"; diff --git a/packages/backend/src/server/api/stream/channels/recommended-timeline.ts b/packages/backend/src/server/api/stream/channels/recommended-timeline.ts index 12dab8c29..a74c44a8a 100644 --- a/packages/backend/src/server/api/stream/channels/recommended-timeline.ts +++ b/packages/backend/src/server/api/stream/channels/recommended-timeline.ts @@ -1,5 +1,5 @@ import Channel from "../channel.js"; -import { fetchMeta } from "@/misc/fetch-meta.js"; +import { fetchMeta } from "@/misc/backend-rs.js"; import { getWordHardMute } from "@/misc/check-word-mute.js"; import { isUserRelated } from "@/misc/is-user-related.js"; import { isInstanceMuted } from "@/misc/is-instance-muted.js"; diff --git a/packages/backend/src/server/index.ts b/packages/backend/src/server/index.ts index e6f015575..f213f7709 100644 --- a/packages/backend/src/server/index.ts +++ b/packages/backend/src/server/index.ts @@ -16,7 +16,7 @@ import { IsNull } from "typeorm"; import config from "@/config/index.js"; import Logger from "@/services/logger.js"; import { Users } from "@/models/index.js"; -import { fetchMeta } from "@/misc/fetch-meta.js"; +import { fetchMeta } from "@/misc/backend-rs.js"; import { genIdenticon } from "@/misc/gen-identicon.js"; import { createTemp } from "@/misc/create-temp.js"; import { stringToAcct } from "backend-rs"; diff --git a/packages/backend/src/server/nodeinfo.ts b/packages/backend/src/server/nodeinfo.ts index 82288428c..2389518cb 100644 --- a/packages/backend/src/server/nodeinfo.ts +++ b/packages/backend/src/server/nodeinfo.ts @@ -1,6 +1,6 @@ import Router from "@koa/router"; import config from "@/config/index.js"; -import { fetchMeta } from "@/misc/fetch-meta.js"; +import { fetchMeta } from "@/misc/backend-rs.js"; import { Users, Notes } from "@/models/index.js"; import { IsNull, MoreThan } from "typeorm"; import { MAX_NOTE_TEXT_LENGTH, MAX_CAPTION_TEXT_LENGTH } from "@/const.js"; diff --git a/packages/backend/src/server/web/index.ts b/packages/backend/src/server/web/index.ts index 039718714..b36b8485b 100644 --- a/packages/backend/src/server/web/index.ts +++ b/packages/backend/src/server/web/index.ts @@ -16,7 +16,8 @@ import { BullAdapter } from "@bull-board/api/bullAdapter.js"; import { KoaAdapter } from "@bull-board/koa"; import { In, IsNull } from "typeorm"; -import { fetchMeta, metaToPugArgs } from "@/misc/fetch-meta.js"; +import { fetchMeta } from "@/misc/backend-rs.js"; +import { metaToPugArgs } from "backend-rs"; import config from "@/config/index.js"; import { Users, diff --git a/packages/backend/src/server/web/manifest.ts b/packages/backend/src/server/web/manifest.ts index bbcf639ff..751164903 100644 --- a/packages/backend/src/server/web/manifest.ts +++ b/packages/backend/src/server/web/manifest.ts @@ -1,5 +1,5 @@ import type Koa from "koa"; -import { fetchMeta } from "@/misc/fetch-meta.js"; +import { fetchMeta } from "@/misc/backend-rs.js"; import config from "@/config/index.js"; import manifest from "./manifest.json" assert { type: "json" }; diff --git a/packages/backend/src/server/web/url-preview.ts b/packages/backend/src/server/web/url-preview.ts index c9f3b6cac..3577a3e04 100644 --- a/packages/backend/src/server/web/url-preview.ts +++ b/packages/backend/src/server/web/url-preview.ts @@ -1,6 +1,6 @@ import type Koa from "koa"; import summaly from "summaly"; -import { fetchMeta } from "@/misc/fetch-meta.js"; +import { fetchMeta } from "@/misc/backend-rs.js"; import Logger from "@/services/logger.js"; import config from "@/config/index.js"; import { query } from "@/prelude/url.js"; diff --git a/packages/backend/src/server/web/views/base.pug b/packages/backend/src/server/web/views/base.pug index a778fbf91..ad1bbeec5 100644 --- a/packages/backend/src/server/web/views/base.pug +++ b/packages/backend/src/server/web/views/base.pug @@ -72,8 +72,8 @@ html div#splash img#splashIcon(src= splashIcon || `/static-assets/splash.svg?${ timestamp }`) span#splashText - block randomMOTD - = randomMOTD + block randomMotd + = randomMotd div#splashSpinner diff --git a/packages/backend/src/services/drive/add-file.ts b/packages/backend/src/services/drive/add-file.ts index 3071e0abf..8f25c095d 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 "@/misc/fetch-meta.js"; +import { fetchMeta } from "@/misc/backend-rs.js"; import { contentDisposition } from "@/misc/content-disposition.js"; import { getFileInfo } from "@/misc/get-file-info.js"; import { diff --git a/packages/backend/src/services/drive/delete-file.ts b/packages/backend/src/services/drive/delete-file.ts index b172c7d9b..3b597baeb 100644 --- a/packages/backend/src/services/drive/delete-file.ts +++ b/packages/backend/src/services/drive/delete-file.ts @@ -2,7 +2,7 @@ import type { DriveFile } from "@/models/entities/drive-file.js"; import { InternalStorage } from "./internal-storage.js"; import { DriveFiles } from "@/models/index.js"; import { createDeleteObjectStorageFileJob } from "@/queue/index.js"; -import { fetchMeta } from "@/misc/fetch-meta.js"; +import { fetchMeta } from "@/misc/backend-rs.js"; import { getS3 } from "./s3.js"; import { v4 as uuid } from "uuid"; diff --git a/packages/backend/src/services/push-notification.ts b/packages/backend/src/services/push-notification.ts index a207fae39..1f1827e1f 100644 --- a/packages/backend/src/services/push-notification.ts +++ b/packages/backend/src/services/push-notification.ts @@ -1,7 +1,7 @@ import push from "web-push"; import config from "@/config/index.js"; import { SwSubscriptions } from "@/models/index.js"; -import { fetchMeta } from "@/misc/fetch-meta.js"; +import { fetchMeta } from "@/misc/backend-rs.js"; import type { Packed } from "@/misc/schema.js"; import { getNoteSummary } from "@/misc/get-note-summary.js"; diff --git a/packages/backend/src/services/send-email.ts b/packages/backend/src/services/send-email.ts index fd8f7328b..7497e8c72 100644 --- a/packages/backend/src/services/send-email.ts +++ b/packages/backend/src/services/send-email.ts @@ -1,5 +1,5 @@ import * as nodemailer from "nodemailer"; -import { fetchMeta } from "@/misc/fetch-meta.js"; +import { fetchMeta } from "@/misc/backend-rs.js"; import Logger from "@/services/logger.js"; import config from "@/config/index.js"; diff --git a/packages/backend/src/services/validate-email-for-account.ts b/packages/backend/src/services/validate-email-for-account.ts index 535a389f0..67e01597c 100644 --- a/packages/backend/src/services/validate-email-for-account.ts +++ b/packages/backend/src/services/validate-email-for-account.ts @@ -1,6 +1,6 @@ import { validate as validateEmail } from "deep-email-validator"; import { UserProfiles } from "@/models/index.js"; -import { fetchMeta } from "@/misc/fetch-meta.js"; +import { fetchMeta } from "@/misc/backend-rs.js"; export async function validateEmailForAccount(emailAddress: string): Promise<{ available: boolean;