From b37448e608f8239836c479acdb4e9fce530f5cb0 Mon Sep 17 00:00:00 2001 From: naskya Date: Thu, 25 Jul 2024 01:31:17 +0900 Subject: [PATCH 01/43] container: simplify container build steps This reduces the cache hit rate, but caches are invalidated so often that I don't think it matters --- .dockerignore | 2 ++ Dockerfile | 56 +++++++++++++-------------------------------------- 2 files changed, 16 insertions(+), 42 deletions(-) diff --git a/.dockerignore b/.dockerignore index d4c11934d1..334516810a 100644 --- a/.dockerignore +++ b/.dockerignore @@ -40,6 +40,7 @@ packages/backend/assets/instance.css .gitattributes .weblate animated.svg +compose.yml docker-compose.yml docker-compose.example.yml title.svg @@ -48,6 +49,7 @@ title.svg /dev /docs /scripts +!/scripts/copy-index.mjs !/scripts/copy-assets.mjs biome.json CODE_OF_CONDUCT.md diff --git a/Dockerfile b/Dockerfile index 26e3446fbc..f9087b93b3 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,56 +1,28 @@ -## Install dev and compilation dependencies, build files -FROM docker.io/node:20-alpine as build +# Install dev and compilation dependencies, build files +FROM docker.io/node:20-alpine AS build WORKDIR /firefish -# Copy only backend-rs pnpm-related files first, to cache efficiently -COPY package.json pnpm-workspace.yaml ./ -COPY packages/backend-rs/package.json packages/backend-rs/package.json - -# Install compilation dependencies +# Install build tools and work around the linker name issue RUN apk update && apk add --no-cache build-base linux-headers curl ca-certificates python3 perl +RUN ln -s $(which gcc) /usr/bin/aarch64-linux-musl-gcc + +# Install Rust toolchain RUN curl --proto '=https' --tlsv1.2 --silent --show-error --fail https://sh.rustup.rs | sh -s -- -y ENV PATH="/root/.cargo/bin:${PATH}" -# Copy only backend-rs dependency-related files first, to cache efficiently -COPY packages/macro-rs packages/macro-rs/ -COPY packages/backend-rs/src/lib.rs packages/backend-rs/src/ -COPY packages/backend-rs/Cargo.toml packages/backend-rs/Cargo.toml -COPY Cargo.toml Cargo.lock ./ +# Configure pnpm +RUN corepack enable && corepack prepare pnpm@latest --activate -# Configure pnpm, and install backend-rs dependencies -RUN corepack enable && corepack prepare pnpm@latest --activate && pnpm --filter backend-rs install -RUN cargo fetch --locked --manifest-path Cargo.toml - -# Copy in the rest of the rust files -COPY packages/backend-rs packages/backend-rs/ - -# Compile backend-rs -RUN ln -s $(which gcc) /usr/bin/aarch64-linux-musl-gcc -RUN NODE_ENV='production' NODE_OPTIONS='--max_old_space_size=3072' pnpm run --filter backend-rs build - -# Copy/Overwrite index.js to mitigate the bug in napi-rs codegen -COPY packages/backend-rs/index.js packages/backend-rs/built/index.js - -# Copy only the dependency-related files first, to cache efficiently -COPY packages/backend/package.json packages/backend/package.json -COPY packages/client/package.json packages/client/package.json -COPY packages/sw/package.json packages/sw/package.json -COPY packages/firefish-js/package.json packages/firefish-js/package.json -COPY pnpm-lock.yaml ./ - -# Install dev mode dependencies for compilation -RUN pnpm install --frozen-lockfile - -# Copy in the rest of the files to build +# Build COPY . ./ - -# Build other workspaces -RUN NODE_ENV='production' NODE_OPTIONS='--max_old_space_size=3072' pnpm run --recursive --filter '!backend-rs' build && pnpm run build:assets +RUN pnpm install --frozen-lockfile +RUN cargo fetch --locked --manifest-path Cargo.toml +RUN NODE_ENV='production' NODE_OPTIONS='--max_old_space_size=3072' pnpm run build # Trim down the dependencies to only those for production RUN find . -path '*/node_modules/*' -delete && pnpm install --prod --frozen-lockfile -## Runtime container +# Runtime container FROM docker.io/node:20-alpine WORKDIR /firefish @@ -66,7 +38,7 @@ COPY --from=build /firefish/packages/backend/node_modules /firefish/packages/bac # COPY --from=build /firefish/packages/client/node_modules /firefish/packages/client/node_modules COPY --from=build /firefish/packages/firefish-js/node_modules /firefish/packages/firefish-js/node_modules -# Copy the finished compiled files +# Copy the build artifacts COPY --from=build /firefish/built /firefish/built COPY --from=build /firefish/packages/backend/built /firefish/packages/backend/built COPY --from=build /firefish/packages/backend/assets/instance.css /firefish/packages/backend/assets/instance.css From 9f97d899fa278ebc47810fb8b173ab30d630bd72 Mon Sep 17 00:00:00 2001 From: GitLab CI Date: Wed, 24 Jul 2024 20:06:06 +0000 Subject: [PATCH 02/43] chore(deps): update rust crate emojis to 0.6.3 --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 88b6db1a06..e54fd29b98 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -871,9 +871,9 @@ dependencies = [ [[package]] name = "emojis" -version = "0.6.2" +version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9f619a926616ae7149a0d82610b051134a0d6c4ae2962d990c06c847a445c5d9" +checksum = "e72f23d65b46527e461b161ab9a126c378aa2249d8a8d15718d23ab1fb4d8786" dependencies = [ "phf", ] diff --git a/Cargo.toml b/Cargo.toml index 2cf48527f2..f5ff08b03d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -22,7 +22,7 @@ bcrypt = { version = "0.15.1", default-features = false } chrono = { version = "0.4.38", default-features = false } convert_case = { version = "0.6.0", default-features = false } cuid2 = { version = "0.1.2", default-features = false } -emojis = { version = "0.6.2", default-features = false } +emojis = { version = "0.6.3", default-features = false } idna = { version = "1.0.2", default-features = false } image = { version = "0.25.2", default-features = false } isahc = { version = "1.7.2", default-features = false } From 9d22f9f87ab969b356c7eac0010804d7e3b9e09f Mon Sep 17 00:00:00 2001 From: GitLab CI Date: Wed, 24 Jul 2024 20:06:56 +0000 Subject: [PATCH 03/43] chore(deps): update vue monorepo to v3.4.34 --- packages/client/package.json | 4 +- pnpm-lock.yaml | 134 +++++++++++++++++++++-------------- 2 files changed, 81 insertions(+), 57 deletions(-) diff --git a/packages/client/package.json b/packages/client/package.json index 3827866669..670e6b8f28 100644 --- a/packages/client/package.json +++ b/packages/client/package.json @@ -34,7 +34,7 @@ "@types/tinycolor2": "1.4.6", "@types/uuid": "10.0.0", "@vitejs/plugin-vue": "5.1.0", - "@vue/runtime-core": "3.4.33", + "@vue/runtime-core": "3.4.34", "autobind-decorator": "2.4.0", "autosize": "6.0.1", "broadcast-channel": "7.0.0", @@ -85,7 +85,7 @@ "uuid": "10.0.0", "vite": "5.3.4", "vite-plugin-compression": "0.5.1", - "vue": "3.4.33", + "vue": "3.4.34", "vue-draggable-plus": "0.5.2", "vue-plyr": "7.0.0", "vue-prism-editor": "2.0.0-alpha.2", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index b382641a86..0f21d525af 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -558,10 +558,10 @@ importers: version: 10.0.0 '@vitejs/plugin-vue': specifier: 5.1.0 - version: 5.1.0(vite@5.3.4(@types/node@20.14.12)(sass@1.77.8)(terser@5.31.3))(vue@3.4.33(typescript@5.5.4)) + version: 5.1.0(vite@5.3.4(@types/node@20.14.12)(sass@1.77.8)(terser@5.31.3))(vue@3.4.34(typescript@5.5.4)) '@vue/runtime-core': - specifier: 3.4.33 - version: 3.4.33 + specifier: 3.4.34 + version: 3.4.34 autobind-decorator: specifier: 2.4.0 version: 2.4.0 @@ -618,7 +618,7 @@ importers: version: 7.5.4 focus-trap-vue: specifier: 4.0.3 - version: 4.0.3(focus-trap@7.5.4)(vue@3.4.33(typescript@5.5.4)) + version: 4.0.3(focus-trap@7.5.4)(vue@3.4.34(typescript@5.5.4)) gsap: specifier: 3.12.5 version: 3.12.5 @@ -713,8 +713,8 @@ importers: specifier: 0.5.1 version: 0.5.1(vite@5.3.4(@types/node@20.14.12)(sass@1.77.8)(terser@5.31.3)) vue: - specifier: 3.4.33 - version: 3.4.33(typescript@5.5.4) + specifier: 3.4.34 + version: 3.4.34(typescript@5.5.4) vue-draggable-plus: specifier: 0.5.2 version: 0.5.2(@types/sortablejs@1.15.8) @@ -723,7 +723,7 @@ importers: version: 7.0.0 vue-prism-editor: specifier: 2.0.0-alpha.2 - version: 2.0.0-alpha.2(vue@3.4.33(typescript@5.5.4)) + version: 2.0.0-alpha.2(vue@3.4.34(typescript@5.5.4)) vue-tsc: specifier: 2.0.28 version: 2.0.28(typescript@5.5.4) @@ -2627,17 +2627,23 @@ packages: '@vue/compiler-core@3.4.33': resolution: {integrity: sha512-MoIREbkdPQlnGfSKDMgzTqzqx5nmEjIc0ydLVYlTACGBsfvOJ4tHSbZXKVF536n6fB+0eZaGEOqsGThPpdvF5A==} + '@vue/compiler-core@3.4.34': + resolution: {integrity: sha512-Z0izUf32+wAnQewjHu+pQf1yw00EGOmevl1kE+ljjjMe7oEfpQ+BI3/JNK7yMB4IrUsqLDmPecUrpj3mCP+yJQ==} + '@vue/compiler-dom@3.4.33': resolution: {integrity: sha512-GzB8fxEHKw0gGet5BKlpfXEqoBnzSVWwMnT+dc25wE7pFEfrU/QsvjZMP9rD4iVXHBBoemTct8mN0GJEI6ZX5A==} + '@vue/compiler-dom@3.4.34': + resolution: {integrity: sha512-3PUOTS1h5cskdOJMExCu2TInXuM0j60DRPpSCJDqOCupCfUZCJoyQmKtRmA8EgDNZ5kcEE7vketamRZfrEuVDw==} + '@vue/compiler-sfc@2.7.16': resolution: {integrity: sha512-KWhJ9k5nXuNtygPU7+t1rX6baZeqOYLEforUPjgNDBnLicfHCoi48H87Q8XyLZOrNNsmhuwKqtpDQWjEFe6Ekg==} - '@vue/compiler-sfc@3.4.33': - resolution: {integrity: sha512-7rk7Vbkn21xMwIUpHQR4hCVejwE6nvhBOiDgoBcR03qvGqRKA7dCBSsHZhwhYUsmjlbJ7OtD5UFIyhP6BY+c8A==} + '@vue/compiler-sfc@3.4.34': + resolution: {integrity: sha512-x6lm0UrM03jjDXTPZgD9Ad8bIVD1ifWNit2EaWQIZB5CULr46+FbLQ5RpK7AXtDHGjx9rmvC7QRCTjsiGkAwRw==} - '@vue/compiler-ssr@3.4.33': - resolution: {integrity: sha512-0WveC9Ai+eT/1b6LCV5IfsufBZ0HP7pSSTdDjcuW302tTEgoBw8rHVHKPbGUtzGReUFCRXbv6zQDDgucnV2WzQ==} + '@vue/compiler-ssr@3.4.34': + resolution: {integrity: sha512-8TDBcLaTrFm5rnF+Qm4BlliaopJgqJ28Nsrc80qazynm5aJO+Emu7y0RWw34L8dNnTRdcVBpWzJxhGYzsoVu4g==} '@vue/language-core@2.0.28': resolution: {integrity: sha512-0z4tyCCaqqPbdyz0T4yTFQeLpCo4TOM/ZHAC3geGLHeCiFAjVbROB9PiEtrXR1AoLObqUPFHSmKZeWtEMssSqw==} @@ -2647,23 +2653,26 @@ packages: typescript: optional: true - '@vue/reactivity@3.4.33': - resolution: {integrity: sha512-B24QIelahDbyHipBgbUItQblbd4w5HpG3KccL+YkGyo3maXyS253FzcTR3pSz739OTphmzlxP7JxEMWBpewilA==} + '@vue/reactivity@3.4.34': + resolution: {integrity: sha512-ua+Lo+wBRlBEX9TtgPOShE2JwIO7p6BTZ7t1KZVPoaBRfqbC7N3c8Mpzicx173fXxx5VXeU6ykiHo7WgLzJQDA==} - '@vue/runtime-core@3.4.33': - resolution: {integrity: sha512-6wavthExzT4iAxpe8q37/rDmf44nyOJGISJPxCi9YsQO+8w9v0gLCFLfH5TzD1V1AYrTAdiF4Y1cgUmP68jP6w==} + '@vue/runtime-core@3.4.34': + resolution: {integrity: sha512-PXhkiRPwcPGJ1BnyBZFI96GfInCVskd0HPNIAZn7i3YOmLbtbTZpB7/kDTwC1W7IqdGPkTVC63IS7J2nZs4Ebg==} - '@vue/runtime-dom@3.4.33': - resolution: {integrity: sha512-iHsMCUSFJ+4z432Bn9kZzHX+zOXa6+iw36DaVRmKYZpPt9jW9riF32SxNwB124i61kp9+AZtheQ/mKoJLerAaQ==} + '@vue/runtime-dom@3.4.34': + resolution: {integrity: sha512-dXqIe+RqFAK2Euak4UsvbIupalrhc67OuQKpD7HJ3W2fv8jlqvI7szfBCsAEcE8o/wyNpkloxB6J8viuF/E3gw==} - '@vue/server-renderer@3.4.33': - resolution: {integrity: sha512-jTH0d6gQcaYideFP/k0WdEu8PpRS9MF8d0b6SfZzNi+ap972pZ0TNIeTaESwdOtdY0XPVj54XEJ6K0wXxir4fw==} + '@vue/server-renderer@3.4.34': + resolution: {integrity: sha512-GeyEUfMVRZMD/mZcNONEqg7MiU10QQ1DB3O/Qr6+8uXpbwdlmVgQ5Qs1/ZUAFX1X2UUtqMoGrDRbxdWfOJFT7Q==} peerDependencies: - vue: 3.4.33 + vue: 3.4.34 '@vue/shared@3.4.33': resolution: {integrity: sha512-aoRY0jQk3A/cuvdkodTrM4NMfxco8n55eG4H7ML/CRy7OryHfiqvug4xrCBBMbbN+dvXAetDDwZW9DXWWjBntA==} + '@vue/shared@3.4.34': + resolution: {integrity: sha512-x5LmiRLpRsd9KTjAB8MPKf0CDPMcuItjP0gbNqFCIgL1I8iYp4zglhj9w9FPCdIbHG2M91RVeIbArFfFTz9I3A==} + '@webassemblyjs/ast@1.12.1': resolution: {integrity: sha512-EKfMUOPRRUTy5UII4qJDGPpqfwjOmZ5jeGFwid9mnoqIFK+e0vqoi1qH56JpmZSzEL53jKnNzScdmftJyG5xWg==} @@ -6667,8 +6676,8 @@ packages: resolution: {integrity: sha512-4gCtFXaAA3zYZdTp5s4Hl2sozuySsgz4jy1EnpBHNfpMa9dK1ZCG7viqBPCwXtmgc8nHqUsAu3G4gtmXkkY3Sw==} deprecated: Vue 2 has reached EOL and is no longer actively maintained. See https://v2.vuejs.org/eol/ for more details. - vue@3.4.33: - resolution: {integrity: sha512-VdMCWQOummbhctl4QFMcW6eNtXHsFyDlX60O/tsSQuCcuDOnJ1qPOhhVla65Niece7xq/P2zyZReIO5mP+LGTQ==} + vue@3.4.34: + resolution: {integrity: sha512-VZze05HWlA3ItreQ/ka7Sx7PoD0/3St8FEiSlSTVgb6l4hL+RjtP2/8g5WQBzZgyf8WG2f+g1bXzC7zggLhAJA==} peerDependencies: typescript: '*' peerDependenciesMeta: @@ -8719,10 +8728,10 @@ snapshots: dependencies: '@types/yargs-parser': 21.0.3 - '@vitejs/plugin-vue@5.1.0(vite@5.3.4(@types/node@20.14.12)(sass@1.77.8)(terser@5.31.3))(vue@3.4.33(typescript@5.5.4))': + '@vitejs/plugin-vue@5.1.0(vite@5.3.4(@types/node@20.14.12)(sass@1.77.8)(terser@5.31.3))(vue@3.4.34(typescript@5.5.4))': dependencies: vite: 5.3.4(@types/node@20.14.12)(sass@1.77.8)(terser@5.31.3) - vue: 3.4.33(typescript@5.5.4) + vue: 3.4.34(typescript@5.5.4) '@volar/language-core@2.4.0-alpha.18': dependencies: @@ -8744,11 +8753,24 @@ snapshots: estree-walker: 2.0.2 source-map-js: 1.2.0 + '@vue/compiler-core@3.4.34': + dependencies: + '@babel/parser': 7.24.8 + '@vue/shared': 3.4.34 + entities: 4.5.0 + estree-walker: 2.0.2 + source-map-js: 1.2.0 + '@vue/compiler-dom@3.4.33': dependencies: '@vue/compiler-core': 3.4.33 '@vue/shared': 3.4.33 + '@vue/compiler-dom@3.4.34': + dependencies: + '@vue/compiler-core': 3.4.34 + '@vue/shared': 3.4.34 + '@vue/compiler-sfc@2.7.16': dependencies: '@babel/parser': 7.24.8 @@ -8757,22 +8779,22 @@ snapshots: optionalDependencies: prettier: 2.8.8 - '@vue/compiler-sfc@3.4.33': + '@vue/compiler-sfc@3.4.34': dependencies: '@babel/parser': 7.24.8 - '@vue/compiler-core': 3.4.33 - '@vue/compiler-dom': 3.4.33 - '@vue/compiler-ssr': 3.4.33 - '@vue/shared': 3.4.33 + '@vue/compiler-core': 3.4.34 + '@vue/compiler-dom': 3.4.34 + '@vue/compiler-ssr': 3.4.34 + '@vue/shared': 3.4.34 estree-walker: 2.0.2 magic-string: 0.30.10 postcss: 8.4.39 source-map-js: 1.2.0 - '@vue/compiler-ssr@3.4.33': + '@vue/compiler-ssr@3.4.34': dependencies: - '@vue/compiler-dom': 3.4.33 - '@vue/shared': 3.4.33 + '@vue/compiler-dom': 3.4.34 + '@vue/shared': 3.4.34 '@vue/language-core@2.0.28(typescript@5.5.4)': dependencies: @@ -8787,30 +8809,32 @@ snapshots: optionalDependencies: typescript: 5.5.4 - '@vue/reactivity@3.4.33': + '@vue/reactivity@3.4.34': dependencies: - '@vue/shared': 3.4.33 + '@vue/shared': 3.4.34 - '@vue/runtime-core@3.4.33': + '@vue/runtime-core@3.4.34': dependencies: - '@vue/reactivity': 3.4.33 - '@vue/shared': 3.4.33 + '@vue/reactivity': 3.4.34 + '@vue/shared': 3.4.34 - '@vue/runtime-dom@3.4.33': + '@vue/runtime-dom@3.4.34': dependencies: - '@vue/reactivity': 3.4.33 - '@vue/runtime-core': 3.4.33 - '@vue/shared': 3.4.33 + '@vue/reactivity': 3.4.34 + '@vue/runtime-core': 3.4.34 + '@vue/shared': 3.4.34 csstype: 3.1.3 - '@vue/server-renderer@3.4.33(vue@3.4.33(typescript@5.5.4))': + '@vue/server-renderer@3.4.34(vue@3.4.34(typescript@5.5.4))': dependencies: - '@vue/compiler-ssr': 3.4.33 - '@vue/shared': 3.4.33 - vue: 3.4.33(typescript@5.5.4) + '@vue/compiler-ssr': 3.4.34 + '@vue/shared': 3.4.34 + vue: 3.4.34(typescript@5.5.4) '@vue/shared@3.4.33': {} + '@vue/shared@3.4.34': {} + '@webassemblyjs/ast@1.12.1': dependencies: '@webassemblyjs/helper-numbers': 1.11.6 @@ -10132,10 +10156,10 @@ snapshots: async: 0.2.10 which: 1.3.1 - focus-trap-vue@4.0.3(focus-trap@7.5.4)(vue@3.4.33(typescript@5.5.4)): + focus-trap-vue@4.0.3(focus-trap@7.5.4)(vue@3.4.34(typescript@5.5.4)): dependencies: focus-trap: 7.5.4 - vue: 3.4.33(typescript@5.5.4) + vue: 3.4.34(typescript@5.5.4) focus-trap@7.5.4: dependencies: @@ -13008,9 +13032,9 @@ snapshots: plyr: https://codeload.github.com/sampotts/plyr/tar.gz/d434c9af16e641400aaee93188594208d88f2658 vue: 2.7.16 - vue-prism-editor@2.0.0-alpha.2(vue@3.4.33(typescript@5.5.4)): + vue-prism-editor@2.0.0-alpha.2(vue@3.4.34(typescript@5.5.4)): dependencies: - vue: 3.4.33(typescript@5.5.4) + vue: 3.4.34(typescript@5.5.4) vue-template-compiler@2.7.16: dependencies: @@ -13029,13 +13053,13 @@ snapshots: '@vue/compiler-sfc': 2.7.16 csstype: 3.1.3 - vue@3.4.33(typescript@5.5.4): + vue@3.4.34(typescript@5.5.4): dependencies: - '@vue/compiler-dom': 3.4.33 - '@vue/compiler-sfc': 3.4.33 - '@vue/runtime-dom': 3.4.33 - '@vue/server-renderer': 3.4.33(vue@3.4.33(typescript@5.5.4)) - '@vue/shared': 3.4.33 + '@vue/compiler-dom': 3.4.34 + '@vue/compiler-sfc': 3.4.34 + '@vue/runtime-dom': 3.4.34 + '@vue/server-renderer': 3.4.34(vue@3.4.34(typescript@5.5.4)) + '@vue/shared': 3.4.34 optionalDependencies: typescript: 5.5.4 From 8e88fbdbc471665216d61040de2e21d231fdf016 Mon Sep 17 00:00:00 2001 From: GitLab CI Date: Wed, 24 Jul 2024 20:07:29 +0000 Subject: [PATCH 04/43] fix(deps): update dependency aws-sdk to v2.1663.0 --- packages/backend/package.json | 2 +- pnpm-lock.yaml | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/backend/package.json b/packages/backend/package.json index 2355f2d62f..2557e1f14e 100644 --- a/packages/backend/package.json +++ b/packages/backend/package.json @@ -33,7 +33,7 @@ "archiver": "7.0.1", "async-lock": "1.4.1", "async-mutex": "0.5.0", - "aws-sdk": "2.1662.0", + "aws-sdk": "2.1663.0", "axios": "1.7.2", "backend-rs": "workspace:*", "blurhash": "2.0.5", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index b382641a86..8ca88ca3e9 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -88,8 +88,8 @@ importers: specifier: 0.5.0 version: 0.5.0 aws-sdk: - specifier: 2.1662.0 - version: 2.1662.0 + specifier: 2.1663.0 + version: 2.1663.0 axios: specifier: 1.7.2 version: 1.7.2 @@ -2871,8 +2871,8 @@ packages: resolution: {integrity: sha512-wvUjBtSGN7+7SjNpq/9M2Tg350UZD3q62IFZLbRAR1bSMlCo1ZaeW+BJ+D090e4hIIZLBcTDWe4Mh4jvUDajzQ==} engines: {node: '>= 0.4'} - aws-sdk@2.1662.0: - resolution: {integrity: sha512-ISKN3yxjQtjIMOBU2b3zO8Qrxd9UqdYlJlxSQUn5/4jfqCSad/s1mF66Cwzl5UByJtvFn0xoJORIZ7K6BTLuuw==} + aws-sdk@2.1663.0: + resolution: {integrity: sha512-zgXHOw0sBhYcw/yC2YKPLEMNTLnglYLB5UzhAYYShFgOng2NvxkrkuqGFFQ9+haMx2zx6t6CgeqQ7nT0TFUf/g==} engines: {node: '>= 10.0.0'} axios@0.24.0: @@ -9033,7 +9033,7 @@ snapshots: dependencies: possible-typed-array-names: 1.0.0 - aws-sdk@2.1662.0: + aws-sdk@2.1663.0: dependencies: buffer: 4.9.2 events: 1.1.1 From 7d2e98963d202caef8c679444cb42e5e76c4be12 Mon Sep 17 00:00:00 2001 From: naskya Date: Thu, 25 Jul 2024 06:39:40 +0900 Subject: [PATCH 05/43] refactor (backend): port publishNoteUpdatesStream to backend-rs --- packages/backend-rs/index.d.ts | 2 ++ packages/backend-rs/index.js | 1 + packages/backend-rs/src/service/stream.rs | 3 +++ .../backend-rs/src/service/stream/note_edit.rs | 18 ++++++++++++++++++ packages/backend/src/const.ts | 1 - .../server/api/endpoints/notes/translate.ts | 6 +----- .../backend/src/services/drive/add-file.ts | 6 +----- packages/backend/src/services/note/edit.ts | 9 +++------ packages/backend/src/services/stream.ts | 17 +++++++++-------- 9 files changed, 38 insertions(+), 25 deletions(-) create mode 100644 packages/backend-rs/src/service/stream/note_edit.rs diff --git a/packages/backend-rs/index.d.ts b/packages/backend-rs/index.d.ts index 3385d524a0..63d845f587 100644 --- a/packages/backend-rs/index.d.ts +++ b/packages/backend-rs/index.d.ts @@ -1117,6 +1117,8 @@ export declare function publishToModerationStream(moderatorId: string, report: A export declare function publishToNotesStream(note: Note): Promise +export declare function publishToNoteUpdatesStream(note: Note): Promise + export interface PugArgs { img: string | null title: string diff --git a/packages/backend-rs/index.js b/packages/backend-rs/index.js index 4d6d72e1cb..673bdc8d52 100644 --- a/packages/backend-rs/index.js +++ b/packages/backend-rs/index.js @@ -424,6 +424,7 @@ module.exports.publishToDriveFolderStream = nativeBinding.publishToDriveFolderSt module.exports.publishToGroupChatStream = nativeBinding.publishToGroupChatStream module.exports.publishToModerationStream = nativeBinding.publishToModerationStream module.exports.publishToNotesStream = nativeBinding.publishToNotesStream +module.exports.publishToNoteUpdatesStream = nativeBinding.publishToNoteUpdatesStream module.exports.PushNotificationKind = nativeBinding.PushNotificationKind module.exports.PushSubscriptionType = nativeBinding.PushSubscriptionType module.exports.RelayStatus = nativeBinding.RelayStatus diff --git a/packages/backend-rs/src/service/stream.rs b/packages/backend-rs/src/service/stream.rs index d1acbfa4a7..cd386e7115 100644 --- a/packages/backend-rs/src/service/stream.rs +++ b/packages/backend-rs/src/service/stream.rs @@ -6,6 +6,7 @@ pub mod custom_emoji; pub mod drive; pub mod group_chat; pub mod moderation; +pub mod note_edit; pub mod notes; use crate::{ @@ -30,6 +31,7 @@ pub enum Stream { note_id: String, }, Notes, + NoteEdit, UserList { list_id: String, }, @@ -86,6 +88,7 @@ pub async fn publish_to_stream( Stream::User { user_id } => format!("user:{user_id}"), Stream::Channel { channel_id } => format!("channelStream:{channel_id}"), Stream::Note { note_id } => format!("noteStream:{note_id}"), + Stream::NoteEdit => format!("noteUpdatesStream"), Stream::Notes => "notesStream".to_owned(), Stream::UserList { list_id } => format!("userListStream:{list_id}"), Stream::Main { user_id } => format!("mainStream:{user_id}"), diff --git a/packages/backend-rs/src/service/stream/note_edit.rs b/packages/backend-rs/src/service/stream/note_edit.rs new file mode 100644 index 0000000000..3b54a35359 --- /dev/null +++ b/packages/backend-rs/src/service/stream/note_edit.rs @@ -0,0 +1,18 @@ +use crate::{ + model::entity::note, + service::stream::{publish_to_stream, Error, Stream}, +}; + +// for napi export +// https://github.com/napi-rs/napi-rs/issues/2060 +type Note = note::Model; + +#[macros::export(js_name = "publishToNoteUpdatesStream")] +pub async fn publish(note: &Note) -> Result<(), Error> { + publish_to_stream( + &Stream::NoteEdit, + Some("updated"), + Some(serde_json::to_string(note)?), + ) + .await +} diff --git a/packages/backend/src/const.ts b/packages/backend/src/const.ts index fee1e3e1ea..78aafc3075 100644 --- a/packages/backend/src/const.ts +++ b/packages/backend/src/const.ts @@ -18,7 +18,6 @@ export const DB_MAX_NOTE_TEXT_LENGTH = 100000; */ export const DB_MAX_IMAGE_COMMENT_LENGTH = 8192; - export const MAX_NOTE_TEXT_LENGTH = Math.min( config.maxNoteLength ?? 3000, DB_MAX_NOTE_TEXT_LENGTH, diff --git a/packages/backend/src/server/api/endpoints/notes/translate.ts b/packages/backend/src/server/api/endpoints/notes/translate.ts index c939ab231a..9362c2c9fe 100644 --- a/packages/backend/src/server/api/endpoints/notes/translate.ts +++ b/packages/backend/src/server/api/endpoints/notes/translate.ts @@ -44,9 +44,5 @@ export default define(meta, paramDef, async (ps, user) => { return 204; } - return translate( - note.text, - note.lang as string | null, - ps.targetLang, - ); + return translate(note.text, note.lang as string | null, ps.targetLang); }); diff --git a/packages/backend/src/services/drive/add-file.ts b/packages/backend/src/services/drive/add-file.ts index c729a5e7a0..3525082bc0 100644 --- a/packages/backend/src/services/drive/add-file.ts +++ b/packages/backend/src/services/drive/add-file.ts @@ -6,11 +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 } from "@/services/stream.js"; -import { - fetchMeta, - genId, - publishToDriveFileStream, -} from "backend-rs"; +import { fetchMeta, genId, publishToDriveFileStream } from "backend-rs"; import { FILE_TYPE_BROWSERSAFE } from "@/const.js"; import { contentDisposition } from "@/misc/content-disposition.js"; import { getFileInfo } from "@/misc/get-file-info.js"; diff --git a/packages/backend/src/services/note/edit.ts b/packages/backend/src/services/note/edit.ts index 8b5116a99b..04bfb3c9bd 100644 --- a/packages/backend/src/services/note/edit.ts +++ b/packages/backend/src/services/note/edit.ts @@ -1,8 +1,5 @@ import * as mfm from "mfm-js"; -import { - publishNoteStream, - publishNoteUpdatesStream, -} from "@/services/stream.js"; +import { publishNoteStream } from "@/services/stream.js"; import DeliverManager from "@/remote/activitypub/deliver-manager.js"; import renderNote from "@/remote/activitypub/renderer/note.js"; import { renderActivity } from "@/remote/activitypub/renderer/index.js"; @@ -21,7 +18,7 @@ import { import type { DriveFile } from "@/models/entities/drive-file.js"; import { In } from "typeorm"; import type { ILocalUser, IRemoteUser } from "@/models/entities/user.js"; -import { genId } from "backend-rs"; +import { genId, publishToNoteUpdatesStream } from "backend-rs"; import type { IPoll } from "@/models/entities/poll.js"; import { deliverToRelays } from "../relay.js"; import renderUpdate from "@/remote/activitypub/renderer/update.js"; @@ -194,7 +191,7 @@ export default async function ( updatedAt: update.updatedAt, }); - publishNoteUpdatesStream("updated", note); + publishToNoteUpdatesStream(note); (async () => { const noteActivity = await renderNote(note, false); diff --git a/packages/backend/src/services/stream.ts b/packages/backend/src/services/stream.ts index d1094b1454..d5a89c82c5 100644 --- a/packages/backend/src/services/stream.ts +++ b/packages/backend/src/services/stream.ts @@ -21,7 +21,7 @@ import type { NoteStreamTypes, UserListStreamTypes, UserStreamTypes, - NoteUpdatesStreamTypes, + // NoteUpdatesStreamTypes, } from "@/server/api/stream/types.js"; class Publisher { @@ -113,12 +113,13 @@ class Publisher { }); }; - public publishNoteUpdatesStream = ( - type: K, - value: NoteUpdatesStreamTypes[K], - ): void => { - this.publish("noteUpdatesStream", type, value); - }; + /* ported to backend-rs */ + // public publishNoteUpdatesStream = ( + // type: K, + // value: NoteUpdatesStreamTypes[K], + // ): void => { + // this.publish("noteUpdatesStream", type, value); + // }; /* ported to backend-rs */ // public publishChannelStream = ( @@ -232,7 +233,7 @@ export const publishMainStream = publisher.publishMainStream; // export const publishDriveStream = publisher.publishDriveStream; export const publishNoteStream = publisher.publishNoteStream; // export const publishNotesStream = publisher.publishNotesStream; -export const publishNoteUpdatesStream = publisher.publishNoteUpdatesStream; +// export const publishNoteUpdatesStream = publisher.publishNoteUpdatesStream; // export const publishChannelStream = publisher.publishChannelStream; export const publishUserListStream = publisher.publishUserListStream; // export const publishAntennaStream = publisher.publishAntennaStream; From 0ba868cc3cd9f0b632bfd652301f633bf3fc65e8 Mon Sep 17 00:00:00 2001 From: naskya Date: Thu, 25 Jul 2024 07:29:21 +0900 Subject: [PATCH 06/43] refactor (backend): remove publishUserListStream --- packages/backend-rs/src/service/stream.rs | 4 --- .../server/api/endpoints/users/lists/pull.ts | 34 ++++++++----------- .../src/server/api/mastodon/helpers/list.ts | 24 +++++-------- .../server/api/stream/channels/user-list.ts | 5 +-- .../backend/src/server/api/stream/types.ts | 10 ------ packages/backend/src/services/stream.ts | 14 -------- .../backend/src/services/user-list/pull.ts | 11 ------ .../backend/src/services/user-list/push.ts | 3 -- 8 files changed, 25 insertions(+), 80 deletions(-) delete mode 100644 packages/backend/src/services/user-list/pull.ts diff --git a/packages/backend-rs/src/service/stream.rs b/packages/backend-rs/src/service/stream.rs index cd386e7115..a3f34c4185 100644 --- a/packages/backend-rs/src/service/stream.rs +++ b/packages/backend-rs/src/service/stream.rs @@ -32,9 +32,6 @@ pub enum Stream { }, Notes, NoteEdit, - UserList { - list_id: String, - }, Main { user_id: String, }, @@ -90,7 +87,6 @@ pub async fn publish_to_stream( Stream::Note { note_id } => format!("noteStream:{note_id}"), Stream::NoteEdit => format!("noteUpdatesStream"), Stream::Notes => "notesStream".to_owned(), - Stream::UserList { list_id } => format!("userListStream:{list_id}"), Stream::Main { user_id } => format!("mainStream:{user_id}"), Stream::Drive { user_id } => format!("driveStream:{user_id}"), Stream::Antenna { antenna_id } => format!("antennaStream:{antenna_id}"), diff --git a/packages/backend/src/server/api/endpoints/users/lists/pull.ts b/packages/backend/src/server/api/endpoints/users/lists/pull.ts index ffca5b205a..a0ae191c9a 100644 --- a/packages/backend/src/server/api/endpoints/users/lists/pull.ts +++ b/packages/backend/src/server/api/endpoints/users/lists/pull.ts @@ -1,8 +1,6 @@ -import { publishUserListStream } from "@/services/stream.js"; import { UserLists, UserListJoinings, Users } from "@/models/index.js"; import define from "@/server/api/define.js"; import { ApiError } from "@/server/api/error.js"; -import { getUser } from "@/server/api/common/getters.js"; export const meta = { tags: ["lists", "users"], @@ -38,25 +36,23 @@ export const paramDef = { } as const; export default define(meta, paramDef, async (ps, me) => { - // Fetch the list - const userList = await UserLists.findOneBy({ - id: ps.listId, - userId: me.id, - }); + const [userExists, listExists] = await Promise.all([ + Users.existsBy({ + id: ps.userId, + }), + UserLists.existsBy({ + id: ps.listId, + userId: me.id, + }), + ]); - if (userList == null) { + if (!userExists) { + throw new ApiError(meta.errors.noSuchUser); + } + if (!listExists) { throw new ApiError(meta.errors.noSuchList); } - // Fetch the user - const user = await getUser(ps.userId).catch((e) => { - if (e.id === "15348ddd-432d-49c2-8a5a-8069753becff") - throw new ApiError(meta.errors.noSuchUser); - throw e; - }); - - // Pull the user - await UserListJoinings.delete({ userListId: userList.id, userId: user.id }); - - publishUserListStream(userList.id, "userRemoved", await Users.pack(user)); + // Remove the user from the list + await UserListJoinings.delete({ userListId: ps.listId, userId: ps.userId }); }); diff --git a/packages/backend/src/server/api/mastodon/helpers/list.ts b/packages/backend/src/server/api/mastodon/helpers/list.ts index ef59473167..b7564c1048 100644 --- a/packages/backend/src/server/api/mastodon/helpers/list.ts +++ b/packages/backend/src/server/api/mastodon/helpers/list.ts @@ -12,8 +12,6 @@ import { pushUserToUserList } from "@/services/user-list/push.js"; import { genId } from "backend-rs"; import { MastoApiError } from "@/server/api/mastodon/middleware/catch-errors.js"; import type { MastoContext } from "@/server/api/mastodon/index.js"; -import { pullUserFromUserList } from "@/services/user-list/pull.js"; -import { publishUserEvent } from "@/services/stream.js"; export class ListHelpers { public static async getLists( @@ -123,14 +121,12 @@ export class ListHelpers { throw Error("Can’t add users you’re not following to list"); } - const exist = await UserListJoinings.exists({ - where: { - userListId: list.id, - userId: user.id, - }, + const exists = await UserListJoinings.existsBy({ + userListId: list.id, + userId: user.id, }); - if (exist) continue; + if (exists) continue; await pushUserToUserList(user, list); } } @@ -144,15 +140,13 @@ export class ListHelpers { if (localUser.id !== list.userId) throw new Error("List is not owned by user"); for (const user of usersToRemove) { - const exist = await UserListJoinings.exists({ - where: { - userListId: list.id, - userId: user.id, - }, + const exists = await UserListJoinings.existsBy({ + userListId: list.id, + userId: user.id, }); - if (!exist) continue; - await pullUserFromUserList(user, list); + if (!exists) continue; + await UserListJoinings.delete({ userListId: list.id, userId: user.id }); } } diff --git a/packages/backend/src/server/api/stream/channels/user-list.ts b/packages/backend/src/server/api/stream/channels/user-list.ts index d8d2fbb378..f699ffcf50 100644 --- a/packages/backend/src/server/api/stream/channels/user-list.ts +++ b/packages/backend/src/server/api/stream/channels/user-list.ts @@ -29,12 +29,10 @@ export default class extends Channel { if (!exists) return; // Subscribe stream - this.subscriber.on(`userListStream:${this.listId}`, this.send); - this.subscriber.on("notesStream", this.onNote); this.updateListUsers(); - this.listUsersClock = setInterval(this.updateListUsers, 5000); + this.listUsersClock = setInterval(this.updateListUsers, 10000); } private async updateListUsers() { @@ -65,7 +63,6 @@ export default class extends Channel { public dispose() { // Unsubscribe events - this.subscriber.off(`userListStream:${this.listId}`, this.send); this.subscriber.off("notesStream", this.onNote); clearInterval(this.listUsersClock); diff --git a/packages/backend/src/server/api/stream/types.ts b/packages/backend/src/server/api/stream/types.ts index b9d5bb6fc2..138bcedfae 100644 --- a/packages/backend/src/server/api/stream/types.ts +++ b/packages/backend/src/server/api/stream/types.ts @@ -7,7 +7,6 @@ import type { Note } from "@/models/entities/note.js"; import type { Antenna } from "@/models/entities/antenna.js"; import type { DriveFile } from "@/models/entities/drive-file.js"; import type { DriveFolder } from "@/models/entities/drive-folder.js"; -import type { UserList } from "@/models/entities/user-list.js"; import type { MessagingMessage } from "@/models/entities/messaging-message.js"; import type { UserGroup } from "@/models/entities/user-group.js"; import type { AbuseUserReport } from "@/models/entities/abuse-user-report.js"; @@ -165,11 +164,6 @@ export interface ChannelStreamTypes { typing: User["id"]; } -export interface UserListStreamTypes { - userAdded: Packed<"User">; - userRemoved: Packed<"User">; -} - export interface AntennaStreamTypes { note: Note; } @@ -242,10 +236,6 @@ export type StreamMessages = { name: `channelStream:${Channel["id"]}`; payload: EventUnionFromDictionary; }; - userList: { - name: `userListStream:${UserList["id"]}`; - payload: EventUnionFromDictionary; - }; antenna: { name: `antennaStream:${Antenna["id"]}`; payload: EventUnionFromDictionary; diff --git a/packages/backend/src/services/stream.ts b/packages/backend/src/services/stream.ts index d5a89c82c5..d4a38797bb 100644 --- a/packages/backend/src/services/stream.ts +++ b/packages/backend/src/services/stream.ts @@ -19,7 +19,6 @@ import type { // MessagingIndexStreamTypes, // MessagingStreamTypes, NoteStreamTypes, - UserListStreamTypes, UserStreamTypes, // NoteUpdatesStreamTypes, } from "@/server/api/stream/types.js"; @@ -134,18 +133,6 @@ class Publisher { // ); // }; - public publishUserListStream = ( - listId: UserList["id"], - type: K, - value?: UserListStreamTypes[K], - ): void => { - this.publish( - `userListStream:${listId}`, - type, - typeof value === "undefined" ? null : value, - ); - }; - /* ported to backend-rs */ // public publishAntennaStream = ( // antennaId: Antenna["id"], @@ -235,7 +222,6 @@ export const publishNoteStream = publisher.publishNoteStream; // export const publishNotesStream = publisher.publishNotesStream; // export const publishNoteUpdatesStream = publisher.publishNoteUpdatesStream; // export const publishChannelStream = publisher.publishChannelStream; -export const publishUserListStream = publisher.publishUserListStream; // export const publishAntennaStream = publisher.publishAntennaStream; // export const publishMessagingStream = publisher.publishMessagingStream; // export const publishGroupMessagingStream = publisher.publishGroupMessagingStream; diff --git a/packages/backend/src/services/user-list/pull.ts b/packages/backend/src/services/user-list/pull.ts deleted file mode 100644 index 9d6bd16b31..0000000000 --- a/packages/backend/src/services/user-list/pull.ts +++ /dev/null @@ -1,11 +0,0 @@ -import { publishUserListStream } from "@/services/stream.js"; -import type { User } from "@/models/entities/user.js"; -import type { UserList } from "@/models/entities/user-list.js"; -import { UserListJoinings, Users } from "@/models/index.js"; - -export async function pullUserFromUserList(target: User, list: UserList) { - await UserListJoinings.delete({ userListId: list.id, userId: target.id }); - - const packed = await Users.pack(target); - publishUserListStream(list.id, "userRemoved", packed); -} diff --git a/packages/backend/src/services/user-list/push.ts b/packages/backend/src/services/user-list/push.ts index 1ec4289672..e34bb59aeb 100644 --- a/packages/backend/src/services/user-list/push.ts +++ b/packages/backend/src/services/user-list/push.ts @@ -1,4 +1,3 @@ -import { publishUserListStream } from "@/services/stream.js"; import type { User } from "@/models/entities/user.js"; import type { UserList } from "@/models/entities/user-list.js"; import { UserListJoinings, Users } from "@/models/index.js"; @@ -17,8 +16,6 @@ export async function pushUserToUserList(target: User, list: UserList) { userListId: list.id, } as UserListJoining); - publishUserListStream(list.id, "userAdded", await Users.pack(target)); - // このインスタンス内にこのリモートユーザーをフォローしているユーザーがいなくても投稿を受け取るためにダミーのユーザーがフォローしたということにする if (Users.isRemoteUser(target)) { const proxy = await fetchProxyAccount(); From 0edf177e9985a3284d4db373acdc3c18f9810424 Mon Sep 17 00:00:00 2001 From: naskya Date: Thu, 25 Jul 2024 08:16:30 +0900 Subject: [PATCH 07/43] fix (backend): check word mutes in lists --- .../server/api/endpoints/notes/user-list-timeline.ts | 2 ++ .../src/server/api/stream/channels/user-list.ts | 12 ++++++++++++ 2 files changed, 14 insertions(+) diff --git a/packages/backend/src/server/api/endpoints/notes/user-list-timeline.ts b/packages/backend/src/server/api/endpoints/notes/user-list-timeline.ts index 3a87ed647c..7eab4eb843 100644 --- a/packages/backend/src/server/api/endpoints/notes/user-list-timeline.ts +++ b/packages/backend/src/server/api/endpoints/notes/user-list-timeline.ts @@ -5,6 +5,7 @@ import define from "@/server/api/define.js"; import { ApiError } from "@/server/api/error.js"; import { makePaginationQuery } from "@/server/api/common/make-pagination-query.js"; import { generateVisibilityQuery } from "@/server/api/common/generate-visibility-query.js"; +import { generateMutedNoteQuery } from "@/server/api/common/generate-muted-note-query.js"; export const meta = { tags: ["notes", "lists"], @@ -95,6 +96,7 @@ export default define(meta, paramDef, async (ps, user) => { }); generateVisibilityQuery(query, user); + generateMutedNoteQuery(query, user); if (ps.includeMyRenotes === false) { query.andWhere( diff --git a/packages/backend/src/server/api/stream/channels/user-list.ts b/packages/backend/src/server/api/stream/channels/user-list.ts index f699ffcf50..e0a3ec6480 100644 --- a/packages/backend/src/server/api/stream/channels/user-list.ts +++ b/packages/backend/src/server/api/stream/channels/user-list.ts @@ -3,6 +3,7 @@ import { UserListJoinings, UserLists } from "@/models/index.js"; import type { User } from "@/models/entities/user.js"; import { isUserRelated } from "@/misc/is-user-related.js"; import type { Packed } from "@/misc/schema.js"; +import { checkWordMute } from "backend-rs"; export default class extends Channel { public readonly chName = "userList"; @@ -58,6 +59,17 @@ export default class extends Channel { if (note.renote && !note.text && this.renoteMuting.has(note.userId)) return; if (note.replyId != null && this.replyMuting.has(note.userId)) return; + if ( + this.userProfile && + this.user?.id !== note.userId && + (await checkWordMute( + note, + this.userProfile.mutedWords, + this.userProfile.mutedPatterns, + )) + ) + return; + this.send("note", note); } From d4bbd092924a59037d4853aa484bbcb08c823267 Mon Sep 17 00:00:00 2001 From: GitLab CI Date: Thu, 25 Jul 2024 12:05:24 +0000 Subject: [PATCH 08/43] chore(deps): update dependency vite to v5.3.5 --- packages/client/package.json | 2 +- packages/sw/package.json | 2 +- pnpm-lock.yaml | 28 ++++++++++++++-------------- 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/packages/client/package.json b/packages/client/package.json index 670e6b8f28..ffd5b1c770 100644 --- a/packages/client/package.json +++ b/packages/client/package.json @@ -83,7 +83,7 @@ "typescript": "5.5.4", "unicode-emoji-json": "0.6.0", "uuid": "10.0.0", - "vite": "5.3.4", + "vite": "5.3.5", "vite-plugin-compression": "0.5.1", "vue": "3.4.34", "vue-draggable-plus": "0.5.2", diff --git a/packages/sw/package.json b/packages/sw/package.json index daf8b43b43..dbe160779d 100644 --- a/packages/sw/package.json +++ b/packages/sw/package.json @@ -12,7 +12,7 @@ "devDependencies": { "firefish-js": "workspace:*", "idb-keyval": "6.2.1", - "vite": "5.3.4", + "vite": "5.3.5", "vite-plugin-compression": "0.5.1" } } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 969a262a63..4bc61032ef 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -558,7 +558,7 @@ importers: version: 10.0.0 '@vitejs/plugin-vue': specifier: 5.1.0 - version: 5.1.0(vite@5.3.4(@types/node@20.14.12)(sass@1.77.8)(terser@5.31.3))(vue@3.4.34(typescript@5.5.4)) + version: 5.1.0(vite@5.3.5(@types/node@20.14.12)(sass@1.77.8)(terser@5.31.3))(vue@3.4.34(typescript@5.5.4)) '@vue/runtime-core': specifier: 3.4.34 version: 3.4.34 @@ -707,11 +707,11 @@ importers: specifier: 10.0.0 version: 10.0.0 vite: - specifier: 5.3.4 - version: 5.3.4(@types/node@20.14.12)(sass@1.77.8)(terser@5.31.3) + specifier: 5.3.5 + version: 5.3.5(@types/node@20.14.12)(sass@1.77.8)(terser@5.31.3) vite-plugin-compression: specifier: 0.5.1 - version: 0.5.1(vite@5.3.4(@types/node@20.14.12)(sass@1.77.8)(terser@5.31.3)) + version: 0.5.1(vite@5.3.5(@types/node@20.14.12)(sass@1.77.8)(terser@5.31.3)) vue: specifier: 3.4.34 version: 3.4.34(typescript@5.5.4) @@ -780,11 +780,11 @@ importers: specifier: 6.2.1 version: 6.2.1 vite: - specifier: 5.3.4 - version: 5.3.4(@types/node@20.14.12)(sass@1.77.8)(terser@5.31.3) + specifier: 5.3.5 + version: 5.3.5(@types/node@20.14.12)(sass@1.77.8)(terser@5.31.3) vite-plugin-compression: specifier: 0.5.1 - version: 0.5.1(vite@5.3.4(@types/node@20.14.12)(sass@1.77.8)(terser@5.31.3)) + version: 0.5.1(vite@5.3.5(@types/node@20.14.12)(sass@1.77.8)(terser@5.31.3)) packages: @@ -6610,8 +6610,8 @@ packages: peerDependencies: vite: '>=2.0.0' - vite@5.3.4: - resolution: {integrity: sha512-Cw+7zL3ZG9/NZBB8C+8QbQZmR54GwqIz+WMI4b3JgdYJvX+ny9AjJXqkGQlDXSXRP9rP0B4tbciRMOVEKulVOA==} + vite@5.3.5: + resolution: {integrity: sha512-MdjglKR6AQXQb9JGiS7Rc2wC6uMjcm7Go/NHNO63EwiJXfuk9PgqiP/n5IDJCziMkfw9n4Ubp7lttNwz+8ZVKA==} engines: {node: ^18.0.0 || >=20.0.0} hasBin: true peerDependencies: @@ -8728,9 +8728,9 @@ snapshots: dependencies: '@types/yargs-parser': 21.0.3 - '@vitejs/plugin-vue@5.1.0(vite@5.3.4(@types/node@20.14.12)(sass@1.77.8)(terser@5.31.3))(vue@3.4.34(typescript@5.5.4))': + '@vitejs/plugin-vue@5.1.0(vite@5.3.5(@types/node@20.14.12)(sass@1.77.8)(terser@5.31.3))(vue@3.4.34(typescript@5.5.4))': dependencies: - vite: 5.3.4(@types/node@20.14.12)(sass@1.77.8)(terser@5.31.3) + vite: 5.3.5(@types/node@20.14.12)(sass@1.77.8)(terser@5.31.3) vue: 3.4.34(typescript@5.5.4) '@volar/language-core@2.4.0-alpha.18': @@ -12999,16 +12999,16 @@ snapshots: core-util-is: 1.0.2 extsprintf: 1.3.0 - vite-plugin-compression@0.5.1(vite@5.3.4(@types/node@20.14.12)(sass@1.77.8)(terser@5.31.3)): + vite-plugin-compression@0.5.1(vite@5.3.5(@types/node@20.14.12)(sass@1.77.8)(terser@5.31.3)): dependencies: chalk: 4.1.2 debug: 4.3.5 fs-extra: 10.1.0 - vite: 5.3.4(@types/node@20.14.12)(sass@1.77.8)(terser@5.31.3) + vite: 5.3.5(@types/node@20.14.12)(sass@1.77.8)(terser@5.31.3) transitivePeerDependencies: - supports-color - vite@5.3.4(@types/node@20.14.12)(sass@1.77.8)(terser@5.31.3): + vite@5.3.5(@types/node@20.14.12)(sass@1.77.8)(terser@5.31.3): dependencies: esbuild: 0.21.5 postcss: 8.4.39 From a28854c5d504d46734a37d2161fa8b4d9effa465 Mon Sep 17 00:00:00 2001 From: GitLab CI Date: Thu, 25 Jul 2024 12:06:04 +0000 Subject: [PATCH 09/43] chore(deps): update dependency vue-tsc to v2.0.29 --- packages/client/package.json | 2 +- pnpm-lock.yaml | 64 +++++++++++------------------------- 2 files changed, 21 insertions(+), 45 deletions(-) diff --git a/packages/client/package.json b/packages/client/package.json index 670e6b8f28..75cc30b77c 100644 --- a/packages/client/package.json +++ b/packages/client/package.json @@ -89,6 +89,6 @@ "vue-draggable-plus": "0.5.2", "vue-plyr": "7.0.0", "vue-prism-editor": "2.0.0-alpha.2", - "vue-tsc": "2.0.28" + "vue-tsc": "2.0.29" } } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 969a262a63..0cf05cea82 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -725,8 +725,8 @@ importers: specifier: 2.0.0-alpha.2 version: 2.0.0-alpha.2(vue@3.4.34(typescript@5.5.4)) vue-tsc: - specifier: 2.0.28 - version: 2.0.28(typescript@5.5.4) + specifier: 2.0.29 + version: 2.0.29(typescript@5.5.4) packages/firefish-js: dependencies: @@ -2624,15 +2624,9 @@ packages: '@volar/typescript@2.4.0-alpha.18': resolution: {integrity: sha512-sXh5Y8sqGUkgxpMWUGvRXggxYHAVxg0Pa1C42lQZuPDrW6vHJPR0VCK8Sr7WJsAW530HuNQT/ZIskmXtxjybMQ==} - '@vue/compiler-core@3.4.33': - resolution: {integrity: sha512-MoIREbkdPQlnGfSKDMgzTqzqx5nmEjIc0ydLVYlTACGBsfvOJ4tHSbZXKVF536n6fB+0eZaGEOqsGThPpdvF5A==} - '@vue/compiler-core@3.4.34': resolution: {integrity: sha512-Z0izUf32+wAnQewjHu+pQf1yw00EGOmevl1kE+ljjjMe7oEfpQ+BI3/JNK7yMB4IrUsqLDmPecUrpj3mCP+yJQ==} - '@vue/compiler-dom@3.4.33': - resolution: {integrity: sha512-GzB8fxEHKw0gGet5BKlpfXEqoBnzSVWwMnT+dc25wE7pFEfrU/QsvjZMP9rD4iVXHBBoemTct8mN0GJEI6ZX5A==} - '@vue/compiler-dom@3.4.34': resolution: {integrity: sha512-3PUOTS1h5cskdOJMExCu2TInXuM0j60DRPpSCJDqOCupCfUZCJoyQmKtRmA8EgDNZ5kcEE7vketamRZfrEuVDw==} @@ -2645,8 +2639,11 @@ packages: '@vue/compiler-ssr@3.4.34': resolution: {integrity: sha512-8TDBcLaTrFm5rnF+Qm4BlliaopJgqJ28Nsrc80qazynm5aJO+Emu7y0RWw34L8dNnTRdcVBpWzJxhGYzsoVu4g==} - '@vue/language-core@2.0.28': - resolution: {integrity: sha512-0z4tyCCaqqPbdyz0T4yTFQeLpCo4TOM/ZHAC3geGLHeCiFAjVbROB9PiEtrXR1AoLObqUPFHSmKZeWtEMssSqw==} + '@vue/compiler-vue2@2.7.16': + resolution: {integrity: sha512-qYC3Psj9S/mfu9uVi5WvNZIzq+xnXMhOwbTFKKDD7b1lhpnn71jXSFdTQ+WsIEk0ONCd7VV2IMm7ONl6tbQ86A==} + + '@vue/language-core@2.0.29': + resolution: {integrity: sha512-o2qz9JPjhdoVj8D2+9bDXbaI4q2uZTHQA/dbyZT4Bj1FR9viZxDJnLcKVHfxdn6wsOzRgpqIzJEEmSSvgMvDTQ==} peerDependencies: typescript: '*' peerDependenciesMeta: @@ -2667,9 +2664,6 @@ packages: peerDependencies: vue: 3.4.34 - '@vue/shared@3.4.33': - resolution: {integrity: sha512-aoRY0jQk3A/cuvdkodTrM4NMfxco8n55eG4H7ML/CRy7OryHfiqvug4xrCBBMbbN+dvXAetDDwZW9DXWWjBntA==} - '@vue/shared@3.4.34': resolution: {integrity: sha512-x5LmiRLpRsd9KTjAB8MPKf0CDPMcuItjP0gbNqFCIgL1I8iYp4zglhj9w9FPCdIbHG2M91RVeIbArFfFTz9I3A==} @@ -6663,11 +6657,8 @@ packages: peerDependencies: vue: ^3.0.0 - vue-template-compiler@2.7.16: - resolution: {integrity: sha512-AYbUWAJHLGGQM7+cNTELw+KsOG9nl2CnSv467WobS5Cv9uk3wFcnr1Etsz2sEIHEZvw1U+o9mRlEO6QbZvUPGQ==} - - vue-tsc@2.0.28: - resolution: {integrity: sha512-PQ/OFDM3NtQVMThaVlQf8plyL0j7UGdak4lb1KkUOSL0uyx/F9Liu6aOclgHiMMBKNGIjJWoiFh3HjIdV6DS/Q==} + vue-tsc@2.0.29: + resolution: {integrity: sha512-MHhsfyxO3mYShZCGYNziSbc63x7cQ5g9kvijV7dRe1TTXBRLxXyL0FnXWpUF1xII2mJ86mwYpYsUmMwkmerq7Q==} hasBin: true peerDependencies: typescript: '>=5.0.0' @@ -8745,14 +8736,6 @@ snapshots: path-browserify: 1.0.1 vscode-uri: 3.0.8 - '@vue/compiler-core@3.4.33': - dependencies: - '@babel/parser': 7.24.8 - '@vue/shared': 3.4.33 - entities: 4.5.0 - estree-walker: 2.0.2 - source-map-js: 1.2.0 - '@vue/compiler-core@3.4.34': dependencies: '@babel/parser': 7.24.8 @@ -8761,11 +8744,6 @@ snapshots: estree-walker: 2.0.2 source-map-js: 1.2.0 - '@vue/compiler-dom@3.4.33': - dependencies: - '@vue/compiler-core': 3.4.33 - '@vue/shared': 3.4.33 - '@vue/compiler-dom@3.4.34': dependencies: '@vue/compiler-core': 3.4.34 @@ -8796,16 +8774,21 @@ snapshots: '@vue/compiler-dom': 3.4.34 '@vue/shared': 3.4.34 - '@vue/language-core@2.0.28(typescript@5.5.4)': + '@vue/compiler-vue2@2.7.16': + dependencies: + de-indent: 1.0.2 + he: 1.2.0 + + '@vue/language-core@2.0.29(typescript@5.5.4)': dependencies: '@volar/language-core': 2.4.0-alpha.18 - '@vue/compiler-dom': 3.4.33 - '@vue/shared': 3.4.33 + '@vue/compiler-dom': 3.4.34 + '@vue/compiler-vue2': 2.7.16 + '@vue/shared': 3.4.34 computeds: 0.0.1 minimatch: 9.0.5 muggle-string: 0.4.1 path-browserify: 1.0.1 - vue-template-compiler: 2.7.16 optionalDependencies: typescript: 5.5.4 @@ -8831,8 +8814,6 @@ snapshots: '@vue/shared': 3.4.34 vue: 3.4.34(typescript@5.5.4) - '@vue/shared@3.4.33': {} - '@vue/shared@3.4.34': {} '@webassemblyjs/ast@1.12.1': @@ -13036,15 +13017,10 @@ snapshots: dependencies: vue: 3.4.34(typescript@5.5.4) - vue-template-compiler@2.7.16: - dependencies: - de-indent: 1.0.2 - he: 1.2.0 - - vue-tsc@2.0.28(typescript@5.5.4): + vue-tsc@2.0.29(typescript@5.5.4): dependencies: '@volar/typescript': 2.4.0-alpha.18 - '@vue/language-core': 2.0.28(typescript@5.5.4) + '@vue/language-core': 2.0.29(typescript@5.5.4) semver: 7.6.3 typescript: 5.5.4 From a1e6affc27cacbfb8165c5815c6064b2e241df44 Mon Sep 17 00:00:00 2001 From: GitLab CI Date: Thu, 25 Jul 2024 12:07:17 +0000 Subject: [PATCH 10/43] chore(deps): update rust crate nom-exif to 1.3.0 --- Cargo.lock | 5 +++-- Cargo.toml | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index e54fd29b98..f3c4f1754c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1919,14 +1919,15 @@ dependencies = [ [[package]] name = "nom-exif" -version = "1.2.6" +version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3dac386e49252f313c88764101ca16681caa4a5b0260d494d58b6af7f04edd3a" +checksum = "ab35c38930e837f191de96c6f23e8dee7547916fbae0ce25e4d5fad405bbc2d2" dependencies = [ "chrono", "nom", "regex", "thiserror", + "tracing", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index f5ff08b03d..2ce3a83cdb 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -26,7 +26,7 @@ emojis = { version = "0.6.3", default-features = false } idna = { version = "1.0.2", default-features = false } image = { version = "0.25.2", default-features = false } isahc = { version = "1.7.2", default-features = false } -nom-exif = { version = "1.2.6", default-features = false } +nom-exif = { version = "1.3.0", default-features = false } once_cell = { version = "1.19.0", default-features = false } pretty_assertions = { version = "1.4.0", default-features = false } proc-macro2 = { version = "1.0.86", default-features = false } From 911b35f356225eee9f02e998651b9394c8cbb687 Mon Sep 17 00:00:00 2001 From: naskya Date: Fri, 26 Jul 2024 02:32:59 +0900 Subject: [PATCH 11/43] refactor (macro-rs): use syn::Result for internal outputs --- Cargo.lock | 1 + packages/macro-rs/macros-impl/src/error.rs | 9 +-------- packages/macro-rs/macros-impl/src/napi.rs | 10 +++++----- packages/macro-rs/macros-impl/src/util/tester.rs | 6 +++--- packages/macro-rs/macros/Cargo.toml | 1 + packages/macro-rs/macros/src/helper.rs | 5 ++++- 6 files changed, 15 insertions(+), 17 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f3c4f1754c..d3d7afb7e4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1768,6 +1768,7 @@ dependencies = [ "quote", "serde", "serde_json", + "syn 2.0.72", ] [[package]] diff --git a/packages/macro-rs/macros-impl/src/error.rs b/packages/macro-rs/macros-impl/src/error.rs index e14ea70c94..dd81f395b4 100644 --- a/packages/macro-rs/macros-impl/src/error.rs +++ b/packages/macro-rs/macros-impl/src/error.rs @@ -1,14 +1,7 @@ use proc_macro2::TokenStream; use quote::quote; -pub fn error_variants(_attr: TokenStream, item: TokenStream) -> TokenStream { - match error_variants_impl(item) { - Ok(tokens) => tokens, - Err(error) => error.to_compile_error(), - } -} - -fn error_variants_impl(item: TokenStream) -> syn::Result { +pub fn error_variants(_attr: TokenStream, item: TokenStream) -> syn::Result { let mut item: syn::ItemEnum = syn::parse2(item)?; item.variants = item diff --git a/packages/macro-rs/macros-impl/src/napi.rs b/packages/macro-rs/macros-impl/src/napi.rs index 13e2242ab8..57de95c273 100644 --- a/packages/macro-rs/macros-impl/src/napi.rs +++ b/packages/macro-rs/macros-impl/src/napi.rs @@ -184,7 +184,7 @@ use quote::{quote, ToTokens}; /// # }); /// ``` /// -pub fn napi(macro_attr: TokenStream, item: TokenStream) -> TokenStream { +pub fn napi(macro_attr: TokenStream, item: TokenStream) -> syn::Result { let macro_attr_tokens: Vec = macro_attr.clone().into_iter().collect(); // generated extra macro attr TokenStream (prepended before original input `macro_attr`) let mut extra_macro_attr = TokenStream::new(); @@ -202,10 +202,10 @@ pub fn napi(macro_attr: TokenStream, item: TokenStream) -> TokenStream { }) { quote! { use_nullable = true, }.to_tokens(&mut extra_macro_attr); } - return quote! { + return Ok(quote! { #[napi_derive::napi(#extra_macro_attr #macro_attr)] #item - }; + }); }; // handle functions @@ -333,7 +333,7 @@ pub fn napi(macro_attr: TokenStream, item: TokenStream) -> TokenStream { quote! { js_name = #js_name, }.to_tokens(&mut extra_macro_attr); } - quote! { + Ok(quote! { #item_fn #[napi_derive::napi(#extra_macro_attr #macro_attr)] @@ -342,7 +342,7 @@ pub fn napi(macro_attr: TokenStream, item: TokenStream) -> TokenStream { #ident(#(#called_args),*) #(#function_call_modifiers)* } - } + }) } crate::macro_unit_tests! { diff --git a/packages/macro-rs/macros-impl/src/util/tester.rs b/packages/macro-rs/macros-impl/src/util/tester.rs index 717ed5fb19..dfe9d3bea0 100644 --- a/packages/macro-rs/macros-impl/src/util/tester.rs +++ b/packages/macro-rs/macros-impl/src/util/tester.rs @@ -33,7 +33,7 @@ macro_rules! macro_doctest { &$macro_name( ::quote::quote!($( $($attr)* )?), ::quote::quote!($($item)*), - ) + ).unwrap() ), ::std::string::ToString::to_string( &::quote::quote!($($expanded)*) @@ -81,14 +81,14 @@ macro_rules! macro_doctest { macro_rules! macro_unit_tests { (@test $macro_name:ident($attr:ident, $item:ident) becomes $expanded:ident) => { assert_eq!( - ::std::format!("{}", $macro_name($attr, $item)), + ::std::format!("{}", $macro_name($attr, $item).unwrap()), ::std::format!("{}", $expanded), ); }; (@test $macro_name:ident($attr:ident, $item:ident) generates $expanded:ident) => { let item_str = format!("{}", $item); assert_eq!( - ::std::format!("{}", $macro_name($attr, $item)), + ::std::format!("{}", $macro_name($attr, $item).unwrap()), ::std::format!("{} {}", item_str, $expanded), ); }; diff --git a/packages/macro-rs/macros/Cargo.toml b/packages/macro-rs/macros/Cargo.toml index 323c87ac6b..9300948bb2 100644 --- a/packages/macro-rs/macros/Cargo.toml +++ b/packages/macro-rs/macros/Cargo.toml @@ -16,3 +16,4 @@ proc-macro2 = { workspace = true } quote = { workspace = true } serde = { workspace = true, features = ["derive"] } serde_json = { workspace = true, features = ["std"] } +syn = { workspace = true } diff --git a/packages/macro-rs/macros/src/helper.rs b/packages/macro-rs/macros/src/helper.rs index a901ba27e9..cf77ae1f3c 100644 --- a/packages/macro-rs/macros/src/helper.rs +++ b/packages/macro-rs/macros/src/helper.rs @@ -80,7 +80,10 @@ macro_rules! reexport_proc_macro_attributes { attr: ::proc_macro::TokenStream, item: ::proc_macro::TokenStream, ) -> ::proc_macro::TokenStream { - $impl_path(attr.into(), item.into()).into() + match $impl_path(attr.into(), item.into()) { + ::std::result::Result::Ok(token_stream) => token_stream.into(), + ::std::result::Result::Err(error) => error.to_compile_error().into(), + } } )* } From e63daa4b34d977d21151df931ceae4614b5061da Mon Sep 17 00:00:00 2001 From: naskya Date: Fri, 26 Jul 2024 03:09:10 +0900 Subject: [PATCH 12/43] chore (macro-rs): add comments and doctests --- Cargo.lock | 1 + packages/macro-rs/macros-impl/src/error.rs | 41 ++++++++++++++++++++++ packages/macro-rs/macros/Cargo.toml | 3 ++ packages/macro-rs/macros/src/lib.rs | 29 ++++++++++++--- 4 files changed, 69 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index d3d7afb7e4..e30176f639 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1769,6 +1769,7 @@ dependencies = [ "serde", "serde_json", "syn 2.0.72", + "thiserror", ] [[package]] diff --git a/packages/macro-rs/macros-impl/src/error.rs b/packages/macro-rs/macros-impl/src/error.rs index dd81f395b4..199c753568 100644 --- a/packages/macro-rs/macros-impl/src/error.rs +++ b/packages/macro-rs/macros-impl/src/error.rs @@ -1,6 +1,47 @@ +//! Automatically generate doc comments for error variants from the error messages + use proc_macro2::TokenStream; use quote::quote; +/// Generates doc comments for error enums. +/// +/// # Example +/// ``` +/// # use macros_impl::error::error_variants as errors; +/// # macros_impl::macro_doctest!({ +/// #[macros::errors] +/// pub enum Error { +/// #[error("config file name is not set")] +/// NoConfigFileName, +/// #[error("failed to read the config file")] +/// ReadConfigFile(#[from] io::Error), +/// #[error("invalid file content ({0})")] +/// #[doc = "invalid file content"] +/// InvalidContent(String), +/// #[error(transparent)] +/// #[doc = "database error"] +/// Db(#[from] sea_orm::DbErr) +/// } +/// +/// # }, { +/// /******* the code above expands to *******/ +/// +/// pub enum Error { +/// #[error("config file name is not set")] +/// #[doc = "config file name is not set"] +/// NoConfigFileName, +/// #[error("failed to read the config file")] +/// #[doc = "failed to read the config file"] +/// ReadConfigFile(#[from] io::Error), +/// #[error("invalid file content ({0})")] +/// #[doc = "invalid file content"] +/// InvalidContent(String), +/// #[error(transparent)] +/// #[doc = "database error"] +/// Db(#[from] sea_orm::DbErr) +/// } +/// # }); +/// ``` pub fn error_variants(_attr: TokenStream, item: TokenStream) -> syn::Result { let mut item: syn::ItemEnum = syn::parse2(item)?; diff --git a/packages/macro-rs/macros/Cargo.toml b/packages/macro-rs/macros/Cargo.toml index 9300948bb2..860567004d 100644 --- a/packages/macro-rs/macros/Cargo.toml +++ b/packages/macro-rs/macros/Cargo.toml @@ -17,3 +17,6 @@ quote = { workspace = true } serde = { workspace = true, features = ["derive"] } serde_json = { workspace = true, features = ["std"] } syn = { workspace = true } + +[dev-dependencies] +thiserror = { workspace = true } diff --git a/packages/macro-rs/macros/src/lib.rs b/packages/macro-rs/macros/src/lib.rs index 3619839a74..65de60e7aa 100644 --- a/packages/macro-rs/macros/src/lib.rs +++ b/packages/macro-rs/macros/src/lib.rs @@ -37,7 +37,7 @@ define_wrapper_proc_macro_attributes! { /// #[cfg_attr(feature = "napi", napi_derive::napi(attr))] /// # enum E {} // to work around doc test compilation error /// ``` - /// where `attr` is given attribute(s). + /// where `attr` is given attribute(s). See [`macros_impl::napi::napi`] for more details. derive_clone_and_export(attr, item) { #[cfg_attr(not(feature = "napi"), derive(Clone))] #[cfg_attr(feature = "napi", napi_derive::napi(#attr))] @@ -51,7 +51,7 @@ define_wrapper_proc_macro_attributes! { /// #[cfg_attr(feature = "napi", macros::napi(attr))] /// # fn f() {} // to work around doc test compilation error /// ``` - /// where `attr` is given attribute(s). See [macro@napi] and [macros_impl::napi::napi] for more details. + /// where `attr` is given attribute(s). See [`macros_impl::napi::napi`] for more details. export(attr, item) { #[cfg_attr(feature = "napi", macros::napi(#attr))] #item @@ -66,7 +66,7 @@ define_wrapper_proc_macro_attributes! { /// #[macros::napi(attr)] /// # fn f() {} // to work around doc test compilation error /// ``` - /// where `attr` is given attribute(s). See [macro@napi] for more details. + /// where `attr` is given attribute(s). See [`macros_impl::napi::napi`] for more details. ts_export(attr, item) { #[cfg(feature = "napi")] #[macros::napi(#attr)] @@ -76,8 +76,26 @@ define_wrapper_proc_macro_attributes! { #item } - /// When applied to error variant enums, this macro generates a document - /// based on error messages unless there is a doc comment + /// When applied to enums, this macro implements [`std::error::Error`] trait + /// and generates a document based on error messages unless there is already a doc comment + /// + /// See [`macros_impl::error::error_variants`] for more details. + /// + /// # Example + /// + /// ``` + /// # use std::io; + /// #[macros::errors] + /// pub enum Error { + /// #[error("config file name is not set")] + /// NoConfigFileName, + /// #[error("failed to read the config file")] + /// ReadConfigFile(#[from] io::Error), + /// #[error("invalid file content ({0})")] + /// #[doc = "invalid file content"] + /// InvalidContent(String), + /// } + /// ``` errors(attr, item) { #[derive(::thiserror::Error, ::std::fmt::Debug)] #[macros::error_variants(#attr, #item)] @@ -90,5 +108,6 @@ reexport_proc_macro_attributes! { /// See [macros_impl::napi::napi] for details. macros_impl::napi::napi as napi + /// Generates doc comments for error variants from the error messages macros_impl::error::error_variants as error_variants } From 3fb719a9f6082ebf240dc5e31082164d32b5a1ee Mon Sep 17 00:00:00 2001 From: naskya Date: Fri, 26 Jul 2024 03:13:00 +0900 Subject: [PATCH 13/43] chore: format --- packages/macro-rs/macros-impl/src/error.rs | 4 ++-- packages/macro-rs/macros/src/lib.rs | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/macro-rs/macros-impl/src/error.rs b/packages/macro-rs/macros-impl/src/error.rs index 199c753568..52b4ef6ddf 100644 --- a/packages/macro-rs/macros-impl/src/error.rs +++ b/packages/macro-rs/macros-impl/src/error.rs @@ -22,10 +22,10 @@ use quote::quote; /// #[doc = "database error"] /// Db(#[from] sea_orm::DbErr) /// } -/// +/// /// # }, { /// /******* the code above expands to *******/ -/// +/// /// pub enum Error { /// #[error("config file name is not set")] /// #[doc = "config file name is not set"] diff --git a/packages/macro-rs/macros/src/lib.rs b/packages/macro-rs/macros/src/lib.rs index 65de60e7aa..b0beab95bd 100644 --- a/packages/macro-rs/macros/src/lib.rs +++ b/packages/macro-rs/macros/src/lib.rs @@ -80,9 +80,9 @@ define_wrapper_proc_macro_attributes! { /// and generates a document based on error messages unless there is already a doc comment /// /// See [`macros_impl::error::error_variants`] for more details. - /// + /// /// # Example - /// + /// /// ``` /// # use std::io; /// #[macros::errors] From 9d0dc4f67389b45dcc0acb8f7e194bc11021ba2a Mon Sep 17 00:00:00 2001 From: GitLab CI Date: Thu, 25 Jul 2024 20:05:56 +0000 Subject: [PATCH 14/43] fix(deps): update dependency aws-sdk to v2.1664.0 --- packages/backend/package.json | 2 +- pnpm-lock.yaml | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/backend/package.json b/packages/backend/package.json index 2557e1f14e..4cddcb6c14 100644 --- a/packages/backend/package.json +++ b/packages/backend/package.json @@ -33,7 +33,7 @@ "archiver": "7.0.1", "async-lock": "1.4.1", "async-mutex": "0.5.0", - "aws-sdk": "2.1663.0", + "aws-sdk": "2.1664.0", "axios": "1.7.2", "backend-rs": "workspace:*", "blurhash": "2.0.5", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index ef24ee2665..1d6b03f09a 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -88,8 +88,8 @@ importers: specifier: 0.5.0 version: 0.5.0 aws-sdk: - specifier: 2.1663.0 - version: 2.1663.0 + specifier: 2.1664.0 + version: 2.1664.0 axios: specifier: 1.7.2 version: 1.7.2 @@ -2874,8 +2874,8 @@ packages: resolution: {integrity: sha512-wvUjBtSGN7+7SjNpq/9M2Tg350UZD3q62IFZLbRAR1bSMlCo1ZaeW+BJ+D090e4hIIZLBcTDWe4Mh4jvUDajzQ==} engines: {node: '>= 0.4'} - aws-sdk@2.1663.0: - resolution: {integrity: sha512-zgXHOw0sBhYcw/yC2YKPLEMNTLnglYLB5UzhAYYShFgOng2NvxkrkuqGFFQ9+haMx2zx6t6CgeqQ7nT0TFUf/g==} + aws-sdk@2.1664.0: + resolution: {integrity: sha512-S2IA1cCGz38d8ZKsuQGwlK3LE+9cXFt7OFsSGQtKX1Mc40xFXpiqQy7jX1r0vZIiy9ZMnxeTcBPM28G/yYu2kA==} engines: {node: '>= 10.0.0'} axios@0.24.0: @@ -9038,7 +9038,7 @@ snapshots: dependencies: possible-typed-array-names: 1.0.0 - aws-sdk@2.1663.0: + aws-sdk@2.1664.0: dependencies: buffer: 4.9.2 events: 1.1.1 From c7de3aae3f74c752d9c7c7ee7033cb2f7dafe472 Mon Sep 17 00:00:00 2001 From: naskya Date: Fri, 26 Jul 2024 07:12:20 +0900 Subject: [PATCH 15/43] chore (backend-rs): fix clippy warning --- packages/backend-rs/src/service/stream.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/backend-rs/src/service/stream.rs b/packages/backend-rs/src/service/stream.rs index a3f34c4185..59e68e20cd 100644 --- a/packages/backend-rs/src/service/stream.rs +++ b/packages/backend-rs/src/service/stream.rs @@ -85,7 +85,7 @@ pub async fn publish_to_stream( Stream::User { user_id } => format!("user:{user_id}"), Stream::Channel { channel_id } => format!("channelStream:{channel_id}"), Stream::Note { note_id } => format!("noteStream:{note_id}"), - Stream::NoteEdit => format!("noteUpdatesStream"), + Stream::NoteEdit => "noteUpdatesStream".to_owned(), Stream::Notes => "notesStream".to_owned(), Stream::Main { user_id } => format!("mainStream:{user_id}"), Stream::Drive { user_id } => format!("driveStream:{user_id}"), From 8066c46476f2cfc7518da7f2a85dcfae07c0b77c Mon Sep 17 00:00:00 2001 From: naskya Date: Fri, 26 Jul 2024 07:33:13 +0900 Subject: [PATCH 16/43] chore: rename meta/instance to instanceMeta prevent name collision & improve code searchability (we eventually want to get rid of all these fetchMeta()s) --- packages/backend/src/daemons/server-stats.ts | 4 +- .../backend/src/misc/fetch-proxy-account.ts | 6 +- .../src/models/repositories/drive-file.ts | 14 +- .../src/remote/activitypub/check-fetch.ts | 8 +- .../src/remote/activitypub/models/image.ts | 4 +- packages/backend/src/server/activitypub.ts | 32 ++-- .../src/server/activitypub/featured.ts | 4 +- .../src/server/activitypub/followers.ts | 4 +- .../src/server/activitypub/following.ts | 4 +- .../backend/src/server/activitypub/outbox.ts | 4 +- packages/backend/src/server/api/call.ts | 4 +- .../src/server/api/endpoints/admin/meta.ts | 171 +++++++++--------- .../server/api/endpoints/antennas/create.ts | 4 +- .../src/server/api/endpoints/custom-motd.ts | 4 +- .../api/endpoints/custom-splash-icons.ts | 4 +- .../backend/src/server/api/endpoints/drive.ts | 4 +- .../api/endpoints/federation/instances.ts | 20 +- .../server/api/endpoints/hashtags/trend.ts | 4 +- .../backend/src/server/api/endpoints/meta.ts | 131 +++++++------- .../api/endpoints/notes/global-timeline.ts | 4 +- .../api/endpoints/notes/hybrid-timeline.ts | 4 +- .../api/endpoints/notes/local-timeline.ts | 4 +- .../endpoints/notes/recommended-timeline.ts | 6 +- .../src/server/api/endpoints/pinned-users.ts | 4 +- .../api/endpoints/recommended-instances.ts | 6 +- .../src/server/api/endpoints/sw/register.ts | 6 +- .../api/mastodon/converters/notification.ts | 4 +- .../src/server/api/mastodon/helpers/misc.ts | 44 ++--- .../src/server/api/mastodon/helpers/note.ts | 8 +- .../server/api/mastodon/helpers/timeline.ts | 4 +- .../api/mastodon/streaming/channels/public.ts | 4 +- .../backend/src/server/api/private/signup.ts | 16 +- .../api/stream/channels/global-timeline.ts | 6 +- .../api/stream/channels/hybrid-timeline.ts | 4 +- .../api/stream/channels/local-timeline.ts | 6 +- .../stream/channels/recommended-timeline.ts | 8 +- packages/backend/src/server/index.ts | 4 +- packages/backend/src/server/web/index.ts | 36 ++-- packages/backend/src/server/web/manifest.ts | 8 +- .../backend/src/server/web/url-preview.ts | 8 +- .../backend/src/services/drive/add-file.ts | 40 ++-- .../backend/src/services/drive/delete-file.ts | 6 +- packages/backend/src/services/send-email.ts | 21 ++- .../services/validate-email-for-account.ts | 4 +- 44 files changed, 354 insertions(+), 341 deletions(-) diff --git a/packages/backend/src/daemons/server-stats.ts b/packages/backend/src/daemons/server-stats.ts index 04a1542b11..c85a7a433e 100644 --- a/packages/backend/src/daemons/server-stats.ts +++ b/packages/backend/src/daemons/server-stats.ts @@ -13,8 +13,8 @@ export default async function () { ev.emit(`serverStatsLog:${x.id}`, log.slice(0, x.length || 50)); }); - const meta = await fetchMeta(); - if (!meta.enableServerMachineStats) return; + const instanceMeta = await fetchMeta(); + if (!instanceMeta.enableServerMachineStats) return; async function tick() { const stats = { diff --git a/packages/backend/src/misc/fetch-proxy-account.ts b/packages/backend/src/misc/fetch-proxy-account.ts index 26fb733781..836f64ce8b 100644 --- a/packages/backend/src/misc/fetch-proxy-account.ts +++ b/packages/backend/src/misc/fetch-proxy-account.ts @@ -3,9 +3,9 @@ import type { ILocalUser } from "@/models/entities/user.js"; import { Users } from "@/models/index.js"; export async function fetchProxyAccount(): Promise { - const meta = await fetchMeta(); - if (meta.proxyAccountId == null) return null; + const instanceMeta = await fetchMeta(); + if (instanceMeta.proxyAccountId == null) return null; return (await Users.findOneByOrFail({ - id: meta.proxyAccountId, + id: instanceMeta.proxyAccountId, })) as ILocalUser; } diff --git a/packages/backend/src/models/repositories/drive-file.ts b/packages/backend/src/models/repositories/drive-file.ts index 80ed1727d2..5c998c3d83 100644 --- a/packages/backend/src/models/repositories/drive-file.ts +++ b/packages/backend/src/models/repositories/drive-file.ts @@ -231,13 +231,13 @@ export const DriveFileRepository = db.getRepository(DriveFile).extend({ if (url.startsWith(`${config.url}/identicon`)) return url; if (url.startsWith(`${config.url}/avatar`)) return url; - const meta = await fetchMeta(); - const baseUrl = meta - ? meta.objectStorageBaseUrl ?? - `${meta.objectStorageUseSsl ? "https" : "http"}://${ - meta.objectStorageEndpoint - }${meta.objectStoragePort ? `:${meta.objectStoragePort}` : ""}/${ - meta.objectStorageBucket + const instanceMeta = await fetchMeta(); + const baseUrl = instanceMeta + ? instanceMeta.objectStorageBaseUrl ?? + `${instanceMeta.objectStorageUseSsl ? "https" : "http"}://${ + instanceMeta.objectStorageEndpoint + }${instanceMeta.objectStoragePort ? `:${instanceMeta.objectStoragePort}` : ""}/${ + instanceMeta.objectStorageBucket }` : null; if (baseUrl !== null && url.startsWith(baseUrl)) return url; diff --git a/packages/backend/src/remote/activitypub/check-fetch.ts b/packages/backend/src/remote/activitypub/check-fetch.ts index 3ab10f1939..77201d1348 100644 --- a/packages/backend/src/remote/activitypub/check-fetch.ts +++ b/packages/backend/src/remote/activitypub/check-fetch.ts @@ -15,8 +15,8 @@ import type { UserPublickey } from "@/models/entities/user-publickey.js"; import { verify } from "node:crypto"; export async function hasSignature(req: IncomingMessage): Promise { - const meta = await fetchMeta(); - const required = meta.secureMode || meta.privateMode; + const instanceMeta = await fetchMeta(); + const required = instanceMeta.secureMode || instanceMeta.privateMode; try { httpSignature.parseRequest(req, { headers: [] }); @@ -30,8 +30,8 @@ export async function hasSignature(req: IncomingMessage): Promise { } export async function checkFetch(req: IncomingMessage): Promise { - const meta = await fetchMeta(); - if (meta.secureMode || meta.privateMode) { + const instanceMeta = await fetchMeta(); + if (instanceMeta.secureMode || instanceMeta.privateMode) { if (req.headers.host !== config.host) return 400; let signature; diff --git a/packages/backend/src/remote/activitypub/models/image.ts b/packages/backend/src/remote/activitypub/models/image.ts index e8ba7629a8..22746dab89 100644 --- a/packages/backend/src/remote/activitypub/models/image.ts +++ b/packages/backend/src/remote/activitypub/models/image.ts @@ -36,14 +36,14 @@ export async function createImage( apLogger.info(`Creating an image: ${image.url}`); - const instance = await fetchMeta(); + const instanceMeta = await fetchMeta(); let file = await uploadFromUrl({ url: image.url, user: actor, uri: image.url, sensitive: image.sensitive, - isLink: !instance.cacheRemoteFiles, + isLink: !instanceMeta.cacheRemoteFiles, comment: truncate(image.name, config.maxCaptionLength), usageHint: usage, }); diff --git a/packages/backend/src/server/activitypub.ts b/packages/backend/src/server/activitypub.ts index 7b05ebffd0..84a72f54cc 100644 --- a/packages/backend/src/server/activitypub.ts +++ b/packages/backend/src/server/activitypub.ts @@ -242,8 +242,8 @@ router.get("/notes/:note", async (ctx, next) => { ctx.body = renderActivity(await renderNote(note, false)); - const meta = await fetchMeta(); - if (meta.secureMode || meta.privateMode) { + const instanceMeta = await fetchMeta(); + if (instanceMeta.secureMode || instanceMeta.privateMode) { ctx.set("Cache-Control", "private, max-age=0, must-revalidate"); } else { ctx.set("Cache-Control", "public, max-age=180"); @@ -272,8 +272,8 @@ router.get("/notes/:note/activity", async (ctx) => { } ctx.body = renderActivity(await packActivity(note)); - const meta = await fetchMeta(); - if (meta.secureMode || meta.privateMode) { + const instanceMeta = await fetchMeta(); + if (instanceMeta.secureMode || instanceMeta.privateMode) { ctx.set("Cache-Control", "private, max-age=0, must-revalidate"); } else { ctx.set("Cache-Control", "public, max-age=180"); @@ -327,8 +327,8 @@ router.get("/users/:user/publickey", async (ctx) => { if (Users.isLocalUser(user)) { ctx.body = renderActivity(renderKey(user, keypair)); - const meta = await fetchMeta(); - if (meta.secureMode || meta.privateMode) { + const instanceMeta = await fetchMeta(); + if (instanceMeta.secureMode || instanceMeta.privateMode) { ctx.set("Cache-Control", "private, max-age=0, must-revalidate"); } else { ctx.set("Cache-Control", "public, max-age=180"); @@ -347,8 +347,8 @@ async function userInfo(ctx: Router.RouterContext, user: User | null) { } ctx.body = renderActivity(await renderPerson(user as ILocalUser)); - const meta = await fetchMeta(); - if (meta.secureMode || meta.privateMode) { + const instanceMeta = await fetchMeta(); + if (instanceMeta.secureMode || instanceMeta.privateMode) { ctx.set("Cache-Control", "private, max-age=0, must-revalidate"); } else { ctx.set("Cache-Control", "public, max-age=180"); @@ -431,8 +431,8 @@ router.get("/emojis/:emoji", async (ctx) => { } ctx.body = renderActivity(renderEmoji(emoji)); - const meta = await fetchMeta(); - if (meta.secureMode || meta.privateMode) { + const instanceMeta = await fetchMeta(); + if (instanceMeta.secureMode || instanceMeta.privateMode) { ctx.set("Cache-Control", "private, max-age=0, must-revalidate"); } else { ctx.set("Cache-Control", "public, max-age=180"); @@ -463,8 +463,8 @@ router.get("/likes/:like", async (ctx) => { } ctx.body = renderActivity(await renderLike(reaction, note)); - const meta = await fetchMeta(); - if (meta.secureMode || meta.privateMode) { + const instanceMeta = await fetchMeta(); + if (instanceMeta.secureMode || instanceMeta.privateMode) { ctx.set("Cache-Control", "private, max-age=0, must-revalidate"); } else { ctx.set("Cache-Control", "public, max-age=180"); @@ -501,8 +501,8 @@ router.get( } ctx.body = renderActivity(renderFollow(follower, followee)); - const meta = await fetchMeta(); - if (meta.secureMode || meta.privateMode) { + const instanceMeta = await fetchMeta(); + if (instanceMeta.secureMode || instanceMeta.privateMode) { ctx.set("Cache-Control", "private, max-age=0, must-revalidate"); } else { ctx.set("Cache-Control", "public, max-age=180"); @@ -544,8 +544,8 @@ router.get("/follows/:followRequestId", async (ctx: Router.RouterContext) => { return; } - const meta = await fetchMeta(); - if (meta.secureMode || meta.privateMode) { + const instanceMeta = await fetchMeta(); + if (instanceMeta.secureMode || instanceMeta.privateMode) { ctx.set("Cache-Control", "private, max-age=0, must-revalidate"); } else { ctx.set("Cache-Control", "public, max-age=180"); diff --git a/packages/backend/src/server/activitypub/featured.ts b/packages/backend/src/server/activitypub/featured.ts index 4dc93e734a..ae7ee80708 100644 --- a/packages/backend/src/server/activitypub/featured.ts +++ b/packages/backend/src/server/activitypub/featured.ts @@ -57,8 +57,8 @@ export default async (ctx: Router.RouterContext) => { ctx.body = renderActivity(rendered); - const meta = await fetchMeta(); - if (meta.secureMode || meta.privateMode) { + const instanceMeta = await fetchMeta(); + if (instanceMeta.secureMode || instanceMeta.privateMode) { ctx.set("Cache-Control", "private, max-age=0, must-revalidate"); } else { ctx.set("Cache-Control", "public, max-age=180"); diff --git a/packages/backend/src/server/activitypub/followers.ts b/packages/backend/src/server/activitypub/followers.ts index 92d6e800ea..96391e213a 100644 --- a/packages/backend/src/server/activitypub/followers.ts +++ b/packages/backend/src/server/activitypub/followers.ts @@ -110,8 +110,8 @@ export default async (ctx: Router.RouterContext) => { ctx.body = renderActivity(rendered); setResponseType(ctx); } - const meta = await fetchMeta(); - if (meta.secureMode || meta.privateMode) { + const instanceMeta = await fetchMeta(); + if (instanceMeta.secureMode || instanceMeta.privateMode) { ctx.set("Cache-Control", "private, max-age=0, must-revalidate"); } else { ctx.set("Cache-Control", "public, max-age=180"); diff --git a/packages/backend/src/server/activitypub/following.ts b/packages/backend/src/server/activitypub/following.ts index 8ded68b8c4..9270d39efe 100644 --- a/packages/backend/src/server/activitypub/following.ts +++ b/packages/backend/src/server/activitypub/following.ts @@ -110,8 +110,8 @@ export default async (ctx: Router.RouterContext) => { ctx.body = renderActivity(rendered); setResponseType(ctx); } - const meta = await fetchMeta(); - if (meta.secureMode || meta.privateMode) { + const instanceMeta = await fetchMeta(); + if (instanceMeta.secureMode || instanceMeta.privateMode) { ctx.set("Cache-Control", "private, max-age=0, must-revalidate"); } else { ctx.set("Cache-Control", "public, max-age=180"); diff --git a/packages/backend/src/server/activitypub/outbox.ts b/packages/backend/src/server/activitypub/outbox.ts index f04dcb6bf6..cd4bde64cd 100644 --- a/packages/backend/src/server/activitypub/outbox.ts +++ b/packages/backend/src/server/activitypub/outbox.ts @@ -117,8 +117,8 @@ export default async (ctx: Router.RouterContext) => { setResponseType(ctx); } - const meta = await fetchMeta(); - if (meta.secureMode || meta.privateMode) { + const instanceMeta = await fetchMeta(); + if (instanceMeta.secureMode || instanceMeta.privateMode) { ctx.set("Cache-Control", "private, max-age=0, must-revalidate"); } else { ctx.set("Cache-Control", "public, max-age=180"); diff --git a/packages/backend/src/server/api/call.ts b/packages/backend/src/server/api/call.ts index 80be763b13..bb6936f0a4 100644 --- a/packages/backend/src/server/api/call.ts +++ b/packages/backend/src/server/api/call.ts @@ -117,9 +117,9 @@ export default async ( } // private mode - const meta = await fetchMeta(); + const instanceMeta = await fetchMeta(); if ( - meta.privateMode && + instanceMeta.privateMode && ep.meta.requireCredentialPrivateMode && user == null ) { diff --git a/packages/backend/src/server/api/endpoints/admin/meta.ts b/packages/backend/src/server/api/endpoints/admin/meta.ts index 052f89452e..674262c5e0 100644 --- a/packages/backend/src/server/api/endpoints/admin/meta.ts +++ b/packages/backend/src/server/api/endpoints/admin/meta.ts @@ -470,97 +470,98 @@ export const paramDef = { } as const; export default define(meta, paramDef, async () => { - const instance = await fetchMeta(); + const instanceMeta = await fetchMeta(); return { - maintainerName: instance.maintainerName, - maintainerEmail: instance.maintainerEmail, + maintainerName: instanceMeta.maintainerName, + maintainerEmail: instanceMeta.maintainerEmail, version: config.version, - name: instance.name, + name: instanceMeta.name, uri: config.url, - description: instance.description, - langs: instance.langs, - tosUrl: instance.tosUrl, - moreUrls: instance.moreUrls, - repositoryUrl: instance.repositoryUrl, - feedbackUrl: instance.feedbackUrl, - disableRegistration: instance.disableRegistration, - disableLocalTimeline: instance.disableLocalTimeline, - disableRecommendedTimeline: instance.disableRecommendedTimeline, - disableGlobalTimeline: instance.disableGlobalTimeline, - enableGuestTimeline: instance.enableGuestTimeline, - driveCapacityPerLocalUserMb: instance.localDriveCapacityMb, - driveCapacityPerRemoteUserMb: instance.remoteDriveCapacityMb, - antennaLimit: instance.antennaLimit, - emailRequiredForSignup: instance.emailRequiredForSignup, - enableHcaptcha: instance.enableHcaptcha, - hcaptchaSiteKey: instance.hcaptchaSiteKey, - enableRecaptcha: instance.enableRecaptcha, - recaptchaSiteKey: instance.recaptchaSiteKey, - swPublickey: instance.swPublicKey, - themeColor: instance.themeColor, - mascotImageUrl: instance.mascotImageUrl, - bannerUrl: instance.bannerUrl, - errorImageUrl: instance.errorImageUrl, - iconUrl: instance.iconUrl, - backgroundImageUrl: instance.backgroundImageUrl, - logoImageUrl: instance.logoImageUrl, + description: instanceMeta.description, + langs: instanceMeta.langs, + tosUrl: instanceMeta.tosUrl, + moreUrls: instanceMeta.moreUrls, + repositoryUrl: instanceMeta.repositoryUrl, + feedbackUrl: instanceMeta.feedbackUrl, + disableRegistration: instanceMeta.disableRegistration, + disableLocalTimeline: instanceMeta.disableLocalTimeline, + disableRecommendedTimeline: instanceMeta.disableRecommendedTimeline, + disableGlobalTimeline: instanceMeta.disableGlobalTimeline, + enableGuestTimeline: instanceMeta.enableGuestTimeline, + driveCapacityPerLocalUserMb: instanceMeta.localDriveCapacityMb, + driveCapacityPerRemoteUserMb: instanceMeta.remoteDriveCapacityMb, + antennaLimit: instanceMeta.antennaLimit, + emailRequiredForSignup: instanceMeta.emailRequiredForSignup, + enableHcaptcha: instanceMeta.enableHcaptcha, + hcaptchaSiteKey: instanceMeta.hcaptchaSiteKey, + enableRecaptcha: instanceMeta.enableRecaptcha, + recaptchaSiteKey: instanceMeta.recaptchaSiteKey, + swPublickey: instanceMeta.swPublicKey, + themeColor: instanceMeta.themeColor, + mascotImageUrl: instanceMeta.mascotImageUrl, + bannerUrl: instanceMeta.bannerUrl, + errorImageUrl: instanceMeta.errorImageUrl, + iconUrl: instanceMeta.iconUrl, + backgroundImageUrl: instanceMeta.backgroundImageUrl, + logoImageUrl: instanceMeta.logoImageUrl, maxNoteTextLength: config.maxNoteLength, // for backward compatibility maxCaptionTextLength: config.maxCaptionLength, - defaultLightTheme: instance.defaultLightTheme, - defaultDarkTheme: instance.defaultDarkTheme, - enableEmail: instance.enableEmail, - enableServiceWorker: instance.enableServiceWorker, + defaultLightTheme: instanceMeta.defaultLightTheme, + defaultDarkTheme: instanceMeta.defaultDarkTheme, + enableEmail: instanceMeta.enableEmail, + enableServiceWorker: instanceMeta.enableServiceWorker, translatorAvailable: - instance.deeplAuthKey != null || instance.libreTranslateApiUrl != null, - pinnedPages: instance.pinnedPages, - pinnedClipId: instance.pinnedClipId, - cacheRemoteFiles: instance.cacheRemoteFiles, - markLocalFilesNsfwByDefault: instance.markLocalFilesNsfwByDefault, - defaultReaction: instance.defaultReaction, - recommendedInstances: instance.recommendedInstances, - pinnedUsers: instance.pinnedUsers, - customMOTD: instance.customMotd, - customSplashIcons: instance.customSplashIcons, - hiddenTags: instance.hiddenTags, - blockedHosts: instance.blockedHosts, - silencedHosts: instance.silencedHosts, - allowedHosts: instance.allowedHosts, - privateMode: instance.privateMode, - secureMode: instance.secureMode, - hcaptchaSecretKey: instance.hcaptchaSecretKey, - recaptchaSecretKey: instance.recaptchaSecretKey, - proxyAccountId: instance.proxyAccountId, - summalyProxy: instance.summalyProxy, - email: instance.email, - smtpSecure: instance.smtpSecure, - smtpHost: instance.smtpHost, - smtpPort: instance.smtpPort, - smtpUser: instance.smtpUser, - smtpPass: instance.smtpPass, - swPrivateKey: instance.swPrivateKey, - useObjectStorage: instance.useObjectStorage, - objectStorageBaseUrl: instance.objectStorageBaseUrl, - objectStorageBucket: instance.objectStorageBucket, - objectStoragePrefix: instance.objectStoragePrefix, - objectStorageEndpoint: instance.objectStorageEndpoint, - objectStorageRegion: instance.objectStorageRegion, - objectStoragePort: instance.objectStoragePort, - objectStorageAccessKey: instance.objectStorageAccessKey, - objectStorageSecretKey: instance.objectStorageSecretKey, - objectStorageUseSSL: instance.objectStorageUseSsl, - objectStorageUseProxy: instance.objectStorageUseProxy, - objectStorageSetPublicRead: instance.objectStorageSetPublicRead, - objectStorageS3ForcePathStyle: instance.objectStorageS3ForcePathStyle, - deeplAuthKey: instance.deeplAuthKey, - deeplIsPro: instance.deeplIsPro, - libreTranslateApiUrl: instance.libreTranslateApiUrl, - libreTranslateApiKey: instance.libreTranslateApiKey, - enableIpLogging: instance.enableIpLogging, - enableActiveEmailValidation: instance.enableActiveEmailValidation, - experimentalFeatures: instance.experimentalFeatures, - enableServerMachineStats: instance.enableServerMachineStats, - enableIdenticonGeneration: instance.enableIdenticonGeneration, - donationLink: instance.donationLink, + instanceMeta.deeplAuthKey != null || + instanceMeta.libreTranslateApiUrl != null, + pinnedPages: instanceMeta.pinnedPages, + pinnedClipId: instanceMeta.pinnedClipId, + cacheRemoteFiles: instanceMeta.cacheRemoteFiles, + markLocalFilesNsfwByDefault: instanceMeta.markLocalFilesNsfwByDefault, + defaultReaction: instanceMeta.defaultReaction, + recommendedInstances: instanceMeta.recommendedInstances, + pinnedUsers: instanceMeta.pinnedUsers, + customMOTD: instanceMeta.customMotd, + customSplashIcons: instanceMeta.customSplashIcons, + hiddenTags: instanceMeta.hiddenTags, + blockedHosts: instanceMeta.blockedHosts, + silencedHosts: instanceMeta.silencedHosts, + allowedHosts: instanceMeta.allowedHosts, + privateMode: instanceMeta.privateMode, + secureMode: instanceMeta.secureMode, + hcaptchaSecretKey: instanceMeta.hcaptchaSecretKey, + recaptchaSecretKey: instanceMeta.recaptchaSecretKey, + proxyAccountId: instanceMeta.proxyAccountId, + summalyProxy: instanceMeta.summalyProxy, + email: instanceMeta.email, + smtpSecure: instanceMeta.smtpSecure, + smtpHost: instanceMeta.smtpHost, + smtpPort: instanceMeta.smtpPort, + smtpUser: instanceMeta.smtpUser, + smtpPass: instanceMeta.smtpPass, + swPrivateKey: instanceMeta.swPrivateKey, + useObjectStorage: instanceMeta.useObjectStorage, + objectStorageBaseUrl: instanceMeta.objectStorageBaseUrl, + objectStorageBucket: instanceMeta.objectStorageBucket, + objectStoragePrefix: instanceMeta.objectStoragePrefix, + objectStorageEndpoint: instanceMeta.objectStorageEndpoint, + objectStorageRegion: instanceMeta.objectStorageRegion, + objectStoragePort: instanceMeta.objectStoragePort, + objectStorageAccessKey: instanceMeta.objectStorageAccessKey, + objectStorageSecretKey: instanceMeta.objectStorageSecretKey, + objectStorageUseSSL: instanceMeta.objectStorageUseSsl, + objectStorageUseProxy: instanceMeta.objectStorageUseProxy, + objectStorageSetPublicRead: instanceMeta.objectStorageSetPublicRead, + objectStorageS3ForcePathStyle: instanceMeta.objectStorageS3ForcePathStyle, + deeplAuthKey: instanceMeta.deeplAuthKey, + deeplIsPro: instanceMeta.deeplIsPro, + libreTranslateApiUrl: instanceMeta.libreTranslateApiUrl, + libreTranslateApiKey: instanceMeta.libreTranslateApiKey, + enableIpLogging: instanceMeta.enableIpLogging, + enableActiveEmailValidation: instanceMeta.enableActiveEmailValidation, + experimentalFeatures: instanceMeta.experimentalFeatures, + enableServerMachineStats: instanceMeta.enableServerMachineStats, + enableIdenticonGeneration: instanceMeta.enableIdenticonGeneration, + donationLink: instanceMeta.donationLink, }; }); diff --git a/packages/backend/src/server/api/endpoints/antennas/create.ts b/packages/backend/src/server/api/endpoints/antennas/create.ts index 69dd19b0cb..332cff3ab6 100644 --- a/packages/backend/src/server/api/endpoints/antennas/create.ts +++ b/packages/backend/src/server/api/endpoints/antennas/create.ts @@ -123,12 +123,12 @@ export default define(meta, paramDef, async (ps, user) => { let userList; let userGroupJoining; - const instance = await fetchMeta(); + const instanceMeta = await fetchMeta(); const antennas = await Antennas.findBy({ userId: user.id, }); - if (antennas.length >= instance.antennaLimit) { + if (antennas.length >= instanceMeta.antennaLimit) { throw new ApiError(meta.errors.tooManyAntennas); } diff --git a/packages/backend/src/server/api/endpoints/custom-motd.ts b/packages/backend/src/server/api/endpoints/custom-motd.ts index ea3571a362..ebcc42bdbc 100644 --- a/packages/backend/src/server/api/endpoints/custom-motd.ts +++ b/packages/backend/src/server/api/endpoints/custom-motd.ts @@ -27,7 +27,7 @@ export const paramDef = { } as const; export default define(meta, paramDef, async () => { - const meta = await fetchMeta(); - const motd = await Promise.all(meta.customMotd.map((x) => x)); + const instanceMeta = await fetchMeta(); + const motd = await Promise.all(instanceMeta.customMotd.map((x) => x)); return motd; }); 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 2493ea0bde..d133a6300c 100644 --- a/packages/backend/src/server/api/endpoints/custom-splash-icons.ts +++ b/packages/backend/src/server/api/endpoints/custom-splash-icons.ts @@ -27,7 +27,7 @@ export const paramDef = { } as const; export default define(meta, paramDef, async () => { - const meta = await fetchMeta(); - const icons = await Promise.all(meta.customSplashIcons.map((x) => x)); + const instanceMeta = await fetchMeta(); + const icons = await Promise.all(instanceMeta.customSplashIcons.map((x) => x)); return icons; }); diff --git a/packages/backend/src/server/api/endpoints/drive.ts b/packages/backend/src/server/api/endpoints/drive.ts index f19ccf3b45..f9b1bb84c4 100644 --- a/packages/backend/src/server/api/endpoints/drive.ts +++ b/packages/backend/src/server/api/endpoints/drive.ts @@ -35,7 +35,7 @@ export const paramDef = { } as const; export default define(meta, paramDef, async (ps, user) => { - const instance = await fetchMeta(); + const instanceMeta = await fetchMeta(); // Calculate drive usage const usage = await DriveFiles.calcDriveUsageOf(user.id); @@ -44,7 +44,7 @@ export default define(meta, paramDef, async (ps, user) => { capacity: 1024 * 1024 * - (user.driveCapacityOverrideMb || instance.localDriveCapacityMb), + (user.driveCapacityOverrideMb || instanceMeta.localDriveCapacityMb), usage: usage, }; }); diff --git a/packages/backend/src/server/api/endpoints/federation/instances.ts b/packages/backend/src/server/api/endpoints/federation/instances.ts index ab636ac2f7..ae6617d1b7 100644 --- a/packages/backend/src/server/api/endpoints/federation/instances.ts +++ b/packages/backend/src/server/api/endpoints/federation/instances.ts @@ -100,33 +100,33 @@ export default define(meta, paramDef, async (ps, me) => { } if (typeof ps.blocked === "boolean") { - const meta = await fetchMeta(); + const instanceMeta = await fetchMeta(); if (ps.blocked) { - if (meta.blockedHosts.length === 0) { + if (instanceMeta.blockedHosts.length === 0) { return []; } query.andWhere("instance.host IN (:...blocks)", { - blocks: meta.blockedHosts, + blocks: instanceMeta.blockedHosts, }); - } else if (meta.blockedHosts.length > 0) { + } else if (instanceMeta.blockedHosts.length > 0) { query.andWhere("instance.host NOT IN (:...blocks)", { - blocks: meta.blockedHosts, + blocks: instanceMeta.blockedHosts, }); } } if (typeof ps.silenced === "boolean") { - const meta = await fetchMeta(); + const instanceMeta = await fetchMeta(); if (ps.silenced) { - if (meta.silencedHosts.length === 0) { + if (instanceMeta.silencedHosts.length === 0) { return []; } query.andWhere("instance.host IN (:...silences)", { - silences: meta.silencedHosts, + silences: instanceMeta.silencedHosts, }); - } else if (meta.silencedHosts.length > 0) { + } else if (instanceMeta.silencedHosts.length > 0) { query.andWhere("instance.host NOT IN (:...silences)", { - silences: meta.silencedHosts, + silences: instanceMeta.silencedHosts, }); } } diff --git a/packages/backend/src/server/api/endpoints/hashtags/trend.ts b/packages/backend/src/server/api/endpoints/hashtags/trend.ts index 2f606110fa..0a5586445a 100644 --- a/packages/backend/src/server/api/endpoints/hashtags/trend.ts +++ b/packages/backend/src/server/api/endpoints/hashtags/trend.ts @@ -66,8 +66,8 @@ export const paramDef = { } as const; export default define(meta, paramDef, async () => { - const instance = await fetchMeta(); - const hiddenTags = instance.hiddenTags.map((t) => normalizeForSearch(t)); + const instanceMeta = await fetchMeta(); + const hiddenTags = instanceMeta.hiddenTags.map((t) => normalizeForSearch(t)); const now = new Date(); // 5分単位で丸めた現在日時 now.setMinutes(Math.round(now.getMinutes() / 5) * 5, 0, 0); diff --git a/packages/backend/src/server/api/endpoints/meta.ts b/packages/backend/src/server/api/endpoints/meta.ts index 5c74bb32df..aca84c5b34 100644 --- a/packages/backend/src/server/api/endpoints/meta.ts +++ b/packages/backend/src/server/api/endpoints/meta.ts @@ -402,7 +402,7 @@ export const paramDef = { } as const; export default define(meta, paramDef, async (ps, me) => { - const instance = await fetchMeta(); + const instanceMeta = await fetchMeta(); const emojis = await Emojis.find({ where: { @@ -425,56 +425,57 @@ export default define(meta, paramDef, async (ps, me) => { }); const response: any = { - maintainerName: instance.maintainerName, - maintainerEmail: instance.maintainerEmail, + maintainerName: instanceMeta.maintainerName, + maintainerEmail: instanceMeta.maintainerEmail, version: config.version, - name: instance.name, + name: instanceMeta.name, uri: config.url, - description: instance.description, - langs: instance.langs, - tosUrl: instance.tosUrl, - moreUrls: instance.moreUrls, - repositoryUrl: instance.repositoryUrl, - feedbackUrl: instance.feedbackUrl, + description: instanceMeta.description, + langs: instanceMeta.langs, + tosUrl: instanceMeta.tosUrl, + moreUrls: instanceMeta.moreUrls, + repositoryUrl: instanceMeta.repositoryUrl, + feedbackUrl: instanceMeta.feedbackUrl, - secureMode: instance.secureMode, - privateMode: instance.privateMode, + secureMode: instanceMeta.secureMode, + privateMode: instanceMeta.privateMode, - disableRegistration: instance.disableRegistration, - disableLocalTimeline: instance.disableLocalTimeline, - disableRecommendedTimeline: instance.disableRecommendedTimeline, - disableGlobalTimeline: instance.disableGlobalTimeline, - enableGuestTimeline: instance.enableGuestTimeline, - driveCapacityPerLocalUserMb: instance.localDriveCapacityMb, - driveCapacityPerRemoteUserMb: instance.remoteDriveCapacityMb, - antennaLimit: instance.antennaLimit, - emailRequiredForSignup: instance.emailRequiredForSignup, - enableHcaptcha: instance.enableHcaptcha, - hcaptchaSiteKey: instance.hcaptchaSiteKey, - enableRecaptcha: instance.enableRecaptcha, - recaptchaSiteKey: instance.recaptchaSiteKey, - swPublickey: instance.swPublicKey, - themeColor: instance.themeColor, - mascotImageUrl: instance.mascotImageUrl, - bannerUrl: instance.bannerUrl, - errorImageUrl: instance.errorImageUrl, - iconUrl: instance.iconUrl, - backgroundImageUrl: instance.backgroundImageUrl, - logoImageUrl: instance.logoImageUrl, + disableRegistration: instanceMeta.disableRegistration, + disableLocalTimeline: instanceMeta.disableLocalTimeline, + disableRecommendedTimeline: instanceMeta.disableRecommendedTimeline, + disableGlobalTimeline: instanceMeta.disableGlobalTimeline, + enableGuestTimeline: instanceMeta.enableGuestTimeline, + driveCapacityPerLocalUserMb: instanceMeta.localDriveCapacityMb, + driveCapacityPerRemoteUserMb: instanceMeta.remoteDriveCapacityMb, + antennaLimit: instanceMeta.antennaLimit, + emailRequiredForSignup: instanceMeta.emailRequiredForSignup, + enableHcaptcha: instanceMeta.enableHcaptcha, + hcaptchaSiteKey: instanceMeta.hcaptchaSiteKey, + enableRecaptcha: instanceMeta.enableRecaptcha, + recaptchaSiteKey: instanceMeta.recaptchaSiteKey, + swPublickey: instanceMeta.swPublicKey, + themeColor: instanceMeta.themeColor, + mascotImageUrl: instanceMeta.mascotImageUrl, + bannerUrl: instanceMeta.bannerUrl, + errorImageUrl: instanceMeta.errorImageUrl, + iconUrl: instanceMeta.iconUrl, + backgroundImageUrl: instanceMeta.backgroundImageUrl, + logoImageUrl: instanceMeta.logoImageUrl, maxNoteTextLength: config.maxNoteLength, // for backward compatibility maxCaptionTextLength: config.maxCaptionLength, - emojis: instance.privateMode && !me ? [] : await Emojis.packMany(emojis), + emojis: + instanceMeta.privateMode && !me ? [] : await Emojis.packMany(emojis), // クライアントの手間を減らすためあらかじめJSONに変換しておく - defaultLightTheme: instance.defaultLightTheme - ? JSON.stringify(JSON5.parse(instance.defaultLightTheme)) + defaultLightTheme: instanceMeta.defaultLightTheme + ? JSON.stringify(JSON5.parse(instanceMeta.defaultLightTheme)) : null, - defaultDarkTheme: instance.defaultDarkTheme - ? JSON.stringify(JSON5.parse(instance.defaultDarkTheme)) + defaultDarkTheme: instanceMeta.defaultDarkTheme + ? JSON.stringify(JSON5.parse(instanceMeta.defaultDarkTheme)) : null, ads: - instance.privateMode && !me + instanceMeta.privateMode && !me ? [] : ads.map((ad) => ({ id: ad.id, @@ -483,50 +484,52 @@ export default define(meta, paramDef, async (ps, me) => { ratio: ad.ratio, imageUrl: ad.imageUrl, })), - enableEmail: instance.enableEmail, + enableEmail: instanceMeta.enableEmail, - enableServiceWorker: instance.enableServiceWorker, + enableServiceWorker: instanceMeta.enableServiceWorker, translatorAvailable: - instance.deeplAuthKey != null || instance.libreTranslateApiUrl != null, - defaultReaction: instance.defaultReaction, - donationLink: instance.donationLink, - enableServerMachineStats: instance.enableServerMachineStats, - enableIdenticonGeneration: instance.enableIdenticonGeneration, + instanceMeta.deeplAuthKey != null || + instanceMeta.libreTranslateApiUrl != null, + defaultReaction: instanceMeta.defaultReaction, + donationLink: instanceMeta.donationLink, + enableServerMachineStats: instanceMeta.enableServerMachineStats, + enableIdenticonGeneration: instanceMeta.enableIdenticonGeneration, ...(ps.detail ? { - pinnedPages: instance.privateMode && !me ? [] : instance.pinnedPages, + pinnedPages: + instanceMeta.privateMode && !me ? [] : instanceMeta.pinnedPages, pinnedClipId: - instance.privateMode && !me ? [] : instance.pinnedClipId, - cacheRemoteFiles: instance.cacheRemoteFiles, - markLocalFilesNsfwByDefault: instance.markLocalFilesNsfwByDefault, + instanceMeta.privateMode && !me ? [] : instanceMeta.pinnedClipId, + cacheRemoteFiles: instanceMeta.cacheRemoteFiles, + markLocalFilesNsfwByDefault: instanceMeta.markLocalFilesNsfwByDefault, requireSetup: (await countLocalUsers()) === 0, } : {}), }; if (ps.detail) { - if (!instance.privateMode || me) { - const proxyAccount = instance.proxyAccountId - ? await Users.pack(instance.proxyAccountId).catch(() => null) + if (!instanceMeta.privateMode || me) { + const proxyAccount = instanceMeta.proxyAccountId + ? await Users.pack(instanceMeta.proxyAccountId).catch(() => null) : null; response.proxyAccountName = proxyAccount ? proxyAccount.username : null; } response.features = { - registration: !instance.disableRegistration, - localTimeLine: !instance.disableLocalTimeline, - recommendedTimeline: !instance.disableRecommendedTimeline, - globalTimeLine: !instance.disableGlobalTimeline, - guestTimeline: instance.enableGuestTimeline, - emailRequiredForSignup: instance.emailRequiredForSignup, - hcaptcha: instance.enableHcaptcha, - recaptcha: instance.enableRecaptcha, - objectStorage: instance.useObjectStorage, - serviceWorker: instance.enableServiceWorker, + registration: !instanceMeta.disableRegistration, + localTimeLine: !instanceMeta.disableLocalTimeline, + recommendedTimeline: !instanceMeta.disableRecommendedTimeline, + globalTimeLine: !instanceMeta.disableGlobalTimeline, + guestTimeline: instanceMeta.enableGuestTimeline, + emailRequiredForSignup: instanceMeta.emailRequiredForSignup, + hcaptcha: instanceMeta.enableHcaptcha, + recaptcha: instanceMeta.enableRecaptcha, + objectStorage: instanceMeta.useObjectStorage, + serviceWorker: instanceMeta.enableServiceWorker, postEditing: true, - postImports: instance.experimentalFeatures?.postImports || false, + postImports: instanceMeta.experimentalFeatures?.postImports || false, miauth: true, }; } 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 a56f4ae9d6..31ec70285e 100644 --- a/packages/backend/src/server/api/endpoints/notes/global-timeline.ts +++ b/packages/backend/src/server/api/endpoints/notes/global-timeline.ts @@ -64,8 +64,8 @@ export const paramDef = { } as const; export default define(meta, paramDef, async (ps, user) => { - const m = await fetchMeta(); - if (m.disableGlobalTimeline) { + const instanceMeta = await fetchMeta(); + if (instanceMeta.disableGlobalTimeline) { if (user == null || !(user.isAdmin || user.isModerator)) { throw new ApiError(meta.errors.gtlDisabled); } 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 3b5486ec8c..5cc00d8e2d 100644 --- a/packages/backend/src/server/api/endpoints/notes/hybrid-timeline.ts +++ b/packages/backend/src/server/api/endpoints/notes/hybrid-timeline.ts @@ -71,8 +71,8 @@ export const paramDef = { } as const; export default define(meta, paramDef, async (ps, user) => { - const m = await fetchMeta(); - if (m.disableLocalTimeline && !user.isAdmin && !user.isModerator) { + const instanceMeta = await fetchMeta(); + if (instanceMeta.disableLocalTimeline && !user.isAdmin && !user.isModerator) { throw new ApiError(meta.errors.stlDisabled); } 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 1d7453e67f..c2720f4544 100644 --- a/packages/backend/src/server/api/endpoints/notes/local-timeline.ts +++ b/packages/backend/src/server/api/endpoints/notes/local-timeline.ts @@ -74,8 +74,8 @@ export const paramDef = { } as const; export default define(meta, paramDef, async (ps, user) => { - const m = await fetchMeta(); - if (m.disableLocalTimeline) { + const instanceMeta = await fetchMeta(); + if (instanceMeta.disableLocalTimeline) { if (user == null || !(user.isAdmin || user.isModerator)) { throw new ApiError(meta.errors.ltlDisabled); } 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 a2aba37aa2..65ac2129a5 100644 --- a/packages/backend/src/server/api/endpoints/notes/recommended-timeline.ts +++ b/packages/backend/src/server/api/endpoints/notes/recommended-timeline.ts @@ -74,8 +74,8 @@ export const paramDef = { } as const; export default define(meta, paramDef, async (ps, user) => { - const m = await fetchMeta(); - if (m.disableRecommendedTimeline) { + const instanceMeta = await fetchMeta(); + if (instanceMeta.disableRecommendedTimeline) { if (user == null || !(user.isAdmin || user.isModerator)) { throw new ApiError(meta.errors.rtlDisabled); } @@ -90,7 +90,7 @@ export default define(meta, paramDef, async (ps, user) => { ps.untilDate, ) .andWhere( - `(note.userHost = ANY ('{"${m.recommendedInstances.join('","')}"}'))`, + `(note.userHost = ANY ('{"${instanceMeta.recommendedInstances.join('","')}"}'))`, ) .andWhere("(note.visibility = 'public')") .innerJoinAndSelect("note.user", "user") diff --git a/packages/backend/src/server/api/endpoints/pinned-users.ts b/packages/backend/src/server/api/endpoints/pinned-users.ts index 7762159f11..09d4c6a877 100644 --- a/packages/backend/src/server/api/endpoints/pinned-users.ts +++ b/packages/backend/src/server/api/endpoints/pinned-users.ts @@ -30,10 +30,10 @@ export const paramDef = { } as const; export default define(meta, paramDef, async (ps, me) => { - const meta = await fetchMeta(); + const instanceMeta = await fetchMeta(); const users = await Promise.all( - meta.pinnedUsers + instanceMeta.pinnedUsers .map((acct) => stringToAcct(acct)) .map((acct) => Users.findOneBy({ diff --git a/packages/backend/src/server/api/endpoints/recommended-instances.ts b/packages/backend/src/server/api/endpoints/recommended-instances.ts index abdcb420e8..c305dfa398 100644 --- a/packages/backend/src/server/api/endpoints/recommended-instances.ts +++ b/packages/backend/src/server/api/endpoints/recommended-instances.ts @@ -27,7 +27,9 @@ export const paramDef = { } as const; export default define(meta, paramDef, async () => { - const meta = await fetchMeta(); - const instances = await Promise.all(meta.recommendedInstances.map((x) => x)); + const instanceMeta = await fetchMeta(); + const instances = await Promise.all( + instanceMeta.recommendedInstances.map((x) => x), + ); return instances; }); diff --git a/packages/backend/src/server/api/endpoints/sw/register.ts b/packages/backend/src/server/api/endpoints/sw/register.ts index 2d696b1598..5effc6664f 100644 --- a/packages/backend/src/server/api/endpoints/sw/register.ts +++ b/packages/backend/src/server/api/endpoints/sw/register.ts @@ -63,13 +63,13 @@ export default define(meta, paramDef, async (ps, me) => { publickey: ps.publickey, }); - const instance = await fetchMeta(); + const instanceMeta = await fetchMeta(); // if already subscribed if (subscription != null) { return { state: "already-subscribed" as const, - key: instance.swPublicKey, + key: instanceMeta.swPublicKey, userId: me.id, endpoint: subscription.endpoint, sendReadMessage: subscription.sendReadMessage, @@ -90,7 +90,7 @@ export default define(meta, paramDef, async (ps, me) => { return { state: "subscribed" as const, - key: instance.swPublicKey, + key: instanceMeta.swPublicKey, userId: me.id, endpoint: ps.endpoint, sendReadMessage: ps.sendReadMessage, diff --git a/packages/backend/src/server/api/mastodon/converters/notification.ts b/packages/backend/src/server/api/mastodon/converters/notification.ts index e694dadd5a..9aba42461f 100644 --- a/packages/backend/src/server/api/mastodon/converters/notification.ts +++ b/packages/backend/src/server/api/mastodon/converters/notification.ts @@ -158,11 +158,11 @@ export class NotificationConverter { subscription: SwSubscription, ctx: MastoContext, ): Promise { - const instance = await fetchMeta(); + const instanceMeta = await fetchMeta(); const result: MastodonEntity.PushSubscription = { id: subscription.id, endpoint: subscription.endpoint, - server_key: instance.swPublicKey ?? "", + server_key: instanceMeta.swPublicKey ?? "", alerts: { follow: subscription.subscriptionTypes.includes("follow"), favourite: subscription.subscriptionTypes.includes("favourite"), diff --git a/packages/backend/src/server/api/mastodon/helpers/misc.ts b/packages/backend/src/server/api/mastodon/helpers/misc.ts index 5d43423815..01a321273b 100644 --- a/packages/backend/src/server/api/mastodon/helpers/misc.ts +++ b/packages/backend/src/server/api/mastodon/helpers/misc.ts @@ -43,18 +43,18 @@ export class MiscHelpers { }, order: { id: "ASC" }, }).then((p) => (p ? UserConverter.encode(p, ctx) : null)); - const meta = await fetchMeta(); + const instanceMeta = await fetchMeta(); const res = { uri: config.host, - title: meta.name || "Firefish", + title: instanceMeta.name || "Firefish", short_description: - meta.description?.substring(0, 50) || + instanceMeta.description?.substring(0, 50) || "This is a Firefish instance. It doesn’t seem to have a description.", description: - meta.description || + instanceMeta.description || "This is a Firefish instance. It doesn’t seem to have a description.", - email: meta.maintainerEmail || "", + email: instanceMeta.maintainerEmail || "", version: `4.2.8 (compatible; Firefish ${config.version})`, urls: { streaming_api: `${config.url.replace(/^http(?=s?:\/\/)/, "ws")}`, @@ -65,11 +65,11 @@ export class MiscHelpers { domain_count: instanceCount, }), max_toot_chars: config.maxNoteLength, - thumbnail: meta.bannerUrl || "/static-assets/transparent.png", - languages: meta.langs, - registrations: !meta.disableRegistration, - approval_required: meta.disableRegistration, - invites_enabled: meta.disableRegistration, + thumbnail: instanceMeta.bannerUrl || "/static-assets/transparent.png", + languages: instanceMeta.langs, + registrations: !instanceMeta.disableRegistration, + approval_required: instanceMeta.disableRegistration, + invites_enabled: instanceMeta.disableRegistration, configuration: { accounts: { max_featured_tags: 20, @@ -96,7 +96,7 @@ export class MiscHelpers { }, reactions: { max_reactions: 1, - default_reaction: meta.defaultReaction, + default_reaction: instanceMeta.defaultReaction, }, }, contact_account: contact, @@ -119,15 +119,15 @@ export class MiscHelpers { }, order: { id: "ASC" }, }).then((p) => (p ? UserConverter.encode(p, ctx) : null)); - const meta = await fetchMeta(); + const instanceMeta = await fetchMeta(); const res = { domain: config.host, - title: meta.name || "Firefish", + title: instanceMeta.name || "Firefish", version: `4.2.8 (compatible; Firefish ${config.version})`, - source_url: meta.repositoryUrl, + source_url: instanceMeta.repositoryUrl, description: - meta.description || + instanceMeta.description || "This is a Firefish instance. It doesn’t seem to have a description.", usage: { users: { @@ -135,15 +135,15 @@ export class MiscHelpers { }, }, thumbnail: { - url: meta.bannerUrl || "/static-assets/transparent.png", + url: instanceMeta.bannerUrl || "/static-assets/transparent.png", }, - languages: meta.langs, + languages: instanceMeta.langs, configuration: { urls: { streaming: `${config.url.replace(/^http(?=s?:\/\/)/, "ws")}`, }, vapid: { - public_key: meta.swPublicKey || "", + public_key: instanceMeta.swPublicKey || "", }, accounts: { max_featured_tags: 20, @@ -168,16 +168,18 @@ export class MiscHelpers { max_expiration: 2629746, }, translation: { - enabled: !!(meta.libreTranslateApiKey || meta.deeplAuthKey), + enabled: !!( + instanceMeta.libreTranslateApiKey || instanceMeta.deeplAuthKey + ), }, }, registrations: { - enabled: !meta.disableRegistration, + enabled: !instanceMeta.disableRegistration, approval_required: false, message: null, }, contact: { - email: meta.maintainerEmail || "", + email: instanceMeta.maintainerEmail || "", account: contact, }, rules: [], diff --git a/packages/backend/src/server/api/mastodon/helpers/note.ts b/packages/backend/src/server/api/mastodon/helpers/note.ts index 15ae9b5d4a..ac2958e5e3 100644 --- a/packages/backend/src/server/api/mastodon/helpers/note.ts +++ b/packages/backend/src/server/api/mastodon/helpers/note.ts @@ -727,17 +727,17 @@ export class NoteHelpers { ctx: MastoContext, ): Promise { const user = ctx.user as ILocalUser; - const instance = await fetchMeta(); - const provider = instance.libreTranslateApiUrl + const instanceMeta = await fetchMeta(); + const provider = instanceMeta.libreTranslateApiUrl ? "LibreTranslate" - : instance.deeplAuthKey + : instanceMeta.deeplAuthKey ? "DeepL" : undefined; if (provider === undefined) throw new Error("No translator is set up on this server."); // DeepL API only allows "en-US" or "en-GB" for English ("en" won’t work) - if (instance.deeplAuthKey && targetLang === "en") { + if (instanceMeta.deeplAuthKey && targetLang === "en") { targetLang = "en-US"; } diff --git a/packages/backend/src/server/api/mastodon/helpers/timeline.ts b/packages/backend/src/server/api/mastodon/helpers/timeline.ts index 21147c61a1..cdb3d40b8d 100644 --- a/packages/backend/src/server/api/mastodon/helpers/timeline.ts +++ b/packages/backend/src/server/api/mastodon/helpers/timeline.ts @@ -86,8 +86,8 @@ export class TimelineHelpers { } if (!local) { - const m = await fetchMeta(); - if (m.disableGlobalTimeline) { + const instanceMeta = await fetchMeta(); + if (instanceMeta.disableGlobalTimeline) { if (user == null || !(user.isAdmin || user.isModerator)) { throw new Error("global timeline is disabled"); } diff --git a/packages/backend/src/server/api/mastodon/streaming/channels/public.ts b/packages/backend/src/server/api/mastodon/streaming/channels/public.ts index f824dbffab..1412470e9f 100644 --- a/packages/backend/src/server/api/mastodon/streaming/channels/public.ts +++ b/packages/backend/src/server/api/mastodon/streaming/channels/public.ts @@ -25,8 +25,8 @@ export class MastodonStreamPublic extends MastodonStream { } public async init() { - const meta = await fetchMeta(); - if (meta.disableGlobalTimeline) { + const instanceMeta = await fetchMeta(); + if (instanceMeta.disableGlobalTimeline) { if (this.user == null || !(this.user.isAdmin || this.user.isModerator)) return; } diff --git a/packages/backend/src/server/api/private/signup.ts b/packages/backend/src/server/api/private/signup.ts index b8a4c32138..12c16b3e30 100644 --- a/packages/backend/src/server/api/private/signup.ts +++ b/packages/backend/src/server/api/private/signup.ts @@ -11,23 +11,23 @@ import { validateEmailForAccount } from "@/services/validate-email-for-account.j export default async (ctx: Koa.Context) => { const body = ctx.request.body; - const instance = await fetchMeta(); + const instanceMeta = await fetchMeta(); // Verify *Captcha // ただしテスト時はこの機構は障害となるため無効にする if (process.env.NODE_ENV !== "test") { - if (instance.enableHcaptcha && instance.hcaptchaSecretKey) { + if (instanceMeta.enableHcaptcha && instanceMeta.hcaptchaSecretKey) { await verifyHcaptcha( - instance.hcaptchaSecretKey, + instanceMeta.hcaptchaSecretKey, body["hcaptcha-response"], ).catch((e) => { ctx.throw(400, e); }); } - if (instance.enableRecaptcha && instance.recaptchaSecretKey) { + if (instanceMeta.enableRecaptcha && instanceMeta.recaptchaSecretKey) { await verifyRecaptcha( - instance.recaptchaSecretKey, + instanceMeta.recaptchaSecretKey, body["g-recaptcha-response"], ).catch((e) => { ctx.throw(400, e); @@ -47,7 +47,7 @@ export default async (ctx: Koa.Context) => { return; } - if (instance.emailRequiredForSignup) { + if (instanceMeta.emailRequiredForSignup) { if (emailAddress == null || typeof emailAddress !== "string") { ctx.status = 400; return; @@ -60,7 +60,7 @@ export default async (ctx: Koa.Context) => { } } - if (instance.disableRegistration) { + if (instanceMeta.disableRegistration) { if (invitationCode == null || typeof invitationCode !== "string") { ctx.status = 400; return; @@ -78,7 +78,7 @@ export default async (ctx: Koa.Context) => { RegistrationTickets.delete(ticket.id); } - if (instance.emailRequiredForSignup) { + if (instanceMeta.emailRequiredForSignup) { const code = rndstr("a-z0-9", 16); // Generate hash of password 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 be6de739b3..68a4757ebb 100644 --- a/packages/backend/src/server/api/stream/channels/global-timeline.ts +++ b/packages/backend/src/server/api/stream/channels/global-timeline.ts @@ -16,13 +16,13 @@ export default class extends Channel { } public async init(params: any) { - const meta = await fetchMeta(); - if (meta.disableGlobalTimeline) { + const instanceMeta = await fetchMeta(); + if (instanceMeta.disableGlobalTimeline) { if (this.user == null || !(this.user.isAdmin || this.user.isModerator)) return; } - if (!meta.enableGuestTimeline && this.user == null) return; + if (!instanceMeta.enableGuestTimeline && this.user == null) return; this.withReplies = params != null ? !!params.withReplies : true; 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 c0224e5661..b38542a048 100644 --- a/packages/backend/src/server/api/stream/channels/hybrid-timeline.ts +++ b/packages/backend/src/server/api/stream/channels/hybrid-timeline.ts @@ -16,9 +16,9 @@ export default class extends Channel { } public async init(params: any) { - const meta = await fetchMeta(); + const instanceMeta = await fetchMeta(); if ( - meta.disableLocalTimeline && + instanceMeta.disableLocalTimeline && !this.user!.isAdmin && !this.user!.isModerator ) 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 6d750d67d7..878f1929e3 100644 --- a/packages/backend/src/server/api/stream/channels/local-timeline.ts +++ b/packages/backend/src/server/api/stream/channels/local-timeline.ts @@ -15,13 +15,13 @@ export default class extends Channel { } public async init(params: any) { - const meta = await fetchMeta(); - if (meta.disableLocalTimeline) { + const instanceMeta = await fetchMeta(); + if (instanceMeta.disableLocalTimeline) { if (this.user == null || !(this.user.isAdmin || this.user.isModerator)) return; } - if (!meta.enableGuestTimeline && this.user == null) return; + if (!instanceMeta.enableGuestTimeline && this.user == null) return; this.withReplies = params != null ? !!params.withReplies : true; 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 b42f936a01..7bd693a200 100644 --- a/packages/backend/src/server/api/stream/channels/recommended-timeline.ts +++ b/packages/backend/src/server/api/stream/channels/recommended-timeline.ts @@ -16,9 +16,9 @@ export default class extends Channel { } public async init(params: any) { - const meta = await fetchMeta(); + const instanceMeta = await fetchMeta(); if ( - meta.disableRecommendedTimeline && + instanceMeta.disableRecommendedTimeline && !this.user!.isAdmin && !this.user!.isModerator ) @@ -36,11 +36,11 @@ export default class extends Channel { // チャンネルの投稿ではなく、その投稿のユーザーをフォローしている または // チャンネルの投稿ではなく、全体公開のローカルの投稿 または // フォローしているチャンネルの投稿 の場合だけ - const meta = await fetchMeta(); + const instanceMeta = await fetchMeta(); if ( !( note.user.host != null && - meta.recommendedInstances.includes(note.user.host) && + instanceMeta.recommendedInstances.includes(note.user.host) && note.visibility === "public" ) ) diff --git a/packages/backend/src/server/index.ts b/packages/backend/src/server/index.ts index d8fa9d32a5..6db3c37a15 100644 --- a/packages/backend/src/server/index.ts +++ b/packages/backend/src/server/index.ts @@ -117,8 +117,8 @@ router.get("/avatar/@:acct", async (ctx) => { }); router.get("/identicon/:x", async (ctx) => { - const meta = await fetchMeta(); - if (meta.enableIdenticonGeneration) { + const instanceMeta = await fetchMeta(); + if (instanceMeta.enableIdenticonGeneration) { const [temp, cleanup] = await createTemp(); await genIdenticon(ctx.params.x, fs.createWriteStream(temp)); ctx.set("Content-Type", "image/png"); diff --git a/packages/backend/src/server/web/index.ts b/packages/backend/src/server/web/index.ts index fe15a70a79..5ef9e58f6d 100644 --- a/packages/backend/src/server/web/index.ts +++ b/packages/backend/src/server/web/index.ts @@ -333,8 +333,8 @@ const getFeed = async ( noRenotes: string, noReplies: string, ) => { - const meta = await fetchMeta(); - if (meta.privateMode) { + const instanceMeta = await fetchMeta(); + if (instanceMeta.privateMode) { return; } const { username, host } = stringToAcct(acct); @@ -481,7 +481,7 @@ const userPage: Router.Middleware = async (ctx, next) => { } const profile = await UserProfiles.findOneByOrFail({ userId: user.id }); - const meta = await fetchMeta(); + const instanceMeta = await fetchMeta(); const me = profile.fields ? profile.fields .filter((filed) => filed.value?.match(/^https?:/)) @@ -489,7 +489,7 @@ const userPage: Router.Middleware = async (ctx, next) => { : []; const userDetail = { - ...metaToPugArgs(meta), + ...metaToPugArgs(instanceMeta), user, profile, me, @@ -530,9 +530,9 @@ router.get("/notes/:note", async (ctx, next) => { const profile = await UserProfiles.findOneByOrFail({ userId: note.userId, }); - const meta = await fetchMeta(); + const instanceMeta = await fetchMeta(); await ctx.render("note", { - ...metaToPugArgs(meta), + ...metaToPugArgs(instanceMeta), note: packedNote, profile, avatarUrl: await Users.getAvatarUrl( @@ -564,9 +564,9 @@ router.get("/posts/:note", async (ctx, next) => { if (note != null) { const packedNote = await Notes.pack(note); const profile = await UserProfiles.findOneByOrFail({ userId: note.userId }); - const meta = await fetchMeta(); + const instanceMeta = await fetchMeta(); await ctx.render("note", { - ...metaToPugArgs(meta), + ...metaToPugArgs(instanceMeta), note: packedNote, profile, avatarUrl: await Users.getAvatarUrl( @@ -602,9 +602,9 @@ router.get("/@:user/pages/:page", async (ctx, next) => { if (page) { const _page = await Pages.pack(page); const profile = await UserProfiles.findOneByOrFail({ userId: page.userId }); - const meta = await fetchMeta(); + const instanceMeta = await fetchMeta(); await ctx.render("page", { - ...metaToPugArgs(meta), + ...metaToPugArgs(instanceMeta), page: _page, profile, avatarUrl: await Users.getAvatarUrl( @@ -634,9 +634,9 @@ router.get("/clips/:clip", async (ctx, next) => { if (clip) { const _clip = await Clips.pack(clip); const profile = await UserProfiles.findOneByOrFail({ userId: clip.userId }); - const meta = await fetchMeta(); + const instanceMeta = await fetchMeta(); await ctx.render("clip", { - ...metaToPugArgs(meta), + ...metaToPugArgs(instanceMeta), clip: _clip, profile, avatarUrl: await Users.getAvatarUrl( @@ -659,9 +659,9 @@ router.get("/gallery/:post", async (ctx, next) => { if (post) { const _post = await GalleryPosts.pack(post); const profile = await UserProfiles.findOneByOrFail({ userId: post.userId }); - const meta = await fetchMeta(); + const instanceMeta = await fetchMeta(); await ctx.render("gallery-post", { - ...metaToPugArgs(meta), + ...metaToPugArgs(instanceMeta), post: _post, profile, avatarUrl: await Users.getAvatarUrl( @@ -685,9 +685,9 @@ router.get("/channels/:channel", async (ctx, next) => { if (channel) { const _channel = await Channels.pack(channel); - const meta = await fetchMeta(); + const instanceMeta = await fetchMeta(); await ctx.render("channel", { - ...metaToPugArgs(meta), + ...metaToPugArgs(instanceMeta), channel: _channel, }); @@ -738,10 +738,10 @@ router.get("/api/v1/streaming", async (ctx) => { // Render base html for all requests router.get("(.*)", async (ctx) => { - const meta = await fetchMeta(); + const instanceMeta = await fetchMeta(); await ctx.render("base", { - ...metaToPugArgs(meta), + ...metaToPugArgs(instanceMeta), }); ctx.set("Cache-Control", "public, max-age=3"); }); diff --git a/packages/backend/src/server/web/manifest.ts b/packages/backend/src/server/web/manifest.ts index cad253bee4..812ffad3eb 100644 --- a/packages/backend/src/server/web/manifest.ts +++ b/packages/backend/src/server/web/manifest.ts @@ -77,11 +77,11 @@ const manifest = { }; export const manifestHandler = async (ctx: Koa.Context) => { - const instance = await fetchMeta(); + const instanceMeta = await fetchMeta(); - manifest.short_name = instance.name || "Firefish"; - manifest.name = instance.name || "Firefish"; - if (instance.themeColor) manifest.theme_color = instance.themeColor; + manifest.short_name = instanceMeta.name || "Firefish"; + manifest.name = instanceMeta.name || "Firefish"; + if (instanceMeta.themeColor) manifest.theme_color = instanceMeta.themeColor; ctx.set("Cache-Control", "max-age=300"); ctx.body = manifest; diff --git a/packages/backend/src/server/web/url-preview.ts b/packages/backend/src/server/web/url-preview.ts index e164f41518..28278bbc4c 100644 --- a/packages/backend/src/server/web/url-preview.ts +++ b/packages/backend/src/server/web/url-preview.ts @@ -22,18 +22,18 @@ export const urlPreviewHandler = async (ctx: Koa.Context) => { return; } - const meta = await fetchMeta(); + const instanceMeta = await fetchMeta(); logger.info( - meta.summalyProxy + instanceMeta.summalyProxy ? `(Proxy) Getting preview of ${url}@${lang} ...` : `Getting preview of ${url}@${lang} ...`, ); try { - const summary = meta.summalyProxy + const summary = instanceMeta.summalyProxy ? await getJson( - `${meta.summalyProxy}?${query({ + `${instanceMeta.summalyProxy}?${query({ url: url, lang: lang ?? "en-US", })}`, diff --git a/packages/backend/src/services/drive/add-file.ts b/packages/backend/src/services/drive/add-file.ts index 3525082bc0..f42a987356 100644 --- a/packages/backend/src/services/drive/add-file.ts +++ b/packages/backend/src/services/drive/add-file.ts @@ -80,9 +80,9 @@ async function save( // thunbnail, webpublic を必要なら生成 const alts = await generateAlts(path, type, !file.uri); - const meta = await fetchMeta(); + const instanceMeta = await fetchMeta(); - if (meta.useObjectStorage) { + if (instanceMeta.useObjectStorage) { //#region ObjectStorage params let [ext] = name.match(/\.([a-zA-Z0-9_-]+)$/) || [""]; @@ -102,14 +102,18 @@ async function save( } const baseUrl = new URL( - meta.objectStorageBaseUrl ?? `/${meta.objectStorageBucket}`, - `${meta.objectStorageUseSsl ? "https" : "http"}://${ - meta.objectStorageEndpoint - }${meta.objectStoragePort ? `:${meta.objectStoragePort}` : ""}`, + instanceMeta.objectStorageBaseUrl ?? + `/${instanceMeta.objectStorageBucket}`, + `${instanceMeta.objectStorageUseSsl ? "https" : "http"}://${ + instanceMeta.objectStorageEndpoint + }${instanceMeta.objectStoragePort ? `:${instanceMeta.objectStoragePort}` : ""}`, ); // for original - const key = urlPathJoin([meta.objectStoragePrefix, `${uuid()}${ext}`]); + const key = urlPathJoin([ + instanceMeta.objectStoragePrefix, + `${uuid()}${ext}`, + ]); const url = urlPathJoin(baseUrl, [key]); // for alts @@ -125,7 +129,7 @@ async function save( if (alts.webpublic) { webpublicKey = urlPathJoin([ - meta.objectStoragePrefix, + instanceMeta.objectStoragePrefix, `webpublic-${uuid()}.${alts.webpublic.ext}`, ]); webpublicUrl = urlPathJoin(baseUrl, [webpublicKey]); @@ -138,7 +142,7 @@ async function save( if (alts.thumbnail) { thumbnailKey = urlPathJoin([ - meta.objectStoragePrefix, + instanceMeta.objectStoragePrefix, `thumbnail-${uuid()}.${alts.thumbnail.ext}`, ]); thumbnailUrl = urlPathJoin(baseUrl, [thumbnailKey]); @@ -365,10 +369,10 @@ async function upload( if (type === "image/apng") type = "image/png"; if (!FILE_TYPE_BROWSERSAFE.includes(type)) type = "application/octet-stream"; - const meta = await fetchMeta(); + const instanceMeta = await fetchMeta(); const params = { - Bucket: meta.objectStorageBucket, + Bucket: instanceMeta.objectStorageBucket, Key: key, Body: stream, ContentType: type, @@ -377,9 +381,9 @@ async function upload( if (filename) params.ContentDisposition = contentDisposition("inline", filename); - if (meta.objectStorageSetPublicRead) params.ACL = "public-read"; + if (instanceMeta.objectStorageSetPublicRead) params.ACL = "public-read"; - const s3 = getS3(meta); + const s3 = getS3(instanceMeta); const upload = s3.upload(params, { partSize: @@ -509,13 +513,13 @@ export async function addFile({ const usage = await DriveFiles.calcDriveUsageOf(user); const u = await Users.findOneBy({ id: user.id }); - const instance = await fetchMeta(); + const instanceMeta = await fetchMeta(); let driveCapacity = 1024 * 1024 * (Users.isLocalUser(user) - ? instance.localDriveCapacityMb - : instance.remoteDriveCapacityMb); + ? instanceMeta.localDriveCapacityMb + : instanceMeta.remoteDriveCapacityMb); if (Users.isLocalUser(user) && u?.driveCapacityOverrideMb != null) { driveCapacity = 1024 * 1024 * u.driveCapacityOverrideMb; @@ -581,7 +585,7 @@ export async function addFile({ : null; const folder = await fetchFolder(); - const instance = await fetchMeta(); + const instanceMeta = await fetchMeta(); let file = new DriveFile(); file.id = genId(); @@ -598,7 +602,7 @@ export async function addFile({ file.usageHint = usageHint; file.isSensitive = user ? Users.isLocalUser(user) && - (instance!.markLocalFilesNsfwByDefault || profile!.alwaysMarkNsfw) + (instanceMeta!.markLocalFilesNsfwByDefault || profile!.alwaysMarkNsfw) ? true : sensitive != null ? sensitive diff --git a/packages/backend/src/services/drive/delete-file.ts b/packages/backend/src/services/drive/delete-file.ts index 94371f1b0f..23ffd96b83 100644 --- a/packages/backend/src/services/drive/delete-file.ts +++ b/packages/backend/src/services/drive/delete-file.ts @@ -82,13 +82,13 @@ async function postProcess(file: DriveFile, isExpired = false) { } export async function deleteObjectStorageFile(key: string) { - const meta = await fetchMeta(); + const instanceMeta = await fetchMeta(); - const s3 = getS3(meta); + const s3 = getS3(instanceMeta); await s3 .deleteObject({ - Bucket: meta.objectStorageBucket!, + Bucket: instanceMeta.objectStorageBucket!, Key: key, }) .promise(); diff --git a/packages/backend/src/services/send-email.ts b/packages/backend/src/services/send-email.ts index daf57a68cd..c0c1cbd4a1 100644 --- a/packages/backend/src/services/send-email.ts +++ b/packages/backend/src/services/send-email.ts @@ -12,30 +12,31 @@ export async function sendEmail( html: string, text: string, ) { - const meta = await fetchMeta(); + const instanceMeta = await fetchMeta(); const iconUrl = `${config.url}/static-assets/mi-white.png`; const emailSettingUrl = `${config.url}/settings/email`; - const enableAuth = meta.smtpUser != null && meta.smtpUser !== ""; + const enableAuth = + instanceMeta.smtpUser != null && instanceMeta.smtpUser !== ""; const transporter = nodemailer.createTransport({ - host: meta.smtpHost, - port: meta.smtpPort, - secure: meta.smtpSecure, + host: instanceMeta.smtpHost, + port: instanceMeta.smtpPort, + secure: instanceMeta.smtpSecure, ignoreTLS: !enableAuth, proxy: config.proxySmtp, auth: enableAuth ? { - user: meta.smtpUser, - pass: meta.smtpPass, + user: instanceMeta.smtpUser, + pass: instanceMeta.smtpPass, } : undefined, } as any); try { const info = await transporter.sendMail({ - from: meta.email!, + from: instanceMeta.email!, to: to, subject: subject, text: text, @@ -48,8 +49,8 @@ export async function sendEmail(
- -

${meta.name}

+ +

${instanceMeta.name}

${subject}

diff --git a/packages/backend/src/services/validate-email-for-account.ts b/packages/backend/src/services/validate-email-for-account.ts index 616dbccebf..aacf3820b9 100644 --- a/packages/backend/src/services/validate-email-for-account.ts +++ b/packages/backend/src/services/validate-email-for-account.ts @@ -6,14 +6,14 @@ export async function validateEmailForAccount(emailAddress: string): Promise<{ available: boolean; reason: null | "used" | "format" | "disposable" | "mx" | "smtp"; }> { - const meta = await fetchMeta(); + const instanceMeta = await fetchMeta(); const exist = await UserProfiles.countBy({ emailVerified: true, email: emailAddress, }); - const validated = meta.enableActiveEmailValidation + const validated = instanceMeta.enableActiveEmailValidation ? await validateEmail({ email: emailAddress, validateRegex: true, From 056d8cd949ed066dc168455cebdd9d5b17757cad Mon Sep 17 00:00:00 2001 From: GitLab CI Date: Fri, 26 Jul 2024 04:07:20 +0000 Subject: [PATCH 17/43] chore(deps): update dependency city-timezones to v1.3.0 --- packages/client/package.json | 2 +- pnpm-lock.yaml | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/client/package.json b/packages/client/package.json index da697f7643..a04c3032e0 100644 --- a/packages/client/package.json +++ b/packages/client/package.json @@ -44,7 +44,7 @@ "chartjs-plugin-gradient": "0.6.1", "chartjs-plugin-zoom": "2.0.1", "check-password-strength": "2.0.10", - "city-timezones": "1.2.1", + "city-timezones": "1.3.0", "compare-versions": "6.1.1", "cropperjs": "2.0.0-rc.1", "date-fns": "3.6.0", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 1d6b03f09a..8242ae059a 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -590,8 +590,8 @@ importers: specifier: 2.0.10 version: 2.0.10 city-timezones: - specifier: 1.2.1 - version: 1.2.1 + specifier: 1.3.0 + version: 1.3.0 compare-versions: specifier: 6.1.1 version: 6.1.1 @@ -3146,8 +3146,8 @@ packages: resolution: {integrity: sha512-NIxF55hv4nSqQswkAeiOi1r83xy8JldOFDTWiug55KBu9Jnblncd2U6ViHmYgHf01TPZS77NJBhBMKdWj9HQMQ==} engines: {node: '>=8'} - city-timezones@1.2.1: - resolution: {integrity: sha512-hruuB611QFoUFMsan7xd9B2VPMrA8XC716O/999WW34kmaJUT1hxKF2W8TSXAWkhSqgvbu70DjcDv7/wpM6vow==} + city-timezones@1.3.0: + resolution: {integrity: sha512-S/FiU8F/1HgMvbd8POvb+8xorp0tp5VJwUfYC/ssnbxykLbwEZ9poZWFMPfBVuh1KlXxP63DGCkdr0D8aFEADQ==} cjs-module-lexer@1.3.1: resolution: {integrity: sha512-a3KdPAANPbNE4ZUv9h6LckSl9zLsYOP4MBmhIPkRaeyybt+r4UghLvq+xw/YwUcC1gqylCkL4rdVs3Lwupjm4Q==} @@ -9394,7 +9394,7 @@ snapshots: ci-info@3.9.0: {} - city-timezones@1.2.1: + city-timezones@1.3.0: dependencies: lodash: 4.17.21 From 3e416a9a0722a59f12062922fbf56d846f8f9a3a Mon Sep 17 00:00:00 2001 From: naskya Date: Fri, 26 Jul 2024 14:30:24 +0900 Subject: [PATCH 18/43] feat (backend): enhance add emoji API --- docs/api-change.md | 5 ++ .../server/api/endpoints/admin/emoji/add.ts | 49 +++++++++++++++---- .../endpoints/drive/files/upload-from-url.ts | 2 + .../backend/src/server/api/endpoints/emoji.ts | 12 ++--- .../src/services/drive/upload-from-url.ts | 12 +++-- 5 files changed, 58 insertions(+), 22 deletions(-) diff --git a/docs/api-change.md b/docs/api-change.md index d5a7a25f78..38d259a764 100644 --- a/docs/api-change.md +++ b/docs/api-change.md @@ -2,6 +2,11 @@ Breaking changes are indicated by the :warning: icon. +## Unreleased + +- Added `name`, `category`, `aliases`, `license` optional parameters to `admin/emoji/add` endpoint. +- Added `name` optional parameter to `drive/files/upload-from-url` endpoint. + ## v20240725 - Added `i/export-followers` endpoint. diff --git a/packages/backend/src/server/api/endpoints/admin/emoji/add.ts b/packages/backend/src/server/api/endpoints/admin/emoji/add.ts index 7b10ad99b1..9b8053d3e0 100644 --- a/packages/backend/src/server/api/endpoints/admin/emoji/add.ts +++ b/packages/backend/src/server/api/endpoints/admin/emoji/add.ts @@ -2,7 +2,7 @@ import define from "@/server/api/define.js"; import { Emojis, DriveFiles } from "@/models/index.js"; import { type ImageSize, - genId, + genIdAt, getImageSizeFromUrl, publishToBroadcastStream, } from "backend-rs"; @@ -36,7 +36,31 @@ export const meta = { export const paramDef = { type: "object", properties: { - fileId: { type: "string", format: "misskey:id" }, + fileId: { + type: "string", + format: "misskey:id", + nullable: false, + }, + name: { + type: "string", + nullable: false, + }, + category: { + type: "string", + nullable: false, + }, + aliases: { + type: "array", + nullable: false, + items: { + type: "string", + nullable: false, + }, + }, + license: { + type: "string", + nullable: false, + }, }, required: ["fileId"], } as const; @@ -50,9 +74,12 @@ export default define(meta, paramDef, async (ps, me) => { if (file == null) throw new ApiError(meta.errors.noSuchFile); - const name = file.name.split(".")[0].match(/^[a-z0-9_]+$/) - ? file.name.split(".")[0] - : `_${rndstr("a-z0-9", 8)}_`; + const name = + ps.name != null + ? ps.name + : file.name.split(".")[0].match(/^[a-z0-9_]+$/) + ? file.name.split(".")[0] + : `_${rndstr("a-z0-9", 8)}_`; let size: ImageSize | null = null; try { @@ -62,17 +89,19 @@ export default define(meta, paramDef, async (ps, me) => { apiLogger.debug(inspect(err)); } + const now = new Date(); + const emoji = await Emojis.insert({ - id: genId(), - updatedAt: new Date(), + id: genIdAt(now), + updatedAt: now, name: name, - category: null, + category: ps.category ?? null, host: null, - aliases: [], + aliases: ps.aliases ?? [], originalUrl: file.url, publicUrl: file.webpublicUrl ?? file.url, type: file.webpublicType ?? file.type, - license: null, + license: ps.license ?? null, width: size?.width || null, height: size?.height || null, }).then((x) => Emojis.findOneByOrFail(x.identifiers[0])); 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..97b3e4963c 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 @@ -24,6 +24,7 @@ export const paramDef = { type: "object", properties: { url: { type: "string" }, + name: { type: "string" }, folderId: { type: "string", format: "misskey:id", @@ -41,6 +42,7 @@ export const paramDef = { export default define(meta, paramDef, async (ps, user) => { uploadFromUrl({ url: ps.url, + name: ps.name, user, folderId: ps.folderId, sensitive: ps.isSensitive, diff --git a/packages/backend/src/server/api/endpoints/emoji.ts b/packages/backend/src/server/api/endpoints/emoji.ts index 2675ba7bdc..996e648d64 100644 --- a/packages/backend/src/server/api/endpoints/emoji.ts +++ b/packages/backend/src/server/api/endpoints/emoji.ts @@ -37,15 +37,13 @@ export const paramDef = { required: ["name"], } as const; -export default define(meta, paramDef, async (ps, me) => { - const emoji = await Emojis.findOne({ - where: { - name: ps.name, - host: IsNull(), - }, +export default define(meta, paramDef, async (ps) => { + const emoji = await Emojis.findOneBy({ + name: ps.name, + host: IsNull(), }); - if (!emoji) { + if (emoji == null) { throw new ApiError(meta.errors.noSuchEmoji); } diff --git a/packages/backend/src/services/drive/upload-from-url.ts b/packages/backend/src/services/drive/upload-from-url.ts index a3b6fc7e51..d4863ca98c 100644 --- a/packages/backend/src/services/drive/upload-from-url.ts +++ b/packages/backend/src/services/drive/upload-from-url.ts @@ -21,6 +21,7 @@ type Args = { host: User["host"]; driveCapacityOverrideMb: User["driveCapacityOverrideMb"]; } | null; + name?: string; folderId?: DriveFolder["id"] | null; uri?: string | null; sensitive?: boolean; @@ -34,6 +35,7 @@ type Args = { export async function uploadFromUrl({ url, + name, user, folderId = null, uri = null, @@ -53,14 +55,14 @@ export async function uploadFromUrl({ throw new Error("Private IP is not allowed"); } - let name = parsedUrl.pathname.split("/").pop() || null; - if (name == null || !DriveFiles.validateFileName(name)) { - name = null; + let filename = name ?? parsedUrl.pathname.split("/").pop(); + if (filename == null || !DriveFiles.validateFileName(filename)) { + filename = null; } // If the comment is same as the name, skip comment // (image.name is passed in when receiving attachment) - if (comment != null && name === comment) { + if (comment != null && filename === comment) { comment = null; } @@ -74,7 +76,7 @@ export async function uploadFromUrl({ const driveFile = await addFile({ user, path, - name, + name: filename, comment, folderId, force, From eb11b32c5cdec300ad41d0800b2856c9a1235522 Mon Sep 17 00:00:00 2001 From: naskya Date: Fri, 26 Jul 2024 17:50:00 +0900 Subject: [PATCH 19/43] refactor (backend): only cache the id of @relay.actor --- packages/backend-rs/index.d.ts | 4 +- packages/backend-rs/index.js | 3 +- .../src/federation/internal_actor/cache.rs | 87 ------------------- .../src/federation/internal_actor/instance.rs | 50 +++++++++++ .../src/federation/internal_actor/mod.rs | 5 +- .../src/federation/internal_actor/relay.rs | 45 ++++++++++ packages/backend/src/queue/index.ts | 4 +- .../src/remote/activitypub/deliver-manager.ts | 2 +- .../activitypub/renderer/follow-relay.ts | 4 +- .../src/remote/activitypub/renderer/undo.ts | 5 +- .../src/remote/activitypub/resolver.ts | 4 +- packages/backend/src/server/activitypub.ts | 10 +-- .../api/common/read-messaging-message.ts | 4 +- .../admin/resolve-abuse-user-report.ts | 7 +- .../server/api/endpoints/notes/polls/vote.ts | 2 +- .../src/server/api/mastodon/helpers/poll.ts | 2 +- .../backend/src/services/blocking/create.ts | 14 +-- .../backend/src/services/blocking/delete.ts | 8 +- .../backend/src/services/following/create.ts | 4 +- .../backend/src/services/following/delete.ts | 8 +- .../backend/src/services/following/reject.ts | 2 +- .../src/services/following/requests/accept.ts | 2 +- .../src/services/following/requests/cancel.ts | 6 +- .../src/services/following/requests/create.ts | 2 +- .../backend/src/services/messages/create.ts | 2 +- .../backend/src/services/messages/delete.ts | 2 +- packages/backend/src/services/note/delete.ts | 4 +- .../src/services/note/reaction/delete.ts | 4 +- packages/backend/src/services/relay.ts | 20 ++--- packages/backend/src/services/suspend-user.ts | 2 +- .../backend/src/services/unsuspend-user.ts | 6 +- 31 files changed, 168 insertions(+), 156 deletions(-) delete mode 100644 packages/backend-rs/src/federation/internal_actor/cache.rs create mode 100644 packages/backend-rs/src/federation/internal_actor/instance.rs create mode 100644 packages/backend-rs/src/federation/internal_actor/relay.rs diff --git a/packages/backend-rs/index.d.ts b/packages/backend-rs/index.d.ts index 63d845f587..6d82b6d413 100644 --- a/packages/backend-rs/index.d.ts +++ b/packages/backend-rs/index.d.ts @@ -448,10 +448,12 @@ export declare function getFullApAccount(username: string, host?: string | undef export declare function getImageSizeFromUrl(url: string): Promise -export declare function getInternalActor(actor: InternalActor): Promise +export declare function getInstanceActor(): Promise export declare function getNoteSummary(fileIds: Array, text: string | undefined | null, cw: string | undefined | null, hasPoll: boolean): string +export declare function getRelayActorId(): Promise + export declare function getTimestamp(id: string): number /** Prints the greeting message and the Firefish version to stdout. */ diff --git a/packages/backend-rs/index.js b/packages/backend-rs/index.js index 673bdc8d52..7504ca5ead 100644 --- a/packages/backend-rs/index.js +++ b/packages/backend-rs/index.js @@ -384,8 +384,9 @@ module.exports.genId = nativeBinding.genId module.exports.genIdAt = nativeBinding.genIdAt module.exports.getFullApAccount = nativeBinding.getFullApAccount module.exports.getImageSizeFromUrl = nativeBinding.getImageSizeFromUrl -module.exports.getInternalActor = nativeBinding.getInternalActor +module.exports.getInstanceActor = nativeBinding.getInstanceActor module.exports.getNoteSummary = nativeBinding.getNoteSummary +module.exports.getRelayActorId = nativeBinding.getRelayActorId module.exports.getTimestamp = nativeBinding.getTimestamp module.exports.greet = nativeBinding.greet module.exports.hashPassword = nativeBinding.hashPassword diff --git a/packages/backend-rs/src/federation/internal_actor/cache.rs b/packages/backend-rs/src/federation/internal_actor/cache.rs deleted file mode 100644 index de250f3d20..0000000000 --- a/packages/backend-rs/src/federation/internal_actor/cache.rs +++ /dev/null @@ -1,87 +0,0 @@ -//! In-memory internal actor cache handler - -// TODO: refactoring - -use super::*; -use crate::{database::db_conn, model::entity::user}; -use sea_orm::prelude::*; -use std::sync::Mutex; - -#[macros::errors] -pub enum Error { - #[error(transparent)] - #[doc = "database error"] - Db(#[from] DbErr), - #[error("{} does not exist", Acct::from(.0.to_owned()))] - #[doc = "internal actor does not exist"] - InternalActorNotFound(InternalActor), -} - -static INSTANCE_ACTOR: Mutex> = Mutex::new(None); -static RELAY_ACTOR: Mutex> = Mutex::new(None); - -fn set_instance_actor(value: &user::Model) { - let _ = INSTANCE_ACTOR - .lock() - .map(|mut cache| *cache = Some(value.to_owned())); -} -fn set_relay_actor(value: &user::Model) { - let _ = RELAY_ACTOR - .lock() - .map(|mut cache| *cache = Some(value.to_owned())); -} - -async fn cache_instance_actor() -> Result { - let actor = user::Entity::find() - .filter(user::Column::Username.eq(INSTANCE_ACTOR_USERNAME)) - .filter(user::Column::Host.is_null()) - .one(db_conn().await?) - .await?; - - if let Some(actor) = actor { - set_instance_actor(&actor); - Ok(actor) - } else { - Err(Error::InternalActorNotFound(InternalActor::Instance)) - } -} -async fn cache_relay_actor() -> Result { - let actor = user::Entity::find() - .filter(user::Column::Username.eq(RELAY_ACTOR_USERNAME)) - .filter(user::Column::Host.is_null()) - .one(db_conn().await?) - .await?; - - if let Some(actor) = actor { - set_relay_actor(&actor); - Ok(actor) - } else { - Err(Error::InternalActorNotFound(InternalActor::Relay)) - } -} - -// for napi export -// https://github.com/napi-rs/napi-rs/issues/2060 -type User = user::Model; - -#[macros::export(js_name = "getInternalActor")] -pub async fn get(actor: InternalActor) -> Result { - match actor { - InternalActor::Instance => { - if let Some(cache) = INSTANCE_ACTOR.lock().ok().and_then(|cache| cache.clone()) { - tracing::debug!("Using cached instance.actor"); - return Ok(cache); - } - tracing::debug!("Caching instance.actor"); - cache_instance_actor().await - } - InternalActor::Relay => { - if let Some(cache) = RELAY_ACTOR.lock().ok().and_then(|cache| cache.clone()) { - tracing::debug!("Using cached relay.actor"); - return Ok(cache); - } - tracing::debug!("Caching relay.actor"); - cache_relay_actor().await - } - } -} diff --git a/packages/backend-rs/src/federation/internal_actor/instance.rs b/packages/backend-rs/src/federation/internal_actor/instance.rs new file mode 100644 index 0000000000..4bf298c364 --- /dev/null +++ b/packages/backend-rs/src/federation/internal_actor/instance.rs @@ -0,0 +1,50 @@ +//! In-memory instance actor cache + +use super::INSTANCE_ACTOR_USERNAME; +use crate::{database::db_conn, model::entity::user}; +use sea_orm::prelude::*; +use tokio::sync::OnceCell; + +// for napi export +// https://github.com/napi-rs/napi-rs/issues/2060 +type User = user::Model; + +static INSTANCE_ACTOR: OnceCell = OnceCell::const_new(); + +#[macros::errors] +pub enum Error { + #[error("@instance.actor not found")] + InstanceActorNotFound, + #[error(transparent)] + #[doc = "database error"] + Db(#[from] DbErr), +} + +async fn set_cache() -> Result<&'static User, Error> { + let instance_actor = INSTANCE_ACTOR + .get_or_try_init(|| async { + tracing::debug!("caching @instance.actor"); + let found_model = user::Entity::find() + .filter(user::Column::Username.eq(INSTANCE_ACTOR_USERNAME)) + .filter(user::Column::Host.is_null()) + .one(db_conn().await?) + .await?; + + Ok::(found_model.ok_or(Error::InstanceActorNotFound)?) + }) + .await?; + + Ok(instance_actor) +} + +pub async fn get() -> Result<&'static User, Error> { + match INSTANCE_ACTOR.get() { + Some(model) => Ok(model), + None => set_cache().await, + } +} + +#[macros::ts_export(js_name = "getInstanceActor")] +pub async fn get_js() -> Result { + Ok(get().await?.to_owned()) +} diff --git a/packages/backend-rs/src/federation/internal_actor/mod.rs b/packages/backend-rs/src/federation/internal_actor/mod.rs index 6996062b16..a8ffc40ecd 100644 --- a/packages/backend-rs/src/federation/internal_actor/mod.rs +++ b/packages/backend-rs/src/federation/internal_actor/mod.rs @@ -1,6 +1,5 @@ -mod cache; - -pub use cache::get; +pub mod instance; +pub mod relay; use super::acct::Acct; diff --git a/packages/backend-rs/src/federation/internal_actor/relay.rs b/packages/backend-rs/src/federation/internal_actor/relay.rs new file mode 100644 index 0000000000..e2926ceda1 --- /dev/null +++ b/packages/backend-rs/src/federation/internal_actor/relay.rs @@ -0,0 +1,45 @@ +//! In-memory relay actor id cache + +use super::RELAY_ACTOR_USERNAME; +use crate::{database::db_conn, model::entity::user}; +use sea_orm::{prelude::*, QuerySelect, SelectColumns}; +use tokio::sync::OnceCell; + +static RELAY_ACTOR_ID: OnceCell = OnceCell::const_new(); + +#[macros::errors] +pub enum Error { + #[error("@relay.actor not found")] + RelayActorNotFound, + #[error(transparent)] + #[doc = "database error"] + Db(#[from] DbErr), +} + +async fn set_id_cache() -> Result<&'static str, Error> { + let id = RELAY_ACTOR_ID + .get_or_try_init(|| async { + tracing::debug!("caching @relay.actor"); + let found_id = user::Entity::find() + .select_only() + .select_column(user::Column::Id) + .filter(user::Column::Username.eq(RELAY_ACTOR_USERNAME)) + .filter(user::Column::Host.is_null()) + .into_tuple::() + .one(db_conn().await?) + .await?; + + Ok::(found_id.ok_or(Error::RelayActorNotFound)?) + }) + .await?; + + Ok(id) +} + +#[macros::export(js_name = "getRelayActorId")] +pub async fn get_id() -> Result<&'static str, Error> { + match RELAY_ACTOR_ID.get() { + Some(id) => Ok(id), + None => set_id_cache().await, + } +} diff --git a/packages/backend/src/queue/index.ts b/packages/backend/src/queue/index.ts index b46e7acc1f..b4c692ef05 100644 --- a/packages/backend/src/queue/index.ts +++ b/packages/backend/src/queue/index.ts @@ -155,13 +155,13 @@ webhookDeliverQueue webhookLogger.warn(`stalled ${getJobInfo(job)} to=${job.data.to}`), ); -export function deliver(user: ThinUser, content: unknown, to: string | null) { +export function deliver(userId: string, content: unknown, to: string | null) { if (content == null) return null; if (to == null) return null; const data = { user: { - id: user.id, + id: userId, }, content, to, diff --git a/packages/backend/src/remote/activitypub/deliver-manager.ts b/packages/backend/src/remote/activitypub/deliver-manager.ts index 47db9ef273..140800cfe6 100644 --- a/packages/backend/src/remote/activitypub/deliver-manager.ts +++ b/packages/backend/src/remote/activitypub/deliver-manager.ts @@ -148,7 +148,7 @@ export default class DeliverManager { // skip instances as indicated if (instancesToSkip.includes(valid.host)) continue; - deliver(this.actor, this.activity, valid.inbox); + deliver(this.actor.id, this.activity, valid.inbox); } } } diff --git a/packages/backend/src/remote/activitypub/renderer/follow-relay.ts b/packages/backend/src/remote/activitypub/renderer/follow-relay.ts index b62d9c4011..48e73777e5 100644 --- a/packages/backend/src/remote/activitypub/renderer/follow-relay.ts +++ b/packages/backend/src/remote/activitypub/renderer/follow-relay.ts @@ -2,11 +2,11 @@ import { config } from "@/config.js"; import type { Relay } from "@/models/entities/relay.js"; import type { ILocalUser } from "@/models/entities/user.js"; -export function renderFollowRelay(relay: Relay, relayActor: ILocalUser) { +export function renderFollowRelay(relay: Relay, relayActorId: string) { const follow = { id: `${config.url}/activities/follow-relay/${relay.id}`, type: "Follow", - actor: `${config.url}/users/${relayActor.id}`, + actor: `${config.url}/users/${relayActorId}`, object: "https://www.w3.org/ns/activitystreams#Public", }; diff --git a/packages/backend/src/remote/activitypub/renderer/undo.ts b/packages/backend/src/remote/activitypub/renderer/undo.ts index a0285ea9c7..e622050995 100644 --- a/packages/backend/src/remote/activitypub/renderer/undo.ts +++ b/packages/backend/src/remote/activitypub/renderer/undo.ts @@ -1,7 +1,6 @@ import { config } from "@/config.js"; -import type { User } from "@/models/entities/user.js"; -export default (object: any, user: { id: User["id"] }) => { +export const renderUndo = (object: any, userId: string) => { if (object == null) return null; const id = typeof object.id === "string" && object.id.startsWith(config.url) @@ -11,7 +10,7 @@ export default (object: any, user: { id: User["id"] }) => { return { type: "Undo", ...(id ? { id } : {}), - actor: `${config.url}/users/${user.id}`, + actor: `${config.url}/users/${userId}`, object, published: new Date().toISOString(), }; diff --git a/packages/backend/src/remote/activitypub/resolver.ts b/packages/backend/src/remote/activitypub/resolver.ts index fab913f869..c9d94e9fd6 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.js"; import type { ILocalUser } from "@/models/entities/user.js"; import { extractHost, - getInternalActor, + getInstanceActor, isAllowedServer, isBlockedServer, isSelfHost, @@ -112,7 +112,7 @@ export default class Resolver { } if (!this.user) { - this.user = await getInternalActor("instance"); + this.user = (await getInstanceActor()) as ILocalUser; } apLogger.info( diff --git a/packages/backend/src/server/activitypub.ts b/packages/backend/src/server/activitypub.ts index 84a72f54cc..81513f5d89 100644 --- a/packages/backend/src/server/activitypub.ts +++ b/packages/backend/src/server/activitypub.ts @@ -9,7 +9,7 @@ import renderKey from "@/remote/activitypub/renderer/key.js"; import { renderPerson } from "@/remote/activitypub/renderer/person.js"; import renderEmoji from "@/remote/activitypub/renderer/emoji.js"; import { inbox as processInbox } from "@/queue/index.js"; -import { fetchMeta, getInternalActor, isSelfHost } from "backend-rs"; +import { fetchMeta, getInstanceActor, isSelfHost } from "backend-rs"; import { Notes, Users, @@ -295,7 +295,7 @@ router.get("/users/:user/collections/featured", Featured); // publickey router.get("/users/:user/publickey", async (ctx) => { - const instanceActor = await getInternalActor("instance"); + const instanceActor = (await getInstanceActor()) as ILocalUser; if (ctx.params.user === instanceActor.id) { ctx.body = renderActivity( renderKey(instanceActor, await getUserKeypair(instanceActor.id)), @@ -359,7 +359,7 @@ async function userInfo(ctx: Router.RouterContext, user: User | null) { router.get("/users/:user", async (ctx, next) => { if (!isActivityPubReq(ctx)) return await next(); - const instanceActor = await getInternalActor("instance"); + const instanceActor = (await getInstanceActor()) as ILocalUser; if (ctx.params.user === instanceActor.id) { await userInfo(ctx, instanceActor); return; @@ -386,7 +386,7 @@ router.get("/@:user", async (ctx, next) => { if (!isActivityPubReq(ctx)) return await next(); if (ctx.params.user === "instance.actor") { - const instanceActor = await getInternalActor("instance"); + const instanceActor = (await getInstanceActor()) as ILocalUser; await userInfo(ctx, instanceActor); return; } @@ -407,7 +407,7 @@ router.get("/@:user", async (ctx, next) => { }); router.get("/actor", async (ctx, _next) => { - const instanceActor = await getInternalActor("instance"); + const instanceActor = (await getInstanceActor()) as ILocalUser; await userInfo(ctx, instanceActor); }); //#endregion diff --git a/packages/backend/src/server/api/common/read-messaging-message.ts b/packages/backend/src/server/api/common/read-messaging-message.ts index 90f4b9dc66..a2c8ba70cf 100644 --- a/packages/backend/src/server/api/common/read-messaging-message.ts +++ b/packages/backend/src/server/api/common/read-messaging-message.ts @@ -173,10 +173,10 @@ export async function deliverReadActivity( undefined, contents, ); - deliver(user, renderActivity(collection), recipient.inbox); + deliver(user.id, renderActivity(collection), recipient.inbox); } else { for (const content of contents) { - deliver(user, renderActivity(content), recipient.inbox); + deliver(user.id, renderActivity(content), recipient.inbox); } } } diff --git a/packages/backend/src/server/api/endpoints/admin/resolve-abuse-user-report.ts b/packages/backend/src/server/api/endpoints/admin/resolve-abuse-user-report.ts index 1104a591c8..c93024b41b 100644 --- a/packages/backend/src/server/api/endpoints/admin/resolve-abuse-user-report.ts +++ b/packages/backend/src/server/api/endpoints/admin/resolve-abuse-user-report.ts @@ -1,9 +1,10 @@ import define from "@/server/api/define.js"; import { AbuseUserReports, Users } from "@/models/index.js"; -import { getInternalActor } from "backend-rs"; +import { getInstanceActor } from "backend-rs"; import { deliver } from "@/queue/index.js"; import { renderActivity } from "@/remote/activitypub/renderer/index.js"; import { renderFlag } from "@/remote/activitypub/renderer/flag.js"; +import { ILocalUser } from "@/models/entities/user"; export const meta = { tags: ["admin"], @@ -29,11 +30,11 @@ export default define(meta, paramDef, async (ps, me) => { } if (ps.forward && report.targetUserHost != null) { - const actor = await getInternalActor("instance"); + const actor = (await getInstanceActor()) as ILocalUser; const targetUser = await Users.findOneByOrFail({ id: report.targetUserId }); deliver( - actor, + actor.id, renderActivity(renderFlag(actor, [targetUser.uri!], report.comment)), targetUser.inbox, ); diff --git a/packages/backend/src/server/api/endpoints/notes/polls/vote.ts b/packages/backend/src/server/api/endpoints/notes/polls/vote.ts index 9f67404875..5b29f1e37c 100644 --- a/packages/backend/src/server/api/endpoints/notes/polls/vote.ts +++ b/packages/backend/src/server/api/endpoints/notes/polls/vote.ts @@ -172,7 +172,7 @@ export default define(meta, paramDef, async (ps, user) => { })) as IRemoteUser; deliver( - user, + user.id, renderActivity(await renderVote(user, vote, note, poll, pollOwner)), pollOwner.inbox, ); diff --git a/packages/backend/src/server/api/mastodon/helpers/poll.ts b/packages/backend/src/server/api/mastodon/helpers/poll.ts index b06ce1d6c9..b5c3794892 100644 --- a/packages/backend/src/server/api/mastodon/helpers/poll.ts +++ b/packages/backend/src/server/api/mastodon/helpers/poll.ts @@ -141,7 +141,7 @@ export class PollHelpers { })) as IRemoteUser; deliver( - user, + user.id, renderActivity(await renderVote(user, vote, note, poll, pollOwner)), pollOwner.inbox, ); diff --git a/packages/backend/src/services/blocking/create.ts b/packages/backend/src/services/blocking/create.ts index b5e23c8277..8c41d93665 100644 --- a/packages/backend/src/services/blocking/create.ts +++ b/packages/backend/src/services/blocking/create.ts @@ -1,7 +1,7 @@ import { publishMainStream, publishUserEvent } from "@/services/stream.js"; import { renderActivity } from "@/remote/activitypub/renderer/index.js"; import renderFollow from "@/remote/activitypub/renderer/follow.js"; -import renderUndo from "@/remote/activitypub/renderer/undo.js"; +import { renderUndo } from "@/remote/activitypub/renderer/undo.js"; import { renderBlock } from "@/remote/activitypub/renderer/block.js"; import { deliver } from "@/queue/index.js"; import renderReject from "@/remote/activitypub/renderer/reject.js"; @@ -43,7 +43,7 @@ export default async function (blocker: User, blockee: User) { if (Users.isLocalUser(blocker) && Users.isRemoteUser(blockee)) { const content = renderActivity(renderBlock(blocking)); - deliver(blocker, content, blockee.inbox); + deliver(blocker.id, content, blockee.inbox); } } @@ -89,9 +89,9 @@ async function cancelRequest(follower: User, followee: User) { // リモートにフォローリクエストをしていたらUndoFollow送信 if (Users.isLocalUser(follower) && Users.isRemoteUser(followee)) { const content = renderActivity( - renderUndo(renderFollow(follower, followee), follower), + renderUndo(renderFollow(follower, followee), follower.id), ); - deliver(follower, content, followee.inbox); + deliver(follower.id, content, followee.inbox); } // リモートからフォローリクエストを受けていたらReject送信 @@ -102,7 +102,7 @@ async function cancelRequest(follower: User, followee: User) { followee, ), ); - deliver(followee, content, follower.inbox); + deliver(followee.id, content, follower.inbox); } } @@ -144,9 +144,9 @@ async function unFollow(follower: User, followee: User) { // リモートにフォローをしていたらUndoFollow送信 if (Users.isLocalUser(follower) && Users.isRemoteUser(followee)) { const content = renderActivity( - renderUndo(renderFollow(follower, followee), follower), + renderUndo(renderFollow(follower, followee), follower.id), ); - deliver(follower, content, followee.inbox); + deliver(follower.id, content, followee.inbox); } } diff --git a/packages/backend/src/services/blocking/delete.ts b/packages/backend/src/services/blocking/delete.ts index 271883fe89..fe9528d48c 100644 --- a/packages/backend/src/services/blocking/delete.ts +++ b/packages/backend/src/services/blocking/delete.ts @@ -1,6 +1,6 @@ import { renderActivity } from "@/remote/activitypub/renderer/index.js"; import { renderBlock } from "@/remote/activitypub/renderer/block.js"; -import renderUndo from "@/remote/activitypub/renderer/undo.js"; +import { renderUndo } from "@/remote/activitypub/renderer/undo.js"; import { deliver } from "@/queue/index.js"; import Logger from "@/services/logger.js"; import type { CacheableUser } from "@/models/entities/user.js"; @@ -30,7 +30,9 @@ export default async function (blocker: CacheableUser, blockee: CacheableUser) { // deliver if remote bloking if (Users.isLocalUser(blocker) && Users.isRemoteUser(blockee)) { - const content = renderActivity(renderUndo(renderBlock(blocking), blocker)); - deliver(blocker, content, blockee.inbox); + const content = renderActivity( + renderUndo(renderBlock(blocking), blocker.id), + ); + deliver(blocker.id, content, blockee.inbox); } } diff --git a/packages/backend/src/services/following/create.ts b/packages/backend/src/services/following/create.ts index df9ab8ab2f..6788cd13f6 100644 --- a/packages/backend/src/services/following/create.ts +++ b/packages/backend/src/services/following/create.ts @@ -192,7 +192,7 @@ export default async function ( const content = renderActivity( renderReject(renderFollow(follower, followee, requestId), followee), ); - deliver(followee, content, follower.inbox); + deliver(followee.id, content, follower.inbox); return; } else if ( Users.isRemoteUser(follower) && @@ -271,6 +271,6 @@ export default async function ( const content = renderActivity( renderAccept(renderFollow(follower, followee, requestId), followee), ); - deliver(followee, content, follower.inbox); + deliver(followee.id, content, follower.inbox); } } diff --git a/packages/backend/src/services/following/delete.ts b/packages/backend/src/services/following/delete.ts index e71e23de74..2fe863fc57 100644 --- a/packages/backend/src/services/following/delete.ts +++ b/packages/backend/src/services/following/delete.ts @@ -1,7 +1,7 @@ import { publishMainStream, publishUserEvent } from "@/services/stream.js"; import { renderActivity } from "@/remote/activitypub/renderer/index.js"; import renderFollow from "@/remote/activitypub/renderer/follow.js"; -import renderUndo from "@/remote/activitypub/renderer/undo.js"; +import { renderUndo } from "@/remote/activitypub/renderer/undo.js"; import renderReject from "@/remote/activitypub/renderer/reject.js"; import { deliver, webhookDeliver } from "@/queue/index.js"; import Logger from "../logger.js"; @@ -66,9 +66,9 @@ export default async function ( if (Users.isLocalUser(follower) && Users.isRemoteUser(followee)) { const content = renderActivity( - renderUndo(renderFollow(follower, followee), follower), + renderUndo(renderFollow(follower, followee), follower.id), ); - deliver(follower, content, followee.inbox); + deliver(follower.id, content, followee.inbox); } if (Users.isLocalUser(followee) && Users.isRemoteUser(follower)) { @@ -76,7 +76,7 @@ export default async function ( const content = renderActivity( renderReject(renderFollow(follower, followee), followee), ); - deliver(followee, content, follower.inbox); + deliver(followee.id, content, follower.inbox); } } diff --git a/packages/backend/src/services/following/reject.ts b/packages/backend/src/services/following/reject.ts index 3f461268dd..821fe9f639 100644 --- a/packages/backend/src/services/following/reject.ts +++ b/packages/backend/src/services/following/reject.ts @@ -108,7 +108,7 @@ async function deliverReject(followee: Local, follower: Remote) { followee, ), ); - deliver(followee, content, follower.inbox); + deliver(followee.id, content, follower.inbox); } /** diff --git a/packages/backend/src/services/following/requests/accept.ts b/packages/backend/src/services/following/requests/accept.ts index 1bc10f6082..f0425c20b9 100644 --- a/packages/backend/src/services/following/requests/accept.ts +++ b/packages/backend/src/services/following/requests/accept.ts @@ -39,7 +39,7 @@ export default async function ( followee, ), ); - deliver(followee, content, follower.inbox); + deliver(followee.id, content, follower.inbox); } Users.pack(followee.id, followee, { diff --git a/packages/backend/src/services/following/requests/cancel.ts b/packages/backend/src/services/following/requests/cancel.ts index 45b8ee0639..f271b15058 100644 --- a/packages/backend/src/services/following/requests/cancel.ts +++ b/packages/backend/src/services/following/requests/cancel.ts @@ -1,6 +1,6 @@ import { renderActivity } from "@/remote/activitypub/renderer/index.js"; import renderFollow from "@/remote/activitypub/renderer/follow.js"; -import renderUndo from "@/remote/activitypub/renderer/undo.js"; +import { renderUndo } from "@/remote/activitypub/renderer/undo.js"; import { deliver } from "@/queue/index.js"; import { publishMainStream } from "@/services/stream.js"; import { IdentifiableError } from "@/misc/identifiable-error.js"; @@ -18,12 +18,12 @@ export default async function ( ) { if (Users.isRemoteUser(followee)) { const content = renderActivity( - renderUndo(renderFollow(follower, followee), follower), + renderUndo(renderFollow(follower, followee), follower.id), ); if (Users.isLocalUser(follower)) { // 本来このチェックは不要だけどTSに怒られるので - deliver(follower, content, followee.inbox); + deliver(follower.id, content, followee.inbox); } } diff --git a/packages/backend/src/services/following/requests/create.ts b/packages/backend/src/services/following/requests/create.ts index e4f093dfc1..648fd38a0a 100644 --- a/packages/backend/src/services/following/requests/create.ts +++ b/packages/backend/src/services/following/requests/create.ts @@ -89,6 +89,6 @@ export default async function ( requestId ?? `${config.url}/follows/${followRequest.id}`, ), ); - deliver(follower, content, followee.inbox); + deliver(follower.id, content, followee.inbox); } } diff --git a/packages/backend/src/services/messages/create.ts b/packages/backend/src/services/messages/create.ts index 5dba6216e3..32c800f0b3 100644 --- a/packages/backend/src/services/messages/create.ts +++ b/packages/backend/src/services/messages/create.ts @@ -185,7 +185,7 @@ export async function createMessage( const activity = renderActivity(renderCreate(renderedNote, note)); - deliver(user, activity, recipientUser.inbox); + deliver(user.id, activity, recipientUser.inbox); } return messageObj; } diff --git a/packages/backend/src/services/messages/delete.ts b/packages/backend/src/services/messages/delete.ts index bd7422de0b..f0b65151ec 100644 --- a/packages/backend/src/services/messages/delete.ts +++ b/packages/backend/src/services/messages/delete.ts @@ -41,7 +41,7 @@ async function postDeleteMessage(message: MessagingMessage) { user, ), ); - deliver(user, activity, recipient.inbox); + deliver(user.id, activity, recipient.inbox); } } else if (message.groupId != null) { await publishToGroupChatStream(message.groupId, "deleted", message.id); diff --git a/packages/backend/src/services/note/delete.ts b/packages/backend/src/services/note/delete.ts index 966d72a036..82e523c84b 100644 --- a/packages/backend/src/services/note/delete.ts +++ b/packages/backend/src/services/note/delete.ts @@ -2,7 +2,7 @@ import { Brackets, In } from "typeorm"; import { publishNoteStream } from "@/services/stream.js"; import renderDelete from "@/remote/activitypub/renderer/delete.js"; import renderAnnounce from "@/remote/activitypub/renderer/announce.js"; -import renderUndo from "@/remote/activitypub/renderer/undo.js"; +import { renderUndo } from "@/remote/activitypub/renderer/undo.js"; import { renderActivity } from "@/remote/activitypub/renderer/index.js"; import renderTombstone from "@/remote/activitypub/renderer/tombstone.js"; import { config } from "@/config.js"; @@ -100,7 +100,7 @@ export default async function ( renote.uri || `${config.url}/notes/${renote.id}`, note, ), - user, + user.id, ) : renderDelete(renderTombstone(`${config.url}/notes/${note.id}`), user), ); diff --git a/packages/backend/src/services/note/reaction/delete.ts b/packages/backend/src/services/note/reaction/delete.ts index e5416a78a8..7e37cd38ed 100644 --- a/packages/backend/src/services/note/reaction/delete.ts +++ b/packages/backend/src/services/note/reaction/delete.ts @@ -1,6 +1,6 @@ import { publishNoteStream } from "@/services/stream.js"; import { renderLike } from "@/remote/activitypub/renderer/like.js"; -import renderUndo from "@/remote/activitypub/renderer/undo.js"; +import { renderUndo } from "@/remote/activitypub/renderer/undo.js"; import { renderActivity } from "@/remote/activitypub/renderer/index.js"; import DeliverManager from "@/remote/activitypub/deliver-manager.js"; import { IdentifiableError } from "@/misc/identifiable-error.js"; @@ -56,7 +56,7 @@ export default async ( //#region 配信 if (Users.isLocalUser(user) && !note.localOnly) { const content = renderActivity( - renderUndo(await renderLike(reaction, note), user), + renderUndo(await renderLike(reaction, note), user.id), ); const dm = new DeliverManager(user, content); if (note.userHost != null) { diff --git a/packages/backend/src/services/relay.ts b/packages/backend/src/services/relay.ts index 90e217c2e9..e1ecc707e3 100644 --- a/packages/backend/src/services/relay.ts +++ b/packages/backend/src/services/relay.ts @@ -3,11 +3,11 @@ import { renderActivity, attachLdSignature, } from "@/remote/activitypub/renderer/index.js"; -import renderUndo from "@/remote/activitypub/renderer/undo.js"; +import { renderUndo } from "@/remote/activitypub/renderer/undo.js"; import { deliver } from "@/queue/index.js"; import type { User } from "@/models/entities/user.js"; import { Relays } from "@/models/index.js"; -import { getInternalActor, genId } from "backend-rs"; +import { getRelayActorId, genId } from "backend-rs"; import { Cache } from "@/misc/cache.js"; import type { Relay } from "@/models/entities/relay.js"; @@ -20,10 +20,10 @@ export async function addRelay(inbox: string) { status: "requesting", }).then((x) => Relays.findOneByOrFail(x.identifiers[0])); - const relayActor = await getInternalActor("relay"); - const follow = renderFollowRelay(relay, relayActor); + const relayActorId = await getRelayActorId(); + const follow = renderFollowRelay(relay, relayActorId); const activity = renderActivity(follow); - deliver(relayActor, activity, relay.inbox); + deliver(relayActorId, activity, relay.inbox); return relay; } @@ -37,11 +37,11 @@ export async function removeRelay(inbox: string) { throw new Error("relay not found"); } - const relayActor = await getInternalActor("relay"); - const follow = renderFollowRelay(relay, relayActor); - const undo = renderUndo(follow, relayActor); + const relayActorId = await getRelayActorId(); + const follow = renderFollowRelay(relay, relayActorId); + const undo = renderUndo(follow, relayActorId); const activity = renderActivity(undo); - deliver(relayActor, activity, relay.inbox); + deliver(relayActorId, activity, relay.inbox); await Relays.delete(relay.id); await updateRelaysCache(); @@ -102,6 +102,6 @@ export async function deliverToRelays( const signed = await attachLdSignature(copy, user); for (const relay of relays) { - deliver(user, signed, relay.inbox); + deliver(user.id, signed, relay.inbox); } } diff --git a/packages/backend/src/services/suspend-user.ts b/packages/backend/src/services/suspend-user.ts index 0babd31bc5..22b83d3fdb 100644 --- a/packages/backend/src/services/suspend-user.ts +++ b/packages/backend/src/services/suspend-user.ts @@ -41,7 +41,7 @@ export async function doPostSuspend(user: { } for (const inbox of queue) { - deliver(user, content, inbox); + deliver(user.id, content, inbox); } } } diff --git a/packages/backend/src/services/unsuspend-user.ts b/packages/backend/src/services/unsuspend-user.ts index 72d7e30d66..b5e83a4151 100644 --- a/packages/backend/src/services/unsuspend-user.ts +++ b/packages/backend/src/services/unsuspend-user.ts @@ -1,5 +1,5 @@ import renderDelete from "@/remote/activitypub/renderer/delete.js"; -import renderUndo from "@/remote/activitypub/renderer/undo.js"; +import { renderUndo } from "@/remote/activitypub/renderer/undo.js"; import { renderActivity } from "@/remote/activitypub/renderer/index.js"; import { deliver } from "@/queue/index.js"; import { config } from "@/config.js"; @@ -17,7 +17,7 @@ export async function doPostUnsuspend(user: User) { if (Users.isLocalUser(user)) { // 知り得る全SharedInboxにUndo Delete配信 const content = renderActivity( - renderUndo(renderDelete(`${config.url}/users/${user.id}`, user), user), + renderUndo(renderDelete(`${config.url}/users/${user.id}`, user), user.id), ); const queue: string[] = []; @@ -39,7 +39,7 @@ export async function doPostUnsuspend(user: User) { } for (const inbox of queue) { - deliver(user as any, content, inbox); + deliver(user.id, content, inbox); } } } From e35ce24369d1a5710687fdc9ec18d204723134ab Mon Sep 17 00:00:00 2001 From: naskya Date: Fri, 26 Jul 2024 17:54:18 +0900 Subject: [PATCH 20/43] chore (backend-rs): remove unused things --- packages/backend-rs/index.d.ts | 3 -- packages/backend-rs/index.js | 1 - .../src/federation/internal_actor/instance.rs | 4 +-- .../src/federation/internal_actor/mod.rs | 29 ------------------- .../src/federation/internal_actor/relay.rs | 4 +-- 5 files changed, 4 insertions(+), 37 deletions(-) diff --git a/packages/backend-rs/index.d.ts b/packages/backend-rs/index.d.ts index 6d82b6d413..ca7bd247cc 100644 --- a/packages/backend-rs/index.d.ts +++ b/packages/backend-rs/index.d.ts @@ -531,9 +531,6 @@ export interface Instance { faviconUrl: string | null } -export type InternalActor = 'instance'| -'relay'; - /** * Checks if a server is allowlisted. * Returns `Ok(true)` if private mode is disabled. diff --git a/packages/backend-rs/index.js b/packages/backend-rs/index.js index 7504ca5ead..d248ab3231 100644 --- a/packages/backend-rs/index.js +++ b/packages/backend-rs/index.js @@ -392,7 +392,6 @@ module.exports.greet = nativeBinding.greet module.exports.hashPassword = nativeBinding.hashPassword module.exports.Inbound = nativeBinding.Inbound module.exports.initializeRustLogger = nativeBinding.initializeRustLogger -module.exports.InternalActor = nativeBinding.InternalActor module.exports.isAllowedServer = nativeBinding.isAllowedServer module.exports.isBlockedServer = nativeBinding.isBlockedServer module.exports.isOldPasswordAlgorithm = nativeBinding.isOldPasswordAlgorithm diff --git a/packages/backend-rs/src/federation/internal_actor/instance.rs b/packages/backend-rs/src/federation/internal_actor/instance.rs index 4bf298c364..000ff83d49 100644 --- a/packages/backend-rs/src/federation/internal_actor/instance.rs +++ b/packages/backend-rs/src/federation/internal_actor/instance.rs @@ -1,6 +1,5 @@ //! In-memory instance actor cache -use super::INSTANCE_ACTOR_USERNAME; use crate::{database::db_conn, model::entity::user}; use sea_orm::prelude::*; use tokio::sync::OnceCell; @@ -9,6 +8,7 @@ use tokio::sync::OnceCell; // https://github.com/napi-rs/napi-rs/issues/2060 type User = user::Model; +pub const USERNAME: &str = "instance.actor"; static INSTANCE_ACTOR: OnceCell = OnceCell::const_new(); #[macros::errors] @@ -25,7 +25,7 @@ async fn set_cache() -> Result<&'static User, Error> { .get_or_try_init(|| async { tracing::debug!("caching @instance.actor"); let found_model = user::Entity::find() - .filter(user::Column::Username.eq(INSTANCE_ACTOR_USERNAME)) + .filter(user::Column::Username.eq(USERNAME)) .filter(user::Column::Host.is_null()) .one(db_conn().await?) .await?; diff --git a/packages/backend-rs/src/federation/internal_actor/mod.rs b/packages/backend-rs/src/federation/internal_actor/mod.rs index a8ffc40ecd..b2f361dcb2 100644 --- a/packages/backend-rs/src/federation/internal_actor/mod.rs +++ b/packages/backend-rs/src/federation/internal_actor/mod.rs @@ -1,33 +1,4 @@ pub mod instance; pub mod relay; -use super::acct::Acct; - -#[derive(Debug)] -#[macros::derive_clone_and_export(string_enum = "lowercase")] -pub enum InternalActor { - Instance, - Relay, -} - -const INSTANCE_ACTOR_USERNAME: &str = "instance.actor"; -const RELAY_ACTOR_USERNAME: &str = "relay.actor"; - -// TODO: When `std::mem::variant_count` is stabilized, use -// it to count system actors instead of hard coding the magic number pub const INTERNAL_ACTORS: u64 = 2; - -impl From for Acct { - fn from(actor: InternalActor) -> Self { - match actor { - InternalActor::Instance => Acct { - username: INSTANCE_ACTOR_USERNAME.to_owned(), - host: None, - }, - InternalActor::Relay => Acct { - username: RELAY_ACTOR_USERNAME.to_owned(), - host: None, - }, - } - } -} diff --git a/packages/backend-rs/src/federation/internal_actor/relay.rs b/packages/backend-rs/src/federation/internal_actor/relay.rs index e2926ceda1..849a148201 100644 --- a/packages/backend-rs/src/federation/internal_actor/relay.rs +++ b/packages/backend-rs/src/federation/internal_actor/relay.rs @@ -1,10 +1,10 @@ //! In-memory relay actor id cache -use super::RELAY_ACTOR_USERNAME; use crate::{database::db_conn, model::entity::user}; use sea_orm::{prelude::*, QuerySelect, SelectColumns}; use tokio::sync::OnceCell; +pub const USERNAME: &str = "relay.actor"; static RELAY_ACTOR_ID: OnceCell = OnceCell::const_new(); #[macros::errors] @@ -23,7 +23,7 @@ async fn set_id_cache() -> Result<&'static str, Error> { let found_id = user::Entity::find() .select_only() .select_column(user::Column::Id) - .filter(user::Column::Username.eq(RELAY_ACTOR_USERNAME)) + .filter(user::Column::Username.eq(USERNAME)) .filter(user::Column::Host.is_null()) .into_tuple::() .one(db_conn().await?) From ffcde7c7ece8839db3fde201f79a7c937b20793a Mon Sep 17 00:00:00 2001 From: naskya Date: Fri, 26 Jul 2024 18:53:07 +0900 Subject: [PATCH 21/43] chore (backend-rs): apply clippy suggestions --- packages/backend-rs/src/federation/internal_actor/instance.rs | 2 +- packages/backend-rs/src/federation/internal_actor/relay.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/backend-rs/src/federation/internal_actor/instance.rs b/packages/backend-rs/src/federation/internal_actor/instance.rs index 000ff83d49..957aa57492 100644 --- a/packages/backend-rs/src/federation/internal_actor/instance.rs +++ b/packages/backend-rs/src/federation/internal_actor/instance.rs @@ -30,7 +30,7 @@ async fn set_cache() -> Result<&'static User, Error> { .one(db_conn().await?) .await?; - Ok::(found_model.ok_or(Error::InstanceActorNotFound)?) + found_model.ok_or(Error::InstanceActorNotFound) }) .await?; diff --git a/packages/backend-rs/src/federation/internal_actor/relay.rs b/packages/backend-rs/src/federation/internal_actor/relay.rs index 849a148201..2c7c4bafcc 100644 --- a/packages/backend-rs/src/federation/internal_actor/relay.rs +++ b/packages/backend-rs/src/federation/internal_actor/relay.rs @@ -29,7 +29,7 @@ async fn set_id_cache() -> Result<&'static str, Error> { .one(db_conn().await?) .await?; - Ok::(found_id.ok_or(Error::RelayActorNotFound)?) + found_id.ok_or(Error::RelayActorNotFound) }) .await?; From 023f39a47c30b51bd54fe52f1c64f7bc1127f2d3 Mon Sep 17 00:00:00 2001 From: GitLab CI Date: Fri, 26 Jul 2024 12:06:12 +0000 Subject: [PATCH 22/43] chore(deps): update rust crate redis to 0.26.0 --- Cargo.lock | 12 ++++++++++-- Cargo.toml | 2 +- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index e30176f639..d52b933fa2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -84,6 +84,12 @@ version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7d5a26814d8dcb93b0e5a0ff3c6d80a8843bafb21b39e8e18a6f05471870e110" +[[package]] +name = "arc-swap" +version = "1.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "69f7f8c3906b62b754cd5326047894316021dcfe5a194c8ea52bdd94934a3457" + [[package]] name = "arg_enum_proc_macro" version = "0.3.4" @@ -2624,15 +2630,17 @@ dependencies = [ [[package]] name = "redis" -version = "0.25.4" +version = "0.26.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e0d7a6955c7511f60f3ba9e86c6d02b3c3f144f8c24b288d1f4e18074ab8bbec" +checksum = "8cc5b667390cb038bc65fc4b18c06e2550469f7e06a02d886f1a018a11f63563" dependencies = [ + "arc-swap", "async-trait", "bytes", "combine", "futures-util", "itoa", + "num-bigint", "percent-encoding", "pin-project-lite", "ryu", diff --git a/Cargo.toml b/Cargo.toml index 2ce3a83cdb..266f4beb38 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -32,7 +32,7 @@ pretty_assertions = { version = "1.4.0", default-features = false } proc-macro2 = { version = "1.0.86", default-features = false } quote = { version = "1.0.36", default-features = false } rand = { version = "0.8.5", default-features = false } -redis = { version = "0.25.4", default-features = false } +redis = { version = "0.26.0", default-features = false } regex = { version = "1.10.5", default-features = false } rmp-serde = { version = "1.3.0", default-features = false } sea-orm = { version = "0.12.15", default-features = false } From 036d7972cf7d1157d9e4467a3965c4de9e3cc5c4 Mon Sep 17 00:00:00 2001 From: GitLab CI Date: Fri, 26 Jul 2024 20:05:32 +0000 Subject: [PATCH 23/43] chore(deps): update dependency swiper to v11.1.8 --- packages/client/package.json | 2 +- pnpm-lock.yaml | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/client/package.json b/packages/client/package.json index a04c3032e0..3113d0fb93 100644 --- a/packages/client/package.json +++ b/packages/client/package.json @@ -75,7 +75,7 @@ "sass": "1.77.8", "seedrandom": "3.0.5", "stringz": "2.1.0", - "swiper": "11.1.7", + "swiper": "11.1.8", "textarea-caret": "3.1.0", "throttle-debounce": "5.0.2", "tinycolor2": "1.6.0", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 8242ae059a..2e2e4df7a2 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -683,8 +683,8 @@ importers: specifier: 2.1.0 version: 2.1.0 swiper: - specifier: 11.1.7 - version: 11.1.7 + specifier: 11.1.8 + version: 11.1.8 textarea-caret: specifier: 3.1.0 version: 3.1.0 @@ -6178,8 +6178,8 @@ packages: resolution: {integrity: sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w==} engines: {node: '>= 0.4'} - swiper@11.1.7: - resolution: {integrity: sha512-2EpQvhgKb+DNbi8/i9uRXhddivcMZQxca341t2NZYV1xroCR2p4YtYd3azuqRQ4OEBGcG4nv3aN24O80bMipow==} + swiper@11.1.8: + resolution: {integrity: sha512-sBFp7fA+IfZ/7BMcg8/JSEqDD1qZXBUyliT76yk3zIYVu2fMwFVAghhAJ9vBM5tJUtHW5qcD0pmeEGQs1EK14w==} engines: {node: '>= 4.7.0'} symbol-tree@3.2.4: @@ -12606,7 +12606,7 @@ snapshots: supports-preserve-symlinks-flag@1.0.0: {} - swiper@11.1.7: {} + swiper@11.1.8: {} symbol-tree@3.2.4: {} From e80113ae6f07c5c1b6447259990298bc8f9772d9 Mon Sep 17 00:00:00 2001 From: naskya Date: Sat, 27 Jul 2024 10:52:42 +0900 Subject: [PATCH 24/43] chore (backend): fix default maxFileSize value --- packages/backend-rs/index.d.ts | 2 +- packages/backend-rs/src/config/server.rs | 4 ++-- packages/backend/src/misc/download-url.ts | 2 +- packages/backend/src/server/api/index.ts | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/backend-rs/index.d.ts b/packages/backend-rs/index.d.ts index ca7bd247cc..e6a1e5d0ec 100644 --- a/packages/backend-rs/index.d.ts +++ b/packages/backend-rs/index.d.ts @@ -217,7 +217,7 @@ export interface Config { proxySmtp?: string proxyBypassHosts?: Array allowedPrivateNetworks?: Array - maxFileSize?: number + maxFileSize: number accessLog?: string clusterLimits: WorkerConfig cuid?: IdConfig diff --git a/packages/backend-rs/src/config/server.rs b/packages/backend-rs/src/config/server.rs index 19f4d19da0..37af3587c8 100644 --- a/packages/backend-rs/src/config/server.rs +++ b/packages/backend-rs/src/config/server.rs @@ -200,7 +200,7 @@ pub struct Config { pub proxy_smtp: Option, pub proxy_bypass_hosts: Option>, pub allowed_private_networks: Option>, - pub max_file_size: Option, + pub max_file_size: i64, pub access_log: Option, pub cluster_limits: WorkerConfig, pub cuid: Option, @@ -309,7 +309,7 @@ pub fn load_config() -> Config { proxy_smtp: server_config.proxy_smtp, proxy_bypass_hosts: server_config.proxy_bypass_hosts, allowed_private_networks: server_config.allowed_private_networks, - max_file_size: server_config.max_file_size, + max_file_size: server_config.max_file_size.unwrap_or(262144000), access_log: server_config.access_log, cluster_limits, cuid: server_config.cuid, diff --git a/packages/backend/src/misc/download-url.ts b/packages/backend/src/misc/download-url.ts index 08dedcd3ed..6c3aea650d 100644 --- a/packages/backend/src/misc/download-url.ts +++ b/packages/backend/src/misc/download-url.ts @@ -20,7 +20,7 @@ export async function downloadUrl(url: string, path: string): Promise { const timeout = 30 * 1000; const operationTimeout = 60 * 1000; - const maxSize = config.maxFileSize || 262144000; + const maxSize = config.maxFileSize; const req = got .stream(url, { diff --git a/packages/backend/src/server/api/index.ts b/packages/backend/src/server/api/index.ts index f5bf3bf097..0fd443e99e 100644 --- a/packages/backend/src/server/api/index.ts +++ b/packages/backend/src/server/api/index.ts @@ -43,7 +43,7 @@ const errorRouter = new Router(); const upload = multer({ storage: multer.diskStorage({}), limits: { - fileSize: config.maxFileSize || 262144000, + fileSize: config.maxFileSize, files: 1, }, }); From bca44bf50af5074cd557f85c186e225ea5a30cf5 Mon Sep 17 00:00:00 2001 From: naskya Date: Sat, 27 Jul 2024 16:32:19 +0900 Subject: [PATCH 25/43] chore (backend): remove gen-key-pair.ts --- .../1720618854585-create-system-actors.ts | 22 +++++++++- packages/backend/src/misc/gen-key-pair.ts | 42 ------------------- 2 files changed, 21 insertions(+), 43 deletions(-) delete mode 100644 packages/backend/src/misc/gen-key-pair.ts diff --git a/packages/backend/src/migration/1720618854585-create-system-actors.ts b/packages/backend/src/migration/1720618854585-create-system-actors.ts index b66bfed800..05a06099c7 100644 --- a/packages/backend/src/migration/1720618854585-create-system-actors.ts +++ b/packages/backend/src/migration/1720618854585-create-system-actors.ts @@ -1,9 +1,29 @@ import type { MigrationInterface, QueryRunner } from "typeorm"; import { v4 as uuid } from "uuid"; -import { genRsaKeyPair } from "@/misc/gen-key-pair.js"; import { generateUserToken, genIdAt, hashPassword } from "backend-rs"; +import * as crypto from "node:crypto"; +import * as util from "node:util"; + +const generateKeyPair = util.promisify(crypto.generateKeyPair); + +export async function genRsaKeyPair(modulusLength = 2048) { + return await generateKeyPair("rsa", { + modulusLength, + publicKeyEncoding: { + type: "spki", + format: "pem", + }, + privateKeyEncoding: { + type: "pkcs8", + format: "pem", + cipher: undefined, + passphrase: undefined, + }, + }); +} + async function createSystemUser(username: string, queryRunner: QueryRunner) { const password = uuid(); diff --git a/packages/backend/src/misc/gen-key-pair.ts b/packages/backend/src/misc/gen-key-pair.ts deleted file mode 100644 index 8ae4175e30..0000000000 --- a/packages/backend/src/misc/gen-key-pair.ts +++ /dev/null @@ -1,42 +0,0 @@ -import * as crypto from "node:crypto"; -import * as util from "node:util"; - -const generateKeyPair = util.promisify(crypto.generateKeyPair); - -export async function genRsaKeyPair(modulusLength = 2048) { - return await generateKeyPair("rsa", { - modulusLength, - publicKeyEncoding: { - type: "spki", - format: "pem", - }, - privateKeyEncoding: { - type: "pkcs8", - format: "pem", - cipher: undefined, - passphrase: undefined, - }, - }); -} - -export async function genEcKeyPair( - namedCurve: - | "prime256v1" - | "secp384r1" - | "secp521r1" - | "curve25519" = "prime256v1", -) { - return await generateKeyPair("ec", { - namedCurve, - publicKeyEncoding: { - type: "spki", - format: "pem", - }, - privateKeyEncoding: { - type: "pkcs8", - format: "pem", - cipher: undefined, - passphrase: undefined, - }, - }); -} From 55e46c03b9945020a645653d154c173b64d476e7 Mon Sep 17 00:00:00 2001 From: naskya Date: Sat, 27 Jul 2024 17:02:24 +0900 Subject: [PATCH 26/43] refactor (backend): port renderFollowRelay to backend-rs --- packages/backend-rs/index.d.ts | 11 ++++++++ packages/backend-rs/index.js | 2 ++ .../src/federation/activitypub/mod.rs | 1 + .../src/federation/activitypub/object/mod.rs | 9 ++++++ .../federation/activitypub/object/relay.rs | 28 +++++++++++++++++++ packages/backend-rs/src/federation/mod.rs | 1 + .../activitypub/renderer/follow-relay.ts | 14 ---------- packages/backend/src/services/relay.ts | 7 ++--- 8 files changed, 55 insertions(+), 18 deletions(-) create mode 100644 packages/backend-rs/src/federation/activitypub/mod.rs create mode 100644 packages/backend-rs/src/federation/activitypub/object/mod.rs create mode 100644 packages/backend-rs/src/federation/activitypub/object/relay.rs delete mode 100644 packages/backend/src/remote/activitypub/renderer/follow-relay.ts diff --git a/packages/backend-rs/index.d.ts b/packages/backend-rs/index.d.ts index e6a1e5d0ec..b4bf0f65a9 100644 --- a/packages/backend-rs/index.d.ts +++ b/packages/backend-rs/index.d.ts @@ -48,6 +48,8 @@ export interface Acct { export declare function acctToString(acct: Acct): string +export type Activity = 'Follow'; + export interface Ad { id: string createdAt: DateTimeWithTimeZone @@ -389,6 +391,13 @@ export interface Following { followeeSharedInbox: string | null } +export interface FollowRelay { + id: string + type: Activity + actor: string + object: string +} + export interface FollowRequest { id: string createdAt: DateTimeWithTimeZone @@ -1190,6 +1199,8 @@ export type RelayStatus = 'accepted'| /** Delete all entries in the [attestation_challenge] table created at more than 5 minutes ago */ export declare function removeOldAttestationChallenges(): Promise +export declare function renderFollowRelay(relayId: string): Promise + export interface RenoteMuting { id: string createdAt: DateTimeWithTimeZone diff --git a/packages/backend-rs/index.js b/packages/backend-rs/index.js index d248ab3231..de95ac634c 100644 --- a/packages/backend-rs/index.js +++ b/packages/backend-rs/index.js @@ -362,6 +362,7 @@ if (!nativeBinding) { } module.exports.acctToString = nativeBinding.acctToString +module.exports.Activity = nativeBinding.Activity module.exports.AntennaSrc = nativeBinding.AntennaSrc module.exports.ChatEvent = nativeBinding.ChatEvent module.exports.ChatIndexEvent = nativeBinding.ChatIndexEvent @@ -429,6 +430,7 @@ module.exports.PushNotificationKind = nativeBinding.PushNotificationKind module.exports.PushSubscriptionType = nativeBinding.PushSubscriptionType module.exports.RelayStatus = nativeBinding.RelayStatus module.exports.removeOldAttestationChallenges = nativeBinding.removeOldAttestationChallenges +module.exports.renderFollowRelay = nativeBinding.renderFollowRelay module.exports.safeForSql = nativeBinding.safeForSql module.exports.sendPushNotification = nativeBinding.sendPushNotification module.exports.shouldNyaify = nativeBinding.shouldNyaify diff --git a/packages/backend-rs/src/federation/activitypub/mod.rs b/packages/backend-rs/src/federation/activitypub/mod.rs new file mode 100644 index 0000000000..e63d53de85 --- /dev/null +++ b/packages/backend-rs/src/federation/activitypub/mod.rs @@ -0,0 +1 @@ +pub mod object; diff --git a/packages/backend-rs/src/federation/activitypub/object/mod.rs b/packages/backend-rs/src/federation/activitypub/object/mod.rs new file mode 100644 index 0000000000..b245bca98a --- /dev/null +++ b/packages/backend-rs/src/federation/activitypub/object/mod.rs @@ -0,0 +1,9 @@ +pub mod relay; + +pub trait ActivityPubObject {} + +#[derive(serde::Serialize)] +#[macros::export(string_enum)] +pub enum Activity { + Follow, +} diff --git a/packages/backend-rs/src/federation/activitypub/object/relay.rs b/packages/backend-rs/src/federation/activitypub/object/relay.rs new file mode 100644 index 0000000000..f3d7656564 --- /dev/null +++ b/packages/backend-rs/src/federation/activitypub/object/relay.rs @@ -0,0 +1,28 @@ +use super::*; +use crate::{config::CONFIG, federation::internal_actor}; +use serde::Serialize; + +#[derive(Serialize)] +#[macros::export(object)] +pub struct FollowRelay { + pub id: String, + pub r#type: Activity, + pub actor: String, + pub object: String, +} + +impl ActivityPubObject for FollowRelay {} + +#[macros::export(js_name = "renderFollowRelay")] +pub async fn follow(relay_id: &str) -> Result { + Ok(FollowRelay { + id: format!("{}/activities/follow-relay/{}", CONFIG.url, relay_id), + r#type: Activity::Follow, + actor: format!( + "{}/users/{}", + CONFIG.url, + internal_actor::relay::get_id().await? + ), + object: "https://www.w3.org/ns/activitystreams#Public".to_owned(), + }) +} diff --git a/packages/backend-rs/src/federation/mod.rs b/packages/backend-rs/src/federation/mod.rs index 1db28b0858..c432fc9be8 100644 --- a/packages/backend-rs/src/federation/mod.rs +++ b/packages/backend-rs/src/federation/mod.rs @@ -1,5 +1,6 @@ //! Services used to federate with other servers pub mod acct; +pub mod activitypub; pub mod internal_actor; pub mod nodeinfo; diff --git a/packages/backend/src/remote/activitypub/renderer/follow-relay.ts b/packages/backend/src/remote/activitypub/renderer/follow-relay.ts deleted file mode 100644 index 48e73777e5..0000000000 --- a/packages/backend/src/remote/activitypub/renderer/follow-relay.ts +++ /dev/null @@ -1,14 +0,0 @@ -import { config } from "@/config.js"; -import type { Relay } from "@/models/entities/relay.js"; -import type { ILocalUser } from "@/models/entities/user.js"; - -export function renderFollowRelay(relay: Relay, relayActorId: string) { - const follow = { - id: `${config.url}/activities/follow-relay/${relay.id}`, - type: "Follow", - actor: `${config.url}/users/${relayActorId}`, - object: "https://www.w3.org/ns/activitystreams#Public", - }; - - return follow; -} diff --git a/packages/backend/src/services/relay.ts b/packages/backend/src/services/relay.ts index e1ecc707e3..c0d5b3935a 100644 --- a/packages/backend/src/services/relay.ts +++ b/packages/backend/src/services/relay.ts @@ -1,4 +1,3 @@ -import { renderFollowRelay } from "@/remote/activitypub/renderer/follow-relay.js"; import { renderActivity, attachLdSignature, @@ -7,7 +6,7 @@ import { renderUndo } from "@/remote/activitypub/renderer/undo.js"; import { deliver } from "@/queue/index.js"; import type { User } from "@/models/entities/user.js"; import { Relays } from "@/models/index.js"; -import { getRelayActorId, genId } from "backend-rs"; +import { getRelayActorId, genId, renderFollowRelay } from "backend-rs"; import { Cache } from "@/misc/cache.js"; import type { Relay } from "@/models/entities/relay.js"; @@ -21,7 +20,7 @@ export async function addRelay(inbox: string) { }).then((x) => Relays.findOneByOrFail(x.identifiers[0])); const relayActorId = await getRelayActorId(); - const follow = renderFollowRelay(relay, relayActorId); + const follow = await renderFollowRelay(relay.id); const activity = renderActivity(follow); deliver(relayActorId, activity, relay.inbox); @@ -38,7 +37,7 @@ export async function removeRelay(inbox: string) { } const relayActorId = await getRelayActorId(); - const follow = renderFollowRelay(relay, relayActorId); + const follow = await renderFollowRelay(relay.id); const undo = renderUndo(follow, relayActorId); const activity = renderActivity(undo); deliver(relayActorId, activity, relay.inbox); From 7186af04e0f9545025c1de5536f047932051c253 Mon Sep 17 00:00:00 2001 From: naskya Date: Sat, 27 Jul 2024 17:15:52 +0900 Subject: [PATCH 27/43] chore (backend): remove misc/post.ts --- packages/backend/src/misc/post.ts | 25 ------------------- .../processors/db/import-firefish-post.ts | 23 ++++++++++------- 2 files changed, 14 insertions(+), 34 deletions(-) delete mode 100644 packages/backend/src/misc/post.ts diff --git a/packages/backend/src/misc/post.ts b/packages/backend/src/misc/post.ts deleted file mode 100644 index fd89a4d7e3..0000000000 --- a/packages/backend/src/misc/post.ts +++ /dev/null @@ -1,25 +0,0 @@ -import { noteVisibilities } from "@/types.js"; - -export type Post = { - text: string | undefined; - cw: string | null; - localOnly: boolean; - createdAt: Date; - visibility: string; -}; - -export function parse(acct: any): Post { - return { - text: acct.text || undefined, - cw: acct.cw, - localOnly: acct.localOnly, - createdAt: new Date(acct.createdAt), - visibility: noteVisibilities.includes(acct.visibility) - ? acct.visibility - : "specified", - }; -} - -export function toJson(acct: Post): string { - return { text: acct.text, cw: acct.cw, localOnly: acct.localOnly }.toString(); -} diff --git a/packages/backend/src/queue/processors/db/import-firefish-post.ts b/packages/backend/src/queue/processors/db/import-firefish-post.ts index 8d318a0d2a..d0044819ec 100644 --- a/packages/backend/src/queue/processors/db/import-firefish-post.ts +++ b/packages/backend/src/queue/processors/db/import-firefish-post.ts @@ -1,4 +1,3 @@ -import * as Post from "@/misc/post.js"; import create from "@/services/note/create.js"; import { NoteFiles, Users } from "@/models/index.js"; import type { DbUserImportMastoPostJobData } from "@/queue/types.js"; @@ -10,6 +9,7 @@ import { createImportCkPostJob } from "@/queue/index.js"; import { Notes, NoteEdits } from "@/models/index.js"; import type { Note } from "@/models/entities/note.js"; import { genId } from "backend-rs"; +import { noteVisibilities } from "@/types.js"; const logger = queueLogger.createSubLogger("import-firefish-post"); @@ -52,10 +52,15 @@ export async function importCkPost( logger.info(`Skipped adding file to drive: ${url}`); } } - const { text, cw, localOnly, createdAt, visibility } = Post.parse(post); + + const createdAt = new Date(post.createdAt); + const visibility = noteVisibilities.includes(post.visibility) + ? post.visibility + : "specified"; + let note = await Notes.findOneBy({ - createdAt: createdAt, - text: text, + createdAt, + text: post.text || undefined, userId: user.id, }); @@ -95,16 +100,16 @@ export async function importCkPost( note = await create( user, { - createdAt: createdAt, + createdAt, scheduledAt: undefined, files: files.length === 0 ? undefined : files, poll: undefined, - text: text || undefined, + text: post.text || undefined, reply: post.replyId ? job.data.parent : null, renote: post.renoteId ? job.data.parent : null, - cw: cw, - localOnly, - visibility: visibility, + cw: post.cw, + localOnly: post.localOnly, + visibility, visibleUsers: [], channel: null, apMentions: new Array(0), From 5a74760252e6b9a8491c9c12e705fb371a3dc651 Mon Sep 17 00:00:00 2001 From: naskya Date: Sat, 27 Jul 2024 17:41:50 +0900 Subject: [PATCH 28/43] refactor (backend): port publishNoteStream to backend-rs --- packages/backend-rs/index.d.ts | 11 +++++ packages/backend-rs/index.js | 2 + packages/backend-rs/src/service/stream.rs | 1 + .../backend-rs/src/service/stream/note.rs | 43 +++++++++++++++++++ .../src/remote/activitypub/models/note.ts | 5 ++- .../src/server/api/endpoints/notes/edit.ts | 5 +-- .../api/endpoints/notes/make-private.ts | 4 +- .../server/api/endpoints/notes/polls/vote.ts | 5 +-- .../src/server/api/mastodon/helpers/poll.ts | 5 +-- packages/backend/src/services/note/create.ts | 6 ++- packages/backend/src/services/note/delete.ts | 6 +-- packages/backend/src/services/note/edit.ts | 10 +++-- .../backend/src/services/note/polls/vote.ts | 5 +-- .../src/services/note/reaction/create.ts | 11 +++-- .../src/services/note/reaction/delete.ts | 5 +-- packages/backend/src/services/stream.ts | 29 +++++++------ 16 files changed, 109 insertions(+), 44 deletions(-) create mode 100644 packages/backend-rs/src/service/stream/note.rs diff --git a/packages/backend-rs/index.d.ts b/packages/backend-rs/index.d.ts index b4bf0f65a9..c988e15f98 100644 --- a/packages/backend-rs/index.d.ts +++ b/packages/backend-rs/index.d.ts @@ -840,6 +840,15 @@ export interface NoteEdit { emojis: Array } +export declare enum NoteEvent { + Delete = 0, + React = 1, + Unreact = 2, + Reply = 3, + Update = 4, + Vote = 5 +} + export interface NoteFavorite { id: string createdAt: DateTimeWithTimeZone @@ -1125,6 +1134,8 @@ export declare function publishToModerationStream(moderatorId: string, report: A export declare function publishToNotesStream(note: Note): Promise +export declare function publishToNoteStream(noteId: string, kind: NoteEvent, object: any): Promise + export declare function publishToNoteUpdatesStream(note: Note): Promise export interface PugArgs { diff --git a/packages/backend-rs/index.js b/packages/backend-rs/index.js index de95ac634c..398a76358f 100644 --- a/packages/backend-rs/index.js +++ b/packages/backend-rs/index.js @@ -409,6 +409,7 @@ module.exports.metaToPugArgs = nativeBinding.metaToPugArgs module.exports.MutedNoteReason = nativeBinding.MutedNoteReason module.exports.nodeinfo_2_0 = nativeBinding.nodeinfo_2_0 module.exports.nodeinfo_2_1 = nativeBinding.nodeinfo_2_1 +module.exports.NoteEvent = nativeBinding.NoteEvent module.exports.NoteVisibility = nativeBinding.NoteVisibility module.exports.NotificationType = nativeBinding.NotificationType module.exports.nyaify = nativeBinding.nyaify @@ -425,6 +426,7 @@ module.exports.publishToDriveFolderStream = nativeBinding.publishToDriveFolderSt module.exports.publishToGroupChatStream = nativeBinding.publishToGroupChatStream module.exports.publishToModerationStream = nativeBinding.publishToModerationStream module.exports.publishToNotesStream = nativeBinding.publishToNotesStream +module.exports.publishToNoteStream = nativeBinding.publishToNoteStream module.exports.publishToNoteUpdatesStream = nativeBinding.publishToNoteUpdatesStream module.exports.PushNotificationKind = nativeBinding.PushNotificationKind module.exports.PushSubscriptionType = nativeBinding.PushSubscriptionType diff --git a/packages/backend-rs/src/service/stream.rs b/packages/backend-rs/src/service/stream.rs index 59e68e20cd..fe8175900c 100644 --- a/packages/backend-rs/src/service/stream.rs +++ b/packages/backend-rs/src/service/stream.rs @@ -6,6 +6,7 @@ pub mod custom_emoji; pub mod drive; pub mod group_chat; pub mod moderation; +pub mod note; pub mod note_edit; pub mod notes; diff --git a/packages/backend-rs/src/service/stream/note.rs b/packages/backend-rs/src/service/stream/note.rs new file mode 100644 index 0000000000..d19aeda0d8 --- /dev/null +++ b/packages/backend-rs/src/service/stream/note.rs @@ -0,0 +1,43 @@ +use crate::service::stream::{publish_to_stream, Error, Stream}; +use serde_json::json; + +#[macros::export] +pub enum NoteEvent { + Delete, + React, + Unreact, + Reply, + Update, + Vote, +} + +// We want to merge `kind` and `object` into a single enum +// https://github.com/napi-rs/napi-rs/issues/2036 + +#[macros::export(js_name = "publishToNoteStream")] +pub async fn publish( + note_id: String, + kind: NoteEvent, + object: &serde_json::Value, +) -> Result<(), Error> { + let kind = match kind { + NoteEvent::Delete => "deleted", + NoteEvent::React => "reacted", + NoteEvent::Unreact => "unreacted", + NoteEvent::Reply => "replied", + NoteEvent::Update => "updated", + NoteEvent::Vote => "pollVoted", + }; + + let value = json!({ + "id": note_id.clone(), + "body": object, + }); + + publish_to_stream( + &Stream::Note { note_id }, + Some(kind), + Some(serde_json::to_string(&value)?), + ) + .await +} diff --git a/packages/backend/src/remote/activitypub/models/note.ts b/packages/backend/src/remote/activitypub/models/note.ts index 65ad217d51..bbe9a0b028 100644 --- a/packages/backend/src/remote/activitypub/models/note.ts +++ b/packages/backend/src/remote/activitypub/models/note.ts @@ -15,11 +15,13 @@ import { apLogger } from "../logger.js"; import type { DriveFile } from "@/models/entities/drive-file.js"; import { type ImageSize, + NoteEvent, extractHost, genId, getImageSizeFromUrl, isBlockedServer, isSameOrigin, + publishToNoteStream, toPuny, } from "backend-rs"; import { @@ -47,7 +49,6 @@ import { parseAudience } from "../audience.js"; import { extractApMentions } from "./mention.js"; import DbResolver from "../db-resolver.js"; import { StatusError } from "@/misc/fetch.js"; -import { publishNoteStream } from "@/services/stream.js"; import { extractHashtags } from "@/misc/extract-hashtags.js"; import { UserProfiles } from "@/models/index.js"; import { In } from "typeorm"; @@ -795,7 +796,7 @@ export async function updateNote(value: string | IObject, resolver?: Resolver) { if (publishing) { // Publish update event for the updated note details - publishNoteStream(note.id, "updated", { + publishToNoteStream(note.id, NoteEvent.Update, { updatedAt: update.updatedAt, }); } diff --git a/packages/backend/src/server/api/endpoints/notes/edit.ts b/packages/backend/src/server/api/endpoints/notes/edit.ts index 5481242cb3..7ba46f1f18 100644 --- a/packages/backend/src/server/api/endpoints/notes/edit.ts +++ b/packages/backend/src/server/api/endpoints/notes/edit.ts @@ -18,7 +18,7 @@ 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 { genId } from "backend-rs"; +import { genId, NoteEvent, publishToNoteStream } from "backend-rs"; import { HOUR } from "@/const.js"; import { getNote } from "@/server/api/common/getters.js"; import { Poll } from "@/models/entities/poll.js"; @@ -27,7 +27,6 @@ import { concat } from "@/prelude/array.js"; import { extractHashtags } from "@/misc/extract-hashtags.js"; import { extractCustomEmojisFromMfm } from "@/misc/extract-custom-emojis-from-mfm.js"; import { extractMentionedUsers } from "@/services/note/create.js"; -import { publishNoteStream } from "@/services/stream.js"; import DeliverManager from "@/remote/activitypub/deliver-manager.js"; import { renderActivity } from "@/remote/activitypub/renderer/index.js"; import renderNote from "@/remote/activitypub/renderer/note.js"; @@ -634,7 +633,7 @@ export default define(meta, paramDef, async (ps, user) => { if (publishing && user.isIndexable) { // Publish update event for the updated note details - publishNoteStream(note.id, "updated", { + publishToNoteStream(note.id, NoteEvent.Update, { updatedAt: update.updatedAt, }); 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..4caf0f9cbc 100644 --- a/packages/backend/src/server/api/endpoints/notes/make-private.ts +++ b/packages/backend/src/server/api/endpoints/notes/make-private.ts @@ -4,7 +4,7 @@ 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 { publishNoteStream } from "@/services/stream.js"; +import { NoteEvent, publishToNoteStream } from "backend-rs"; export const meta = { tags: ["notes"], @@ -61,7 +61,7 @@ export default define(meta, paramDef, async (ps, user) => { // Publish update event for the updated note details // TODO: Send "deleted" to other users? - publishNoteStream(note.id, "updated", { + publishToNoteStream(note.id, NoteEvent.Update, { updatedAt: new Date(), }); }); diff --git a/packages/backend/src/server/api/endpoints/notes/polls/vote.ts b/packages/backend/src/server/api/endpoints/notes/polls/vote.ts index 5b29f1e37c..0d9a42e88a 100644 --- a/packages/backend/src/server/api/endpoints/notes/polls/vote.ts +++ b/packages/backend/src/server/api/endpoints/notes/polls/vote.ts @@ -1,5 +1,4 @@ import { Not } from "typeorm"; -import { publishNoteStream } from "@/services/stream.js"; import { createNotification } from "@/services/create-notification.js"; import { deliver } from "@/queue/index.js"; import { renderActivity } from "@/remote/activitypub/renderer/index.js"; @@ -12,7 +11,7 @@ import { Blockings, } from "@/models/index.js"; import type { IRemoteUser } from "@/models/entities/user.js"; -import { genId } from "backend-rs"; +import { genId, NoteEvent, publishToNoteStream } from "backend-rs"; import { getNote } from "@/server/api/common/getters.js"; import { ApiError } from "@/server/api/error.js"; import define from "@/server/api/define.js"; @@ -139,7 +138,7 @@ export default define(meta, paramDef, async (ps, user) => { `UPDATE poll SET votes[${index}] = votes[${index}] + 1 WHERE "noteId" = '${poll.noteId}'`, ); - publishNoteStream(note.id, "pollVoted", { + publishToNoteStream(note.id, NoteEvent.Vote, { choice: ps.choice, userId: user.id, }); diff --git a/packages/backend/src/server/api/mastodon/helpers/poll.ts b/packages/backend/src/server/api/mastodon/helpers/poll.ts index b5c3794892..4dfcdddfd3 100644 --- a/packages/backend/src/server/api/mastodon/helpers/poll.ts +++ b/packages/backend/src/server/api/mastodon/helpers/poll.ts @@ -10,8 +10,7 @@ import { PollVotes, Users, } from "@/models/index.js"; -import { genId } from "backend-rs"; -import { publishNoteStream } from "@/services/stream.js"; +import { genId, NoteEvent, publishToNoteStream } from "backend-rs"; import { createNotification } from "@/services/create-notification.js"; import { deliver } from "@/queue/index.js"; import { renderActivity } from "@/remote/activitypub/renderer/index.js"; @@ -108,7 +107,7 @@ export class PollHelpers { `UPDATE poll SET votes[${index}] = votes[${index}] + 1 WHERE "noteId" = '${poll.noteId}'`, ); - publishNoteStream(note.id, "pollVoted", { + publishToNoteStream(note.id, NoteEvent.Vote, { choice: choice, userId: user.id, }); diff --git a/packages/backend/src/services/note/create.ts b/packages/backend/src/services/note/create.ts index 0f99451e78..33f0913ea0 100644 --- a/packages/backend/src/services/note/create.ts +++ b/packages/backend/src/services/note/create.ts @@ -1,5 +1,5 @@ import * as mfm from "mfm-js"; -import { publishMainStream, publishNoteStream } from "@/services/stream.js"; +import { publishMainStream } from "@/services/stream.js"; import DeliverManager from "@/remote/activitypub/deliver-manager.js"; import renderNote from "@/remote/activitypub/renderer/note.js"; import renderCreate from "@/remote/activitypub/renderer/create.js"; @@ -46,6 +46,8 @@ import { isQuote, isSilencedServer, publishToNotesStream, + publishToNoteStream, + NoteEvent, } from "backend-rs"; import { countSameRenotes } from "@/misc/count-same-renotes.js"; import { deliverToRelays, getCachedRelays } from "../relay.js"; @@ -466,7 +468,7 @@ export default async ( if (note.replyId != null) { // Only provide the reply note id here as the recipient may not be authorized to see the note. - publishNoteStream(note.replyId, "replied", { + publishToNoteStream(note.replyId, NoteEvent.Reply, { id: note.id, }); } diff --git a/packages/backend/src/services/note/delete.ts b/packages/backend/src/services/note/delete.ts index 82e523c84b..0ae03a60ac 100644 --- a/packages/backend/src/services/note/delete.ts +++ b/packages/backend/src/services/note/delete.ts @@ -1,5 +1,4 @@ import { Brackets, In } from "typeorm"; -import { publishNoteStream } from "@/services/stream.js"; import renderDelete from "@/remote/activitypub/renderer/delete.js"; import renderAnnounce from "@/remote/activitypub/renderer/announce.js"; import { renderUndo } from "@/remote/activitypub/renderer/undo.js"; @@ -17,6 +16,7 @@ import { countSameRenotes } from "@/misc/count-same-renotes.js"; import { registerOrFetchInstanceDoc } from "@/services/register-or-fetch-instance-doc.js"; import { deliverToRelays } from "@/services/relay.js"; import type { IActivity } from "@/remote/activitypub/type.js"; +import { NoteEvent, publishToNoteStream } from "backend-rs"; async function recalculateNotesCountOfLocalUser(user: { id: User["id"]; @@ -72,7 +72,7 @@ export default async function ( // Only broadcast "deleted" to local if the note is deleted from db if (deleteFromDb) { - publishNoteStream(note.id, "deleted", { + publishToNoteStream(note.id, NoteEvent.Delete, { deletedAt: deletedAt, }); } @@ -112,7 +112,7 @@ export default async function ( for (const cascadingNote of cascadingNotes) { if (deleteFromDb) { // For other notes, publishNoteStream is also required. - publishNoteStream(cascadingNote.id, "deleted", { + publishToNoteStream(cascadingNote.id, NoteEvent.Delete, { deletedAt: deletedAt, }); } diff --git a/packages/backend/src/services/note/edit.ts b/packages/backend/src/services/note/edit.ts index 04bfb3c9bd..1b10f63312 100644 --- a/packages/backend/src/services/note/edit.ts +++ b/packages/backend/src/services/note/edit.ts @@ -1,5 +1,4 @@ import * as mfm from "mfm-js"; -import { publishNoteStream } from "@/services/stream.js"; import DeliverManager from "@/remote/activitypub/deliver-manager.js"; import renderNote from "@/remote/activitypub/renderer/note.js"; import { renderActivity } from "@/remote/activitypub/renderer/index.js"; @@ -18,7 +17,12 @@ import { import type { DriveFile } from "@/models/entities/drive-file.js"; import { In } from "typeorm"; import type { ILocalUser, IRemoteUser } from "@/models/entities/user.js"; -import { genId, publishToNoteUpdatesStream } from "backend-rs"; +import { + genId, + NoteEvent, + publishToNoteStream, + publishToNoteUpdatesStream, +} from "backend-rs"; import type { IPoll } from "@/models/entities/poll.js"; import { deliverToRelays } from "../relay.js"; import renderUpdate from "@/remote/activitypub/renderer/update.js"; @@ -187,7 +191,7 @@ export default async function ( if (publishing) { // Publish update event for the updated note details - publishNoteStream(note.id, "updated", { + publishToNoteStream(note.id, NoteEvent.Update, { updatedAt: update.updatedAt, }); diff --git a/packages/backend/src/services/note/polls/vote.ts b/packages/backend/src/services/note/polls/vote.ts index c1070576f1..354f67d127 100644 --- a/packages/backend/src/services/note/polls/vote.ts +++ b/packages/backend/src/services/note/polls/vote.ts @@ -1,9 +1,8 @@ -import { publishNoteStream } from "@/services/stream.js"; import type { CacheableUser } from "@/models/entities/user.js"; import type { Note } from "@/models/entities/note.js"; import { PollVotes, NoteWatchings, Polls, Blockings } from "@/models/index.js"; import { Not } from "typeorm"; -import { genIdAt } from "backend-rs"; +import { genIdAt, NoteEvent, publishToNoteStream } from "backend-rs"; import { createNotification } from "@/services/create-notification.js"; export default async function ( @@ -60,7 +59,7 @@ export default async function ( `UPDATE poll SET votes[${index}] = votes[${index}] + 1 WHERE "noteId" = '${poll.noteId}'`, ); - publishNoteStream(note.id, "pollVoted", { + publishToNoteStream(note.id, NoteEvent.Vote, { choice: choice, userId: user.id, }); diff --git a/packages/backend/src/services/note/reaction/create.ts b/packages/backend/src/services/note/reaction/create.ts index 54b0bfaaab..f868a4cac3 100644 --- a/packages/backend/src/services/note/reaction/create.ts +++ b/packages/backend/src/services/note/reaction/create.ts @@ -1,4 +1,3 @@ -import { publishNoteStream } from "@/services/stream.js"; import { renderLike } from "@/remote/activitypub/renderer/like.js"; import DeliverManager from "@/remote/activitypub/deliver-manager.js"; import { renderActivity } from "@/remote/activitypub/renderer/index.js"; @@ -13,7 +12,13 @@ import { Blockings, } from "@/models/index.js"; import { IsNull, Not } from "typeorm"; -import { decodeReaction, genIdAt, toDbReaction } from "backend-rs"; +import { + decodeReaction, + genIdAt, + NoteEvent, + publishToNoteStream, + toDbReaction, +} from "backend-rs"; import { createNotification } from "@/services/create-notification.js"; import deleteReaction from "./delete.js"; import { isDuplicateKeyValueError } from "@/misc/is-duplicate-key-value-error.js"; @@ -102,7 +107,7 @@ export default async ( select: ["name", "host", "originalUrl", "publicUrl"], }); - publishNoteStream(note.id, "reacted", { + publishToNoteStream(note.id, NoteEvent.React, { reaction: decodedReaction.reaction, emoji: emoji != null diff --git a/packages/backend/src/services/note/reaction/delete.ts b/packages/backend/src/services/note/reaction/delete.ts index 7e37cd38ed..00b7f18741 100644 --- a/packages/backend/src/services/note/reaction/delete.ts +++ b/packages/backend/src/services/note/reaction/delete.ts @@ -1,4 +1,3 @@ -import { publishNoteStream } from "@/services/stream.js"; import { renderLike } from "@/remote/activitypub/renderer/like.js"; import { renderUndo } from "@/remote/activitypub/renderer/undo.js"; import { renderActivity } from "@/remote/activitypub/renderer/index.js"; @@ -7,7 +6,7 @@ import { IdentifiableError } from "@/misc/identifiable-error.js"; import type { User, IRemoteUser } from "@/models/entities/user.js"; import type { Note } from "@/models/entities/note.js"; import { NoteReactions, Users, Notes } from "@/models/index.js"; -import { decodeReaction } from "backend-rs"; +import { decodeReaction, NoteEvent, publishToNoteStream } from "backend-rs"; export default async ( user: { id: User["id"]; host: User["host"] }, @@ -48,7 +47,7 @@ export default async ( Notes.decrement({ id: note.id }, "score", 1); - publishNoteStream(note.id, "unreacted", { + publishToNoteStream(note.id, NoteEvent.Unreact, { reaction: decodeReaction(reaction.reaction).reaction, userId: user.id, }); diff --git a/packages/backend/src/services/stream.ts b/packages/backend/src/services/stream.ts index d4a38797bb..79f813523e 100644 --- a/packages/backend/src/services/stream.ts +++ b/packages/backend/src/services/stream.ts @@ -1,7 +1,7 @@ import { redisClient } from "@/db/redis.js"; import type { User } from "@/models/entities/user.js"; -import type { Note } from "@/models/entities/note.js"; -import type { UserList } from "@/models/entities/user-list.js"; +// import type { Note } from "@/models/entities/note.js"; +// import type { UserList } from "@/models/entities/user-list.js"; // import type { UserGroup } from "@/models/entities/user-group.js"; import { config } from "@/config.js"; // import type { Antenna } from "@/models/entities/antenna.js"; @@ -18,7 +18,7 @@ import type { MainStreamTypes, // MessagingIndexStreamTypes, // MessagingStreamTypes, - NoteStreamTypes, + // NoteStreamTypes, UserStreamTypes, // NoteUpdatesStreamTypes, } from "@/server/api/stream/types.js"; @@ -101,16 +101,17 @@ class Publisher { // ); // }; - public publishNoteStream = ( - noteId: Note["id"], - type: K, - value?: NoteStreamTypes[K], - ): void => { - this.publish(`noteStream:${noteId}`, type, { - id: noteId, - body: value, - }); - }; + /* ported to backend-rs */ + // public publishNoteStream = ( + // noteId: Note["id"], + // type: K, + // value?: NoteStreamTypes[K], + // ): void => { + // this.publish(`noteStream:${noteId}`, type, { + // id: noteId, + // body: value, + // }); + // }; /* ported to backend-rs */ // public publishNoteUpdatesStream = ( @@ -218,7 +219,7 @@ export const publishUserEvent = publisher.publishUserEvent; // export const publishBroadcastStream = publisher.publishBroadcastStream; export const publishMainStream = publisher.publishMainStream; // export const publishDriveStream = publisher.publishDriveStream; -export const publishNoteStream = publisher.publishNoteStream; +// export const publishNoteStream = publisher.publishNoteStream; // export const publishNotesStream = publisher.publishNotesStream; // export const publishNoteUpdatesStream = publisher.publishNoteUpdatesStream; // export const publishChannelStream = publisher.publishChannelStream; From 5cae588c745b67550dd026f73f68277090e63a84 Mon Sep 17 00:00:00 2001 From: naskya Date: Sat, 27 Jul 2024 17:56:42 +0900 Subject: [PATCH 29/43] fix (backend): remove unused export in migration --- .../backend/src/migration/1720618854585-create-system-actors.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/backend/src/migration/1720618854585-create-system-actors.ts b/packages/backend/src/migration/1720618854585-create-system-actors.ts index 05a06099c7..288fd89d8a 100644 --- a/packages/backend/src/migration/1720618854585-create-system-actors.ts +++ b/packages/backend/src/migration/1720618854585-create-system-actors.ts @@ -8,7 +8,7 @@ import * as util from "node:util"; const generateKeyPair = util.promisify(crypto.generateKeyPair); -export async function genRsaKeyPair(modulusLength = 2048) { +async function genRsaKeyPair(modulusLength = 2048) { return await generateKeyPair("rsa", { modulusLength, publicKeyEncoding: { From 08e009ebad711d009363e8ecd90284f224c168e4 Mon Sep 17 00:00:00 2001 From: naskya Date: Sat, 27 Jul 2024 19:06:00 +0900 Subject: [PATCH 30/43] fix (client): gray out disabled boost button (#10960) --- packages/client/src/components/MkRenoteButton.vue | 8 ++++++-- packages/client/src/components/note/MkNoteFooter.vue | 1 - 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/packages/client/src/components/MkRenoteButton.vue b/packages/client/src/components/MkRenoteButton.vue index e4cdddc1ca..7d35c3ae11 100644 --- a/packages/client/src/components/MkRenoteButton.vue +++ b/packages/client/src/components/MkRenoteButton.vue @@ -45,8 +45,9 @@ const buttonRef = ref(); const canRenote = computed( () => - ["public", "home"].includes(props.note.visibility) || - props.note.userId === me?.id, + props.note.scheduledAt == null && + (["public", "home"].includes(props.note.visibility) || + props.note.userId === me?.id), ); useTooltip(buttonRef, async (showing) => { @@ -282,5 +283,8 @@ defineExpose({ opacity: 1 !important; font-weight: 700; } + &:disabled { + opacity: 0.3 !important; + } } diff --git a/packages/client/src/components/note/MkNoteFooter.vue b/packages/client/src/components/note/MkNoteFooter.vue index ee6db867f9..2e142b3f6c 100644 --- a/packages/client/src/components/note/MkNoteFooter.vue +++ b/packages/client/src/components/note/MkNoteFooter.vue @@ -22,7 +22,6 @@ :note="note" :count="note.renoteCount" :detailed-view="detailedView" - :disabled="note.scheduledAt != null" /> Date: Sat, 27 Jul 2024 20:16:13 +0900 Subject: [PATCH 31/43] refactor (backend): port publishMainStream to backend-rs --- packages/backend-rs/index.d.ts | 36 ++++++++ packages/backend-rs/index.js | 2 + packages/backend-rs/src/service/stream.rs | 1 + .../backend-rs/src/service/stream/main.rs | 87 +++++++++++++++++++ .../api/common/read-messaging-message.ts | 7 +- .../server/api/common/read-notification.ts | 7 +- .../backend/src/server/api/common/signin.ts | 5 +- .../server/api/endpoints/admin/delete-2fa.ts | 4 +- .../api/endpoints/admin/delete-passkeys.ts | 4 +- .../endpoints/drive/files/upload-from-url.ts | 4 +- .../src/server/api/endpoints/i/2fa/done.ts | 4 +- .../server/api/endpoints/i/2fa/key-done.ts | 7 +- .../api/endpoints/i/2fa/password-less.ts | 4 +- .../server/api/endpoints/i/2fa/remove-key.ts | 7 +- .../server/api/endpoints/i/2fa/unregister.ts | 5 +- .../server/api/endpoints/i/2fa/update-key.ts | 4 +- .../src/server/api/endpoints/i/known-as.ts | 5 +- .../src/server/api/endpoints/i/move.ts | 5 +- .../i/read-all-messaging-messages.ts | 6 +- .../api/endpoints/i/read-all-unread-notes.ts | 6 +- .../api/endpoints/i/read-announcement.ts | 5 +- .../api/endpoints/i/regenerate-token.ts | 15 ++-- .../server/api/endpoints/i/registry/set.ts | 5 +- .../server/api/endpoints/i/update-email.ts | 5 +- .../src/server/api/endpoints/i/update.ts | 5 +- .../notifications/mark-all-as-read.ts | 5 +- .../src/server/api/endpoints/page-push.ts | 4 +- .../src/server/api/private/verify-email.ts | 6 +- .../backend/src/services/blocking/create.ts | 10 +-- .../src/services/create-notification.ts | 13 ++- .../backend/src/services/drive/add-file.ts | 11 ++- .../backend/src/services/following/create.ts | 15 ++-- .../backend/src/services/following/delete.ts | 5 +- .../backend/src/services/following/reject.ts | 5 +- .../src/services/following/requests/accept.ts | 4 +- .../src/services/following/requests/cancel.ts | 4 +- .../src/services/following/requests/create.ts | 7 +- packages/backend/src/services/i/update.ts | 5 +- .../backend/src/services/messages/create.ts | 25 ++++-- packages/backend/src/services/note/create.ts | 9 +- packages/backend/src/services/note/read.ts | 8 +- packages/backend/src/services/note/unread.ts | 9 +- packages/backend/src/services/stream.ts | 27 +++--- 43 files changed, 280 insertions(+), 137 deletions(-) create mode 100644 packages/backend-rs/src/service/stream/main.rs diff --git a/packages/backend-rs/index.d.ts b/packages/backend-rs/index.d.ts index c988e15f98..b67d586e8f 100644 --- a/packages/backend-rs/index.d.ts +++ b/packages/backend-rs/index.d.ts @@ -371,6 +371,40 @@ export interface Emoji { height: number | null } +export declare enum Event { + Notification = 0, + NewNotification = 1, + Mention = 2, + NewMention = 3, + Chat = 4, + NewChat = 5, + NewDm = 6, + Reply = 7, + Renote = 8, + Follow = 9, + Followed = 10, + Unfollow = 11, + NewFollowRequest = 12, + Page = 13, + ReadAllNotifications = 14, + ReadAllMentions = 15, + ReadNotifications = 16, + ReadAllDms = 17, + ReadAllChats = 18, + ReadAntenna = 19, + ReadAllAntennaPosts = 20, + NewAntennaPost = 21, + ReadAllAnnouncements = 22, + ReadAllChannelPosts = 23, + NewChannelPost = 24, + DriveFile = 25, + UrlUploadFinished = 26, + Me = 27, + RegenerateMyToken = 28, + Signin = 29, + Registry = 30 +} + export declare function extractHost(uri: string): string export declare function fetchMeta(): Promise @@ -1130,6 +1164,8 @@ export declare function publishToDriveFolderStream(userId: string, kind: DriveFo export declare function publishToGroupChatStream(groupId: string, kind: ChatEvent, object: any): Promise +export declare function publishToMainStream(userId: string, kind: Event, object: any): Promise + export declare function publishToModerationStream(moderatorId: string, report: AbuseUserReportLike): Promise export declare function publishToNotesStream(note: Note): Promise diff --git a/packages/backend-rs/index.js b/packages/backend-rs/index.js index 398a76358f..f62cbb3626 100644 --- a/packages/backend-rs/index.js +++ b/packages/backend-rs/index.js @@ -375,6 +375,7 @@ module.exports.decodeReaction = nativeBinding.decodeReaction module.exports.DriveFileEvent = nativeBinding.DriveFileEvent module.exports.DriveFileUsageHint = nativeBinding.DriveFileUsageHint module.exports.DriveFolderEvent = nativeBinding.DriveFolderEvent +module.exports.Event = nativeBinding.Event module.exports.extractHost = nativeBinding.extractHost module.exports.fetchMeta = nativeBinding.fetchMeta module.exports.fetchNodeinfo = nativeBinding.fetchNodeinfo @@ -424,6 +425,7 @@ module.exports.publishToChatStream = nativeBinding.publishToChatStream module.exports.publishToDriveFileStream = nativeBinding.publishToDriveFileStream module.exports.publishToDriveFolderStream = nativeBinding.publishToDriveFolderStream module.exports.publishToGroupChatStream = nativeBinding.publishToGroupChatStream +module.exports.publishToMainStream = nativeBinding.publishToMainStream module.exports.publishToModerationStream = nativeBinding.publishToModerationStream module.exports.publishToNotesStream = nativeBinding.publishToNotesStream module.exports.publishToNoteStream = nativeBinding.publishToNoteStream diff --git a/packages/backend-rs/src/service/stream.rs b/packages/backend-rs/src/service/stream.rs index fe8175900c..8998ee9a1f 100644 --- a/packages/backend-rs/src/service/stream.rs +++ b/packages/backend-rs/src/service/stream.rs @@ -5,6 +5,7 @@ pub mod chat_index; pub mod custom_emoji; pub mod drive; pub mod group_chat; +pub mod main; pub mod moderation; pub mod note; pub mod note_edit; diff --git a/packages/backend-rs/src/service/stream/main.rs b/packages/backend-rs/src/service/stream/main.rs new file mode 100644 index 0000000000..a56bfb9266 --- /dev/null +++ b/packages/backend-rs/src/service/stream/main.rs @@ -0,0 +1,87 @@ +use crate::service::stream::{publish_to_stream, Error, Stream}; + +#[macros::export] +pub enum Event { + Notification, + NewNotification, + Mention, + NewMention, + Chat, + NewChat, + NewDm, + Reply, + Renote, + Follow, + Followed, + Unfollow, + NewFollowRequest, + Page, + ReadAllNotifications, + ReadAllMentions, + ReadNotifications, + ReadAllDms, + ReadAllChats, + ReadAntenna, + ReadAllAntennaPosts, + NewAntennaPost, + ReadAllAnnouncements, + ReadAllChannelPosts, + NewChannelPost, + DriveFile, + UrlUploadFinished, + Me, + RegenerateMyToken, + Signin, + Registry, +} + +// We want to merge `kind` and `object` into a single enum +// https://github.com/napi-rs/napi-rs/issues/2036 + +#[macros::export(js_name = "publishToMainStream")] +pub async fn publish( + user_id: String, + kind: Event, + object: &serde_json::Value, +) -> Result<(), Error> { + let kind = match kind { + Event::Notification => "notification", + Event::Mention => "mention", + Event::Reply => "reply", + Event::Renote => "renote", + Event::Follow => "follow", + Event::Followed => "followed", + Event::Unfollow => "unfollow", + Event::Me => "meUpdated", + Event::Page => "pageEvent", + Event::UrlUploadFinished => "urlUploadFinished", + Event::ReadAllNotifications => "readAllNotifications", + Event::ReadNotifications => "readNotifications", + Event::NewNotification => "unreadNotification", + Event::NewMention => "unreadMention", + Event::ReadAllMentions => "readAllUnreadMentions", + Event::ReadAllDms => "readAllUnreadSpecifiedNotes", + Event::NewDm => "unreadSpecifiedNote", + Event::ReadAllChats => "readAllMessagingMessages", + Event::Chat => "messagingMessage", + Event::NewChat => "unreadMessagingMessage", + Event::ReadAllAntennaPosts => "readAllAntennas", + Event::NewAntennaPost => "unreadAntenna", + Event::ReadAllAnnouncements => "readAllAnnouncements", + Event::ReadAllChannelPosts => "readAllChannels", + Event::NewChannelPost => "unreadChannel", + Event::RegenerateMyToken => "myTokenRegenerated", + Event::Signin => "signin", + Event::Registry => "registryUpdated", + Event::DriveFile => "driveFileCreated", + Event::ReadAntenna => "readAntenna", + Event::NewFollowRequest => "receiveFollowRequest", + }; + + publish_to_stream( + &Stream::Main { user_id }, + Some(kind), + Some(serde_json::to_string(&object)?), + ) + .await +} diff --git a/packages/backend/src/server/api/common/read-messaging-message.ts b/packages/backend/src/server/api/common/read-messaging-message.ts index a2c8ba70cf..e15924d231 100644 --- a/packages/backend/src/server/api/common/read-messaging-message.ts +++ b/packages/backend/src/server/api/common/read-messaging-message.ts @@ -1,9 +1,10 @@ -import { publishMainStream } from "@/services/stream.js"; import { publishToChatStream, publishToGroupChatStream, publishToChatIndexStream, sendPushNotification, + publishToMainStream, + Event, } from "backend-rs"; import type { User, IRemoteUser } from "@/models/entities/user.js"; import type { MessagingMessage } from "@/models/entities/messaging-message.js"; @@ -61,7 +62,7 @@ export async function readUserMessagingMessage( if (!(await Users.getHasUnreadMessagingMessage(userId))) { // 全ての(いままで未読だった)自分宛てのメッセージを(これで)読みましたよというイベントを発行 - publishMainStream(userId, "readAllMessagingMessages"); + await publishToMainStream(userId, Event.ReadAllChats, {}); await sendPushNotification(userId, "readAllChats", {}); } else { // そのユーザーとのメッセージで未読がなければイベント発行 @@ -135,7 +136,7 @@ export async function readGroupMessagingMessage( if (!(await Users.getHasUnreadMessagingMessage(userId))) { // 全ての(いままで未読だった)自分宛てのメッセージを(これで)読みましたよというイベントを発行 - publishMainStream(userId, "readAllMessagingMessages"); + await publishToMainStream(userId, Event.ReadAllChats, {}); await sendPushNotification(userId, "readAllChats", {}); } else { // そのグループにおいて未読がなければイベント発行 diff --git a/packages/backend/src/server/api/common/read-notification.ts b/packages/backend/src/server/api/common/read-notification.ts index 6687f5bd9a..a25fad5392 100644 --- a/packages/backend/src/server/api/common/read-notification.ts +++ b/packages/backend/src/server/api/common/read-notification.ts @@ -1,6 +1,5 @@ import { In } from "typeorm"; -import { publishMainStream } from "@/services/stream.js"; -import { sendPushNotification } from "backend-rs"; +import { Event, publishToMainStream, sendPushNotification } from "backend-rs"; import type { User } from "@/models/entities/user.js"; import type { Notification } from "@/models/entities/notification.js"; import { Notifications, Users } from "@/models/index.js"; @@ -46,7 +45,7 @@ export async function readNotificationByQuery( } function postReadAllNotifications(userId: User["id"]) { - publishMainStream(userId, "readAllNotifications"); + publishToMainStream(userId, Event.ReadAllNotifications, {}); return sendPushNotification(userId, "readAllNotifications", {}); } @@ -54,7 +53,7 @@ function postReadNotifications( userId: User["id"], notificationIds: Notification["id"][], ) { - publishMainStream(userId, "readNotifications", notificationIds); + publishToMainStream(userId, Event.ReadNotifications, notificationIds); return sendPushNotification(userId, "readNotifications", { notificationIds, }); diff --git a/packages/backend/src/server/api/common/signin.ts b/packages/backend/src/server/api/common/signin.ts index bafec3dfad..e160d2d8c2 100644 --- a/packages/backend/src/server/api/common/signin.ts +++ b/packages/backend/src/server/api/common/signin.ts @@ -3,8 +3,7 @@ import type Koa from "koa"; import { config } from "@/config.js"; import type { ILocalUser } from "@/models/entities/user.js"; import { Signins } from "@/models/index.js"; -import { genIdAt } from "backend-rs"; -import { publishMainStream } from "@/services/stream.js"; +import { Event, genIdAt, publishToMainStream } from "backend-rs"; export default function (ctx: Koa.Context, user: ILocalUser, redirect = false) { if (redirect) { @@ -40,6 +39,6 @@ export default function (ctx: Koa.Context, user: ILocalUser, redirect = false) { }).then((x) => Signins.findOneByOrFail(x.identifiers[0])); // Publish signin event - publishMainStream(user.id, "signin", await Signins.pack(record)); + publishToMainStream(user.id, Event.Signin, await Signins.pack(record)); })(); } diff --git a/packages/backend/src/server/api/endpoints/admin/delete-2fa.ts b/packages/backend/src/server/api/endpoints/admin/delete-2fa.ts index 1cf60d9c52..85dc2febf4 100644 --- a/packages/backend/src/server/api/endpoints/admin/delete-2fa.ts +++ b/packages/backend/src/server/api/endpoints/admin/delete-2fa.ts @@ -1,5 +1,5 @@ import { Users, UserProfiles } from "@/models/index.js"; -import { publishMainStream } from "@/services/stream.js"; +import { Event, publishToMainStream } from "backend-rs"; import define from "@/server/api/define.js"; export const meta = { @@ -36,5 +36,5 @@ export default define(meta, paramDef, async (ps) => { includeSecrets: true, }); - publishMainStream(user.id, "meUpdated", iObj); + publishToMainStream(user.id, Event.Me, iObj); }); diff --git a/packages/backend/src/server/api/endpoints/admin/delete-passkeys.ts b/packages/backend/src/server/api/endpoints/admin/delete-passkeys.ts index 7a54f5d99f..028be28eb4 100644 --- a/packages/backend/src/server/api/endpoints/admin/delete-passkeys.ts +++ b/packages/backend/src/server/api/endpoints/admin/delete-passkeys.ts @@ -1,5 +1,5 @@ import { Users, UserProfiles, UserSecurityKeys } from "@/models/index.js"; -import { publishMainStream } from "@/services/stream.js"; +import { Event, publishToMainStream } from "backend-rs"; import define from "@/server/api/define.js"; export const meta = { @@ -38,5 +38,5 @@ export default define(meta, paramDef, async (ps) => { includeSecrets: true, }); - publishMainStream(user.id, "meUpdated", iObj); + publishToMainStream(user.id, Event.Me, iObj); }); 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 97b3e4963c..b495541370 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 @@ -1,7 +1,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 { Event, publishToMainStream } from "backend-rs"; import { HOUR } from "@/const.js"; export const meta = { @@ -50,7 +50,7 @@ export default define(meta, paramDef, async (ps, user) => { comment: ps.comment, }).then((file) => { DriveFiles.pack(file, { self: true }).then((packedFile) => { - publishMainStream(user.id, "urlUploadFinished", { + publishToMainStream(user.id, Event.UrlUploadFinished, { marker: ps.marker, file: packedFile, }); diff --git a/packages/backend/src/server/api/endpoints/i/2fa/done.ts b/packages/backend/src/server/api/endpoints/i/2fa/done.ts index c1a7b16a84..69ff627490 100644 --- a/packages/backend/src/server/api/endpoints/i/2fa/done.ts +++ b/packages/backend/src/server/api/endpoints/i/2fa/done.ts @@ -1,4 +1,4 @@ -import { publishMainStream } from "@/services/stream.js"; +import { Event, publishToMainStream } from "backend-rs"; import * as OTPAuth from "otpauth"; import define from "@/server/api/define.js"; import { Users, UserProfiles } from "@/models/index.js"; @@ -47,5 +47,5 @@ export default define(meta, paramDef, async (ps, user) => { includeSecrets: true, }); - publishMainStream(user.id, "meUpdated", iObj); + publishToMainStream(user.id, Event.Me, iObj); }); diff --git a/packages/backend/src/server/api/endpoints/i/2fa/key-done.ts b/packages/backend/src/server/api/endpoints/i/2fa/key-done.ts index 01413d6f37..543744ddad 100644 --- a/packages/backend/src/server/api/endpoints/i/2fa/key-done.ts +++ b/packages/backend/src/server/api/endpoints/i/2fa/key-done.ts @@ -8,8 +8,7 @@ import { } from "@/models/index.js"; import { config } from "@/config.js"; import { procedures, hash } from "@/server/api/2fa.js"; -import { publishMainStream } from "@/services/stream.js"; -import { verifyPassword } from "backend-rs"; +import { Event, publishToMainStream, verifyPassword } from "backend-rs"; const rpIdHashReal = hash(Buffer.from(config.hostname, "utf-8")); @@ -132,9 +131,9 @@ export default define(meta, paramDef, async (ps, user) => { }); // Publish meUpdated event - publishMainStream( + publishToMainStream( user.id, - "meUpdated", + Event.Me, await Users.pack(user.id, user, { detail: true, includeSecrets: true, diff --git a/packages/backend/src/server/api/endpoints/i/2fa/password-less.ts b/packages/backend/src/server/api/endpoints/i/2fa/password-less.ts index 8125f817a0..b0a3b30106 100644 --- a/packages/backend/src/server/api/endpoints/i/2fa/password-less.ts +++ b/packages/backend/src/server/api/endpoints/i/2fa/password-less.ts @@ -1,6 +1,6 @@ import define from "@/server/api/define.js"; import { Users, UserProfiles, UserSecurityKeys } from "@/models/index.js"; -import { publishMainStream } from "@/services/stream.js"; +import { Event, publishToMainStream } from "backend-rs"; import { ApiError } from "@/server/api/error.js"; export const meta = { @@ -57,5 +57,5 @@ export default define(meta, paramDef, async (ps, user) => { includeSecrets: true, }); - publishMainStream(user.id, "meUpdated", iObj); + publishToMainStream(user.id, Event.Me, iObj); }); diff --git a/packages/backend/src/server/api/endpoints/i/2fa/remove-key.ts b/packages/backend/src/server/api/endpoints/i/2fa/remove-key.ts index 4259d8f70d..ac6e0d45af 100644 --- a/packages/backend/src/server/api/endpoints/i/2fa/remove-key.ts +++ b/packages/backend/src/server/api/endpoints/i/2fa/remove-key.ts @@ -1,7 +1,6 @@ -import { verifyPassword } from "backend-rs"; +import { Event, publishToMainStream, verifyPassword } from "backend-rs"; import define from "@/server/api/define.js"; import { UserProfiles, UserSecurityKeys, Users } from "@/models/index.js"; -import { publishMainStream } from "@/services/stream.js"; export const meta = { requireCredential: true, @@ -54,9 +53,9 @@ export default define(meta, paramDef, async (ps, user) => { } // Publish meUpdated event - publishMainStream( + publishToMainStream( user.id, - "meUpdated", + Event.Me, await Users.pack(user.id, user, { detail: true, includeSecrets: true, diff --git a/packages/backend/src/server/api/endpoints/i/2fa/unregister.ts b/packages/backend/src/server/api/endpoints/i/2fa/unregister.ts index 240ff2b34e..d3b6a9c12b 100644 --- a/packages/backend/src/server/api/endpoints/i/2fa/unregister.ts +++ b/packages/backend/src/server/api/endpoints/i/2fa/unregister.ts @@ -1,7 +1,6 @@ -import { publishMainStream } from "@/services/stream.js"; import define from "@/server/api/define.js"; import { Users, UserProfiles } from "@/models/index.js"; -import { verifyPassword } from "backend-rs"; +import { Event, publishToMainStream, verifyPassword } from "backend-rs"; export const meta = { requireCredential: true, @@ -38,5 +37,5 @@ export default define(meta, paramDef, async (ps, user) => { includeSecrets: true, }); - publishMainStream(user.id, "meUpdated", iObj); + publishToMainStream(user.id, Event.Me, iObj); }); diff --git a/packages/backend/src/server/api/endpoints/i/2fa/update-key.ts b/packages/backend/src/server/api/endpoints/i/2fa/update-key.ts index d77ecc88e8..f74cdbad51 100644 --- a/packages/backend/src/server/api/endpoints/i/2fa/update-key.ts +++ b/packages/backend/src/server/api/endpoints/i/2fa/update-key.ts @@ -1,7 +1,7 @@ -import { publishMainStream } from "@/services/stream.js"; import define from "@/server/api/define.js"; import { Users, UserSecurityKeys } from "@/models/index.js"; import { ApiError } from "@/server/api/error.js"; +import { Event, publishToMainStream } from "backend-rs"; export const meta = { requireCredential: true, @@ -54,5 +54,5 @@ export default define(meta, paramDef, async (ps, user) => { includeSecrets: true, }); - publishMainStream(user.id, "meUpdated", iObj); + publishToMainStream(user.id, Event.Me, iObj); }); 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 63d21d93e3..fe26d25441 100644 --- a/packages/backend/src/server/api/endpoints/i/known-as.ts +++ b/packages/backend/src/server/api/endpoints/i/known-as.ts @@ -3,8 +3,7 @@ import { Users } from "@/models/index.js"; 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 { stringToAcct } from "backend-rs"; +import { Event, publishToMainStream, stringToAcct } from "backend-rs"; import { DAY } from "@/const.js"; import { apiLogger } from "@/server/api/logger.js"; import define from "@/server/api/define.js"; @@ -97,7 +96,7 @@ export default define(meta, paramDef, async (ps, user) => { }); // Publish meUpdated event - publishMainStream(user.id, "meUpdated", iObj); + publishToMainStream(user.id, Event.Me, iObj); if (user.isLocked === false) { acceptAllFollowRequests(user); diff --git a/packages/backend/src/server/api/endpoints/i/move.ts b/packages/backend/src/server/api/endpoints/i/move.ts index e7808d7b0a..a0fe50bede 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 { stringToAcct } from "backend-rs"; +import { Event, publishToMainStream, stringToAcct } from "backend-rs"; import { DAY } from "@/const.js"; import DeliverManager from "@/remote/activitypub/deliver-manager.js"; import { renderActivity } from "@/remote/activitypub/renderer/index.js"; @@ -12,7 +12,6 @@ import create from "@/services/following/create.js"; import { getUser } from "@/server/api/common/getters.js"; import { Followings, Users } from "@/models/index.js"; import { config } from "@/config.js"; -import { publishMainStream } from "@/services/stream.js"; import { inspect } from "node:util"; export const meta = { @@ -134,7 +133,7 @@ export default define(meta, paramDef, async (ps, user) => { dm.execute(); // Publish meUpdated event - publishMainStream(user.id, "meUpdated", iObj); + publishToMainStream(user.id, Event.Me, iObj); const followings = await Followings.findBy({ followeeId: user.id, diff --git a/packages/backend/src/server/api/endpoints/i/read-all-messaging-messages.ts b/packages/backend/src/server/api/endpoints/i/read-all-messaging-messages.ts index 505c424edb..2f3ea6855e 100644 --- a/packages/backend/src/server/api/endpoints/i/read-all-messaging-messages.ts +++ b/packages/backend/src/server/api/endpoints/i/read-all-messaging-messages.ts @@ -1,4 +1,4 @@ -import { publishMainStream } from "@/services/stream.js"; +import { Event, publishToMainStream } from "backend-rs"; import define from "@/server/api/define.js"; import { MessagingMessages, UserGroupJoinings } from "@/models/index.js"; @@ -16,7 +16,7 @@ export const paramDef = { required: [], } as const; -export default define(meta, paramDef, async (ps, user) => { +export default define(meta, paramDef, async (_ps, user) => { // Update documents await MessagingMessages.update( { @@ -44,5 +44,5 @@ export default define(meta, paramDef, async (ps, user) => { ), ); - publishMainStream(user.id, "readAllMessagingMessages"); + publishToMainStream(user.id, Event.ReadAllChats, {}); }); diff --git a/packages/backend/src/server/api/endpoints/i/read-all-unread-notes.ts b/packages/backend/src/server/api/endpoints/i/read-all-unread-notes.ts index 6f70e55a1a..e3f5a51473 100644 --- a/packages/backend/src/server/api/endpoints/i/read-all-unread-notes.ts +++ b/packages/backend/src/server/api/endpoints/i/read-all-unread-notes.ts @@ -1,4 +1,4 @@ -import { publishMainStream } from "@/services/stream.js"; +import { Event, publishToMainStream } from "backend-rs"; import define from "@/server/api/define.js"; import { NoteUnreads } from "@/models/index.js"; @@ -23,6 +23,6 @@ export default define(meta, paramDef, async (ps, user) => { }); // 全て既読になったイベントを発行 - publishMainStream(user.id, "readAllUnreadMentions"); - publishMainStream(user.id, "readAllUnreadSpecifiedNotes"); + publishToMainStream(user.id, Event.ReadAllMentions, {}); + publishToMainStream(user.id, Event.ReadAllDms, {}); }); diff --git a/packages/backend/src/server/api/endpoints/i/read-announcement.ts b/packages/backend/src/server/api/endpoints/i/read-announcement.ts index 7981292031..1ad817898f 100644 --- a/packages/backend/src/server/api/endpoints/i/read-announcement.ts +++ b/packages/backend/src/server/api/endpoints/i/read-announcement.ts @@ -1,8 +1,7 @@ import define from "@/server/api/define.js"; import { ApiError } from "@/server/api/error.js"; -import { genIdAt } from "backend-rs"; +import { Event, genIdAt, publishToMainStream } from "backend-rs"; import { AnnouncementReads, Announcements, Users } from "@/models/index.js"; -import { publishMainStream } from "@/services/stream.js"; export const meta = { tags: ["account"], @@ -59,6 +58,6 @@ export default define(meta, paramDef, async (ps, user) => { }); if (!(await Users.getHasUnreadAnnouncement(user.id))) { - publishMainStream(user.id, "readAllAnnouncements"); + publishToMainStream(user.id, Event.ReadAllAnnouncements, {}); } }); diff --git a/packages/backend/src/server/api/endpoints/i/regenerate-token.ts b/packages/backend/src/server/api/endpoints/i/regenerate-token.ts index 4b1b3450af..0f0f79c35e 100644 --- a/packages/backend/src/server/api/endpoints/i/regenerate-token.ts +++ b/packages/backend/src/server/api/endpoints/i/regenerate-token.ts @@ -1,11 +1,12 @@ -import { - publishInternalEvent, - publishMainStream, - publishUserEvent, -} from "@/services/stream.js"; +import { publishInternalEvent, publishUserEvent } from "@/services/stream.js"; import define from "@/server/api/define.js"; import { Users, UserProfiles } from "@/models/index.js"; -import { generateUserToken, verifyPassword } from "backend-rs"; +import { + Event, + generateUserToken, + publishToMainStream, + verifyPassword, +} from "backend-rs"; export const meta = { requireCredential: true, @@ -46,7 +47,7 @@ export default define(meta, paramDef, async (ps, user) => { oldToken, newToken, }); - publishMainStream(user.id, "myTokenRegenerated"); + publishToMainStream(user.id, Event.RegenerateMyToken, {}); // Terminate streaming setTimeout(() => { diff --git a/packages/backend/src/server/api/endpoints/i/registry/set.ts b/packages/backend/src/server/api/endpoints/i/registry/set.ts index e778bd98d8..32e2598c85 100644 --- a/packages/backend/src/server/api/endpoints/i/registry/set.ts +++ b/packages/backend/src/server/api/endpoints/i/registry/set.ts @@ -1,7 +1,6 @@ -import { publishMainStream } from "@/services/stream.js"; import define from "@/server/api/define.js"; import { RegistryItems } from "@/models/index.js"; -import { genIdAt } from "backend-rs"; +import { Event, genIdAt, publishToMainStream } from "backend-rs"; export const meta = { requireCredential: true, @@ -55,7 +54,7 @@ export default define(meta, paramDef, async (ps, user) => { } // TODO: サードパーティアプリが傍受出来てしまうのでどうにかする - publishMainStream(user.id, "registryUpdated", { + publishToMainStream(user.id, Event.Registry, { scope: ps.scope, key: ps.key, value: ps.value, 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 d894eb07e9..4d27846c88 100644 --- a/packages/backend/src/server/api/endpoints/i/update-email.ts +++ b/packages/backend/src/server/api/endpoints/i/update-email.ts @@ -1,4 +1,3 @@ -import { publishMainStream } from "@/services/stream.js"; import define from "@/server/api/define.js"; import rndstr from "rndstr"; import { config } from "@/config.js"; @@ -6,7 +5,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 { verifyPassword } from "backend-rs"; +import { Event, publishToMainStream, verifyPassword } from "backend-rs"; import { HOUR } from "@/const.js"; export const meta = { @@ -72,7 +71,7 @@ export default define(meta, paramDef, async (ps, user) => { }); // Publish meUpdated event - publishMainStream(user.id, "meUpdated", iObj); + publishToMainStream(user.id, Event.Me, iObj); if (ps.email != null) { const code = rndstr("a-z0-9", 16); diff --git a/packages/backend/src/server/api/endpoints/i/update.ts b/packages/backend/src/server/api/endpoints/i/update.ts index dd0511cfed..0620f837ff 100644 --- a/packages/backend/src/server/api/endpoints/i/update.ts +++ b/packages/backend/src/server/api/endpoints/i/update.ts @@ -1,5 +1,6 @@ import * as mfm from "mfm-js"; -import { publishMainStream, publishUserEvent } from "@/services/stream.js"; +import { publishUserEvent } from "@/services/stream.js"; +import { Event, publishToMainStream } from "backend-rs"; import acceptAllFollowRequests from "@/services/following/requests/accept-all.js"; import { publishToFollowers } from "@/services/i/update.js"; import { extractCustomEmojisFromMfm } from "@/misc/extract-custom-emojis-from-mfm.js"; @@ -345,7 +346,7 @@ export default define(meta, paramDef, async (ps, _user, token) => { }); // Publish meUpdated event - publishMainStream(user.id, "meUpdated", iObj); + publishToMainStream(user.id, Event.Me, iObj); publishUserEvent( user.id, "updateUserProfile", diff --git a/packages/backend/src/server/api/endpoints/notifications/mark-all-as-read.ts b/packages/backend/src/server/api/endpoints/notifications/mark-all-as-read.ts index 6b6c207ab1..12005db818 100644 --- a/packages/backend/src/server/api/endpoints/notifications/mark-all-as-read.ts +++ b/packages/backend/src/server/api/endpoints/notifications/mark-all-as-read.ts @@ -1,5 +1,4 @@ -import { publishMainStream } from "@/services/stream.js"; -import { sendPushNotification } from "backend-rs"; +import { Event, publishToMainStream, sendPushNotification } from "backend-rs"; import { Notifications } from "@/models/index.js"; import define from "@/server/api/define.js"; @@ -30,6 +29,6 @@ export default define(meta, paramDef, async (_, user) => { ); // 全ての通知を読みましたよというイベントを発行 - publishMainStream(user.id, "readAllNotifications"); + await publishToMainStream(user.id, Event.ReadAllNotifications, {}); await sendPushNotification(user.id, "readAllNotifications", {}); }); diff --git a/packages/backend/src/server/api/endpoints/page-push.ts b/packages/backend/src/server/api/endpoints/page-push.ts index 1f87372d61..5221063637 100644 --- a/packages/backend/src/server/api/endpoints/page-push.ts +++ b/packages/backend/src/server/api/endpoints/page-push.ts @@ -1,4 +1,4 @@ -import { publishMainStream } from "@/services/stream.js"; +import { Event, publishToMainStream } from "backend-rs"; import { Users, Pages } from "@/models/index.js"; import define from "@/server/api/define.js"; import { ApiError } from "@/server/api/error.js"; @@ -32,7 +32,7 @@ export default define(meta, paramDef, async (ps, user) => { throw new ApiError(meta.errors.noSuchPage); } - publishMainStream(page.userId, "pageEvent", { + publishToMainStream(page.userId, Event.Page, { pageId: ps.pageId, event: ps.event, var: ps.var, diff --git a/packages/backend/src/server/api/private/verify-email.ts b/packages/backend/src/server/api/private/verify-email.ts index e6c8295d18..b5c8f9c954 100644 --- a/packages/backend/src/server/api/private/verify-email.ts +++ b/packages/backend/src/server/api/private/verify-email.ts @@ -1,6 +1,6 @@ import type Koa from "koa"; import { Users, UserProfiles } from "@/models/index.js"; -import { publishMainStream } from "@/services/stream.js"; +import { Event, publishToMainStream } from "backend-rs"; export default async (ctx: Koa.Context) => { const body = ctx.request.body; @@ -20,9 +20,9 @@ export default async (ctx: Koa.Context) => { }, ); - publishMainStream( + publishToMainStream( profile.userId, - "meUpdated", + Event.Me, await Users.pack( profile.userId, { id: profile.userId }, diff --git a/packages/backend/src/services/blocking/create.ts b/packages/backend/src/services/blocking/create.ts index 8c41d93665..02ac813967 100644 --- a/packages/backend/src/services/blocking/create.ts +++ b/packages/backend/src/services/blocking/create.ts @@ -1,4 +1,4 @@ -import { publishMainStream, publishUserEvent } from "@/services/stream.js"; +import { publishUserEvent } from "@/services/stream.js"; import { renderActivity } from "@/remote/activitypub/renderer/index.js"; import renderFollow from "@/remote/activitypub/renderer/follow.js"; import { renderUndo } from "@/remote/activitypub/renderer/undo.js"; @@ -15,7 +15,7 @@ import { UserListJoinings, UserLists, } from "@/models/index.js"; -import { genIdAt } from "backend-rs"; +import { Event, genIdAt, publishToMainStream } from "backend-rs"; import { getActiveWebhooks } from "@/misc/webhook-cache.js"; import { webhookDeliver } from "@/queue/index.js"; @@ -65,7 +65,7 @@ async function cancelRequest(follower: User, followee: User) { if (Users.isLocalUser(followee)) { Users.pack(followee, followee, { detail: true, - }).then((packed) => publishMainStream(followee.id, "meUpdated", packed)); + }).then((packed) => publishToMainStream(followee.id, Event.Me, packed)); } if (Users.isLocalUser(follower)) { @@ -73,7 +73,7 @@ async function cancelRequest(follower: User, followee: User) { detail: true, }).then(async (packed) => { publishUserEvent(follower.id, "unfollow", packed); - publishMainStream(follower.id, "unfollow", packed); + publishToMainStream(follower.id, Event.Unfollow, packed); const webhooks = (await getActiveWebhooks()).filter( (x) => x.userId === follower.id && x.on.includes("unfollow"), @@ -128,7 +128,7 @@ async function unFollow(follower: User, followee: User) { detail: true, }).then(async (packed) => { publishUserEvent(follower.id, "unfollow", packed); - publishMainStream(follower.id, "unfollow", packed); + publishToMainStream(follower.id, Event.Unfollow, packed); const webhooks = (await getActiveWebhooks()).filter( (x) => x.userId === follower.id && x.on.includes("unfollow"), diff --git a/packages/backend/src/services/create-notification.ts b/packages/backend/src/services/create-notification.ts index 6030f0a74d..c862c35d3f 100644 --- a/packages/backend/src/services/create-notification.ts +++ b/packages/backend/src/services/create-notification.ts @@ -1,4 +1,3 @@ -import { publishMainStream } from "@/services/stream.js"; import { Notifications, Mutings, @@ -7,7 +6,13 @@ import { Users, Followings, } from "@/models/index.js"; -import { genIdAt, isSilencedServer, sendPushNotification } from "backend-rs"; +import { + Event, + genIdAt, + isSilencedServer, + publishToMainStream, + sendPushNotification, +} from "backend-rs"; import type { User } from "@/models/entities/user.js"; import type { Notification } from "@/models/entities/notification.js"; import { sendEmailNotification } from "./send-email-notification.js"; @@ -76,7 +81,7 @@ export async function createNotification( const packed = await Notifications.pack(notification, {}); // Publish notification event - publishMainStream(notifieeId, "notification", packed); + publishToMainStream(notifieeId, Event.Notification, packed); // 2秒経っても(今回作成した)通知が既読にならなかったら「未読の通知がありますよ」イベントを発行する setTimeout(async () => { @@ -111,7 +116,7 @@ export async function createNotification( } //#endregion - publishMainStream(notifieeId, "unreadNotification", packed); + publishToMainStream(notifieeId, Event.NewNotification, packed); if (type === "follow") sendEmailNotification.follow( diff --git a/packages/backend/src/services/drive/add-file.ts b/packages/backend/src/services/drive/add-file.ts index f42a987356..541aab170e 100644 --- a/packages/backend/src/services/drive/add-file.ts +++ b/packages/backend/src/services/drive/add-file.ts @@ -5,8 +5,13 @@ import { v4 as uuid } from "uuid"; import type S3 from "aws-sdk/clients/s3.js"; // TODO: migrate to SDK v3 import sharp from "sharp"; import { IsNull } from "typeorm"; -import { publishMainStream } from "@/services/stream.js"; -import { fetchMeta, genId, publishToDriveFileStream } from "backend-rs"; +import { + Event, + fetchMeta, + genId, + publishToDriveFileStream, + publishToMainStream, +} from "backend-rs"; import { FILE_TYPE_BROWSERSAFE } from "@/const.js"; import { contentDisposition } from "@/misc/content-disposition.js"; import { getFileInfo } from "@/misc/get-file-info.js"; @@ -667,7 +672,7 @@ export async function addFile({ if (user != null) { DriveFiles.pack(file, { self: true }).then((packedFile) => { // Publish driveFileCreated event - publishMainStream(user.id, "driveFileCreated", packedFile); + publishToMainStream(user.id, Event.DriveFile, packedFile); publishToDriveFileStream(user.id, "create", toRustObject(file)); }); } diff --git a/packages/backend/src/services/following/create.ts b/packages/backend/src/services/following/create.ts index 6788cd13f6..1c962c9e9e 100644 --- a/packages/backend/src/services/following/create.ts +++ b/packages/backend/src/services/following/create.ts @@ -1,4 +1,4 @@ -import { publishMainStream, publishUserEvent } from "@/services/stream.js"; +import { publishUserEvent } from "@/services/stream.js"; import { renderActivity } from "@/remote/activitypub/renderer/index.js"; import renderFollow from "@/remote/activitypub/renderer/follow.js"; import renderAccept from "@/remote/activitypub/renderer/accept.js"; @@ -17,7 +17,12 @@ import { Instances, UserProfiles, } from "@/models/index.js"; -import { genIdAt, isSilencedServer } from "backend-rs"; +import { + Event, + genIdAt, + isSilencedServer, + publishToMainStream, +} from "backend-rs"; import { createNotification } from "@/services/create-notification.js"; import { isDuplicateKeyValueError } from "@/misc/is-duplicate-key-value-error.js"; import type { Packed } from "@/misc/schema.js"; @@ -126,9 +131,9 @@ export async function insertFollowingDoc( "follow", packed as Packed<"UserDetailedNotMe">, ); - publishMainStream( + publishToMainStream( follower.id, - "follow", + Event.Follow, packed as Packed<"UserDetailedNotMe">, ); @@ -146,7 +151,7 @@ export async function insertFollowingDoc( // Publish followed event if (Users.isLocalUser(followee)) { Users.pack(follower.id, followee).then(async (packed) => { - publishMainStream(followee.id, "followed", packed); + publishToMainStream(followee.id, Event.Followed, packed); const webhooks = (await getActiveWebhooks()).filter( (x) => x.userId === followee.id && x.on.includes("followed"), diff --git a/packages/backend/src/services/following/delete.ts b/packages/backend/src/services/following/delete.ts index 2fe863fc57..65d409f8bf 100644 --- a/packages/backend/src/services/following/delete.ts +++ b/packages/backend/src/services/following/delete.ts @@ -1,4 +1,5 @@ -import { publishMainStream, publishUserEvent } from "@/services/stream.js"; +import { publishUserEvent } from "@/services/stream.js"; +import { Event, publishToMainStream } from "backend-rs"; import { renderActivity } from "@/remote/activitypub/renderer/index.js"; import renderFollow from "@/remote/activitypub/renderer/follow.js"; import { renderUndo } from "@/remote/activitypub/renderer/undo.js"; @@ -51,7 +52,7 @@ export default async function ( detail: true, }).then(async (packed) => { publishUserEvent(follower.id, "unfollow", packed); - publishMainStream(follower.id, "unfollow", packed); + publishToMainStream(follower.id, Event.Unfollow, packed); const webhooks = (await getActiveWebhooks()).filter( (x) => x.userId === follower.id && x.on.includes("unfollow"), diff --git a/packages/backend/src/services/following/reject.ts b/packages/backend/src/services/following/reject.ts index 821fe9f639..71f0220b14 100644 --- a/packages/backend/src/services/following/reject.ts +++ b/packages/backend/src/services/following/reject.ts @@ -2,7 +2,8 @@ import { renderActivity } from "@/remote/activitypub/renderer/index.js"; import renderFollow from "@/remote/activitypub/renderer/follow.js"; import renderReject from "@/remote/activitypub/renderer/reject.js"; import { deliver, webhookDeliver } from "@/queue/index.js"; -import { publishMainStream, publishUserEvent } from "@/services/stream.js"; +import { publishUserEvent } from "@/services/stream.js"; +import { Event, publishToMainStream } from "backend-rs"; import type { ILocalUser, IRemoteUser } from "@/models/entities/user.js"; import { Users, FollowRequests, Followings } from "@/models/index.js"; import { decrementFollowing } from "./delete.js"; @@ -120,7 +121,7 @@ async function publishUnfollow(followee: Both, follower: Local) { }); publishUserEvent(follower.id, "unfollow", packedFollowee); - publishMainStream(follower.id, "unfollow", packedFollowee); + publishToMainStream(follower.id, Event.Unfollow, packedFollowee); const webhooks = (await getActiveWebhooks()).filter( (x) => x.userId === follower.id && x.on.includes("unfollow"), diff --git a/packages/backend/src/services/following/requests/accept.ts b/packages/backend/src/services/following/requests/accept.ts index f0425c20b9..bcd7d2cf4c 100644 --- a/packages/backend/src/services/following/requests/accept.ts +++ b/packages/backend/src/services/following/requests/accept.ts @@ -2,7 +2,7 @@ import { renderActivity } from "@/remote/activitypub/renderer/index.js"; import renderFollow from "@/remote/activitypub/renderer/follow.js"; import renderAccept from "@/remote/activitypub/renderer/accept.js"; import { deliver } from "@/queue/index.js"; -import { publishMainStream } from "@/services/stream.js"; +import { Event, publishToMainStream } from "backend-rs"; import { insertFollowingDoc } from "../create.js"; import type { User, CacheableUser } from "@/models/entities/user.js"; import { FollowRequests, Users } from "@/models/index.js"; @@ -44,5 +44,5 @@ export default async function ( Users.pack(followee.id, followee, { detail: true, - }).then((packed) => publishMainStream(followee.id, "meUpdated", packed)); + }).then((packed) => publishToMainStream(followee.id, Event.Me, packed)); } diff --git a/packages/backend/src/services/following/requests/cancel.ts b/packages/backend/src/services/following/requests/cancel.ts index f271b15058..eb1b2dcb49 100644 --- a/packages/backend/src/services/following/requests/cancel.ts +++ b/packages/backend/src/services/following/requests/cancel.ts @@ -2,7 +2,7 @@ import { renderActivity } from "@/remote/activitypub/renderer/index.js"; import renderFollow from "@/remote/activitypub/renderer/follow.js"; import { renderUndo } from "@/remote/activitypub/renderer/undo.js"; import { deliver } from "@/queue/index.js"; -import { publishMainStream } from "@/services/stream.js"; +import { Event, publishToMainStream } from "backend-rs"; import { IdentifiableError } from "@/misc/identifiable-error.js"; import type { User } from "@/models/entities/user.js"; import { Users, FollowRequests } from "@/models/index.js"; @@ -46,5 +46,5 @@ export default async function ( Users.pack(followee.id, followee, { detail: true, - }).then((packed) => publishMainStream(followee.id, "meUpdated", packed)); + }).then((packed) => publishToMainStream(followee.id, Event.Me, packed)); } diff --git a/packages/backend/src/services/following/requests/create.ts b/packages/backend/src/services/following/requests/create.ts index 648fd38a0a..40f383cfd3 100644 --- a/packages/backend/src/services/following/requests/create.ts +++ b/packages/backend/src/services/following/requests/create.ts @@ -1,10 +1,9 @@ -import { publishMainStream } from "@/services/stream.js"; import { renderActivity } from "@/remote/activitypub/renderer/index.js"; import renderFollow from "@/remote/activitypub/renderer/follow.js"; import { deliver } from "@/queue/index.js"; import type { User } from "@/models/entities/user.js"; import { Blockings, FollowRequests, Users } from "@/models/index.js"; -import { genIdAt } from "backend-rs"; +import { Event, genIdAt, publishToMainStream } from "backend-rs"; import { createNotification } from "@/services/create-notification.js"; import { config } from "@/config.js"; @@ -67,12 +66,12 @@ export default async function ( // Publish receiveRequest event if (Users.isLocalUser(followee)) { Users.pack(follower.id, followee).then((packed) => - publishMainStream(followee.id, "receiveFollowRequest", packed), + publishToMainStream(followee.id, Event.NewFollowRequest, packed), ); Users.pack(followee.id, followee, { detail: true, - }).then((packed) => publishMainStream(followee.id, "meUpdated", packed)); + }).then((packed) => publishToMainStream(followee.id, Event.Me, packed)); // 通知を作成 createNotification(followee.id, "receiveFollowRequest", { diff --git a/packages/backend/src/services/i/update.ts b/packages/backend/src/services/i/update.ts index 2f7e2b5e18..f2752f069b 100644 --- a/packages/backend/src/services/i/update.ts +++ b/packages/backend/src/services/i/update.ts @@ -11,7 +11,8 @@ import mfm from "mfm-js"; import { extractHashtags } from "@/misc/extract-hashtags.js"; import { normalizeForSearch } from "@/misc/normalize-for-search.js"; import { updateUsertags } from "@/services/update-hashtag.js"; -import { publishMainStream, publishUserEvent } from "@/services/stream.js"; +import { publishUserEvent } from "@/services/stream.js"; +import { Event, publishToMainStream } from "backend-rs"; import acceptAllFollowRequests from "@/services/following/requests/accept-all.js"; import { promiseEarlyReturn } from "@/prelude/promise.js"; @@ -79,7 +80,7 @@ export async function updateUserProfileData( includeSecrets: isSecure, }); - publishMainStream(user.id, "meUpdated", iObj); + publishToMainStream(user.id, Event.Me, iObj); publishUserEvent( user.id, "updateUserProfile", diff --git a/packages/backend/src/services/messages/create.ts b/packages/backend/src/services/messages/create.ts index 32c800f0b3..a19bc59168 100644 --- a/packages/backend/src/services/messages/create.ts +++ b/packages/backend/src/services/messages/create.ts @@ -14,9 +14,10 @@ import { publishToGroupChatStream, publishToChatIndexStream, toPuny, + publishToMainStream, + Event, } from "backend-rs"; import type { MessagingMessage } from "@/models/entities/messaging-message.js"; -import { publishMainStream } from "@/services/stream.js"; import { Not } from "typeorm"; import type { Note } from "@/models/entities/note.js"; import renderNote from "@/remote/activitypub/renderer/note.js"; @@ -62,8 +63,8 @@ export async function createMessage( messageObj, ), publishToChatIndexStream(message.userId, "message", messageObj), + publishToMainStream(message.userId, Event.Chat, messageObj), ]); - publishMainStream(message.userId, "messagingMessage", messageObj); } if (Users.isLocalUser(recipientUser)) { @@ -76,8 +77,8 @@ export async function createMessage( messageObj, ), publishToChatIndexStream(recipientUser.id, "message", messageObj), + publishToMainStream(recipientUser.id, Event.Chat, messageObj), ]); - publishMainStream(recipientUser.id, "messagingMessage", messageObj); } } else if (recipientGroup != null) { // group's stream @@ -88,8 +89,10 @@ export async function createMessage( userGroupId: recipientGroup.id, }); for await (const joining of joinings) { - await publishToChatIndexStream(joining.userId, "message", messageObj); - publishMainStream(joining.userId, "messagingMessage", messageObj); + await Promise.all([ + publishToChatIndexStream(joining.userId, "message", messageObj), + publishToMainStream(joining.userId, Event.Chat, messageObj), + ]); } } @@ -108,8 +111,10 @@ export async function createMessage( if (mute.map((m) => m.muteeId).includes(user.id)) return; //#endregion - publishMainStream(recipientUser.id, "unreadMessagingMessage", messageObj); - await sendPushNotification(recipientUser.id, "chat", messageObj); + await Promise.all([ + publishToMainStream(recipientUser.id, Event.NewChat, messageObj), + sendPushNotification(recipientUser.id, "chat", messageObj), + ]); } else if (recipientGroup) { const joinings = await UserGroupJoinings.findBy({ userGroupId: recipientGroup.id, @@ -117,8 +122,10 @@ export async function createMessage( }); for await (const joining of joinings) { if (freshMessage.reads.includes(joining.userId)) return; // 既読 - publishMainStream(joining.userId, "unreadMessagingMessage", messageObj); - await sendPushNotification(joining.userId, "chat", messageObj); + await Promise.all([ + publishToMainStream(joining.userId, Event.NewChat, messageObj), + sendPushNotification(joining.userId, "chat", messageObj), + ]); } } }, 2000); diff --git a/packages/backend/src/services/note/create.ts b/packages/backend/src/services/note/create.ts index 33f0913ea0..4b21c67141 100644 --- a/packages/backend/src/services/note/create.ts +++ b/packages/backend/src/services/note/create.ts @@ -1,5 +1,4 @@ import * as mfm from "mfm-js"; -import { publishMainStream } from "@/services/stream.js"; import DeliverManager from "@/remote/activitypub/deliver-manager.js"; import renderNote from "@/remote/activitypub/renderer/note.js"; import renderCreate from "@/remote/activitypub/renderer/create.js"; @@ -48,6 +47,8 @@ import { publishToNotesStream, publishToNoteStream, NoteEvent, + publishToMainStream, + Event, } from "backend-rs"; import { countSameRenotes } from "@/misc/count-same-renotes.js"; import { deliverToRelays, getCachedRelays } from "../relay.js"; @@ -508,7 +509,7 @@ export default async ( const packedReply = await Notes.pack(note, { id: data.reply.userId, }); - publishMainStream(data.reply.userId, "reply", packedReply); + publishToMainStream(data.reply.userId, Event.Reply, packedReply); const webhooks = (await getActiveWebhooks()).filter( (x) => @@ -548,7 +549,7 @@ export default async ( const packedRenote = await Notes.pack(note, { id: data.renote.userId, }); - publishMainStream(data.renote.userId, "renote", packedRenote); + publishToMainStream(data.renote.userId, Event.Renote, packedRenote); const renote = data.renote; const webhooks = (await getActiveWebhooks()).filter( @@ -874,7 +875,7 @@ async function createMentionedEvents( detail: true, }); - publishMainStream(u.id, "mention", detailPackedNote); + publishToMainStream(u.id, Event.Mention, detailPackedNote); const webhooks = (await getActiveWebhooks()).filter( (x) => x.userId === u.id && x.on.includes("mention"), diff --git a/packages/backend/src/services/note/read.ts b/packages/backend/src/services/note/read.ts index d7fda27a85..98d94e684a 100644 --- a/packages/backend/src/services/note/read.ts +++ b/packages/backend/src/services/note/read.ts @@ -1,4 +1,4 @@ -import { publishMainStream } from "@/services/stream.js"; +import { Event, publishToMainStream } from "backend-rs"; import type { Note } from "@/models/entities/note.js"; import type { User } from "@/models/entities/user.js"; import { NoteUnreads, Followings, ChannelFollowings } from "@/models/index.js"; @@ -84,7 +84,7 @@ export default async function ( }).then((mentionsCount) => { if (mentionsCount === 0) { // 全て既読になったイベントを発行 - publishMainStream(userId, "readAllUnreadMentions"); + publishToMainStream(userId, Event.ReadAllMentions, {}); } }); @@ -94,7 +94,7 @@ export default async function ( }).then((specifiedCount) => { if (specifiedCount === 0) { // 全て既読になったイベントを発行 - publishMainStream(userId, "readAllUnreadSpecifiedNotes"); + publishToMainStream(userId, Event.ReadAllDms, {}); } }); @@ -104,7 +104,7 @@ export default async function ( }).then((channelNoteCount) => { if (channelNoteCount === 0) { // 全て既読になったイベントを発行 - publishMainStream(userId, "readAllChannels"); + publishToMainStream(userId, Event.ReadAllChannelPosts, {}); } }); diff --git a/packages/backend/src/services/note/unread.ts b/packages/backend/src/services/note/unread.ts index d52ac46d4d..f17763290a 100644 --- a/packages/backend/src/services/note/unread.ts +++ b/packages/backend/src/services/note/unread.ts @@ -1,8 +1,7 @@ import type { Note } from "@/models/entities/note.js"; -import { publishMainStream } from "@/services/stream.js"; import type { User } from "@/models/entities/user.js"; import { Mutings, NoteThreadMutings, NoteUnreads } from "@/models/index.js"; -import { genId } from "backend-rs"; +import { Event, genId, publishToMainStream } from "backend-rs"; export async function insertNoteUnread( userId: User["id"], @@ -47,13 +46,13 @@ export async function insertNoteUnread( if (!exists) return; if (params.isMentioned) { - publishMainStream(userId, "unreadMention", note.id); + publishToMainStream(userId, Event.NewMention, note.id); } if (params.isSpecified) { - publishMainStream(userId, "unreadSpecifiedNote", note.id); + publishToMainStream(userId, Event.NewDm, note.id); } if (note.channelId) { - publishMainStream(userId, "unreadChannel", note.id); + publishToMainStream(userId, Event.NewChannelPost, note.id); } }, 2000); } diff --git a/packages/backend/src/services/stream.ts b/packages/backend/src/services/stream.ts index 79f813523e..71c6a3cc65 100644 --- a/packages/backend/src/services/stream.ts +++ b/packages/backend/src/services/stream.ts @@ -15,7 +15,7 @@ import type { // DriveStreamTypes, // GroupMessagingStreamTypes, InternalStreamTypes, - MainStreamTypes, + // MainStreamTypes, // MessagingIndexStreamTypes, // MessagingStreamTypes, // NoteStreamTypes, @@ -76,17 +76,18 @@ class Publisher { // ); // }; - public publishMainStream = ( - userId: User["id"], - type: K, - value?: MainStreamTypes[K], - ): void => { - this.publish( - `mainStream:${userId}`, - type, - typeof value === "undefined" ? null : value, - ); - }; + /* ported to backend-rs */ + // public publishMainStream = ( + // userId: User["id"], + // type: K, + // value?: MainStreamTypes[K], + // ): void => { + // this.publish( + // `mainStream:${userId}`, + // type, + // typeof value === "undefined" ? null : value, + // ); + // }; /* ported to backend-rs */ // public publishDriveStream = ( @@ -217,7 +218,7 @@ export default publisher; export const publishInternalEvent = publisher.publishInternalEvent; export const publishUserEvent = publisher.publishUserEvent; // export const publishBroadcastStream = publisher.publishBroadcastStream; -export const publishMainStream = publisher.publishMainStream; +// export const publishMainStream = publisher.publishMainStream; // export const publishDriveStream = publisher.publishDriveStream; // export const publishNoteStream = publisher.publishNoteStream; // export const publishNotesStream = publisher.publishNotesStream; From 7a54dc8b87b96c6e1a069902af7382d120e7566b Mon Sep 17 00:00:00 2001 From: naskya Date: Sat, 27 Jul 2024 20:39:02 +0900 Subject: [PATCH 32/43] refactor (backend): port publishInternalEvent to backend-rs --- packages/backend-rs/index.d.ts | 17 +++++++ packages/backend-rs/index.js | 2 + packages/backend-rs/src/service/stream.rs | 1 + .../backend-rs/src/service/stream/internal.rs | 45 +++++++++++++++++++ .../src/remote/activitypub/models/person.ts | 12 +++-- .../admin/drive-capacity-override.ts | 4 +- .../api/endpoints/admin/moderators/add.ts | 4 +- .../api/endpoints/admin/moderators/remove.ts | 4 +- .../endpoints/admin/set-emoji-moderator.ts | 6 --- .../api/endpoints/admin/silence-user.ts | 4 +- .../api/endpoints/admin/unsilence-user.ts | 4 +- .../server/api/endpoints/antennas/create.ts | 11 +++-- .../server/api/endpoints/antennas/delete.ts | 9 ++-- .../server/api/endpoints/antennas/update.ts | 11 +++-- .../api/endpoints/i/regenerate-token.ts | 6 ++- .../server/api/endpoints/i/webhooks/create.ts | 5 +-- .../server/api/endpoints/i/webhooks/delete.ts | 4 +- .../server/api/endpoints/i/webhooks/update.ts | 4 +- packages/backend/src/services/stream.ts | 17 +++---- packages/backend/src/services/suspend-user.ts | 4 +- .../backend/src/services/unsuspend-user.ts | 4 +- 21 files changed, 128 insertions(+), 50 deletions(-) create mode 100644 packages/backend-rs/src/service/stream/internal.rs diff --git a/packages/backend-rs/index.d.ts b/packages/backend-rs/index.d.ts index b67d586e8f..8139084116 100644 --- a/packages/backend-rs/index.d.ts +++ b/packages/backend-rs/index.d.ts @@ -574,6 +574,21 @@ export interface Instance { faviconUrl: string | null } +export declare enum InternalEvent { + Suspend = 0, + Silence = 1, + Moderator = 2, + Token = 3, + LocalUser = 4, + RemoteUser = 5, + WebhookCreated = 6, + WebhookUpdated = 7, + WebhookDeleted = 8, + AntennaCreated = 9, + AntennaUpdated = 10, + AntennaDeleted = 11 +} + /** * Checks if a server is allowlisted. * Returns `Ok(true)` if private mode is disabled. @@ -1164,6 +1179,8 @@ export declare function publishToDriveFolderStream(userId: string, kind: DriveFo export declare function publishToGroupChatStream(groupId: string, kind: ChatEvent, object: any): Promise +export declare function publishToInternalStream(kind: InternalEvent, object: any): Promise + export declare function publishToMainStream(userId: string, kind: Event, object: any): Promise export declare function publishToModerationStream(moderatorId: string, report: AbuseUserReportLike): Promise diff --git a/packages/backend-rs/index.js b/packages/backend-rs/index.js index f62cbb3626..9d17a05028 100644 --- a/packages/backend-rs/index.js +++ b/packages/backend-rs/index.js @@ -394,6 +394,7 @@ module.exports.greet = nativeBinding.greet module.exports.hashPassword = nativeBinding.hashPassword module.exports.Inbound = nativeBinding.Inbound module.exports.initializeRustLogger = nativeBinding.initializeRustLogger +module.exports.InternalEvent = nativeBinding.InternalEvent module.exports.isAllowedServer = nativeBinding.isAllowedServer module.exports.isBlockedServer = nativeBinding.isBlockedServer module.exports.isOldPasswordAlgorithm = nativeBinding.isOldPasswordAlgorithm @@ -425,6 +426,7 @@ module.exports.publishToChatStream = nativeBinding.publishToChatStream module.exports.publishToDriveFileStream = nativeBinding.publishToDriveFileStream module.exports.publishToDriveFolderStream = nativeBinding.publishToDriveFolderStream module.exports.publishToGroupChatStream = nativeBinding.publishToGroupChatStream +module.exports.publishToInternalStream = nativeBinding.publishToInternalStream module.exports.publishToMainStream = nativeBinding.publishToMainStream module.exports.publishToModerationStream = nativeBinding.publishToModerationStream module.exports.publishToNotesStream = nativeBinding.publishToNotesStream diff --git a/packages/backend-rs/src/service/stream.rs b/packages/backend-rs/src/service/stream.rs index 8998ee9a1f..47b3891f63 100644 --- a/packages/backend-rs/src/service/stream.rs +++ b/packages/backend-rs/src/service/stream.rs @@ -5,6 +5,7 @@ pub mod chat_index; pub mod custom_emoji; pub mod drive; pub mod group_chat; +pub mod internal; pub mod main; pub mod moderation; pub mod note; diff --git a/packages/backend-rs/src/service/stream/internal.rs b/packages/backend-rs/src/service/stream/internal.rs new file mode 100644 index 0000000000..b78f40e4c9 --- /dev/null +++ b/packages/backend-rs/src/service/stream/internal.rs @@ -0,0 +1,45 @@ +use crate::service::stream::{publish_to_stream, Error, Stream}; + +#[macros::export] +pub enum InternalEvent { + Suspend, + Silence, + Moderator, + Token, + LocalUser, + RemoteUser, + WebhookCreated, + WebhookUpdated, + WebhookDeleted, + AntennaCreated, + AntennaUpdated, + AntennaDeleted, +} + +// We want to merge `kind` and `object` into a single enum +// https://github.com/napi-rs/napi-rs/issues/2036 + +#[macros::export(js_name = "publishToInternalStream")] +pub async fn publish(kind: InternalEvent, object: &serde_json::Value) -> Result<(), Error> { + let kind = match kind { + InternalEvent::Suspend => "userChangeSuspendedState", + InternalEvent::Silence => "userChangeSilencedState", + InternalEvent::Moderator => "userChangeModeratorState", + InternalEvent::Token => "userTokenRegenerated", + InternalEvent::LocalUser => "localUserUpdated", + InternalEvent::RemoteUser => "remoteUserUpdated", + InternalEvent::WebhookCreated => "webhookCreated", + InternalEvent::WebhookUpdated => "webhookUpdated", + InternalEvent::WebhookDeleted => "webhookDeleted", + InternalEvent::AntennaCreated => "antennaCreated", + InternalEvent::AntennaUpdated => "antennaUpdated", + InternalEvent::AntennaDeleted => "antennaDeleted", + }; + + publish_to_stream( + &Stream::Internal, + Some(kind), + Some(serde_json::to_string(&object)?), + ) + .await +} diff --git a/packages/backend/src/remote/activitypub/models/person.ts b/packages/backend/src/remote/activitypub/models/person.ts index e861553e97..8a94af4bed 100644 --- a/packages/backend/src/remote/activitypub/models/person.ts +++ b/packages/backend/src/remote/activitypub/models/person.ts @@ -16,7 +16,14 @@ import type { IRemoteUser, CacheableUser } from "@/models/entities/user.js"; import { User } from "@/models/entities/user.js"; import type { Emoji } from "@/models/entities/emoji.js"; import { UserNotePining } from "@/models/entities/user-note-pining.js"; -import { genId, genIdAt, isSameOrigin, toPuny } from "backend-rs"; +import { + genId, + genIdAt, + InternalEvent, + isSameOrigin, + publishToInternalStream, + toPuny, +} from "backend-rs"; import { UserPublickey } from "@/models/entities/user-publickey.js"; import { isDuplicateKeyValueError } from "@/misc/is-duplicate-key-value-error.js"; import { UserProfile } from "@/models/entities/user-profile.js"; @@ -26,7 +33,6 @@ import { normalizeForSearch } from "@/misc/normalize-for-search.js"; import { truncate } from "@/misc/truncate.js"; import { StatusError } from "@/misc/fetch.js"; import { uriPersonCache } from "@/services/user-cache.js"; -import { publishInternalEvent } from "@/services/stream.js"; import { db } from "@/db/postgre.js"; import { apLogger } from "../logger.js"; import { htmlToMfm } from "../misc/html-to-mfm.js"; @@ -611,7 +617,7 @@ export async function updatePerson( }, ); - publishInternalEvent("remoteUserUpdated", { id: user.id }); + publishToInternalStream(InternalEvent.RemoteUser, { id: user.id }); // Hashtag Update updateUsertags(user, tags); diff --git a/packages/backend/src/server/api/endpoints/admin/drive-capacity-override.ts b/packages/backend/src/server/api/endpoints/admin/drive-capacity-override.ts index d4bb3045c6..26abdb890e 100644 --- a/packages/backend/src/server/api/endpoints/admin/drive-capacity-override.ts +++ b/packages/backend/src/server/api/endpoints/admin/drive-capacity-override.ts @@ -1,7 +1,7 @@ import define from "@/server/api/define.js"; import { Users } from "@/models/index.js"; import { insertModerationLog } from "@/services/insert-moderation-log.js"; -import { publishInternalEvent } from "@/services/stream.js"; +import { InternalEvent, publishToInternalStream } from "backend-rs"; export const meta = { tags: ["admin"], @@ -33,7 +33,7 @@ export default define(meta, paramDef, async (ps, me) => { driveCapacityOverrideMb: ps.overrideMb, }); - publishInternalEvent("localUserUpdated", { + publishToInternalStream(InternalEvent.LocalUser, { id: user.id, }); diff --git a/packages/backend/src/server/api/endpoints/admin/moderators/add.ts b/packages/backend/src/server/api/endpoints/admin/moderators/add.ts index c8b53088cd..a5fefaaaca 100644 --- a/packages/backend/src/server/api/endpoints/admin/moderators/add.ts +++ b/packages/backend/src/server/api/endpoints/admin/moderators/add.ts @@ -1,6 +1,6 @@ import define from "@/server/api/define.js"; import { Users } from "@/models/index.js"; -import { publishInternalEvent } from "@/services/stream.js"; +import { InternalEvent, publishToInternalStream } from "backend-rs"; export const meta = { tags: ["admin"], @@ -32,7 +32,7 @@ export default define(meta, paramDef, async (ps) => { isModerator: true, }); - publishInternalEvent("userChangeModeratorState", { + publishToInternalStream(InternalEvent.Moderator, { id: user.id, isModerator: true, }); diff --git a/packages/backend/src/server/api/endpoints/admin/moderators/remove.ts b/packages/backend/src/server/api/endpoints/admin/moderators/remove.ts index e2af1ca374..5adcae1e3f 100644 --- a/packages/backend/src/server/api/endpoints/admin/moderators/remove.ts +++ b/packages/backend/src/server/api/endpoints/admin/moderators/remove.ts @@ -1,6 +1,6 @@ import define from "@/server/api/define.js"; import { Users } from "@/models/index.js"; -import { publishInternalEvent } from "@/services/stream.js"; +import { InternalEvent, publishToInternalStream } from "backend-rs"; export const meta = { tags: ["admin"], @@ -28,7 +28,7 @@ export default define(meta, paramDef, async (ps) => { isModerator: false, }); - publishInternalEvent("userChangeModeratorState", { + publishToInternalStream(InternalEvent.Moderator, { id: user.id, isModerator: false, }); diff --git a/packages/backend/src/server/api/endpoints/admin/set-emoji-moderator.ts b/packages/backend/src/server/api/endpoints/admin/set-emoji-moderator.ts index 6633edbc8c..f7871bd9b2 100644 --- a/packages/backend/src/server/api/endpoints/admin/set-emoji-moderator.ts +++ b/packages/backend/src/server/api/endpoints/admin/set-emoji-moderator.ts @@ -1,6 +1,5 @@ import define from "@/server/api/define.js"; import { Users } from "@/models/index.js"; -import { publishInternalEvent } from "@/services/stream.js"; import type { EmojiModPerm } from "@/models/entities/user.js"; import { unsafeCast } from "@/prelude/unsafe-cast.js"; @@ -36,9 +35,4 @@ export default define(meta, paramDef, async (ps) => { await Users.update(user.id, { emojiModPerm: unsafeCast(ps.emojiModPerm), }); - - publishInternalEvent("userChangeModeratorState", { - id: user.id, - isModerator: true, - }); }); diff --git a/packages/backend/src/server/api/endpoints/admin/silence-user.ts b/packages/backend/src/server/api/endpoints/admin/silence-user.ts index 8d9dcac681..7cf116b788 100644 --- a/packages/backend/src/server/api/endpoints/admin/silence-user.ts +++ b/packages/backend/src/server/api/endpoints/admin/silence-user.ts @@ -1,7 +1,7 @@ import define from "@/server/api/define.js"; import { Users } from "@/models/index.js"; import { insertModerationLog } from "@/services/insert-moderation-log.js"; -import { publishInternalEvent } from "@/services/stream.js"; +import { InternalEvent, publishToInternalStream } from "backend-rs"; export const meta = { tags: ["admin"], @@ -33,7 +33,7 @@ export default define(meta, paramDef, async (ps, me) => { isSilenced: true, }); - publishInternalEvent("userChangeSilencedState", { + publishToInternalStream(InternalEvent.Silence, { id: user.id, isSilenced: true, }); diff --git a/packages/backend/src/server/api/endpoints/admin/unsilence-user.ts b/packages/backend/src/server/api/endpoints/admin/unsilence-user.ts index 6592bf443c..d376e35b72 100644 --- a/packages/backend/src/server/api/endpoints/admin/unsilence-user.ts +++ b/packages/backend/src/server/api/endpoints/admin/unsilence-user.ts @@ -1,7 +1,7 @@ import define from "@/server/api/define.js"; import { Users } from "@/models/index.js"; import { insertModerationLog } from "@/services/insert-moderation-log.js"; -import { publishInternalEvent } from "@/services/stream.js"; +import { InternalEvent, publishToInternalStream } from "backend-rs"; export const meta = { tags: ["admin"], @@ -29,7 +29,7 @@ export default define(meta, paramDef, async (ps, me) => { isSilenced: false, }); - publishInternalEvent("userChangeSilencedState", { + publishToInternalStream(InternalEvent.Silence, { id: user.id, isSilenced: false, }); diff --git a/packages/backend/src/server/api/endpoints/antennas/create.ts b/packages/backend/src/server/api/endpoints/antennas/create.ts index 332cff3ab6..0a19558f19 100644 --- a/packages/backend/src/server/api/endpoints/antennas/create.ts +++ b/packages/backend/src/server/api/endpoints/antennas/create.ts @@ -1,8 +1,13 @@ import define from "@/server/api/define.js"; -import { fetchMeta, genIdAt, updateAntennaCache } from "backend-rs"; +import { + fetchMeta, + genIdAt, + InternalEvent, + publishToInternalStream, + updateAntennaCache, +} from "backend-rs"; import { Antennas, UserLists, UserGroupJoinings } from "@/models/index.js"; import { ApiError } from "@/server/api/error.js"; -import { publishInternalEvent } from "@/services/stream.js"; export const meta = { tags: ["antennas"], @@ -172,7 +177,7 @@ export default define(meta, paramDef, async (ps, user) => { notify: ps.notify, }).then((x) => Antennas.findOneByOrFail(x.identifiers[0])); - publishInternalEvent("antennaCreated", antenna); + await publishToInternalStream(InternalEvent.AntennaCreated, antenna); await updateAntennaCache(); return await Antennas.pack(antenna); diff --git a/packages/backend/src/server/api/endpoints/antennas/delete.ts b/packages/backend/src/server/api/endpoints/antennas/delete.ts index 64ba1c2e1f..23bbc7c1f9 100644 --- a/packages/backend/src/server/api/endpoints/antennas/delete.ts +++ b/packages/backend/src/server/api/endpoints/antennas/delete.ts @@ -1,8 +1,11 @@ import define from "@/server/api/define.js"; import { ApiError } from "@/server/api/error.js"; import { Antennas } from "@/models/index.js"; -import { publishInternalEvent } from "@/services/stream.js"; -import { updateAntennaCache } from "backend-rs"; +import { + InternalEvent, + publishToInternalStream, + updateAntennaCache, +} from "backend-rs"; export const meta = { tags: ["antennas"], @@ -40,6 +43,6 @@ export default define(meta, paramDef, async (ps, user) => { await Antennas.delete(antenna.id); - publishInternalEvent("antennaDeleted", antenna); + await publishToInternalStream(InternalEvent.AntennaDeleted, antenna); await updateAntennaCache(); }); diff --git a/packages/backend/src/server/api/endpoints/antennas/update.ts b/packages/backend/src/server/api/endpoints/antennas/update.ts index 24d659f47a..5f4544ca2c 100644 --- a/packages/backend/src/server/api/endpoints/antennas/update.ts +++ b/packages/backend/src/server/api/endpoints/antennas/update.ts @@ -1,8 +1,11 @@ import define from "@/server/api/define.js"; import { ApiError } from "@/server/api/error.js"; import { Antennas, UserLists, UserGroupJoinings } from "@/models/index.js"; -import { publishInternalEvent } from "@/services/stream.js"; -import { updateAntennaCache } from "backend-rs"; +import { + InternalEvent, + publishToInternalStream, + updateAntennaCache, +} from "backend-rs"; export const meta = { tags: ["antennas"], @@ -163,8 +166,8 @@ export default define(meta, paramDef, async (ps, user) => { notify: ps.notify, }); - publishInternalEvent( - "antennaUpdated", + await publishToInternalStream( + InternalEvent.AntennaUpdated, await Antennas.findOneByOrFail({ id: antenna.id }), ); await updateAntennaCache(); diff --git a/packages/backend/src/server/api/endpoints/i/regenerate-token.ts b/packages/backend/src/server/api/endpoints/i/regenerate-token.ts index 0f0f79c35e..5666a0011f 100644 --- a/packages/backend/src/server/api/endpoints/i/regenerate-token.ts +++ b/packages/backend/src/server/api/endpoints/i/regenerate-token.ts @@ -1,9 +1,11 @@ -import { publishInternalEvent, publishUserEvent } from "@/services/stream.js"; +import { publishUserEvent } from "@/services/stream.js"; import define from "@/server/api/define.js"; import { Users, UserProfiles } from "@/models/index.js"; import { Event, generateUserToken, + InternalEvent, + publishToInternalStream, publishToMainStream, verifyPassword, } from "backend-rs"; @@ -42,7 +44,7 @@ export default define(meta, paramDef, async (ps, user) => { }); // Publish event - publishInternalEvent("userTokenRegenerated", { + publishToInternalStream(InternalEvent.Token, { id: user.id, oldToken, newToken, diff --git a/packages/backend/src/server/api/endpoints/i/webhooks/create.ts b/packages/backend/src/server/api/endpoints/i/webhooks/create.ts index 031f0e4eab..cf10b6b37b 100644 --- a/packages/backend/src/server/api/endpoints/i/webhooks/create.ts +++ b/packages/backend/src/server/api/endpoints/i/webhooks/create.ts @@ -1,7 +1,6 @@ import define from "@/server/api/define.js"; -import { genIdAt } from "backend-rs"; +import { genIdAt, InternalEvent, publishToInternalStream } from "backend-rs"; import { Webhooks } from "@/models/index.js"; -import { publishInternalEvent } from "@/services/stream.js"; import { webhookEventTypes } from "@/models/entities/webhook.js"; export const meta = { @@ -41,7 +40,7 @@ export default define(meta, paramDef, async (ps, user) => { on: ps.on, }).then((x) => Webhooks.findOneByOrFail(x.identifiers[0])); - publishInternalEvent("webhookCreated", webhook); + publishToInternalStream(InternalEvent.WebhookCreated, webhook); return webhook; }); diff --git a/packages/backend/src/server/api/endpoints/i/webhooks/delete.ts b/packages/backend/src/server/api/endpoints/i/webhooks/delete.ts index a92ed179d0..4c3b0e7849 100644 --- a/packages/backend/src/server/api/endpoints/i/webhooks/delete.ts +++ b/packages/backend/src/server/api/endpoints/i/webhooks/delete.ts @@ -1,7 +1,7 @@ import define from "@/server/api/define.js"; import { ApiError } from "@/server/api/error.js"; import { Webhooks } from "@/models/index.js"; -import { publishInternalEvent } from "@/services/stream.js"; +import { InternalEvent, publishToInternalStream } from "backend-rs"; export const meta = { tags: ["webhooks"], @@ -39,5 +39,5 @@ export default define(meta, paramDef, async (ps, user) => { await Webhooks.delete(webhook.id); - publishInternalEvent("webhookDeleted", webhook); + publishToInternalStream(InternalEvent.WebhookDeleted, webhook); }); diff --git a/packages/backend/src/server/api/endpoints/i/webhooks/update.ts b/packages/backend/src/server/api/endpoints/i/webhooks/update.ts index 4a211b915f..f65690e142 100644 --- a/packages/backend/src/server/api/endpoints/i/webhooks/update.ts +++ b/packages/backend/src/server/api/endpoints/i/webhooks/update.ts @@ -1,7 +1,7 @@ import define from "@/server/api/define.js"; import { ApiError } from "@/server/api/error.js"; import { Webhooks } from "@/models/index.js"; -import { publishInternalEvent } from "@/services/stream.js"; +import { InternalEvent, publishToInternalStream } from "backend-rs"; import { webhookEventTypes } from "@/models/entities/webhook.js"; export const meta = { @@ -57,5 +57,5 @@ export default define(meta, paramDef, async (ps, user) => { active: ps.active, }); - publishInternalEvent("webhookUpdated", webhook); + publishToInternalStream(InternalEvent.WebhookUpdated, webhook); }); diff --git a/packages/backend/src/services/stream.ts b/packages/backend/src/services/stream.ts index 71c6a3cc65..00f5dc92fa 100644 --- a/packages/backend/src/services/stream.ts +++ b/packages/backend/src/services/stream.ts @@ -14,7 +14,7 @@ import type { // ChannelStreamTypes, // DriveStreamTypes, // GroupMessagingStreamTypes, - InternalStreamTypes, + // InternalStreamTypes, // MainStreamTypes, // MessagingIndexStreamTypes, // MessagingStreamTypes, @@ -45,12 +45,13 @@ class Publisher { ); }; - public publishInternalEvent = ( - type: K, - value?: InternalStreamTypes[K], - ): void => { - this.publish("internal", type, typeof value === "undefined" ? null : value); - }; + /* ported to backend-rs */ + // public publishInternalEvent = ( + // type: K, + // value?: InternalStreamTypes[K], + // ): void => { + // this.publish("internal", type, typeof value === "undefined" ? null : value); + // }; public publishUserEvent = ( userId: User["id"], @@ -215,7 +216,7 @@ const publisher = new Publisher(); export default publisher; -export const publishInternalEvent = publisher.publishInternalEvent; +// export const publishInternalEvent = publisher.publishInternalEvent; export const publishUserEvent = publisher.publishUserEvent; // export const publishBroadcastStream = publisher.publishBroadcastStream; // export const publishMainStream = publisher.publishMainStream; diff --git a/packages/backend/src/services/suspend-user.ts b/packages/backend/src/services/suspend-user.ts index 22b83d3fdb..6bf271ba7f 100644 --- a/packages/backend/src/services/suspend-user.ts +++ b/packages/backend/src/services/suspend-user.ts @@ -5,13 +5,13 @@ import { config } from "@/config.js"; import type { User } from "@/models/entities/user.js"; import { Users, Followings } from "@/models/index.js"; import { Not, IsNull } from "typeorm"; -import { publishInternalEvent } from "@/services/stream.js"; +import { InternalEvent, publishToInternalStream } from "backend-rs"; export async function doPostSuspend(user: { id: User["id"]; host: User["host"]; }) { - publishInternalEvent("userChangeSuspendedState", { + await publishToInternalStream(InternalEvent.Suspend, { id: user.id, isSuspended: true, }); diff --git a/packages/backend/src/services/unsuspend-user.ts b/packages/backend/src/services/unsuspend-user.ts index b5e83a4151..33db77b0a3 100644 --- a/packages/backend/src/services/unsuspend-user.ts +++ b/packages/backend/src/services/unsuspend-user.ts @@ -6,10 +6,10 @@ import { config } from "@/config.js"; import type { User } from "@/models/entities/user.js"; import { Users, Followings } from "@/models/index.js"; import { Not, IsNull } from "typeorm"; -import { publishInternalEvent } from "@/services/stream.js"; +import { InternalEvent, publishToInternalStream } from "backend-rs"; export async function doPostUnsuspend(user: User) { - publishInternalEvent("userChangeSuspendedState", { + publishToInternalStream(InternalEvent.Suspend, { id: user.id, isSuspended: false, }); From b6498a12e8e76562a98eb23116cc695a816fa147 Mon Sep 17 00:00:00 2001 From: naskya Date: Sat, 27 Jul 2024 21:02:48 +0900 Subject: [PATCH 33/43] refactor (backend): port publishUserEvent to backend-rs --- packages/backend-rs/index.d.ts | 13 ++++++ packages/backend-rs/index.js | 2 + packages/backend-rs/src/service/stream.rs | 1 + .../backend-rs/src/service/stream/user.rs | 41 +++++++++++++++++++ .../system/check-expired-mutings.ts | 10 +++-- .../api/endpoints/admin/accounts/delete.ts | 4 +- .../api/endpoints/admin/suspend-user.ts | 4 +- .../server/api/endpoints/channels/follow.ts | 5 +-- .../server/api/endpoints/channels/unfollow.ts | 4 +- .../api/endpoints/i/regenerate-token.ts | 5 ++- .../server/api/endpoints/i/revoke-token.ts | 4 +- .../src/server/api/endpoints/i/update.ts | 14 ++++--- .../src/server/api/endpoints/mute/create.ts | 5 +-- .../src/server/api/endpoints/mute/delete.ts | 4 +- .../api/endpoints/renote-mute/create.ts | 2 +- .../api/endpoints/renote-mute/delete.ts | 2 +- .../server/api/endpoints/reply-mute/create.ts | 2 +- .../server/api/endpoints/reply-mute/delete.ts | 2 +- .../src/server/api/mastodon/helpers/list.ts | 4 +- .../src/server/api/mastodon/helpers/user.ts | 7 ++-- .../backend/src/server/api/stream/types.ts | 1 - .../backend/src/services/blocking/create.ts | 15 ++++--- .../backend/src/services/delete-account.ts | 4 +- .../backend/src/services/following/create.ts | 9 ++-- .../backend/src/services/following/delete.ts | 12 ++++-- .../backend/src/services/following/reject.ts | 10 +++-- packages/backend/src/services/i/update.ts | 16 +++++--- packages/backend/src/services/stream.ts | 29 ++++++------- 28 files changed, 155 insertions(+), 76 deletions(-) create mode 100644 packages/backend-rs/src/service/stream/user.rs diff --git a/packages/backend-rs/index.d.ts b/packages/backend-rs/index.d.ts index 8139084116..d939266207 100644 --- a/packages/backend-rs/index.d.ts +++ b/packages/backend-rs/index.d.ts @@ -1191,6 +1191,8 @@ export declare function publishToNoteStream(noteId: string, kind: NoteEvent, obj export declare function publishToNoteUpdatesStream(note: Note): Promise +export declare function publishToUserStream(userId: string, kind: UserEvent, object: any): Promise + export interface PugArgs { img: string | null title: string @@ -1482,6 +1484,17 @@ export type UserEmojiModPerm = 'add'| 'mod'| 'unauthorized'; +export declare enum UserEvent { + Disconnect = 0, + FollowChannel = 1, + UnfollowChannel = 2, + UpdateProfile = 3, + Mute = 4, + Unmute = 5, + Follow = 6, + Unfollow = 7 +} + export interface UserGroup { id: string createdAt: DateTimeWithTimeZone diff --git a/packages/backend-rs/index.js b/packages/backend-rs/index.js index 9d17a05028..9ca4963455 100644 --- a/packages/backend-rs/index.js +++ b/packages/backend-rs/index.js @@ -432,6 +432,7 @@ module.exports.publishToModerationStream = nativeBinding.publishToModerationStre module.exports.publishToNotesStream = nativeBinding.publishToNotesStream module.exports.publishToNoteStream = nativeBinding.publishToNoteStream module.exports.publishToNoteUpdatesStream = nativeBinding.publishToNoteUpdatesStream +module.exports.publishToUserStream = nativeBinding.publishToUserStream module.exports.PushNotificationKind = nativeBinding.PushNotificationKind module.exports.PushSubscriptionType = nativeBinding.PushSubscriptionType module.exports.RelayStatus = nativeBinding.RelayStatus @@ -454,6 +455,7 @@ module.exports.updateAntennasOnNewNote = nativeBinding.updateAntennasOnNewNote module.exports.updateMetaCache = nativeBinding.updateMetaCache module.exports.updateNodeinfoCache = nativeBinding.updateNodeinfoCache module.exports.UserEmojiModPerm = nativeBinding.UserEmojiModPerm +module.exports.UserEvent = nativeBinding.UserEvent module.exports.UserProfileFfvisibility = nativeBinding.UserProfileFfvisibility module.exports.UserProfileMutingNotificationTypes = nativeBinding.UserProfileMutingNotificationTypes module.exports.verifyPassword = nativeBinding.verifyPassword diff --git a/packages/backend-rs/src/service/stream.rs b/packages/backend-rs/src/service/stream.rs index 47b3891f63..bd412b26a9 100644 --- a/packages/backend-rs/src/service/stream.rs +++ b/packages/backend-rs/src/service/stream.rs @@ -11,6 +11,7 @@ pub mod moderation; pub mod note; pub mod note_edit; pub mod notes; +pub mod user; use crate::{ config::CONFIG, diff --git a/packages/backend-rs/src/service/stream/user.rs b/packages/backend-rs/src/service/stream/user.rs new file mode 100644 index 0000000000..fa18456891 --- /dev/null +++ b/packages/backend-rs/src/service/stream/user.rs @@ -0,0 +1,41 @@ +use crate::service::stream::{publish_to_stream, Error, Stream}; + +#[macros::export] +pub enum UserEvent { + Disconnect, + FollowChannel, + UnfollowChannel, + UpdateProfile, + Mute, + Unmute, + Follow, + Unfollow, +} + +// We want to merge `kind` and `object` into a single enum +// https://github.com/napi-rs/napi-rs/issues/2036 + +#[macros::export(js_name = "publishToUserStream")] +pub async fn publish( + user_id: String, + kind: UserEvent, + object: &serde_json::Value, +) -> Result<(), Error> { + let kind = match kind { + UserEvent::Disconnect => "terminate", + UserEvent::FollowChannel => "followChannel", + UserEvent::UnfollowChannel => "unfollowChannel", + UserEvent::UpdateProfile => "updateUserProfile", + UserEvent::Mute => "mute", + UserEvent::Unmute => "unmute", + UserEvent::Follow => "follow", + UserEvent::Unfollow => "unfollow", + }; + + publish_to_stream( + &Stream::User { user_id }, + Some(kind), + Some(serde_json::to_string(&object)?), + ) + .await +} diff --git a/packages/backend/src/queue/processors/system/check-expired-mutings.ts b/packages/backend/src/queue/processors/system/check-expired-mutings.ts index 05518ae8e1..8a189fd5cd 100644 --- a/packages/backend/src/queue/processors/system/check-expired-mutings.ts +++ b/packages/backend/src/queue/processors/system/check-expired-mutings.ts @@ -2,7 +2,7 @@ import type Bull from "bull"; import { In } from "typeorm"; import { Mutings } from "@/models/index.js"; import { queueLogger } from "../../logger.js"; -import { publishUserEvent } from "@/services/stream.js"; +import { publishToUserStream, UserEvent } from "backend-rs"; const logger = queueLogger.createSubLogger("check-expired-mutings"); @@ -23,9 +23,11 @@ export async function checkExpiredMutings( id: In(expired.map((m) => m.id)), }); - for (const m of expired) { - publishUserEvent(m.muterId, "unmute", m.mutee!); - } + await Promise.all( + expired.map((m) => + publishToUserStream(m.muterId, UserEvent.Unmute, m.mutee), + ), + ); } logger.info("All expired mutings checked."); diff --git a/packages/backend/src/server/api/endpoints/admin/accounts/delete.ts b/packages/backend/src/server/api/endpoints/admin/accounts/delete.ts index 4235180838..815b3b3061 100644 --- a/packages/backend/src/server/api/endpoints/admin/accounts/delete.ts +++ b/packages/backend/src/server/api/endpoints/admin/accounts/delete.ts @@ -1,7 +1,7 @@ import define from "@/server/api/define.js"; import { Users } from "@/models/index.js"; import { doPostSuspend } from "@/services/suspend-user.js"; -import { publishUserEvent } from "@/services/stream.js"; +import { publishToUserStream, UserEvent } from "backend-rs"; import { createDeleteAccountJob } from "@/queue/index.js"; export const meta = { @@ -53,6 +53,6 @@ export default define(meta, paramDef, async (ps, me) => { if (Users.isLocalUser(user)) { // Terminate streaming - publishUserEvent(user.id, "terminate", {}); + await publishToUserStream(user.id, UserEvent.Disconnect, {}); } }); diff --git a/packages/backend/src/server/api/endpoints/admin/suspend-user.ts b/packages/backend/src/server/api/endpoints/admin/suspend-user.ts index c6d6f47bc6..03fde41fca 100644 --- a/packages/backend/src/server/api/endpoints/admin/suspend-user.ts +++ b/packages/backend/src/server/api/endpoints/admin/suspend-user.ts @@ -4,7 +4,7 @@ import { Users, Followings, Notifications } from "@/models/index.js"; import type { User } from "@/models/entities/user.js"; import { insertModerationLog } from "@/services/insert-moderation-log.js"; import { doPostSuspend } from "@/services/suspend-user.js"; -import { publishUserEvent } from "@/services/stream.js"; +import { publishToUserStream, UserEvent } from "backend-rs"; export const meta = { tags: ["admin"], @@ -46,7 +46,7 @@ export default define(meta, paramDef, async (ps, me) => { // Terminate streaming if (Users.isLocalUser(user)) { - publishUserEvent(user.id, "terminate", {}); + await publishToUserStream(user.id, UserEvent.Disconnect, {}); } (async () => { diff --git a/packages/backend/src/server/api/endpoints/channels/follow.ts b/packages/backend/src/server/api/endpoints/channels/follow.ts index afc55ac1cf..9f8b0c2317 100644 --- a/packages/backend/src/server/api/endpoints/channels/follow.ts +++ b/packages/backend/src/server/api/endpoints/channels/follow.ts @@ -1,8 +1,7 @@ import define from "@/server/api/define.js"; import { ApiError } from "@/server/api/error.js"; import { Channels, ChannelFollowings } from "@/models/index.js"; -import { genIdAt } from "backend-rs"; -import { publishUserEvent } from "@/services/stream.js"; +import { genIdAt, publishToUserStream, UserEvent } from "backend-rs"; export const meta = { tags: ["channels"], @@ -46,5 +45,5 @@ export default define(meta, paramDef, async (ps, user) => { followeeId: channel.id, }); - publishUserEvent(user.id, "followChannel", channel); + await publishToUserStream(user.id, UserEvent.FollowChannel, channel); }); diff --git a/packages/backend/src/server/api/endpoints/channels/unfollow.ts b/packages/backend/src/server/api/endpoints/channels/unfollow.ts index 3371000394..6c0e26bb53 100644 --- a/packages/backend/src/server/api/endpoints/channels/unfollow.ts +++ b/packages/backend/src/server/api/endpoints/channels/unfollow.ts @@ -1,7 +1,7 @@ import define from "@/server/api/define.js"; import { ApiError } from "@/server/api/error.js"; import { Channels, ChannelFollowings } from "@/models/index.js"; -import { publishUserEvent } from "@/services/stream.js"; +import { publishToUserStream, UserEvent } from "backend-rs"; export const meta = { tags: ["channels"], @@ -41,5 +41,5 @@ export default define(meta, paramDef, async (ps, user) => { followeeId: channel.id, }); - publishUserEvent(user.id, "unfollowChannel", channel); + await publishToUserStream(user.id, UserEvent.UnfollowChannel, channel); }); diff --git a/packages/backend/src/server/api/endpoints/i/regenerate-token.ts b/packages/backend/src/server/api/endpoints/i/regenerate-token.ts index 5666a0011f..e17a483378 100644 --- a/packages/backend/src/server/api/endpoints/i/regenerate-token.ts +++ b/packages/backend/src/server/api/endpoints/i/regenerate-token.ts @@ -1,4 +1,3 @@ -import { publishUserEvent } from "@/services/stream.js"; import define from "@/server/api/define.js"; import { Users, UserProfiles } from "@/models/index.js"; import { @@ -7,6 +6,8 @@ import { InternalEvent, publishToInternalStream, publishToMainStream, + publishToUserStream, + UserEvent, verifyPassword, } from "backend-rs"; @@ -53,6 +54,6 @@ export default define(meta, paramDef, async (ps, user) => { // Terminate streaming setTimeout(() => { - publishUserEvent(user.id, "terminate", {}); + publishToUserStream(user.id, UserEvent.Disconnect, {}); }, 5000); }); diff --git a/packages/backend/src/server/api/endpoints/i/revoke-token.ts b/packages/backend/src/server/api/endpoints/i/revoke-token.ts index e38b330742..ba8d90f91a 100644 --- a/packages/backend/src/server/api/endpoints/i/revoke-token.ts +++ b/packages/backend/src/server/api/endpoints/i/revoke-token.ts @@ -1,6 +1,6 @@ import define from "@/server/api/define.js"; import { AccessTokens } from "@/models/index.js"; -import { publishUserEvent } from "@/services/stream.js"; +import { publishToUserStream, UserEvent } from "backend-rs"; export const meta = { requireCredential: true, @@ -26,6 +26,6 @@ export default define(meta, paramDef, async (ps, user) => { }); // Terminate streaming - publishUserEvent(user.id, "terminate"); + await publishToUserStream(user.id, UserEvent.Disconnect, {}); } }); diff --git a/packages/backend/src/server/api/endpoints/i/update.ts b/packages/backend/src/server/api/endpoints/i/update.ts index 0620f837ff..5f2a18867b 100644 --- a/packages/backend/src/server/api/endpoints/i/update.ts +++ b/packages/backend/src/server/api/endpoints/i/update.ts @@ -1,6 +1,10 @@ import * as mfm from "mfm-js"; -import { publishUserEvent } from "@/services/stream.js"; -import { Event, publishToMainStream } from "backend-rs"; +import { + Event, + publishToMainStream, + publishToUserStream, + UserEvent, +} from "backend-rs"; import acceptAllFollowRequests from "@/services/following/requests/accept-all.js"; import { publishToFollowers } from "@/services/i/update.js"; import { extractCustomEmojisFromMfm } from "@/misc/extract-custom-emojis-from-mfm.js"; @@ -346,10 +350,10 @@ export default define(meta, paramDef, async (ps, _user, token) => { }); // Publish meUpdated event - publishToMainStream(user.id, Event.Me, iObj); - publishUserEvent( + await publishToMainStream(user.id, Event.Me, iObj); + await publishToUserStream( user.id, - "updateUserProfile", + UserEvent.UpdateProfile, await UserProfiles.findOneBy({ userId: user.id }), ); diff --git a/packages/backend/src/server/api/endpoints/mute/create.ts b/packages/backend/src/server/api/endpoints/mute/create.ts index c8d6744b1b..a7c9fc6158 100644 --- a/packages/backend/src/server/api/endpoints/mute/create.ts +++ b/packages/backend/src/server/api/endpoints/mute/create.ts @@ -1,10 +1,9 @@ import define from "@/server/api/define.js"; import { ApiError } from "@/server/api/error.js"; import { getUser } from "@/server/api/common/getters.js"; -import { genIdAt } from "backend-rs"; +import { genIdAt, publishToUserStream, UserEvent } from "backend-rs"; import { Mutings, NoteWatchings } from "@/models/index.js"; import type { Muting } from "@/models/entities/muting.js"; -import { publishUserEvent } from "@/services/stream.js"; export const meta = { tags: ["account"], @@ -88,7 +87,7 @@ export default define(meta, paramDef, async (ps, user) => { muteeId: mutee.id, } as Muting); - publishUserEvent(user.id, "mute", mutee); + await publishToUserStream(user.id, UserEvent.Mute, mutee); NoteWatchings.delete({ userId: muter.id, diff --git a/packages/backend/src/server/api/endpoints/mute/delete.ts b/packages/backend/src/server/api/endpoints/mute/delete.ts index 8058e9a612..9d0dbb661e 100644 --- a/packages/backend/src/server/api/endpoints/mute/delete.ts +++ b/packages/backend/src/server/api/endpoints/mute/delete.ts @@ -2,7 +2,7 @@ import define from "@/server/api/define.js"; import { ApiError } from "@/server/api/error.js"; import { getUser } from "@/server/api/common/getters.js"; import { Mutings } from "@/models/index.js"; -import { publishUserEvent } from "@/services/stream.js"; +import { publishToUserStream, UserEvent } from "backend-rs"; export const meta = { tags: ["account"], @@ -70,5 +70,5 @@ export default define(meta, paramDef, async (ps, user) => { id: muting.id, }); - publishUserEvent(user.id, "unmute", mutee); + await publishToUserStream(user.id, UserEvent.Unmute, mutee); }); diff --git a/packages/backend/src/server/api/endpoints/renote-mute/create.ts b/packages/backend/src/server/api/endpoints/renote-mute/create.ts index 3b2c22a98a..760b819c64 100644 --- a/packages/backend/src/server/api/endpoints/renote-mute/create.ts +++ b/packages/backend/src/server/api/endpoints/renote-mute/create.ts @@ -66,5 +66,5 @@ export default define(meta, paramDef, async (ps, user) => { muteeId: mutee.id, } as RenoteMuting); - // publishUserEvent(user.id, "mute", mutee); + // await publishToUserStream(user.id, UserEvent.RenoteMute, mutee); }); diff --git a/packages/backend/src/server/api/endpoints/renote-mute/delete.ts b/packages/backend/src/server/api/endpoints/renote-mute/delete.ts index 6a824881b0..286db219db 100644 --- a/packages/backend/src/server/api/endpoints/renote-mute/delete.ts +++ b/packages/backend/src/server/api/endpoints/renote-mute/delete.ts @@ -59,5 +59,5 @@ export default define(meta, paramDef, async (ps, user) => { id: muting.id, }); - // publishUserEvent(user.id, "unmute", mutee); + // await publishToUserStream(user.id, UserEvent.RenoteUnMute, mutee); }); diff --git a/packages/backend/src/server/api/endpoints/reply-mute/create.ts b/packages/backend/src/server/api/endpoints/reply-mute/create.ts index 2d9f260b28..97a8faeb33 100644 --- a/packages/backend/src/server/api/endpoints/reply-mute/create.ts +++ b/packages/backend/src/server/api/endpoints/reply-mute/create.ts @@ -66,5 +66,5 @@ export default define(meta, paramDef, async (ps, user) => { muteeId: mutee.id, } as ReplyMuting); - // publishUserEvent(user.id, "mute", mutee); + // await publishToUserStream(user.id, UserEvent.ReplyMute, mutee); }); diff --git a/packages/backend/src/server/api/endpoints/reply-mute/delete.ts b/packages/backend/src/server/api/endpoints/reply-mute/delete.ts index 152d3fca60..28125d6a12 100644 --- a/packages/backend/src/server/api/endpoints/reply-mute/delete.ts +++ b/packages/backend/src/server/api/endpoints/reply-mute/delete.ts @@ -59,5 +59,5 @@ export default define(meta, paramDef, async (ps, user) => { id: record.id, }); - // publishUserEvent(user.id, "unmute", mutee); + // await publishToUserStream(user.id, UserEvent.ReplyUnmute, mutee); }); diff --git a/packages/backend/src/server/api/mastodon/helpers/list.ts b/packages/backend/src/server/api/mastodon/helpers/list.ts index b7564c1048..6937c2e023 100644 --- a/packages/backend/src/server/api/mastodon/helpers/list.ts +++ b/packages/backend/src/server/api/mastodon/helpers/list.ts @@ -195,9 +195,9 @@ export class ListHelpers { if (exclusive !== undefined) { UserListJoinings.findBy({ userListId: list.id }).then((members) => { for (const member of members) { - publishUserEvent( + await publishToUserStream( list.userId, - exclusive ? "userHidden" : "userUnhidden", + exclusive ? UserEvent.Hidden : UserEvent.Unhidden, member.userId, ); } diff --git a/packages/backend/src/server/api/mastodon/helpers/user.ts b/packages/backend/src/server/api/mastodon/helpers/user.ts index 609b2224cf..008429b9e1 100644 --- a/packages/backend/src/server/api/mastodon/helpers/user.ts +++ b/packages/backend/src/server/api/mastodon/helpers/user.ts @@ -27,9 +27,8 @@ import deleteFollowing from "@/services/following/delete.js"; import cancelFollowRequest from "@/services/following/requests/cancel.js"; import createBlocking from "@/services/blocking/create.js"; import deleteBlocking from "@/services/blocking/delete.js"; -import { genId } from "backend-rs"; +import { genId, publishToUserStream, UserEvent } from "backend-rs"; import type { Muting } from "@/models/entities/muting.js"; -import { publishUserEvent } from "@/services/stream.js"; import { UserConverter } from "@/server/api/mastodon/converters/user.js"; import acceptFollowRequest from "@/services/following/requests/accept.js"; import { rejectFollowRequest } from "@/services/following/reject.js"; @@ -152,7 +151,7 @@ export class UserHelpers { muteeId: target.id, } as Muting); - publishUserEvent(localUser.id, "mute", target); + await publishToUserStream(localUser.id, UserEvent.Mute, target); NoteWatchings.delete({ userId: localUser.id, @@ -177,7 +176,7 @@ export class UserHelpers { id: muting.id, }); - publishUserEvent(localUser.id, "unmute", target); + await publishToUserStream(localUser.id, UserEvent.Unmute, target); } return this.getUserRelationshipTo(target.id, localUser.id); diff --git a/packages/backend/src/server/api/stream/types.ts b/packages/backend/src/server/api/stream/types.ts index 138bcedfae..8f0d5a06af 100644 --- a/packages/backend/src/server/api/stream/types.ts +++ b/packages/backend/src/server/api/stream/types.ts @@ -63,7 +63,6 @@ export interface UserStreamTypes { unmute: User; follow: Packed<"UserDetailedNotMe">; unfollow: Packed<"User">; - userAdded: Packed<"User">; } export interface MainStreamTypes { diff --git a/packages/backend/src/services/blocking/create.ts b/packages/backend/src/services/blocking/create.ts index 02ac813967..1d7b80ffbf 100644 --- a/packages/backend/src/services/blocking/create.ts +++ b/packages/backend/src/services/blocking/create.ts @@ -1,4 +1,3 @@ -import { publishUserEvent } from "@/services/stream.js"; import { renderActivity } from "@/remote/activitypub/renderer/index.js"; import renderFollow from "@/remote/activitypub/renderer/follow.js"; import { renderUndo } from "@/remote/activitypub/renderer/undo.js"; @@ -15,7 +14,13 @@ import { UserListJoinings, UserLists, } from "@/models/index.js"; -import { Event, genIdAt, publishToMainStream } from "backend-rs"; +import { + Event, + genIdAt, + publishToMainStream, + publishToUserStream, + UserEvent, +} from "backend-rs"; import { getActiveWebhooks } from "@/misc/webhook-cache.js"; import { webhookDeliver } from "@/queue/index.js"; @@ -72,8 +77,8 @@ async function cancelRequest(follower: User, followee: User) { Users.pack(followee, follower, { detail: true, }).then(async (packed) => { - publishUserEvent(follower.id, "unfollow", packed); - publishToMainStream(follower.id, Event.Unfollow, packed); + await publishToUserStream(follower.id, UserEvent.Unfollow, packed); + await publishToMainStream(follower.id, Event.Unfollow, packed); const webhooks = (await getActiveWebhooks()).filter( (x) => x.userId === follower.id && x.on.includes("unfollow"), @@ -127,7 +132,7 @@ async function unFollow(follower: User, followee: User) { Users.pack(followee, follower, { detail: true, }).then(async (packed) => { - publishUserEvent(follower.id, "unfollow", packed); + publishToUserStream(follower.id, UserEvent.Unfollow, packed); publishToMainStream(follower.id, Event.Unfollow, packed); const webhooks = (await getActiveWebhooks()).filter( diff --git a/packages/backend/src/services/delete-account.ts b/packages/backend/src/services/delete-account.ts index b307611cf5..117c45e612 100644 --- a/packages/backend/src/services/delete-account.ts +++ b/packages/backend/src/services/delete-account.ts @@ -1,6 +1,6 @@ import { Users } from "@/models/index.js"; import { createDeleteAccountJob } from "@/queue/index.js"; -import { publishUserEvent } from "@/services/stream.js"; +import { publishToUserStream, UserEvent } from "backend-rs"; import { doPostSuspend } from "@/services/suspend-user.js"; export async function deleteAccount(user: { @@ -19,5 +19,5 @@ export async function deleteAccount(user: { }); // Terminate streaming - publishUserEvent(user.id, "terminate", {}); + await publishToUserStream(user.id, UserEvent.Disconnect, {}); } diff --git a/packages/backend/src/services/following/create.ts b/packages/backend/src/services/following/create.ts index 1c962c9e9e..aea5bd48a5 100644 --- a/packages/backend/src/services/following/create.ts +++ b/packages/backend/src/services/following/create.ts @@ -1,4 +1,3 @@ -import { publishUserEvent } from "@/services/stream.js"; import { renderActivity } from "@/remote/activitypub/renderer/index.js"; import renderFollow from "@/remote/activitypub/renderer/follow.js"; import renderAccept from "@/remote/activitypub/renderer/accept.js"; @@ -22,6 +21,8 @@ import { genIdAt, isSilencedServer, publishToMainStream, + publishToUserStream, + UserEvent, } from "backend-rs"; import { createNotification } from "@/services/create-notification.js"; import { isDuplicateKeyValueError } from "@/misc/is-duplicate-key-value-error.js"; @@ -126,12 +127,12 @@ export async function insertFollowingDoc( Users.pack(followee.id, follower, { detail: true, }).then(async (packed) => { - publishUserEvent( + await publishToUserStream( follower.id, - "follow", + UserEvent.Follow, packed as Packed<"UserDetailedNotMe">, ); - publishToMainStream( + await publishToMainStream( follower.id, Event.Follow, packed as Packed<"UserDetailedNotMe">, diff --git a/packages/backend/src/services/following/delete.ts b/packages/backend/src/services/following/delete.ts index 65d409f8bf..9d0135b81f 100644 --- a/packages/backend/src/services/following/delete.ts +++ b/packages/backend/src/services/following/delete.ts @@ -1,5 +1,9 @@ -import { publishUserEvent } from "@/services/stream.js"; -import { Event, publishToMainStream } from "backend-rs"; +import { + Event, + publishToMainStream, + publishToUserStream, + UserEvent, +} from "backend-rs"; import { renderActivity } from "@/remote/activitypub/renderer/index.js"; import renderFollow from "@/remote/activitypub/renderer/follow.js"; import { renderUndo } from "@/remote/activitypub/renderer/undo.js"; @@ -51,8 +55,8 @@ export default async function ( Users.pack(followee.id, follower, { detail: true, }).then(async (packed) => { - publishUserEvent(follower.id, "unfollow", packed); - publishToMainStream(follower.id, Event.Unfollow, packed); + await publishToUserStream(follower.id, UserEvent.Unfollow, packed); + await publishToMainStream(follower.id, Event.Unfollow, packed); const webhooks = (await getActiveWebhooks()).filter( (x) => x.userId === follower.id && x.on.includes("unfollow"), diff --git a/packages/backend/src/services/following/reject.ts b/packages/backend/src/services/following/reject.ts index 71f0220b14..1523573bf9 100644 --- a/packages/backend/src/services/following/reject.ts +++ b/packages/backend/src/services/following/reject.ts @@ -2,8 +2,12 @@ import { renderActivity } from "@/remote/activitypub/renderer/index.js"; import renderFollow from "@/remote/activitypub/renderer/follow.js"; import renderReject from "@/remote/activitypub/renderer/reject.js"; import { deliver, webhookDeliver } from "@/queue/index.js"; -import { publishUserEvent } from "@/services/stream.js"; -import { Event, publishToMainStream } from "backend-rs"; +import { + Event, + publishToMainStream, + publishToUserStream, + UserEvent, +} from "backend-rs"; import type { ILocalUser, IRemoteUser } from "@/models/entities/user.js"; import { Users, FollowRequests, Followings } from "@/models/index.js"; import { decrementFollowing } from "./delete.js"; @@ -120,7 +124,7 @@ async function publishUnfollow(followee: Both, follower: Local) { detail: true, }); - publishUserEvent(follower.id, "unfollow", packedFollowee); + publishToUserStream(follower.id, UserEvent.Unfollow, packedFollowee); publishToMainStream(follower.id, Event.Unfollow, packedFollowee); const webhooks = (await getActiveWebhooks()).filter( diff --git a/packages/backend/src/services/i/update.ts b/packages/backend/src/services/i/update.ts index f2752f069b..fcdf2f4f57 100644 --- a/packages/backend/src/services/i/update.ts +++ b/packages/backend/src/services/i/update.ts @@ -11,8 +11,12 @@ import mfm from "mfm-js"; import { extractHashtags } from "@/misc/extract-hashtags.js"; import { normalizeForSearch } from "@/misc/normalize-for-search.js"; import { updateUsertags } from "@/services/update-hashtag.js"; -import { publishUserEvent } from "@/services/stream.js"; -import { Event, publishToMainStream } from "backend-rs"; +import { + Event, + publishToMainStream, + publishToUserStream, + UserEvent, +} from "backend-rs"; import acceptAllFollowRequests from "@/services/following/requests/accept-all.js"; import { promiseEarlyReturn } from "@/prelude/promise.js"; @@ -80,15 +84,15 @@ export async function updateUserProfileData( includeSecrets: isSecure, }); - publishToMainStream(user.id, Event.Me, iObj); - publishUserEvent( + await publishToMainStream(user.id, Event.Me, iObj); + await publishToUserStream( user.id, - "updateUserProfile", + UserEvent.UpdateProfile, await UserProfiles.findOneByOrFail({ userId: user.id }), ); if (user.isLocked && updates.isLocked === false) { - acceptAllFollowRequests(user); + await acceptAllFollowRequests(user); } await promiseEarlyReturn( diff --git a/packages/backend/src/services/stream.ts b/packages/backend/src/services/stream.ts index 00f5dc92fa..0d13b8f5bb 100644 --- a/packages/backend/src/services/stream.ts +++ b/packages/backend/src/services/stream.ts @@ -1,5 +1,5 @@ import { redisClient } from "@/db/redis.js"; -import type { User } from "@/models/entities/user.js"; +// import type { User } from "@/models/entities/user.js"; // import type { Note } from "@/models/entities/note.js"; // import type { UserList } from "@/models/entities/user-list.js"; // import type { UserGroup } from "@/models/entities/user-group.js"; @@ -19,7 +19,7 @@ import type { // MessagingIndexStreamTypes, // MessagingStreamTypes, // NoteStreamTypes, - UserStreamTypes, + // UserStreamTypes, // NoteUpdatesStreamTypes, } from "@/server/api/stream/types.js"; @@ -53,17 +53,18 @@ class Publisher { // this.publish("internal", type, typeof value === "undefined" ? null : value); // }; - public publishUserEvent = ( - userId: User["id"], - type: K, - value?: UserStreamTypes[K], - ): void => { - this.publish( - `user:${userId}`, - type, - typeof value === "undefined" ? null : value, - ); - }; + /* ported to backend-rs */ + // public publishUserEvent = ( + // userId: User["id"], + // type: K, + // value?: UserStreamTypes[K], + // ): void => { + // this.publish( + // `user:${userId}`, + // type, + // typeof value === "undefined" ? null : value, + // ); + // }; /* ported to backend-rs */ // public publishBroadcastStream = ( @@ -217,7 +218,7 @@ const publisher = new Publisher(); export default publisher; // export const publishInternalEvent = publisher.publishInternalEvent; -export const publishUserEvent = publisher.publishUserEvent; +// export const publishUserEvent = publisher.publishUserEvent; // export const publishBroadcastStream = publisher.publishBroadcastStream; // export const publishMainStream = publisher.publishMainStream; // export const publishDriveStream = publisher.publishDriveStream; From 006b95315ce9439196fb0bcfe57dbf1696ec71c6 Mon Sep 17 00:00:00 2001 From: naskya Date: Sat, 27 Jul 2024 21:05:37 +0900 Subject: [PATCH 34/43] chore (backend): remove services/stream.ts --- packages/backend/src/services/stream.ts | 233 ------------------------ 1 file changed, 233 deletions(-) delete mode 100644 packages/backend/src/services/stream.ts diff --git a/packages/backend/src/services/stream.ts b/packages/backend/src/services/stream.ts deleted file mode 100644 index 0d13b8f5bb..0000000000 --- a/packages/backend/src/services/stream.ts +++ /dev/null @@ -1,233 +0,0 @@ -import { redisClient } from "@/db/redis.js"; -// import type { User } from "@/models/entities/user.js"; -// import type { Note } from "@/models/entities/note.js"; -// import type { UserList } from "@/models/entities/user-list.js"; -// import type { UserGroup } from "@/models/entities/user-group.js"; -import { config } from "@/config.js"; -// import type { Antenna } from "@/models/entities/antenna.js"; -// import type { Channel } from "@/models/entities/channel.js"; -import type { - StreamChannels, - // AdminStreamTypes, - // AntennaStreamTypes, - // BroadcastTypes, - // ChannelStreamTypes, - // DriveStreamTypes, - // GroupMessagingStreamTypes, - // InternalStreamTypes, - // MainStreamTypes, - // MessagingIndexStreamTypes, - // MessagingStreamTypes, - // NoteStreamTypes, - // UserStreamTypes, - // NoteUpdatesStreamTypes, -} from "@/server/api/stream/types.js"; - -class Publisher { - private publish = ( - channel: StreamChannels, - type: string | null, - value?: any, - ): void => { - const message = - type == null - ? value - : value == null - ? { type: type, body: null } - : { type: type, body: value }; - - redisClient.publish( - config.host, - JSON.stringify({ - channel: channel, - message: message, - }), - ); - }; - - /* ported to backend-rs */ - // public publishInternalEvent = ( - // type: K, - // value?: InternalStreamTypes[K], - // ): void => { - // this.publish("internal", type, typeof value === "undefined" ? null : value); - // }; - - /* ported to backend-rs */ - // public publishUserEvent = ( - // userId: User["id"], - // type: K, - // value?: UserStreamTypes[K], - // ): void => { - // this.publish( - // `user:${userId}`, - // type, - // typeof value === "undefined" ? null : value, - // ); - // }; - - /* ported to backend-rs */ - // public publishBroadcastStream = ( - // type: K, - // value?: BroadcastTypes[K], - // ): void => { - // this.publish( - // "broadcast", - // type, - // typeof value === "undefined" ? null : value, - // ); - // }; - - /* ported to backend-rs */ - // public publishMainStream = ( - // userId: User["id"], - // type: K, - // value?: MainStreamTypes[K], - // ): void => { - // this.publish( - // `mainStream:${userId}`, - // type, - // typeof value === "undefined" ? null : value, - // ); - // }; - - /* ported to backend-rs */ - // public publishDriveStream = ( - // userId: User["id"], - // type: K, - // value?: DriveStreamTypes[K], - // ): void => { - // this.publish( - // `driveStream:${userId}`, - // type, - // typeof value === "undefined" ? null : value, - // ); - // }; - - /* ported to backend-rs */ - // public publishNoteStream = ( - // noteId: Note["id"], - // type: K, - // value?: NoteStreamTypes[K], - // ): void => { - // this.publish(`noteStream:${noteId}`, type, { - // id: noteId, - // body: value, - // }); - // }; - - /* ported to backend-rs */ - // public publishNoteUpdatesStream = ( - // type: K, - // value: NoteUpdatesStreamTypes[K], - // ): void => { - // this.publish("noteUpdatesStream", type, value); - // }; - - /* ported to backend-rs */ - // public publishChannelStream = ( - // channelId: Channel["id"], - // type: K, - // value?: ChannelStreamTypes[K], - // ): void => { - // this.publish( - // `channelStream:${channelId}`, - // type, - // typeof value === "undefined" ? null : value, - // ); - // }; - - /* ported to backend-rs */ - // public publishAntennaStream = ( - // antennaId: Antenna["id"], - // type: K, - // value?: AntennaStreamTypes[K], - // ): void => { - // this.publish( - // `antennaStream:${antennaId}`, - // type, - // typeof value === "undefined" ? null : value, - // ); - // }; - - /* ported to backend-rs */ - // public publishMessagingStream = ( - // userId: User["id"], - // otherpartyId: User["id"], - // type: K, - // value?: MessagingStreamTypes[K], - // ): void => { - // this.publish( - // `messagingStream:${userId}-${otherpartyId}`, - // type, - // typeof value === "undefined" ? null : value, - // ); - // }; - - /* ported to backend-rs */ - // public publishGroupMessagingStream = < - // K extends keyof GroupMessagingStreamTypes, - // >( - // groupId: UserGroup["id"], - // type: K, - // value?: GroupMessagingStreamTypes[K], - // ): void => { - // this.publish( - // `messagingStream:${groupId}`, - // type, - // typeof value === "undefined" ? null : value, - // ); - // }; - - /* ported to backend-rs */ - // public publishMessagingIndexStream = < - // K extends keyof MessagingIndexStreamTypes, - // >( - // userId: User["id"], - // type: K, - // value?: MessagingIndexStreamTypes[K], - // ): void => { - // this.publish( - // `messagingIndexStream:${userId}`, - // type, - // typeof value === "undefined" ? null : value, - // ); - // }; - - /* ported to backend-rs */ - // public publishNotesStream = (note: Note): void => { - // this.publish("notesStream", null, note); - // }; - - /* ported to backend-rs */ - // public publishAdminStream = ( - // userId: User["id"], - // type: K, - // value?: AdminStreamTypes[K], - // ): void => { - // this.publish( - // `adminStream:${userId}`, - // type, - // typeof value === "undefined" ? null : value, - // ); - // }; -} - -const publisher = new Publisher(); - -export default publisher; - -// export const publishInternalEvent = publisher.publishInternalEvent; -// export const publishUserEvent = publisher.publishUserEvent; -// export const publishBroadcastStream = publisher.publishBroadcastStream; -// export const publishMainStream = publisher.publishMainStream; -// export const publishDriveStream = publisher.publishDriveStream; -// export const publishNoteStream = publisher.publishNoteStream; -// export const publishNotesStream = publisher.publishNotesStream; -// export const publishNoteUpdatesStream = publisher.publishNoteUpdatesStream; -// export const publishChannelStream = publisher.publishChannelStream; -// export const publishAntennaStream = publisher.publishAntennaStream; -// export const publishMessagingStream = publisher.publishMessagingStream; -// export const publishGroupMessagingStream = publisher.publishGroupMessagingStream; -// export const publishMessagingIndexStream = publisher.publishMessagingIndexStream; -// export const publishAdminStream = publisher.publishAdminStream; From bc5289835f26e5280e557a4581d1599622d44913 Mon Sep 17 00:00:00 2001 From: GitLab CI Date: Sat, 27 Jul 2024 12:23:46 +0000 Subject: [PATCH 35/43] chore(deps): update dependency @vitejs/plugin-vue to v5.1.1 --- packages/client/package.json | 2 +- pnpm-lock.yaml | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/client/package.json b/packages/client/package.json index 3113d0fb93..74f43868c0 100644 --- a/packages/client/package.json +++ b/packages/client/package.json @@ -33,7 +33,7 @@ "@types/throttle-debounce": "5.0.2", "@types/tinycolor2": "1.4.6", "@types/uuid": "10.0.0", - "@vitejs/plugin-vue": "5.1.0", + "@vitejs/plugin-vue": "5.1.1", "@vue/runtime-core": "3.4.34", "autobind-decorator": "2.4.0", "autosize": "6.0.1", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 2e2e4df7a2..7d2c9148dd 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -557,8 +557,8 @@ importers: specifier: 10.0.0 version: 10.0.0 '@vitejs/plugin-vue': - specifier: 5.1.0 - version: 5.1.0(vite@5.3.5(@types/node@20.14.12)(sass@1.77.8)(terser@5.31.3))(vue@3.4.34(typescript@5.5.4)) + specifier: 5.1.1 + version: 5.1.1(vite@5.3.5(@types/node@20.14.12)(sass@1.77.8)(terser@5.31.3))(vue@3.4.34(typescript@5.5.4)) '@vue/runtime-core': specifier: 3.4.34 version: 3.4.34 @@ -2608,8 +2608,8 @@ packages: '@types/yargs@17.0.32': resolution: {integrity: sha512-xQ67Yc/laOG5uMfX/093MRlGGCIBzZMarVa+gfNKJxWAIgykYpVGkBdbqEzGDDfCrVUj6Hiff4mTZ5BA6TmAog==} - '@vitejs/plugin-vue@5.1.0': - resolution: {integrity: sha512-QMRxARyrdiwi1mj3AW4fLByoHTavreXq0itdEW696EihXglf1MB3D4C2gBvE0jMPH29ZjC3iK8aIaUMLf4EOGA==} + '@vitejs/plugin-vue@5.1.1': + resolution: {integrity: sha512-sDckXxlHpMsjRQbAH9WanangrfrblsOd3pNifePs+FOHjJg1jfWq5L/P0PsBRndEt3nmdUnmvieP8ULDeX5AvA==} engines: {node: ^18.0.0 || >=20.0.0} peerDependencies: vite: ^5.0.0 @@ -8719,7 +8719,7 @@ snapshots: dependencies: '@types/yargs-parser': 21.0.3 - '@vitejs/plugin-vue@5.1.0(vite@5.3.5(@types/node@20.14.12)(sass@1.77.8)(terser@5.31.3))(vue@3.4.34(typescript@5.5.4))': + '@vitejs/plugin-vue@5.1.1(vite@5.3.5(@types/node@20.14.12)(sass@1.77.8)(terser@5.31.3))(vue@3.4.34(typescript@5.5.4))': dependencies: vite: 5.3.5(@types/node@20.14.12)(sass@1.77.8)(terser@5.31.3) vue: 3.4.34(typescript@5.5.4) From 23aecfcd277f09e625521a87775cfe47416e3ae7 Mon Sep 17 00:00:00 2001 From: GitLab CI Date: Sat, 27 Jul 2024 12:24:19 +0000 Subject: [PATCH 36/43] chore(deps): update dependency rollup to v4.19.1 --- packages/client/package.json | 2 +- pnpm-lock.yaml | 160 +++++++++++++++++------------------ 2 files changed, 81 insertions(+), 81 deletions(-) diff --git a/packages/client/package.json b/packages/client/package.json index 3113d0fb93..6970d58144 100644 --- a/packages/client/package.json +++ b/packages/client/package.json @@ -70,7 +70,7 @@ "punycode": "2.3.1", "qrcode": "1.5.3", "qrcode-vue3": "1.6.8", - "rollup": "4.19.0", + "rollup": "4.19.1", "s-age": "1.1.2", "sass": "1.77.8", "seedrandom": "3.0.5", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 2e2e4df7a2..badfbf0b60 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -507,13 +507,13 @@ importers: version: 2.1.1 '@rollup/plugin-alias': specifier: 5.1.0 - version: 5.1.0(rollup@4.19.0) + version: 5.1.0(rollup@4.19.1) '@rollup/plugin-json': specifier: 6.1.0 - version: 6.1.0(rollup@4.19.0) + version: 6.1.0(rollup@4.19.1) '@rollup/pluginutils': specifier: 5.1.0 - version: 5.1.0(rollup@4.19.0) + version: 5.1.0(rollup@4.19.1) '@syuilo/aiscript': specifier: 0.19.0 version: 0.19.0 @@ -668,8 +668,8 @@ importers: specifier: 1.6.8 version: 1.6.8 rollup: - specifier: 4.19.0 - version: 4.19.0 + specifier: 4.19.1 + version: 4.19.1 s-age: specifier: 1.1.2 version: 1.1.2 @@ -2168,83 +2168,83 @@ packages: rollup: optional: true - '@rollup/rollup-android-arm-eabi@4.19.0': - resolution: {integrity: sha512-JlPfZ/C7yn5S5p0yKk7uhHTTnFlvTgLetl2VxqE518QgyM7C9bSfFTYvB/Q/ftkq0RIPY4ySxTz+/wKJ/dXC0w==} + '@rollup/rollup-android-arm-eabi@4.19.1': + resolution: {integrity: sha512-XzqSg714++M+FXhHfXpS1tDnNZNpgxxuGZWlRG/jSj+VEPmZ0yg6jV4E0AL3uyBKxO8mO3xtOsP5mQ+XLfrlww==} cpu: [arm] os: [android] - '@rollup/rollup-android-arm64@4.19.0': - resolution: {integrity: sha512-RDxUSY8D1tWYfn00DDi5myxKgOk6RvWPxhmWexcICt/MEC6yEMr4HNCu1sXXYLw8iAsg0D44NuU+qNq7zVWCrw==} + '@rollup/rollup-android-arm64@4.19.1': + resolution: {integrity: sha512-thFUbkHteM20BGShD6P08aungq4irbIZKUNbG70LN8RkO7YztcGPiKTTGZS7Kw+x5h8hOXs0i4OaHwFxlpQN6A==} cpu: [arm64] os: [android] - '@rollup/rollup-darwin-arm64@4.19.0': - resolution: {integrity: sha512-emvKHL4B15x6nlNTBMtIaC9tLPRpeA5jMvRLXVbl/W9Ie7HhkrE7KQjvgS9uxgatL1HmHWDXk5TTS4IaNJxbAA==} + '@rollup/rollup-darwin-arm64@4.19.1': + resolution: {integrity: sha512-8o6eqeFZzVLia2hKPUZk4jdE3zW7LCcZr+MD18tXkgBBid3lssGVAYuox8x6YHoEPDdDa9ixTaStcmx88lio5Q==} cpu: [arm64] os: [darwin] - '@rollup/rollup-darwin-x64@4.19.0': - resolution: {integrity: sha512-fO28cWA1dC57qCd+D0rfLC4VPbh6EOJXrreBmFLWPGI9dpMlER2YwSPZzSGfq11XgcEpPukPTfEVFtw2q2nYJg==} + '@rollup/rollup-darwin-x64@4.19.1': + resolution: {integrity: sha512-4T42heKsnbjkn7ovYiAdDVRRWZLU9Kmhdt6HafZxFcUdpjlBlxj4wDrt1yFWLk7G4+E+8p2C9tcmSu0KA6auGA==} cpu: [x64] os: [darwin] - '@rollup/rollup-linux-arm-gnueabihf@4.19.0': - resolution: {integrity: sha512-2Rn36Ubxdv32NUcfm0wB1tgKqkQuft00PtM23VqLuCUR4N5jcNWDoV5iBC9jeGdgS38WK66ElncprqgMUOyomw==} + '@rollup/rollup-linux-arm-gnueabihf@4.19.1': + resolution: {integrity: sha512-MXg1xp+e5GhZ3Vit1gGEyoC+dyQUBy2JgVQ+3hUrD9wZMkUw/ywgkpK7oZgnB6kPpGrxJ41clkPPnsknuD6M2Q==} cpu: [arm] os: [linux] - '@rollup/rollup-linux-arm-musleabihf@4.19.0': - resolution: {integrity: sha512-gJuzIVdq/X1ZA2bHeCGCISe0VWqCoNT8BvkQ+BfsixXwTOndhtLUpOg0A1Fcx/+eA6ei6rMBzlOz4JzmiDw7JQ==} + '@rollup/rollup-linux-arm-musleabihf@4.19.1': + resolution: {integrity: sha512-DZNLwIY4ftPSRVkJEaxYkq7u2zel7aah57HESuNkUnz+3bZHxwkCUkrfS2IWC1sxK6F2QNIR0Qr/YXw7nkF3Pw==} cpu: [arm] os: [linux] - '@rollup/rollup-linux-arm64-gnu@4.19.0': - resolution: {integrity: sha512-0EkX2HYPkSADo9cfeGFoQ7R0/wTKb7q6DdwI4Yn/ULFE1wuRRCHybxpl2goQrx4c/yzK3I8OlgtBu4xvted0ug==} + '@rollup/rollup-linux-arm64-gnu@4.19.1': + resolution: {integrity: sha512-C7evongnjyxdngSDRRSQv5GvyfISizgtk9RM+z2biV5kY6S/NF/wta7K+DanmktC5DkuaJQgoKGf7KUDmA7RUw==} cpu: [arm64] os: [linux] - '@rollup/rollup-linux-arm64-musl@4.19.0': - resolution: {integrity: sha512-GlIQRj9px52ISomIOEUq/IojLZqzkvRpdP3cLgIE1wUWaiU5Takwlzpz002q0Nxxr1y2ZgxC2obWxjr13lvxNQ==} + '@rollup/rollup-linux-arm64-musl@4.19.1': + resolution: {integrity: sha512-89tFWqxfxLLHkAthAcrTs9etAoBFRduNfWdl2xUs/yLV+7XDrJ5yuXMHptNqf1Zw0UCA3cAutkAiAokYCkaPtw==} cpu: [arm64] os: [linux] - '@rollup/rollup-linux-powerpc64le-gnu@4.19.0': - resolution: {integrity: sha512-N6cFJzssruDLUOKfEKeovCKiHcdwVYOT1Hs6dovDQ61+Y9n3Ek4zXvtghPPelt6U0AH4aDGnDLb83uiJMkWYzQ==} + '@rollup/rollup-linux-powerpc64le-gnu@4.19.1': + resolution: {integrity: sha512-PromGeV50sq+YfaisG8W3fd+Cl6mnOOiNv2qKKqKCpiiEke2KiKVyDqG/Mb9GWKbYMHj5a01fq/qlUR28PFhCQ==} cpu: [ppc64] os: [linux] - '@rollup/rollup-linux-riscv64-gnu@4.19.0': - resolution: {integrity: sha512-2DnD3mkS2uuam/alF+I7M84koGwvn3ZVD7uG+LEWpyzo/bq8+kKnus2EVCkcvh6PlNB8QPNFOz6fWd5N8o1CYg==} + '@rollup/rollup-linux-riscv64-gnu@4.19.1': + resolution: {integrity: sha512-/1BmHYh+iz0cNCP0oHCuF8CSiNj0JOGf0jRlSo3L/FAyZyG2rGBuKpkZVH9YF+x58r1jgWxvm1aRg3DHrLDt6A==} cpu: [riscv64] os: [linux] - '@rollup/rollup-linux-s390x-gnu@4.19.0': - resolution: {integrity: sha512-D6pkaF7OpE7lzlTOFCB2m3Ngzu2ykw40Nka9WmKGUOTS3xcIieHe82slQlNq69sVB04ch73thKYIWz/Ian8DUA==} + '@rollup/rollup-linux-s390x-gnu@4.19.1': + resolution: {integrity: sha512-0cYP5rGkQWRZKy9/HtsWVStLXzCF3cCBTRI+qRL8Z+wkYlqN7zrSYm6FuY5Kd5ysS5aH0q5lVgb/WbG4jqXN1Q==} cpu: [s390x] os: [linux] - '@rollup/rollup-linux-x64-gnu@4.19.0': - resolution: {integrity: sha512-HBndjQLP8OsdJNSxpNIN0einbDmRFg9+UQeZV1eiYupIRuZsDEoeGU43NQsS34Pp166DtwQOnpcbV/zQxM+rWA==} + '@rollup/rollup-linux-x64-gnu@4.19.1': + resolution: {integrity: sha512-XUXeI9eM8rMP8aGvii/aOOiMvTs7xlCosq9xCjcqI9+5hBxtjDpD+7Abm1ZhVIFE1J2h2VIg0t2DX/gjespC2Q==} cpu: [x64] os: [linux] - '@rollup/rollup-linux-x64-musl@4.19.0': - resolution: {integrity: sha512-HxfbvfCKJe/RMYJJn0a12eiOI9OOtAUF4G6ozrFUK95BNyoJaSiBjIOHjZskTUffUrB84IPKkFG9H9nEvJGW6A==} + '@rollup/rollup-linux-x64-musl@4.19.1': + resolution: {integrity: sha512-V7cBw/cKXMfEVhpSvVZhC+iGifD6U1zJ4tbibjjN+Xi3blSXaj/rJynAkCFFQfoG6VZrAiP7uGVzL440Q6Me2Q==} cpu: [x64] os: [linux] - '@rollup/rollup-win32-arm64-msvc@4.19.0': - resolution: {integrity: sha512-HxDMKIhmcguGTiP5TsLNolwBUK3nGGUEoV/BO9ldUBoMLBssvh4J0X8pf11i1fTV7WShWItB1bKAKjX4RQeYmg==} + '@rollup/rollup-win32-arm64-msvc@4.19.1': + resolution: {integrity: sha512-88brja2vldW/76jWATlBqHEoGjJLRnP0WOEKAUbMcXaAZnemNhlAHSyj4jIwMoP2T750LE9lblvD4e2jXleZsA==} cpu: [arm64] os: [win32] - '@rollup/rollup-win32-ia32-msvc@4.19.0': - resolution: {integrity: sha512-xItlIAZZaiG/u0wooGzRsx11rokP4qyc/79LkAOdznGRAbOFc+SfEdfUOszG1odsHNgwippUJavag/+W/Etc6Q==} + '@rollup/rollup-win32-ia32-msvc@4.19.1': + resolution: {integrity: sha512-LdxxcqRVSXi6k6JUrTah1rHuaupoeuiv38du8Mt4r4IPer3kwlTo+RuvfE8KzZ/tL6BhaPlzJ3835i6CxrFIRQ==} cpu: [ia32] os: [win32] - '@rollup/rollup-win32-x64-msvc@4.19.0': - resolution: {integrity: sha512-xNo5fV5ycvCCKqiZcpB65VMR11NJB+StnxHz20jdqRAktfdfzhgjTiJ2doTDQE/7dqGaV5I7ZGqKpgph6lCIag==} + '@rollup/rollup-win32-x64-msvc@4.19.1': + resolution: {integrity: sha512-2bIrL28PcK3YCqD9anGxDxamxdiJAxA+l7fWIwM5o8UqNy1t3d1NdAweO2XhA0KTDJ5aH1FsuiT5+7VhtHliXg==} cpu: [x64] os: [win32] @@ -5875,8 +5875,8 @@ packages: rndstr@1.0.0: resolution: {integrity: sha512-3KN+BHTiHcsyW1qjRw3Xhms8TQfTIN4fUVgqqJpj6FnmuCnto5/lLyppSmGfdTmOiKDWeuXU4XPp58I9fsoWFQ==} - rollup@4.19.0: - resolution: {integrity: sha512-5r7EYSQIowHsK4eTZ0Y81qpZuJz+MUuYeqmmYmRMl1nwhdmbiYqt5jwzf6u7wyOzJgYqtCRMtVRKOtHANBz7rA==} + rollup@4.19.1: + resolution: {integrity: sha512-K5vziVlg7hTpYfFBI+91zHBEMo6jafYXpkMlqZjg7/zhIG9iHqazBf4xz9AVdjS9BruRn280ROqLI7G3OFRIlw==} engines: {node: '>=18.0.0', npm: '>=8.0.0'} hasBin: true @@ -8252,72 +8252,72 @@ snapshots: - encoding - supports-color - '@rollup/plugin-alias@5.1.0(rollup@4.19.0)': + '@rollup/plugin-alias@5.1.0(rollup@4.19.1)': dependencies: slash: 4.0.0 optionalDependencies: - rollup: 4.19.0 + rollup: 4.19.1 - '@rollup/plugin-json@6.1.0(rollup@4.19.0)': + '@rollup/plugin-json@6.1.0(rollup@4.19.1)': dependencies: - '@rollup/pluginutils': 5.1.0(rollup@4.19.0) + '@rollup/pluginutils': 5.1.0(rollup@4.19.1) optionalDependencies: - rollup: 4.19.0 + rollup: 4.19.1 - '@rollup/pluginutils@5.1.0(rollup@4.19.0)': + '@rollup/pluginutils@5.1.0(rollup@4.19.1)': dependencies: '@types/estree': 1.0.5 estree-walker: 2.0.2 picomatch: 2.3.1 optionalDependencies: - rollup: 4.19.0 + rollup: 4.19.1 - '@rollup/rollup-android-arm-eabi@4.19.0': + '@rollup/rollup-android-arm-eabi@4.19.1': optional: true - '@rollup/rollup-android-arm64@4.19.0': + '@rollup/rollup-android-arm64@4.19.1': optional: true - '@rollup/rollup-darwin-arm64@4.19.0': + '@rollup/rollup-darwin-arm64@4.19.1': optional: true - '@rollup/rollup-darwin-x64@4.19.0': + '@rollup/rollup-darwin-x64@4.19.1': optional: true - '@rollup/rollup-linux-arm-gnueabihf@4.19.0': + '@rollup/rollup-linux-arm-gnueabihf@4.19.1': optional: true - '@rollup/rollup-linux-arm-musleabihf@4.19.0': + '@rollup/rollup-linux-arm-musleabihf@4.19.1': optional: true - '@rollup/rollup-linux-arm64-gnu@4.19.0': + '@rollup/rollup-linux-arm64-gnu@4.19.1': optional: true - '@rollup/rollup-linux-arm64-musl@4.19.0': + '@rollup/rollup-linux-arm64-musl@4.19.1': optional: true - '@rollup/rollup-linux-powerpc64le-gnu@4.19.0': + '@rollup/rollup-linux-powerpc64le-gnu@4.19.1': optional: true - '@rollup/rollup-linux-riscv64-gnu@4.19.0': + '@rollup/rollup-linux-riscv64-gnu@4.19.1': optional: true - '@rollup/rollup-linux-s390x-gnu@4.19.0': + '@rollup/rollup-linux-s390x-gnu@4.19.1': optional: true - '@rollup/rollup-linux-x64-gnu@4.19.0': + '@rollup/rollup-linux-x64-gnu@4.19.1': optional: true - '@rollup/rollup-linux-x64-musl@4.19.0': + '@rollup/rollup-linux-x64-musl@4.19.1': optional: true - '@rollup/rollup-win32-arm64-msvc@4.19.0': + '@rollup/rollup-win32-arm64-msvc@4.19.1': optional: true - '@rollup/rollup-win32-ia32-msvc@4.19.0': + '@rollup/rollup-win32-ia32-msvc@4.19.1': optional: true - '@rollup/rollup-win32-x64-msvc@4.19.0': + '@rollup/rollup-win32-x64-msvc@4.19.1': optional: true '@sec-ant/readable-stream@0.4.1': {} @@ -12260,26 +12260,26 @@ snapshots: rangestr: 0.0.1 seedrandom: 2.4.2 - rollup@4.19.0: + rollup@4.19.1: dependencies: '@types/estree': 1.0.5 optionalDependencies: - '@rollup/rollup-android-arm-eabi': 4.19.0 - '@rollup/rollup-android-arm64': 4.19.0 - '@rollup/rollup-darwin-arm64': 4.19.0 - '@rollup/rollup-darwin-x64': 4.19.0 - '@rollup/rollup-linux-arm-gnueabihf': 4.19.0 - '@rollup/rollup-linux-arm-musleabihf': 4.19.0 - '@rollup/rollup-linux-arm64-gnu': 4.19.0 - '@rollup/rollup-linux-arm64-musl': 4.19.0 - '@rollup/rollup-linux-powerpc64le-gnu': 4.19.0 - '@rollup/rollup-linux-riscv64-gnu': 4.19.0 - '@rollup/rollup-linux-s390x-gnu': 4.19.0 - '@rollup/rollup-linux-x64-gnu': 4.19.0 - '@rollup/rollup-linux-x64-musl': 4.19.0 - '@rollup/rollup-win32-arm64-msvc': 4.19.0 - '@rollup/rollup-win32-ia32-msvc': 4.19.0 - '@rollup/rollup-win32-x64-msvc': 4.19.0 + '@rollup/rollup-android-arm-eabi': 4.19.1 + '@rollup/rollup-android-arm64': 4.19.1 + '@rollup/rollup-darwin-arm64': 4.19.1 + '@rollup/rollup-darwin-x64': 4.19.1 + '@rollup/rollup-linux-arm-gnueabihf': 4.19.1 + '@rollup/rollup-linux-arm-musleabihf': 4.19.1 + '@rollup/rollup-linux-arm64-gnu': 4.19.1 + '@rollup/rollup-linux-arm64-musl': 4.19.1 + '@rollup/rollup-linux-powerpc64le-gnu': 4.19.1 + '@rollup/rollup-linux-riscv64-gnu': 4.19.1 + '@rollup/rollup-linux-s390x-gnu': 4.19.1 + '@rollup/rollup-linux-x64-gnu': 4.19.1 + '@rollup/rollup-linux-x64-musl': 4.19.1 + '@rollup/rollup-win32-arm64-msvc': 4.19.1 + '@rollup/rollup-win32-ia32-msvc': 4.19.1 + '@rollup/rollup-win32-x64-msvc': 4.19.1 fsevents: 2.3.3 rrweb-cssom@0.6.0: {} @@ -12993,7 +12993,7 @@ snapshots: dependencies: esbuild: 0.21.5 postcss: 8.4.39 - rollup: 4.19.0 + rollup: 4.19.1 optionalDependencies: '@types/node': 20.14.12 fsevents: 2.3.3 From 4b892a7be93bb5a872a8e1ee0116d6e5f5f71671 Mon Sep 17 00:00:00 2001 From: GitLab CI Date: Sat, 27 Jul 2024 12:25:40 +0000 Subject: [PATCH 37/43] chore(deps): update rust crate tokio to 1.39.2 --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index d52b933fa2..80cff6e24b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3687,9 +3687,9 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.39.1" +version = "1.39.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d040ac2b29ab03b09d4129c2f5bbd012a3ac2f79d38ff506a4bf8dd34b0eac8a" +checksum = "daa4fb1bc778bd6f04cbfc4bb2d06a7396a8f299dc33ea1900cedaa316f467b1" dependencies = [ "backtrace", "bytes", diff --git a/Cargo.toml b/Cargo.toml index 266f4beb38..b1d594a12f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -42,7 +42,7 @@ serde_yaml = { version = "0.9.34", default-features = false } syn = { version = "2.0.72", default-features = false } sysinfo = { version = "0.30.13", default-features = false } thiserror = { version = "1.0.63", default-features = false } -tokio = { version = "1.39.1", default-features = false } +tokio = { version = "1.39.2", default-features = false } tokio-test = { version = "0.4.4", default-features = false } tracing = { version = "0.1.40", default-features = false } tracing-subscriber = { version = "0.3.18", default-features = false } From cf638e3662fd718c8773ed075484d5b1467a51b9 Mon Sep 17 00:00:00 2001 From: naskya Date: Sat, 27 Jul 2024 23:17:39 +0900 Subject: [PATCH 38/43] docs: add more notes --- docs/changelog.md | 2 ++ docs/install.md | 8 ++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/docs/changelog.md b/docs/changelog.md index 8b37ce6616..9f2b79c19f 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -2,6 +2,8 @@ Critical security updates are indicated by the :warning: icon. +This changelog is not an exhaustive list. Code refactorings, minor bug fixes, documentation/dependency updates, etc. are usually not listed here. If you want to see all changes, click on the version number and check the commit history. + - Server administrators must check [notice-for-admins.md](https://firefish.dev/firefish/firefish/-/blob/main/docs/notice-for-admins.md) as well. - Third-party client/bot developers may want to check [api-change.md](https://firefish.dev/firefish/firefish/-/blob/main/docs/api-change.md) as well. diff --git a/docs/install.md b/docs/install.md index af34e60006..36bc45a277 100644 --- a/docs/install.md +++ b/docs/install.md @@ -1,8 +1,12 @@ # Install Firefish +Please check the [v20240206 release note](https://firefish.dev/firefish/firefish/-/releases/v20240206) first. This project is barely maintained for those who really want to keep using Firefish. Please understand this before proceeding. + +## Dependencies + Firefish depends on the following software. -## Runtime dependencies +### Runtime dependencies - At least [NodeJS](https://nodejs.org/en/) v18.19.0 (v20/v22 recommended) - At least [PostgreSQL](https://www.postgresql.org/) v12 (v16 recommended) with [PGroonga](https://pgroonga.github.io/) extension @@ -17,7 +21,7 @@ Firefish depends on the following software. - [KeyDB](https://keydb.dev/) - Another [Redis](https://redis.io/) / [Valkey](https://valkey.io/) server -## Build dependencies +### Build dependencies - At least [Rust](https://www.rust-lang.org/) v1.74 - C/C++ compiler & build tools (like [GNU Make](https://www.gnu.org/software/make/)) From 7e8eae6ce7c5cd87e3cd3c5c7c1b14fae38e2ae6 Mon Sep 17 00:00:00 2001 From: naskya Date: Sat, 27 Jul 2024 23:18:40 +0900 Subject: [PATCH 39/43] docs (minor): unpin @rollup/wasm-node version in FreeBSD instruction --- docs/install.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/install.md b/docs/install.md index 36bc45a277..4ed2268e6f 100644 --- a/docs/install.md +++ b/docs/install.md @@ -39,7 +39,7 @@ We don't test Firefish on non-Linux systems, so please install Firefish on such
-Possible setup on FreeBSD (as of version 20240630) +Possible setup on FreeBSD (as of version 20240725) You can install Firefish on FreeBSD by adding these extra steps to the standard instructions: @@ -48,7 +48,7 @@ You can install Firefish on FreeBSD by adding these extra steps to the standard ```json "pnpm": { "overrides": { - "rollup": "npm:@rollup/wasm-node@4.17.2" + "rollup": "npm:@rollup/wasm-node } } ``` From 55c88ceb1b229e834ac53401c1b90bbdb01005cd Mon Sep 17 00:00:00 2001 From: naskya Date: Sat, 27 Jul 2024 23:30:23 +0900 Subject: [PATCH 40/43] docs: update changelog --- docs/changelog.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/docs/changelog.md b/docs/changelog.md index 9f2b79c19f..61d76b0373 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -7,6 +7,11 @@ This changelog is not an exhaustive list. Code refactorings, minor bug fixes, do - Server administrators must check [notice-for-admins.md](https://firefish.dev/firefish/firefish/-/blob/main/docs/notice-for-admins.md) as well. - Third-party client/bot developers may want to check [api-change.md](https://firefish.dev/firefish/firefish/-/blob/main/docs/api-change.md) as well. +## Unreleased + +- Improve `admin/emoji/add` API +- Fix bugs + ## [v20240725](https://firefish.dev/firefish/firefish/-/merge_requests/11196/commits) - Add followers list export feature From cd075c949ffd1c39d7989aea7c140c6f956267ed Mon Sep 17 00:00:00 2001 From: naskya Date: Sat, 27 Jul 2024 23:39:52 +0900 Subject: [PATCH 41/43] chore (deps): lock file maintenance --- Cargo.lock | 36 +-- pnpm-lock.yaml | 617 ++++++++++++++++++++++++------------------------- 2 files changed, 324 insertions(+), 329 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 80cff6e24b..25eacb6a2b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1582,9 +1582,9 @@ checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" [[package]] name = "jobserver" -version = "0.1.31" +version = "0.1.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d2b099aaa34a9751c5bf0878add70444e1ed2dd73f347be99003d4577277de6e" +checksum = "48d1dbcbbeb6a7fec7e059840aa538bd62aaccf972c7346c4d9d2059312853d0" dependencies = [ "libc", ] @@ -2082,9 +2082,9 @@ dependencies = [ [[package]] name = "object" -version = "0.36.1" +version = "0.36.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "081b846d1d56ddfc18fdf1a922e4f6e07a11768ea1b92dec44e42b72712ccfce" +checksum = "3f203fa8daa7bb185f760ae12bd8e097f63d17041dcdcaf675ac54cdf863170e" dependencies = [ "memchr", ] @@ -3032,9 +3032,9 @@ dependencies = [ [[package]] name = "serde_spanned" -version = "0.6.6" +version = "0.6.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "79e674e01f999af37c49f70a6ede167a8a60b2503e56c5599532a65baa5969a0" +checksum = "eb5b1b31579f3811bf615c144393417496f152e12ac8b7663bf664f4a815306d" dependencies = [ "serde", ] @@ -3752,9 +3752,9 @@ dependencies = [ [[package]] name = "toml" -version = "0.8.15" +version = "0.8.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac2caab0bf757388c6c0ae23b3293fdb463fee59434529014f85e3263b995c28" +checksum = "81967dd0dd2c1ab0bc3468bd7caecc32b8a4aa47d0c8c695d8c2b2108168d62c" dependencies = [ "serde", "serde_spanned", @@ -3764,18 +3764,18 @@ dependencies = [ [[package]] name = "toml_datetime" -version = "0.6.6" +version = "0.6.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4badfd56924ae69bcc9039335b2e017639ce3f9b001c393c1b2d1ef846ce2cbf" +checksum = "f8fb9f64314842840f1d940ac544da178732128f1c78c21772e876579e0da1db" dependencies = [ "serde", ] [[package]] name = "toml_edit" -version = "0.22.16" +version = "0.22.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "278f3d518e152219c994ce877758516bca5e118eaed6996192a774fb9fbf0788" +checksum = "8d9f8729f5aea9562aac1cc0441f5d6de3cff1ee0c5d67293eeca5eb36ee7c16" dependencies = [ "indexmap", "serde", @@ -3986,9 +3986,9 @@ checksum = "852e951cb7832cb45cb1169900d19760cfa39b82bc0ea9c0e5a14ae88411c98b" [[package]] name = "version_check" -version = "0.9.4" +version = "0.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" +checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" [[package]] name = "waker-fn" @@ -4296,9 +4296,9 @@ checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" [[package]] name = "winnow" -version = "0.6.14" +version = "0.6.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "374ec40a2d767a3c1b4972d9475ecd557356637be906f2cb3f7fe17a6eb5e22f" +checksum = "b480ae9340fc261e6be3e95a1ba86d54ae3f9171132a73ce8d4bbaf68339507c" dependencies = [ "memchr", ] @@ -4472,9 +4472,9 @@ checksum = "3f423a2c17029964870cfaabb1f13dfab7d092a62a29a89264f4d36990ca414a" [[package]] name = "zune-jpeg" -version = "0.4.11" +version = "0.4.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec866b44a2a1fd6133d363f073ca1b179f438f99e7e5bfb1e33f7181facfe448" +checksum = "16099418600b4d8f028622f73ff6e3deaabdff330fb9a2a131dea781ee8b0768" dependencies = [ "zune-core", ] diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 900ea399af..7bc0de5c3d 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -796,40 +796,28 @@ packages: resolution: {integrity: sha512-BcYH1CVJBO9tvyIZ2jVeXgSIMvGZ2FDRvDdOIVQyuklNKSsx+eppDEBq/g47Ayw+RqNFE+URvOShmf+f/qwAlA==} engines: {node: '>=6.9.0'} - '@babel/compat-data@7.24.9': - resolution: {integrity: sha512-e701mcfApCJqMMueQI0Fb68Amflj83+dvAvHawoBpAz+GDjCIyGHzNwnefjsWJ3xiYAqqiQFoWbspGYBdb2/ng==} + '@babel/compat-data@7.25.0': + resolution: {integrity: sha512-P4fwKI2mjEb3ZU5cnMJzvRsRKGBUcs8jvxIoRmr6ufAY9Xk2Bz7JubRTTivkw55c7WQJfTECeqYVa+HZ0FzREg==} engines: {node: '>=6.9.0'} '@babel/core@7.24.9': resolution: {integrity: sha512-5e3FI4Q3M3Pbr21+5xJwCv6ZT6KmGkI0vw3Tozy5ODAQFTIWe37iT8Cr7Ice2Ntb+M3iSKCEWMB1MBgKrW3whg==} engines: {node: '>=6.9.0'} - '@babel/generator@7.24.10': - resolution: {integrity: sha512-o9HBZL1G2129luEUlG1hB4N/nlYNWHnpwlND9eOMclRqqu1YDy2sSYVCFUZwl8I1Gxh+QSRrP2vD7EpUmFVXxg==} + '@babel/generator@7.25.0': + resolution: {integrity: sha512-3LEEcj3PVW8pW2R1SR1M89g/qrYk/m/mB/tLqn7dn4sbBUQyTqnlod+II2U4dqiGtUmkcnAmkMDralTFZttRiw==} engines: {node: '>=6.9.0'} '@babel/helper-compilation-targets@7.24.8': resolution: {integrity: sha512-oU+UoqCHdp+nWVDkpldqIQL/i/bvAv53tRqLG/s+cOXxe66zOYLU7ar/Xs3LdmBihrUMEUhwu6dMZwbNOYDwvw==} engines: {node: '>=6.9.0'} - '@babel/helper-environment-visitor@7.24.7': - resolution: {integrity: sha512-DoiN84+4Gnd0ncbBOM9AZENV4a5ZiL39HYMyZJGZ/AZEykHYdJw0wW3kdcsh9/Kn+BRXHLkkklZ51ecPKmI1CQ==} - engines: {node: '>=6.9.0'} - - '@babel/helper-function-name@7.24.7': - resolution: {integrity: sha512-FyoJTsj/PEUWu1/TYRiXTIHc8lbw+TDYkZuoE43opPS5TrI7MyONBE1oNvfguEXAD9yhQRrVBnXdXzSLQl9XnA==} - engines: {node: '>=6.9.0'} - - '@babel/helper-hoist-variables@7.24.7': - resolution: {integrity: sha512-MJJwhkoGy5c4ehfoRyrJ/owKeMl19U54h27YYftT0o2teQ3FJ3nQUf/I3LlJsX4l3qlw7WRXUmiyajvHXoTubQ==} - engines: {node: '>=6.9.0'} - '@babel/helper-module-imports@7.24.7': resolution: {integrity: sha512-8AyH3C+74cgCVVXow/myrynrAGv+nTVg5vKu2nZph9x7RcRwzmh0VFallJuFTZ9mx6u4eSdXZfcOzSqTUm0HCA==} engines: {node: '>=6.9.0'} - '@babel/helper-module-transforms@7.24.9': - resolution: {integrity: sha512-oYbh+rtFKj/HwBQkFlUzvcybzklmVdVV3UU+mN7n2t/q3yGHbuVdNxyFvSBO1tfvjyArpHNcWMAzsSPdyI46hw==} + '@babel/helper-module-transforms@7.25.0': + resolution: {integrity: sha512-bIkOa2ZJYn7FHnepzr5iX9Kmz8FjIz4UKzJ9zhX3dnYuVW0xul9RuR3skBfoLu+FPTQw90EHW9rJsSZhyLQ3fQ==} engines: {node: '>=6.9.0'} peerDependencies: '@babel/core': ^7.0.0 @@ -842,10 +830,6 @@ packages: resolution: {integrity: sha512-zBAIvbCMh5Ts+b86r/CjU+4XGYIs+R1j951gxI3KmmxBMhCg4oQMsv6ZXQ64XOm/cvzfU1FmoCyt6+owc5QMYg==} engines: {node: '>=6.9.0'} - '@babel/helper-split-export-declaration@7.24.7': - resolution: {integrity: sha512-oy5V7pD+UvfkEATUKvIjvIAH/xCzfsFVw7ygW2SI6NClZzquT+mwdTfgfdbUiceh6iQO0CHtCPsyze/MZ2YbAA==} - engines: {node: '>=6.9.0'} - '@babel/helper-string-parser@7.24.8': resolution: {integrity: sha512-pO9KhhRcuUyGnJWwyEgnRJTSIZHiT+vMD0kPeD+so0l7mxkMT19g3pjY9GTnHySck/hDzq+dtW/4VgnMkippsQ==} engines: {node: '>=6.9.0'} @@ -858,16 +842,16 @@ packages: resolution: {integrity: sha512-xb8t9tD1MHLungh/AIoWYN+gVHaB9kwlu8gffXGSt3FFEIT7RjS+xWbc2vUD1UTZdIpKj/ab3rdqJ7ufngyi2Q==} engines: {node: '>=6.9.0'} - '@babel/helpers@7.24.8': - resolution: {integrity: sha512-gV2265Nkcz7weJJfvDoAEVzC1e2OTDpkGbEsebse8koXUJUXPsCMi7sRo/+SPMuMZ9MtUPnGwITTnQnU5YjyaQ==} + '@babel/helpers@7.25.0': + resolution: {integrity: sha512-MjgLZ42aCm0oGjJj8CtSM3DB8NOOf8h2l7DCTePJs29u+v7yO/RBX9nShlKMgFnRks/Q4tBAe7Hxnov9VkGwLw==} engines: {node: '>=6.9.0'} '@babel/highlight@7.24.7': resolution: {integrity: sha512-EStJpq4OuY8xYfhGVXngigBJRWxftKX9ksiGDnmlY3o7B/V7KIAc9X4oiK87uPJSc/vs5L869bem5fhZa8caZw==} engines: {node: '>=6.9.0'} - '@babel/parser@7.24.8': - resolution: {integrity: sha512-WzfbgXOkGzZiXXCqk43kKwZjzwx4oulxZi3nq2TYL9mOjQv6kYwul9mz6ID36njuL7Xkp6nJEfok848Zj10j/w==} + '@babel/parser@7.25.0': + resolution: {integrity: sha512-CzdIU9jdP0dg7HdyB+bHvDJGagUv+qtzZt5rYCWwW6tITNqV9odjp6Qu41gkG0ca5UfdDUWrKkiAnHHdGRnOrA==} engines: {node: '>=6.0.0'} hasBin: true @@ -966,16 +950,16 @@ packages: resolution: {integrity: sha512-2Yv65nlWnWlSpe3fXEyX5i7fx5kIKo4Qbcj+hMO0odwaneFjfXw5fdum+4yL20O0QiaHpia0cYQ9xpNMqrBwHg==} engines: {node: '>=6.9.0'} - '@babel/template@7.24.7': - resolution: {integrity: sha512-jYqfPrU9JTF0PmPy1tLYHW4Mp4KlgxJD9l2nP9fD6yT/ICi554DmrWBAEYpIelzjHf1msDP3PxJIRt/nFNfBig==} + '@babel/template@7.25.0': + resolution: {integrity: sha512-aOOgh1/5XzKvg1jvVz7AVrx2piJ2XBi227DHmbY6y+bM9H2FlN+IfecYu4Xl0cNiiVejlsCri89LUsbj8vJD9Q==} engines: {node: '>=6.9.0'} - '@babel/traverse@7.24.8': - resolution: {integrity: sha512-t0P1xxAPzEDcEPmjprAQq19NWum4K0EQPjMwZQZbHt+GiZqvjCHjj755Weq1YRPVzBI+3zSfvScfpnuIecVFJQ==} + '@babel/traverse@7.25.0': + resolution: {integrity: sha512-ubALThHQy4GCf6mbb+5ZRNmLLCI7bJ3f8Q6LHBSRlSKSWj5a7dSUzJBLv3VuIhFrFPgjF4IzPF567YG/HSCdZA==} engines: {node: '>=6.9.0'} - '@babel/types@7.24.9': - resolution: {integrity: sha512-xm8XrMKz0IlUdocVbYJe0Z9xEgidU7msskG8BbhnTPK/HZ2z/7FP7ykqPgrUH+C+r414mNfNWam1f2vqOjqjYQ==} + '@babel/types@7.25.0': + resolution: {integrity: sha512-LcnxQSsd9aXOIgmmSpvZ/1yo46ra2ESYyqLcryaBZOghxy5qqOBjvCWP5JfkI8yl9rlxRgdLTTMCQQRcN2hdCg==} engines: {node: '>=6.9.0'} '@bcoe/v8-coverage@0.2.3': @@ -1389,56 +1373,60 @@ packages: cpu: [x64] os: [win32] - '@inquirer/checkbox@2.4.1': - resolution: {integrity: sha512-Mt6JH1XuTPgzSirE26w1xHxw32z9tjUZPYOGAcgNeV0olSeLDidLF1nylFLZdzJrEQcMylQ+8t0RdP74LKS0oQ==} + '@inquirer/checkbox@2.4.2': + resolution: {integrity: sha512-iZRNbTlSB9xXt/+jdMFViBdxw1ILWu3365rzfM5OLwAyOScbDFFGSH7LEUwoq1uOIo48ymOEwYSqP5y8hQMlmA==} engines: {node: '>=18'} - '@inquirer/confirm@3.1.16': - resolution: {integrity: sha512-DXgLZim+YVTk05zRywvFRfJt2Jje7sZ4DO6Ss9RpGtgXEd/T0IiTqubHWst0IazCwdPI9g/06Rtm/nm4IBFJBA==} + '@inquirer/confirm@3.1.17': + resolution: {integrity: sha512-qCpt/AABzPynz8tr69VDvhcjwmzAryipWXtW8Vi6m651da4H/d0Bdn55LkxXD7Rp2gfgxvxzTdb66AhIA8gzBA==} engines: {node: '>=18'} - '@inquirer/core@9.0.4': - resolution: {integrity: sha512-46LaWACIctSfVKTu71ziFlqO8SVLhWGSxvaHpf0frfDTphSSpIfeNo5ZH/kJPHYJw4VgPGf/9c3zJN/FnCdaIQ==} + '@inquirer/core@9.0.5': + resolution: {integrity: sha512-QWG41I7vn62O9stYKg/juKXt1PEbr/4ZZCPb4KgXDQGwgA9M5NBTQ7FnOvT1ridbxkm/wTxLCNraUs7y47pIRQ==} engines: {node: '>=18'} - '@inquirer/editor@2.1.16': - resolution: {integrity: sha512-SkrpBFUK1XqCS5a66v2dnsjMoXyuxC+2golkM0NoT7XYq47eY8RVFnt5oOjj257MmXjbuSLcc7iQb7bFasHTfA==} + '@inquirer/editor@2.1.17': + resolution: {integrity: sha512-hwx3VpFQzOY2hFWnY+XPsUGCIUVQ5kYxH6+CExv/RbMiAoN3zXtzj8DyrWBOHami0vBrrnPS8CTq3uQWc7N2BA==} engines: {node: '>=18'} - '@inquirer/expand@2.1.16': - resolution: {integrity: sha512-i7qnbjg7bFRd/UXq7I+IHkai84NQCWhFbNvVDp0Gi/DCwfPAoInFnwtPMBpf4Ep/UaLdVl98NR2AzwYRZdLV/w==} + '@inquirer/expand@2.1.17': + resolution: {integrity: sha512-s4V/dC+GeE5s97xoTtZSmC440uNKePKqZgzqEf0XM63ciilnXAtKGvoAWOePFdlK+oGTz0d8bhbPKwpKGvRYfg==} engines: {node: '>=18'} - '@inquirer/figures@1.0.4': - resolution: {integrity: sha512-R7Gsg6elpuqdn55fBH2y9oYzrU/yKrSmIsDX4ROT51vohrECFzTf2zw9BfUbOW8xjfmM2QbVoVYdTwhrtEKWSQ==} + '@inquirer/figures@1.0.5': + resolution: {integrity: sha512-79hP/VWdZ2UVc9bFGJnoQ/lQMpL74mGgzSYX1xUqCVk7/v73vJCMw1VuyWN1jGkZ9B3z7THAbySqGbCNefcjfA==} engines: {node: '>=18'} - '@inquirer/input@2.2.3': - resolution: {integrity: sha512-L3vH9istz91uk43Us4dqLb0UV6XxoSQ2MYRs3QSIPDXj1zUPGOk44Y1R69tPkO4VSHnlZjDp+FPEf/CTaee4dg==} + '@inquirer/input@2.2.4': + resolution: {integrity: sha512-wvYnDITPQn+ltktj/O9kQjPxOvpmwcpxLWh8brAyD+jlEbihxtrx9cZdZcxqaCVQj3caw4eZa2Uq5xELo4yXkA==} engines: {node: '>=18'} - '@inquirer/number@1.0.4': - resolution: {integrity: sha512-kDa06HLzkVUzWnp5APF6JeQw6PCUc5hSQEyFYl8MoIRoJP0Psbf3Ys47skEpASqsSXcCjBy+3dEiFyhL95cbBA==} + '@inquirer/number@1.0.5': + resolution: {integrity: sha512-+H6TJPU2AJEcoF6nVTWssxS7gnhxWvf6CkILAdfq/yGm/htBKNDrvYLYaJvi1Be/aXQoKID9FaP94bUCjOvJNQ==} engines: {node: '>=18'} - '@inquirer/password@2.1.16': - resolution: {integrity: sha512-UXzm1nzb0rGaciJ95ZeEjkZ/2KpPRxC94bTzOEkl5Gy/jQ5X3frJHHTzBMRg1KPuyAQTQSQKYXtjTKoknpTcTg==} + '@inquirer/password@2.1.17': + resolution: {integrity: sha512-/u6DM/fDHXoBWyA+9aRhghkeo5smE7wO9k4E2UoJbgiRCkt3JjBEuBqLOJNrz8E16M0ez4UM1vd5cXrmICHW+A==} engines: {node: '>=18'} - '@inquirer/prompts@5.2.1': - resolution: {integrity: sha512-jS99zPSKAHdSn3q58QRV5H/wPUPMThYA4ZgDV5oSyELj2W7d6QrJi5cezBtAXtsqhKjPBx5lix/vGpIJ5FRFXQ==} + '@inquirer/prompts@5.3.2': + resolution: {integrity: sha512-8Jv+6rbY98ilFAZMYYfetu6XGXF/ZU44i5Z6Jx4t0xmwDh/AihdBV/FgetzDDZZMv5AMW1MT35LI0FiS55LoXw==} engines: {node: '>=18'} - '@inquirer/rawlist@2.1.16': - resolution: {integrity: sha512-RINF+Rw6u5fJQ2kBbAUkNN8bLXUmrl+rLwrlZf24SJt/fosX672U3WseUUHdR3yvIIoIuISrHrh+jbhwl170/Q==} + '@inquirer/rawlist@2.1.17': + resolution: {integrity: sha512-RFrw34xU5aVlMA3ZJCaeKGxYjhu3j4i46O2GMmaRRGeLObCRM1yOKQOsRclSTzjd4A7+M5QleR2iuW/68J9Kwg==} engines: {node: '>=18'} - '@inquirer/select@2.4.1': - resolution: {integrity: sha512-m15ZwV2E2QDy0VbO/BRkVZ6TX6chYU+7K7//R47c3/Xai1d2AESHy4U88G7uq2mR1atl/p4HvMClKASNJvUDRg==} + '@inquirer/search@1.0.2': + resolution: {integrity: sha512-E/JD3MeJwJeNilOnRDmHGnlUksyVqrTQEUNqkRpioj8J0sVxW7+pFRHBM2coFsiCpvI4XKRRhWsai5VP8rrfrQ==} engines: {node: '>=18'} - '@inquirer/type@1.5.0': - resolution: {integrity: sha512-L/UdayX9Z1lLN+itoTKqJ/X4DX5DaWu2Sruwt4XgZzMNv32x4qllbzMX4MbJlz0yxAQtU19UvABGOjmdq1u3qA==} + '@inquirer/select@2.4.2': + resolution: {integrity: sha512-r78JlgShqRxyAtBDeBHSDtfrOhSQwm2ecWGGaxe7kD9JwgL3UN563G1ncVRYdsWD7/tigflcskfipVeoDLhLJg==} + engines: {node: '>=18'} + + '@inquirer/type@1.5.1': + resolution: {integrity: sha512-m3YgGQlKNS0BM+8AFiJkCsTqHEFCWn6s/Rqye3mYwvqY6LdfUv12eSwbsgNzrYyrLXiy7IrrjDLPysaSBwEfhw==} engines: {node: '>=18'} '@ioredis/commands@1.2.0': @@ -1878,91 +1866,103 @@ packages: resolution: {integrity: sha512-XyZoBlYNMvCulK/RmVK/0nB3j7IdH7HpqcrMMg0U+HqQqKRLOQBwvnKNBocPC1bZQ7iZuKWYTLn1ayZwTyek8w==} engines: {node: '>= 10'} - '@napi-rs/tar-android-arm-eabi@0.1.1': - resolution: {integrity: sha512-Ufa0ahZvE5KGrC2WBux5svCe/jvC+e8IgtleiicwqnfgTfbDknYyq/QuqkP1AnMp/IvTmx2iutCZt6OFIG0zAg==} + '@napi-rs/tar-android-arm-eabi@0.1.4': + resolution: {integrity: sha512-LMSysWp5AmZj1NOCB2jshc9KCvp4gm7vm0Cra5U2crMvlj/fwGrvv6+EzSw49y8wCkNEcQ8QaGq5NBQKiLogSg==} engines: {node: '>= 10'} cpu: [arm] os: [android] - '@napi-rs/tar-android-arm64@0.1.1': - resolution: {integrity: sha512-KUu5fHIiIObSuZ/crHxUrQ243+LiCRKPwdCVLHwjtftqFjzls+R2Mp6GrpM41XxexDMN00SUta3kazi93Xr19A==} + '@napi-rs/tar-android-arm64@0.1.4': + resolution: {integrity: sha512-A/2rl8xr7F5yOtHVARROoSwjRRDNL1RlXCsg/K+RE5/V9iPBojsJsLpFPilp7InF6bi+z7aYn+yWCD6wSwfF4A==} engines: {node: '>= 10'} cpu: [arm64] os: [android] - '@napi-rs/tar-darwin-arm64@0.1.1': - resolution: {integrity: sha512-jaqgdX20iIga+2gzotQ78eF00Cm8vECocUYeMY62WqyzJNv/jx1dlOfELWEccOjpmawFT9tjWebsS9F1QMvSUg==} + '@napi-rs/tar-darwin-arm64@0.1.4': + resolution: {integrity: sha512-mnGBswBRtxDqUwXUZx+f9Uuy2uPssxuvcWFTYgUSZqlS2pg/XIWZdHZhbqWqKGpjpZrYcr+42roytbWlZ+epMA==} engines: {node: '>= 10'} cpu: [arm64] os: [darwin] - '@napi-rs/tar-darwin-x64@0.1.1': - resolution: {integrity: sha512-80sa32IxfRso9x9sGTFpfLSx3BnruyJODpSkUzalOCz9i14n5gOKA8KR/JrnSWwDz0p5l5P9kfQD3pu8Voj7WA==} + '@napi-rs/tar-darwin-x64@0.1.4': + resolution: {integrity: sha512-I81Fvl/cfnFVBET49xywNd57dXLJPO7jqrjD9Z2bKeXA0v0Zt1cwV1IOOTihFZXJv7kgu6EfNB7oumoLOTqq5A==} engines: {node: '>= 10'} cpu: [x64] os: [darwin] - '@napi-rs/tar-freebsd-x64@0.1.1': - resolution: {integrity: sha512-P7V1zBjjC1dCrTwtUzuzYM4AeZduigeCtd8qQw2IUZowM5AsmhMd77oYuXjdU29cEpKUpyYjJRxjPCzFy+WbAQ==} + '@napi-rs/tar-freebsd-x64@0.1.4': + resolution: {integrity: sha512-p5OFr3MqidZHkt9bHV2FgeS6k06g+s0GR2kvj/wm2mIxr7u3/sj3+RTr7GHz5DQq08T7uH85HhsrGYWN3vxmSg==} engines: {node: '>= 10'} cpu: [x64] os: [freebsd] - '@napi-rs/tar-linux-arm-gnueabihf@0.1.1': - resolution: {integrity: sha512-qpC71ILPkWKt8k1iJCYt5gjwcOkd2VFSQIelTRr12t5CVNKV04rE/TMdwFoCP7kxbtb9Fl2cZzCRISw2BhMCmQ==} + '@napi-rs/tar-linux-arm-gnueabihf@0.1.4': + resolution: {integrity: sha512-POp2zb/Yuw6taEmrTlEoQI5S+2HmgfV1VtqGQZgRmCa85NlWLDsR6vbW9euu/6NbLj3ld15cCeJC2oJkv9k/xg==} engines: {node: '>= 10'} cpu: [arm] os: [linux] - '@napi-rs/tar-linux-arm64-gnu@0.1.1': - resolution: {integrity: sha512-71QgxcFJCog6O4Tauoge8D0ILkDGJTRk3ru7zG8PUFG1QXJ1kkiRikdT77YmoVxtomc9FUOt+bdEdU5Yn+3QUQ==} + '@napi-rs/tar-linux-arm64-gnu@0.1.4': + resolution: {integrity: sha512-TV+2AppSgJx5U9nk1C9bh1afWcBVnnANJ4SmtqUF6ediHcDS2rLebeI8BGljfnX9F149qbT9gOGN+R8tofpCsg==} engines: {node: '>= 10'} cpu: [arm64] os: [linux] - '@napi-rs/tar-linux-arm64-musl@0.1.1': - resolution: {integrity: sha512-R2e7YEILPKc447N1hUt1zQuyy0st83HX6nhmtFywS1aOj76/3hzxLVrebGiiS6kifyCrO82o66CNTYe7DixMZw==} + '@napi-rs/tar-linux-arm64-musl@0.1.4': + resolution: {integrity: sha512-UFBvKpYmuQRbgmXuSSPb8mRjq4JRZLYJhqwrWWnlfQP13xK2WB7mL2GhewBgynSH4YKDm6biKhK6U5RrSWEDgw==} engines: {node: '>= 10'} cpu: [arm64] os: [linux] - '@napi-rs/tar-linux-x64-gnu@0.1.1': - resolution: {integrity: sha512-tmy9q2LXUB2GQ+IgUzJn3+us52leplMu96ORyFq1iHQEelGSqXt4xi5DzU07JhX3obJPqVqkybtcRS4enBfmBA==} + '@napi-rs/tar-linux-ppc64-gnu@0.1.4': + resolution: {integrity: sha512-HT+h6Wv51SKXqks8UBF+KVuNJ09fM1GyO+SvCnDB5MF66tGiI2C6/MSX69zf1ZeqjACds1K/UwKiZCmE76/j9A==} + engines: {node: '>= 10'} + cpu: [ppc64] + os: [linux] + + '@napi-rs/tar-linux-s390x-gnu@0.1.4': + resolution: {integrity: sha512-SJ+HSr281Y6cgJrQ4nkYbXaTHAmTLv/FZm5k9ZRA6Khml//ZoWi7CiT8dnPeD4QxYwCzAFA4aYMUOQJM/mk2/w==} + engines: {node: '>= 10'} + cpu: [s390x] + os: [linux] + + '@napi-rs/tar-linux-x64-gnu@0.1.4': + resolution: {integrity: sha512-LrF0lRFiFOkO40jfgTdF8dRTvYOLV52fdZ/YnJuBodNcxqEl9rChO3v5Uag//sy0me85FjqtobQNRQP8Nd80dA==} engines: {node: '>= 10'} cpu: [x64] os: [linux] - '@napi-rs/tar-linux-x64-musl@0.1.1': - resolution: {integrity: sha512-j5ePbe6vihApl0cGPPDUVTWZbf2mF4NhxngAoG2jp7AeX3cWP2O4pjsvaOraW6QfvWEMFPeER7S0b6eBS7duvA==} + '@napi-rs/tar-linux-x64-musl@0.1.4': + resolution: {integrity: sha512-etGUWbs+Tk1PtzgyWrVzXa2fQrHNKSc/whHm+4x1Num8Oz+wGdjCDTUktYxAVy33PKZhdblVxxE83QXxkgjneQ==} engines: {node: '>= 10'} cpu: [x64] os: [linux] - '@napi-rs/tar-wasm32-wasi@0.1.1': - resolution: {integrity: sha512-se0+DlOiIRt7mcz7BeOJDoZtCrROpKLwiAOGmNgrjQ/SZS7TnOPuwm3wy9XN9WLoepttEjCEem6UP8yD5GJuQg==} + '@napi-rs/tar-wasm32-wasi@0.1.4': + resolution: {integrity: sha512-mANkm93AKy+OspkOBAC5WI64SopXT0VawdTjpeGW1OgyUSJWdUB5rhs3I7B/HW1bi5tsUoZOZQe3rVgYdfzA6g==} engines: {node: '>=14.0.0'} cpu: [wasm32] - '@napi-rs/tar-win32-arm64-msvc@0.1.1': - resolution: {integrity: sha512-FDZPi2wC7RwzvodogigLh/pJvhqCTVTUqOYuHlLkPSUbSAGiEkI55wk9RqH3y3EdJQaDuzyqC0QKz5ket2U+GA==} + '@napi-rs/tar-win32-arm64-msvc@0.1.4': + resolution: {integrity: sha512-/5/gp6WR9b36CysJDe8AdyjNeje+NqCniYJz/AZc+UvpKwG8MG9nS6TMpJ9IgrQacJXvc4lWXxYyn6uuPQVvaQ==} engines: {node: '>= 10'} cpu: [arm64] os: [win32] - '@napi-rs/tar-win32-ia32-msvc@0.1.1': - resolution: {integrity: sha512-OPR9Tou5z5M912G7Kc7gkf1ltinbOQx5dS/OeDIWHvPGOfdFDIxt0YVKhzSLRJi43+zIDp8/+cbeMD/cKXfX8w==} + '@napi-rs/tar-win32-ia32-msvc@0.1.4': + resolution: {integrity: sha512-HnQi0op9BqJqPekKXhEAI1TWkLtavxKDBDGXNhUSm2//jriMeRykahUcKoUUxr1UGrmtxpc5dx0cThBt13paEw==} engines: {node: '>= 10'} cpu: [ia32] os: [win32] - '@napi-rs/tar-win32-x64-msvc@0.1.1': - resolution: {integrity: sha512-hiv5KfhrMSg8tTRC2oQXVckVg1h6ZVjwbd5aF9Esl0V3p2TaNFwwbqgnAN4Gm/PmSnHWNL/IRTHkk3cOzDWihQ==} + '@napi-rs/tar-win32-x64-msvc@0.1.4': + resolution: {integrity: sha512-vy2ebEXerblni6XOgi3a27+CnI6PdQ9Phy/ru5HM4bVd/oulAJohmynAmBAB1AmXg1NLbAEWu43nATEDp5O2hA==} engines: {node: '>= 10'} cpu: [x64] os: [win32] - '@napi-rs/tar@0.1.1': - resolution: {integrity: sha512-FOMhwwlvoYjHaDBxP26K3D92ltw1Y/CC4CIjgC6qXdzW4MYNwTlEyI58smCM3k+nCVJH3kpOYyH3sgbK4WZA4A==} + '@napi-rs/tar@0.1.4': + resolution: {integrity: sha512-hDsvmMZY8tl2CcLfjnTeE1o5W1eGTSL+ZIX8YEybtcJwA+Cc8SNHb7l6JqMnGcjOrWBZbHt8tzTN+W7qHS5Wmg==} engines: {node: '>= 10'} '@napi-rs/wasm-runtime@0.2.4': @@ -2374,8 +2374,8 @@ packages: '@types/eslint@7.29.0': resolution: {integrity: sha512-VNcvioYDH8/FxaeTKkM4/TiTwt6pBV9E3OfGmvaw8tPl0rrHCJ4Ll15HRT+pMiFAf/MLQvAzC+6RzUMEL9Ceng==} - '@types/eslint@8.56.10': - resolution: {integrity: sha512-Shavhk87gCtY2fhXDctcfS3e6FdxWkCx1iUZ9eEUbh7rTqlZT0/IzOkCOVt0fCjcFuZ9FPYfuezTBImfHCDBGQ==} + '@types/eslint@9.6.0': + resolution: {integrity: sha512-gi6WQJ7cHRgZxtkQEoyHMppPjq9Kxo5Tjn2prSKDSmZrCz8TZ3jSRCeTJm+WoM+oB0WG37bRqLzaaU3q7JypGg==} '@types/estree@1.0.5': resolution: {integrity: sha512-/kYRxGDLWzHOB7q+wtSUQlFrtcdUccpfy+X+9iMBpHK8QLLhx2wIPYuS5DYtR9Wa/YlZAbIovy7qVdB1Aq6Lyw==} @@ -3067,8 +3067,8 @@ packages: resolution: {integrity: sha512-Gmy6FhYlCY7uOElZUSbxo2UCDH8owEk996gkbrpsgGtrJLM3J7jGxl9Ic7Qwwj4ivOE5AWZWRMecDdF7hqGjFA==} engines: {node: '>=10'} - caniuse-lite@1.0.30001642: - resolution: {integrity: sha512-3XQ0DoRgLijXJErLSl+bLnJ+Et4KqV1PY6JJBGAFlsNsz31zeAIncyeZfLCabHK/jtSh+671RM9YMldxjUPZtA==} + caniuse-lite@1.0.30001643: + resolution: {integrity: sha512-ERgWGNleEilSrHM6iUz/zJNSQTP8Mr21wDWpdgvRwcTXGAq6jMtOUPP4dqFPTdKqZ2wKTdtB+uucZ3MRpAUSmg==} canonicalize@1.0.8: resolution: {integrity: sha512-0CNTVCLZggSh7bc5VkX5WWPWO+cyZbNd07IHIsSXLia/eAq+r836hgk+8BKoEh7949Mda87VUOitx5OddVj64A==} @@ -3572,8 +3572,8 @@ packages: supports-color: optional: true - debug@4.3.5: - resolution: {integrity: sha512-pt0bNEmneDIvdL1Xsd9oDQ/wrQRkXDT4AUWlNZNPKvW5x/jyO9VFXkJUP07vQ2upmw5PlaITaPKc31jK13V+jg==} + debug@4.3.6: + resolution: {integrity: sha512-O/09Bd4Z1fBrU4VzkhFqVgpPzaGbw6Sm9FEkBT1A/YBXQFGuuSxa1dN2nxgxS34JmKXqYx8CZAwEVoJFImUXIg==} engines: {node: '>=6.0'} peerDependencies: supports-color: '*' @@ -3751,8 +3751,8 @@ packages: engines: {node: '>=0.10.0'} hasBin: true - electron-to-chromium@1.4.832: - resolution: {integrity: sha512-cTen3SB0H2SGU7x467NRe1eVcQgcuS6jckKfWJHia2eo0cHIGOqHoAxevIYZD4eRHcWjkvFzo93bi3vJ9W+1lA==} + electron-to-chromium@1.5.2: + resolution: {integrity: sha512-kc4r3U3V3WLaaZqThjYz/Y6z8tJe+7K0bbjUVo3i+LWIypVdMx5nXCkwRe6SWbY6ILqLdc1rKcKmr3HoH7wjSQ==} emittery@0.13.1: resolution: {integrity: sha512-DeWwawk6r5yR9jFgnDKYt4sLS0LmHJJi3ZOnb5/JdbYwj3nW+FxQnHIjhBKz8YLC7oRNPVM9NQ47I3CVx34eqQ==} @@ -3777,8 +3777,8 @@ packages: end-of-stream@1.4.4: resolution: {integrity: sha512-+uw1inIHVPQoaVuHzRyXd21icM+cnt4CzD5rW+NC1wjOUSTOs+Te7FOv7AhN7vS9x/oIyhLP5PR1H+phQAHu5Q==} - enhanced-resolve@5.17.0: - resolution: {integrity: sha512-dwDPwZL0dmye8Txp2gzFmA6sxALaSvdRDjPH0viLcKrtlOL3tw62nWWweVD1SdILDTJrbrL6tdWVN58Wo6U3eA==} + enhanced-resolve@5.17.1: + resolution: {integrity: sha512-LMHl3dXhTcfv8gM4kEzIUeTQ+7fpdA0l2tUf34BddXPkz2A5xJ5L/Pchd5BL6rdccM9QGvu0sWZzK1Z1t4wwyg==} engines: {node: '>=10.13.0'} entities@1.1.2: @@ -4301,11 +4301,11 @@ packages: resolution: {integrity: sha512-5Fytz/IraMjqpwfd34ke28PTVMjZjJG2MPn5t7OE4eUCUNf8BAa7b5WUS9/Qvr6mwOQS7Mk6vdsMno5he+T8Xw==} engines: {node: '>= 4'} - immutable@4.3.6: - resolution: {integrity: sha512-Ju0+lEMyzMVZarkTn/gqRpdqd5dOPaz1mCZ0SH3JV6iFw81PldE/PEB1hWVEA288HPt4WXW8O7AWxB10M+03QQ==} + immutable@4.3.7: + resolution: {integrity: sha512-1hqclzwYwjRDFLjcFxOM5AYkkG0rpFPpr1RLPMEuGczoS7YA8gLhy8SWXYRAA/XwfEHpfo3cw5JGioS32fnMRw==} - import-local@3.1.0: - resolution: {integrity: sha512-ASB07uLtnDs1o6EHjKpX34BKYDSqnFerfTOJL2HvMqF70LnxpjkzDB8J44oT9pu4AMPkQwf8jl6szgvNd2tRIg==} + import-local@3.2.0: + resolution: {integrity: sha512-2SPlun1JUPWoM6t3F0dw0FkCF/jWY8kttcY4f599GLTSjh2OCuuhdTkJQsEcZzBqbXZGKMK2OqW1oZsjtf/gQA==} engines: {node: '>=8'} hasBin: true @@ -4334,8 +4334,8 @@ packages: ini@1.3.8: resolution: {integrity: sha512-JV/yugV2uzW5iMRSiZAyDtQd+nxtUnjeLt0acNdw98kKLrvuRVyB80tsREOE7yvGVgalhZ6RNXCmEHkUKBKxew==} - inquirer@10.0.4: - resolution: {integrity: sha512-tBci3o6smIDw5GmUWrPGgeom3XKGJaxFdN1X5zYt9CtLdIw4hkOS6a+d5x80BIKeaz6+2gxMCStzZsD06v+q4g==} + inquirer@10.1.2: + resolution: {integrity: sha512-rwoy4e2xFz3rru5Q5695rKXLbNlVfODRhRftBEPdxHfbGzN1T8Fxzszcb//SaRnQHsRdiwR8dOZOV+y4SoZ4KQ==} engines: {node: '>=18'} insert-text-at-cursor@0.3.0: @@ -5211,8 +5211,8 @@ packages: node-int64@0.4.0: resolution: {integrity: sha512-O5lz91xSOeoXP6DulyHfllpq+Eg00MWitZIbtPfoSEvqIHdl5gfcY6hYzDWnj0qD5tz52PI08u9qUvSVeUBeHw==} - node-releases@2.0.17: - resolution: {integrity: sha512-Ww6ZlOiEQfPfXM45v17oabk77Z7mg5bOt7AjDyzy7RjK9OrLrLC8dyZQoAPEOtFX9SaNf1Tdvr5gRJWdTJj7GA==} + node-releases@2.0.18: + resolution: {integrity: sha512-d9VeXT4SJ7ZeOqGX6R5EM022wpL+eWPooLI+5UpWn2jCT1aosUQEhQP214x33Wkwx3JQMvIm+tIoVOdodFS40g==} nodemailer@6.9.14: resolution: {integrity: sha512-Dobp/ebDKBvz91sbtRKhcznLThrKxKt97GI2FAlAyy+fk19j73Uz3sBXolVtmcXjaorivqsbbbjDY+Jkt4/bQA==} @@ -5529,8 +5529,8 @@ packages: resolution: {integrity: sha512-d7Uw+eZoloe0EHDIYoe+bQ5WXnGMOpmiZFTuMWCwpjzzkL2nTjcKiAk4hh8TjnGye2TwWOk3UXucZ+3rbmBa8Q==} engines: {node: '>= 0.4'} - postcss@8.4.39: - resolution: {integrity: sha512-0vzE+lAiG7hZl1/9I8yzKLx3aR9Xbof3fBHKunvMfOCYAtMhrsnccJY2iTURb9EZd5+pLuiNV9/c/GZJOHsgIw==} + postcss@8.4.40: + resolution: {integrity: sha512-YF2kKIUzAofPMpfH6hOi2cGnv/HrUlfucspc7pDyvv7kGdqXrfj8SCl/t8owkEgKEuu8ZcRjSOxFxVLqwChZ2Q==} engines: {node: ^10 || ^12 || >=14} postgres-array@2.0.0: @@ -5577,8 +5577,8 @@ packages: resolution: {integrity: sha512-Pdlw/oPxN+aXdmM9R00JVC9WVFoCLTKJvDVLgmJ+qAffBMxsV85l/Lu7sNx4zSzPyoL2euImuEwHhOXdEgNFZQ==} engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} - pretty-ms@9.0.0: - resolution: {integrity: sha512-E9e9HJ9R9NasGOgPaPE8VMeiPKAyWR5jcFpNnwIejslIhWqdqOrb2wShBsncMPUb+BcCd2OPYfh7p2W6oemTng==} + pretty-ms@9.1.0: + resolution: {integrity: sha512-o1piW0n3tgKIKCwk2vpM/vOV13zjJzvP37Ioze54YlTHE06m4tjEbzg9WsKkvTuyYln2DHjo5pY4qrZGI0otpw==} engines: {node: '>=18'} pretty@2.0.0: @@ -6151,8 +6151,8 @@ packages: strnum@1.0.5: resolution: {integrity: sha512-J8bbNyKKXl5qYcR36TIO8W3mVGVHrmmxsd5PAItGkmyzwJvybiw2IVq5nqd0i4LSNSkB/sx9VHllbfFdr9k1JA==} - strtok3@8.0.0: - resolution: {integrity: sha512-YzsSP+kli3q1tTA04HsfY1GqIapi3vEMN38jJ+aLpFyoev0onI/RuZWBGkQgc7ORynb3LW4cSOP3XtsKV21X6Q==} + strtok3@8.0.1: + resolution: {integrity: sha512-HNkTAnNWQj2YBzfTtoC5OQyu1QwPsMwiB7VyQmNvQKCrmEDSvFB857Vh97UY9InGLNRAB91sdS1ztifRo/3hdA==} engines: {node: '>=16'} summaly@2.7.0: @@ -6906,71 +6906,57 @@ snapshots: '@babel/highlight': 7.24.7 picocolors: 1.0.1 - '@babel/compat-data@7.24.9': {} + '@babel/compat-data@7.25.0': {} '@babel/core@7.24.9': dependencies: '@ampproject/remapping': 2.3.0 '@babel/code-frame': 7.24.7 - '@babel/generator': 7.24.10 + '@babel/generator': 7.25.0 '@babel/helper-compilation-targets': 7.24.8 - '@babel/helper-module-transforms': 7.24.9(@babel/core@7.24.9) - '@babel/helpers': 7.24.8 - '@babel/parser': 7.24.8 - '@babel/template': 7.24.7 - '@babel/traverse': 7.24.8 - '@babel/types': 7.24.9 + '@babel/helper-module-transforms': 7.25.0(@babel/core@7.24.9) + '@babel/helpers': 7.25.0 + '@babel/parser': 7.25.0 + '@babel/template': 7.25.0 + '@babel/traverse': 7.25.0 + '@babel/types': 7.25.0 convert-source-map: 2.0.0 - debug: 4.3.5 + debug: 4.3.6 gensync: 1.0.0-beta.2 json5: 2.2.3 semver: 6.3.1 transitivePeerDependencies: - supports-color - '@babel/generator@7.24.10': + '@babel/generator@7.25.0': dependencies: - '@babel/types': 7.24.9 + '@babel/types': 7.25.0 '@jridgewell/gen-mapping': 0.3.5 '@jridgewell/trace-mapping': 0.3.25 jsesc: 2.5.2 '@babel/helper-compilation-targets@7.24.8': dependencies: - '@babel/compat-data': 7.24.9 + '@babel/compat-data': 7.25.0 '@babel/helper-validator-option': 7.24.8 browserslist: 4.23.2 lru-cache: 5.1.1 semver: 6.3.1 - '@babel/helper-environment-visitor@7.24.7': - dependencies: - '@babel/types': 7.24.9 - - '@babel/helper-function-name@7.24.7': - dependencies: - '@babel/template': 7.24.7 - '@babel/types': 7.24.9 - - '@babel/helper-hoist-variables@7.24.7': - dependencies: - '@babel/types': 7.24.9 - '@babel/helper-module-imports@7.24.7': dependencies: - '@babel/traverse': 7.24.8 - '@babel/types': 7.24.9 + '@babel/traverse': 7.25.0 + '@babel/types': 7.25.0 transitivePeerDependencies: - supports-color - '@babel/helper-module-transforms@7.24.9(@babel/core@7.24.9)': + '@babel/helper-module-transforms@7.25.0(@babel/core@7.24.9)': dependencies: '@babel/core': 7.24.9 - '@babel/helper-environment-visitor': 7.24.7 '@babel/helper-module-imports': 7.24.7 '@babel/helper-simple-access': 7.24.7 - '@babel/helper-split-export-declaration': 7.24.7 '@babel/helper-validator-identifier': 7.24.7 + '@babel/traverse': 7.25.0 transitivePeerDependencies: - supports-color @@ -6978,25 +6964,21 @@ snapshots: '@babel/helper-simple-access@7.24.7': dependencies: - '@babel/traverse': 7.24.8 - '@babel/types': 7.24.9 + '@babel/traverse': 7.25.0 + '@babel/types': 7.25.0 transitivePeerDependencies: - supports-color - '@babel/helper-split-export-declaration@7.24.7': - dependencies: - '@babel/types': 7.24.9 - '@babel/helper-string-parser@7.24.8': {} '@babel/helper-validator-identifier@7.24.7': {} '@babel/helper-validator-option@7.24.8': {} - '@babel/helpers@7.24.8': + '@babel/helpers@7.25.0': dependencies: - '@babel/template': 7.24.7 - '@babel/types': 7.24.9 + '@babel/template': 7.25.0 + '@babel/types': 7.25.0 '@babel/highlight@7.24.7': dependencies: @@ -7005,9 +6987,9 @@ snapshots: js-tokens: 4.0.0 picocolors: 1.0.1 - '@babel/parser@7.24.8': + '@babel/parser@7.25.0': dependencies: - '@babel/types': 7.24.9 + '@babel/types': 7.25.0 '@babel/plugin-proposal-export-namespace-from@7.18.9(@babel/core@7.24.9)': dependencies: @@ -7093,7 +7075,7 @@ snapshots: '@babel/plugin-transform-modules-commonjs@7.24.8(@babel/core@7.24.9)': dependencies: '@babel/core': 7.24.9 - '@babel/helper-module-transforms': 7.24.9(@babel/core@7.24.9) + '@babel/helper-module-transforms': 7.25.0(@babel/core@7.24.9) '@babel/helper-plugin-utils': 7.24.8 '@babel/helper-simple-access': 7.24.7 transitivePeerDependencies: @@ -7103,28 +7085,25 @@ snapshots: dependencies: regenerator-runtime: 0.14.1 - '@babel/template@7.24.7': + '@babel/template@7.25.0': dependencies: '@babel/code-frame': 7.24.7 - '@babel/parser': 7.24.8 - '@babel/types': 7.24.9 + '@babel/parser': 7.25.0 + '@babel/types': 7.25.0 - '@babel/traverse@7.24.8': + '@babel/traverse@7.25.0': dependencies: '@babel/code-frame': 7.24.7 - '@babel/generator': 7.24.10 - '@babel/helper-environment-visitor': 7.24.7 - '@babel/helper-function-name': 7.24.7 - '@babel/helper-hoist-variables': 7.24.7 - '@babel/helper-split-export-declaration': 7.24.7 - '@babel/parser': 7.24.8 - '@babel/types': 7.24.9 - debug: 4.3.5 + '@babel/generator': 7.25.0 + '@babel/parser': 7.25.0 + '@babel/template': 7.25.0 + '@babel/types': 7.25.0 + debug: 4.3.6 globals: 11.12.0 transitivePeerDependencies: - supports-color - '@babel/types@7.24.9': + '@babel/types@7.25.0': dependencies: '@babel/helper-string-parser': 7.24.8 '@babel/helper-validator-identifier': 7.24.7 @@ -7507,23 +7486,23 @@ snapshots: '@img/sharp-win32-x64@0.33.4': optional: true - '@inquirer/checkbox@2.4.1': + '@inquirer/checkbox@2.4.2': dependencies: - '@inquirer/core': 9.0.4 - '@inquirer/figures': 1.0.4 - '@inquirer/type': 1.5.0 + '@inquirer/core': 9.0.5 + '@inquirer/figures': 1.0.5 + '@inquirer/type': 1.5.1 ansi-escapes: 4.3.2 yoctocolors-cjs: 2.1.2 - '@inquirer/confirm@3.1.16': + '@inquirer/confirm@3.1.17': dependencies: - '@inquirer/core': 9.0.4 - '@inquirer/type': 1.5.0 + '@inquirer/core': 9.0.5 + '@inquirer/type': 1.5.1 - '@inquirer/core@9.0.4': + '@inquirer/core@9.0.5': dependencies: - '@inquirer/figures': 1.0.4 - '@inquirer/type': 1.5.0 + '@inquirer/figures': 1.0.5 + '@inquirer/type': 1.5.1 '@types/mute-stream': 0.0.4 '@types/node': 20.14.12 '@types/wrap-ansi': 3.0.0 @@ -7536,63 +7515,71 @@ snapshots: wrap-ansi: 6.2.0 yoctocolors-cjs: 2.1.2 - '@inquirer/editor@2.1.16': + '@inquirer/editor@2.1.17': dependencies: - '@inquirer/core': 9.0.4 - '@inquirer/type': 1.5.0 + '@inquirer/core': 9.0.5 + '@inquirer/type': 1.5.1 external-editor: 3.1.0 - '@inquirer/expand@2.1.16': + '@inquirer/expand@2.1.17': dependencies: - '@inquirer/core': 9.0.4 - '@inquirer/type': 1.5.0 + '@inquirer/core': 9.0.5 + '@inquirer/type': 1.5.1 yoctocolors-cjs: 2.1.2 - '@inquirer/figures@1.0.4': {} + '@inquirer/figures@1.0.5': {} - '@inquirer/input@2.2.3': + '@inquirer/input@2.2.4': dependencies: - '@inquirer/core': 9.0.4 - '@inquirer/type': 1.5.0 + '@inquirer/core': 9.0.5 + '@inquirer/type': 1.5.1 - '@inquirer/number@1.0.4': + '@inquirer/number@1.0.5': dependencies: - '@inquirer/core': 9.0.4 - '@inquirer/type': 1.5.0 + '@inquirer/core': 9.0.5 + '@inquirer/type': 1.5.1 - '@inquirer/password@2.1.16': + '@inquirer/password@2.1.17': dependencies: - '@inquirer/core': 9.0.4 - '@inquirer/type': 1.5.0 + '@inquirer/core': 9.0.5 + '@inquirer/type': 1.5.1 ansi-escapes: 4.3.2 - '@inquirer/prompts@5.2.1': + '@inquirer/prompts@5.3.2': dependencies: - '@inquirer/checkbox': 2.4.1 - '@inquirer/confirm': 3.1.16 - '@inquirer/editor': 2.1.16 - '@inquirer/expand': 2.1.16 - '@inquirer/input': 2.2.3 - '@inquirer/number': 1.0.4 - '@inquirer/password': 2.1.16 - '@inquirer/rawlist': 2.1.16 - '@inquirer/select': 2.4.1 + '@inquirer/checkbox': 2.4.2 + '@inquirer/confirm': 3.1.17 + '@inquirer/editor': 2.1.17 + '@inquirer/expand': 2.1.17 + '@inquirer/input': 2.2.4 + '@inquirer/number': 1.0.5 + '@inquirer/password': 2.1.17 + '@inquirer/rawlist': 2.1.17 + '@inquirer/search': 1.0.2 + '@inquirer/select': 2.4.2 - '@inquirer/rawlist@2.1.16': + '@inquirer/rawlist@2.1.17': dependencies: - '@inquirer/core': 9.0.4 - '@inquirer/type': 1.5.0 + '@inquirer/core': 9.0.5 + '@inquirer/type': 1.5.1 yoctocolors-cjs: 2.1.2 - '@inquirer/select@2.4.1': + '@inquirer/search@1.0.2': dependencies: - '@inquirer/core': 9.0.4 - '@inquirer/figures': 1.0.4 - '@inquirer/type': 1.5.0 + '@inquirer/core': 9.0.5 + '@inquirer/figures': 1.0.5 + '@inquirer/type': 1.5.1 + yoctocolors-cjs: 2.1.2 + + '@inquirer/select@2.4.2': + dependencies: + '@inquirer/core': 9.0.5 + '@inquirer/figures': 1.0.5 + '@inquirer/type': 1.5.1 ansi-escapes: 4.3.2 yoctocolors-cjs: 2.1.2 - '@inquirer/type@1.5.0': + '@inquirer/type@1.5.1': dependencies: mute-stream: 1.0.0 @@ -7819,7 +7806,7 @@ snapshots: '@koa/router@12.0.1': dependencies: - debug: 4.3.5 + debug: 4.3.6 http-errors: 2.0.0 koa-compose: 4.1.0 methods: 1.1.2 @@ -7839,7 +7826,7 @@ snapshots: '@ladjs/koa-views@9.0.0(@babel/core@7.24.9)(@types/koa@2.15.0)(ejs@3.1.10)(lodash@4.17.21)(pug@3.0.3)': dependencies: '@ladjs/consolidate': 1.0.4(@babel/core@7.24.9)(ejs@3.1.10)(lodash@4.17.21)(pug@3.0.3) - debug: 4.3.5 + debug: 4.3.6 get-paths: 0.0.7 koa-send: 5.0.1 mz: 2.7.0 @@ -7925,8 +7912,8 @@ snapshots: '@octokit/rest': 21.0.1 clipanion: 3.2.1(typanion@3.14.0) colorette: 2.0.20 - debug: 4.3.5 - inquirer: 10.0.4 + debug: 4.3.6 + inquirer: 10.1.2 js-yaml: 4.1.0 lodash-es: 4.17.21 semver: 7.6.3 @@ -7947,8 +7934,8 @@ snapshots: '@napi-rs/cross-toolchain@0.0.16': dependencies: '@napi-rs/lzma': 1.3.1 - '@napi-rs/tar': 0.1.1 - debug: 4.3.5 + '@napi-rs/tar': 0.1.4 + debug: 4.3.6 transitivePeerDependencies: - supports-color @@ -8013,66 +8000,74 @@ snapshots: '@napi-rs/lzma-win32-ia32-msvc': 1.3.1 '@napi-rs/lzma-win32-x64-msvc': 1.3.1 - '@napi-rs/tar-android-arm-eabi@0.1.1': + '@napi-rs/tar-android-arm-eabi@0.1.4': optional: true - '@napi-rs/tar-android-arm64@0.1.1': + '@napi-rs/tar-android-arm64@0.1.4': optional: true - '@napi-rs/tar-darwin-arm64@0.1.1': + '@napi-rs/tar-darwin-arm64@0.1.4': optional: true - '@napi-rs/tar-darwin-x64@0.1.1': + '@napi-rs/tar-darwin-x64@0.1.4': optional: true - '@napi-rs/tar-freebsd-x64@0.1.1': + '@napi-rs/tar-freebsd-x64@0.1.4': optional: true - '@napi-rs/tar-linux-arm-gnueabihf@0.1.1': + '@napi-rs/tar-linux-arm-gnueabihf@0.1.4': optional: true - '@napi-rs/tar-linux-arm64-gnu@0.1.1': + '@napi-rs/tar-linux-arm64-gnu@0.1.4': optional: true - '@napi-rs/tar-linux-arm64-musl@0.1.1': + '@napi-rs/tar-linux-arm64-musl@0.1.4': optional: true - '@napi-rs/tar-linux-x64-gnu@0.1.1': + '@napi-rs/tar-linux-ppc64-gnu@0.1.4': optional: true - '@napi-rs/tar-linux-x64-musl@0.1.1': + '@napi-rs/tar-linux-s390x-gnu@0.1.4': optional: true - '@napi-rs/tar-wasm32-wasi@0.1.1': + '@napi-rs/tar-linux-x64-gnu@0.1.4': + optional: true + + '@napi-rs/tar-linux-x64-musl@0.1.4': + optional: true + + '@napi-rs/tar-wasm32-wasi@0.1.4': dependencies: '@napi-rs/wasm-runtime': 0.2.4 optional: true - '@napi-rs/tar-win32-arm64-msvc@0.1.1': + '@napi-rs/tar-win32-arm64-msvc@0.1.4': optional: true - '@napi-rs/tar-win32-ia32-msvc@0.1.1': + '@napi-rs/tar-win32-ia32-msvc@0.1.4': optional: true - '@napi-rs/tar-win32-x64-msvc@0.1.1': + '@napi-rs/tar-win32-x64-msvc@0.1.4': optional: true - '@napi-rs/tar@0.1.1': + '@napi-rs/tar@0.1.4': optionalDependencies: - '@napi-rs/tar-android-arm-eabi': 0.1.1 - '@napi-rs/tar-android-arm64': 0.1.1 - '@napi-rs/tar-darwin-arm64': 0.1.1 - '@napi-rs/tar-darwin-x64': 0.1.1 - '@napi-rs/tar-freebsd-x64': 0.1.1 - '@napi-rs/tar-linux-arm-gnueabihf': 0.1.1 - '@napi-rs/tar-linux-arm64-gnu': 0.1.1 - '@napi-rs/tar-linux-arm64-musl': 0.1.1 - '@napi-rs/tar-linux-x64-gnu': 0.1.1 - '@napi-rs/tar-linux-x64-musl': 0.1.1 - '@napi-rs/tar-wasm32-wasi': 0.1.1 - '@napi-rs/tar-win32-arm64-msvc': 0.1.1 - '@napi-rs/tar-win32-ia32-msvc': 0.1.1 - '@napi-rs/tar-win32-x64-msvc': 0.1.1 + '@napi-rs/tar-android-arm-eabi': 0.1.4 + '@napi-rs/tar-android-arm64': 0.1.4 + '@napi-rs/tar-darwin-arm64': 0.1.4 + '@napi-rs/tar-darwin-x64': 0.1.4 + '@napi-rs/tar-freebsd-x64': 0.1.4 + '@napi-rs/tar-linux-arm-gnueabihf': 0.1.4 + '@napi-rs/tar-linux-arm64-gnu': 0.1.4 + '@napi-rs/tar-linux-arm64-musl': 0.1.4 + '@napi-rs/tar-linux-ppc64-gnu': 0.1.4 + '@napi-rs/tar-linux-s390x-gnu': 0.1.4 + '@napi-rs/tar-linux-x64-gnu': 0.1.4 + '@napi-rs/tar-linux-x64-musl': 0.1.4 + '@napi-rs/tar-wasm32-wasi': 0.1.4 + '@napi-rs/tar-win32-arm64-msvc': 0.1.4 + '@napi-rs/tar-win32-ia32-msvc': 0.1.4 + '@napi-rs/tar-win32-x64-msvc': 0.1.4 '@napi-rs/wasm-runtime@0.2.4': dependencies: @@ -8391,24 +8386,24 @@ snapshots: '@types/babel__core@7.20.5': dependencies: - '@babel/parser': 7.24.8 - '@babel/types': 7.24.9 + '@babel/parser': 7.25.0 + '@babel/types': 7.25.0 '@types/babel__generator': 7.6.8 '@types/babel__template': 7.4.4 '@types/babel__traverse': 7.20.6 '@types/babel__generator@7.6.8': dependencies: - '@babel/types': 7.24.9 + '@babel/types': 7.25.0 '@types/babel__template@7.4.4': dependencies: - '@babel/parser': 7.24.8 - '@babel/types': 7.24.9 + '@babel/parser': 7.25.0 + '@babel/types': 7.25.0 '@types/babel__traverse@7.20.6': dependencies: - '@babel/types': 7.24.9 + '@babel/types': 7.25.0 '@types/body-parser@1.19.5': dependencies: @@ -8452,7 +8447,7 @@ snapshots: '@types/eslint-scope@3.7.7': dependencies: - '@types/eslint': 8.56.10 + '@types/eslint': 9.6.0 '@types/estree': 1.0.5 '@types/eslint@7.29.0': @@ -8460,7 +8455,7 @@ snapshots: '@types/estree': 1.0.5 '@types/json-schema': 7.0.15 - '@types/eslint@8.56.10': + '@types/eslint@9.6.0': dependencies: '@types/estree': 1.0.5 '@types/json-schema': 7.0.15 @@ -8738,7 +8733,7 @@ snapshots: '@vue/compiler-core@3.4.34': dependencies: - '@babel/parser': 7.24.8 + '@babel/parser': 7.25.0 '@vue/shared': 3.4.34 entities: 4.5.0 estree-walker: 2.0.2 @@ -8751,22 +8746,22 @@ snapshots: '@vue/compiler-sfc@2.7.16': dependencies: - '@babel/parser': 7.24.8 - postcss: 8.4.39 + '@babel/parser': 7.25.0 + postcss: 8.4.40 source-map: 0.6.1 optionalDependencies: prettier: 2.8.8 '@vue/compiler-sfc@3.4.34': dependencies: - '@babel/parser': 7.24.8 + '@babel/parser': 7.25.0 '@vue/compiler-core': 3.4.34 '@vue/compiler-dom': 3.4.34 '@vue/compiler-ssr': 3.4.34 '@vue/shared': 3.4.34 estree-walker: 2.0.2 magic-string: 0.30.10 - postcss: 8.4.39 + postcss: 8.4.40 source-map-js: 1.2.0 '@vue/compiler-ssr@3.4.34': @@ -8923,7 +8918,7 @@ snapshots: agent-base@7.1.1: dependencies: - debug: 4.3.5 + debug: 4.3.6 transitivePeerDependencies: - supports-color @@ -9092,8 +9087,8 @@ snapshots: babel-plugin-jest-hoist@29.6.3: dependencies: - '@babel/template': 7.24.7 - '@babel/types': 7.24.9 + '@babel/template': 7.25.0 + '@babel/types': 7.25.0 '@types/babel__core': 7.20.5 '@types/babel__traverse': 7.20.6 @@ -9121,7 +9116,7 @@ snapshots: babel-walk@3.0.0-canary-5: dependencies: - '@babel/types': 7.24.9 + '@babel/types': 7.25.0 balanced-match@1.0.2: {} @@ -9177,9 +9172,9 @@ snapshots: browserslist@4.23.2: dependencies: - caniuse-lite: 1.0.30001642 - electron-to-chromium: 1.4.832 - node-releases: 2.0.17 + caniuse-lite: 1.0.30001643 + electron-to-chromium: 1.5.2 + node-releases: 2.0.18 update-browserslist-db: 1.1.0(browserslist@4.23.2) bs-logger@0.2.6: @@ -9208,7 +9203,7 @@ snapshots: buffer@4.9.2: dependencies: base64-js: 1.5.1 - ieee754: 1.2.1 + ieee754: 1.1.13 isarray: 1.0.0 buffer@5.7.1: @@ -9294,7 +9289,7 @@ snapshots: camelcase@6.3.0: {} - caniuse-lite@1.0.30001642: {} + caniuse-lite@1.0.30001643: {} canonicalize@1.0.8: {} @@ -9540,8 +9535,8 @@ snapshots: constantinople@4.0.1: dependencies: - '@babel/parser': 7.24.8 - '@babel/types': 7.24.9 + '@babel/parser': 7.25.0 + '@babel/types': 7.25.0 content-disposition@0.5.4: dependencies: @@ -9669,7 +9664,7 @@ snapshots: dependencies: ms: 2.1.2 - debug@4.3.5: + debug@4.3.6: dependencies: ms: 2.1.2 @@ -9850,7 +9845,7 @@ snapshots: dependencies: jake: 10.9.2 - electron-to-chromium@1.4.832: {} + electron-to-chromium@1.5.2: {} emittery@0.13.1: {} @@ -9868,7 +9863,7 @@ snapshots: dependencies: once: 1.4.0 - enhanced-resolve@5.17.0: + enhanced-resolve@5.17.1: dependencies: graceful-fs: 4.2.11 tapable: 2.2.1 @@ -10021,7 +10016,7 @@ snapshots: is-plain-obj: 4.1.0 is-stream: 4.0.1 npm-run-path: 5.3.0 - pretty-ms: 9.0.0 + pretty-ms: 9.1.0 signal-exit: 4.1.0 strip-final-newline: 4.0.0 yoctocolors: 2.1.1 @@ -10101,7 +10096,7 @@ snapshots: file-type@19.3.0: dependencies: - strtok3: 8.0.0 + strtok3: 8.0.1 token-types: 6.0.0 uint8array-extras: 1.4.0 @@ -10414,7 +10409,7 @@ snapshots: http-proxy-agent@7.0.2: dependencies: agent-base: 7.1.1 - debug: 4.3.5 + debug: 4.3.6 transitivePeerDependencies: - supports-color @@ -10431,7 +10426,7 @@ snapshots: https-proxy-agent@7.0.5: dependencies: agent-base: 7.1.1 - debug: 4.3.5 + debug: 4.3.6 transitivePeerDependencies: - supports-color @@ -10457,9 +10452,9 @@ snapshots: ignore@5.3.1: {} - immutable@4.3.6: {} + immutable@4.3.7: {} - import-local@3.1.0: + import-local@3.2.0: dependencies: pkg-dir: 4.2.0 resolve-cwd: 3.0.0 @@ -10481,10 +10476,10 @@ snapshots: ini@1.3.8: {} - inquirer@10.0.4: + inquirer@10.1.2: dependencies: - '@inquirer/prompts': 5.2.1 - '@inquirer/type': 1.5.0 + '@inquirer/prompts': 5.3.2 + '@inquirer/type': 1.5.1 '@types/mute-stream': 0.0.4 ansi-escapes: 4.3.2 mute-stream: 1.0.0 @@ -10497,7 +10492,7 @@ snapshots: dependencies: '@ioredis/commands': 1.2.0 cluster-key-slot: 1.1.2 - debug: 4.3.5 + debug: 4.3.6 denque: 2.1.0 lodash.defaults: 4.2.0 lodash.isarguments: 3.1.0 @@ -10628,7 +10623,7 @@ snapshots: istanbul-lib-instrument@5.2.1: dependencies: '@babel/core': 7.24.9 - '@babel/parser': 7.24.8 + '@babel/parser': 7.25.0 '@istanbuljs/schema': 0.1.3 istanbul-lib-coverage: 3.2.2 semver: 6.3.1 @@ -10638,7 +10633,7 @@ snapshots: istanbul-lib-instrument@6.0.3: dependencies: '@babel/core': 7.24.9 - '@babel/parser': 7.24.8 + '@babel/parser': 7.25.0 '@istanbuljs/schema': 0.1.3 istanbul-lib-coverage: 3.2.2 semver: 7.6.3 @@ -10653,7 +10648,7 @@ snapshots: istanbul-lib-source-maps@4.0.1: dependencies: - debug: 4.3.5 + debug: 4.3.6 istanbul-lib-coverage: 3.2.2 source-map: 0.6.1 transitivePeerDependencies: @@ -10717,7 +10712,7 @@ snapshots: chalk: 4.1.2 create-jest: 29.7.0(@types/node@20.14.12)(ts-node@10.9.2(@types/node@20.14.12)(typescript@5.5.4)) exit: 0.1.2 - import-local: 3.1.0 + import-local: 3.2.0 jest-config: 29.7.0(@types/node@20.14.12)(ts-node@10.9.2(@types/node@20.14.12)(typescript@5.5.4)) jest-util: 29.7.0 jest-validate: 29.7.0 @@ -10923,10 +10918,10 @@ snapshots: jest-snapshot@29.7.0: dependencies: '@babel/core': 7.24.9 - '@babel/generator': 7.24.10 + '@babel/generator': 7.25.0 '@babel/plugin-syntax-jsx': 7.24.7(@babel/core@7.24.9) '@babel/plugin-syntax-typescript': 7.24.7(@babel/core@7.24.9) - '@babel/types': 7.24.9 + '@babel/types': 7.25.0 '@jest/expect-utils': 29.7.0 '@jest/transform': 29.7.0 '@jest/types': 29.6.3 @@ -10996,7 +10991,7 @@ snapshots: dependencies: '@jest/core': 29.7.0(ts-node@10.9.2(@types/node@20.14.12)(typescript@5.5.4)) '@jest/types': 29.6.3 - import-local: 3.1.0 + import-local: 3.2.0 jest-cli: 29.7.0(@types/node@20.14.12)(ts-node@10.9.2(@types/node@20.14.12)(typescript@5.5.4)) transitivePeerDependencies: - '@types/node' @@ -11181,7 +11176,7 @@ snapshots: koa-mount@4.0.0: dependencies: - debug: 4.3.5 + debug: 4.3.6 koa-compose: 4.1.0 transitivePeerDependencies: - supports-color @@ -11190,7 +11185,7 @@ snapshots: koa-router@10.1.1: dependencies: - debug: 4.3.5 + debug: 4.3.6 http-errors: 1.8.1 koa-compose: 4.1.0 methods: 1.1.2 @@ -11200,7 +11195,7 @@ snapshots: koa-send@5.0.1: dependencies: - debug: 4.3.5 + debug: 4.3.6 http-errors: 1.8.1 resolve-path: 1.4.0 transitivePeerDependencies: @@ -11216,7 +11211,7 @@ snapshots: koa-views@7.0.2(@types/koa@2.15.0)(ejs@3.1.10)(lodash@4.17.21)(pug@3.0.3): dependencies: consolidate: 0.16.0(ejs@3.1.10)(lodash@4.17.21)(pug@3.0.3) - debug: 4.3.5 + debug: 4.3.6 get-paths: 0.0.7 koa-send: 5.0.1 mz: 2.7.0 @@ -11287,7 +11282,7 @@ snapshots: content-disposition: 0.5.4 content-type: 1.0.5 cookies: 0.8.0 - debug: 4.3.5 + debug: 4.3.3 delegates: 1.0.0 depd: 2.0.0 destroy: 1.2.0 @@ -11315,7 +11310,7 @@ snapshots: content-disposition: 0.5.4 content-type: 1.0.5 cookies: 0.9.1 - debug: 4.3.5 + debug: 4.3.6 delegates: 1.0.0 depd: 2.0.0 destroy: 1.2.0 @@ -11623,7 +11618,7 @@ snapshots: node-int64@0.4.0: {} - node-releases@2.0.17: {} + node-releases@2.0.18: {} nodemailer@6.9.14: {} @@ -11885,7 +11880,7 @@ snapshots: possible-typed-array-names@1.0.0: {} - postcss@8.4.39: + postcss@8.4.40: dependencies: nanoid: 3.3.7 picocolors: 1.0.1 @@ -11922,7 +11917,7 @@ snapshots: ansi-styles: 5.2.0 react-is: 18.3.1 - pretty-ms@9.0.0: + pretty-ms@9.1.0: dependencies: parse-ms: 4.0.0 @@ -12196,7 +12191,7 @@ snapshots: redis-semaphore@5.6.0(ioredis@5.4.1): dependencies: - debug: 4.3.5 + debug: 4.3.6 optionalDependencies: ioredis: 5.4.1 transitivePeerDependencies: @@ -12316,12 +12311,12 @@ snapshots: htmlparser2: 8.0.2 is-plain-object: 5.0.0 parse-srcset: 1.0.2 - postcss: 8.4.39 + postcss: 8.4.40 sass@1.77.8: dependencies: chokidar: 3.6.0 - immutable: 4.3.6 + immutable: 4.3.7 source-map-js: 1.2.0 sax@1.2.1: {} @@ -12566,7 +12561,7 @@ snapshots: strnum@1.0.5: {} - strtok3@8.0.0: + strtok3@8.0.1: dependencies: '@tokenizer/token': 0.3.0 peek-readable: 5.1.3 @@ -12766,7 +12761,7 @@ snapshots: ts-loader@9.5.1(typescript@5.5.4)(webpack@5.93.0): dependencies: chalk: 4.1.2 - enhanced-resolve: 5.17.0 + enhanced-resolve: 5.17.1 micromatch: 4.0.7 semver: 7.6.3 source-map: 0.7.4 @@ -12857,7 +12852,7 @@ snapshots: chalk: 4.1.2 cli-highlight: 2.1.11 dayjs: 1.11.12 - debug: 4.3.5 + debug: 4.3.6 dotenv: 16.4.5 glob: 10.4.5 mkdirp: 2.1.6 @@ -12983,7 +12978,7 @@ snapshots: vite-plugin-compression@0.5.1(vite@5.3.5(@types/node@20.14.12)(sass@1.77.8)(terser@5.31.3)): dependencies: chalk: 4.1.2 - debug: 4.3.5 + debug: 4.3.6 fs-extra: 10.1.0 vite: 5.3.5(@types/node@20.14.12)(sass@1.77.8)(terser@5.31.3) transitivePeerDependencies: @@ -12992,7 +12987,7 @@ snapshots: vite@5.3.5(@types/node@20.14.12)(sass@1.77.8)(terser@5.31.3): dependencies: esbuild: 0.21.5 - postcss: 8.4.39 + postcss: 8.4.40 rollup: 4.19.1 optionalDependencies: '@types/node': 20.14.12 @@ -13075,7 +13070,7 @@ snapshots: acorn-import-attributes: 1.9.5(acorn@8.12.1) browserslist: 4.23.2 chrome-trace-event: 1.0.4 - enhanced-resolve: 5.17.0 + enhanced-resolve: 5.17.1 es-module-lexer: 1.5.4 eslint-scope: 5.1.1 events: 3.3.0 @@ -13142,8 +13137,8 @@ snapshots: with@7.0.2: dependencies: - '@babel/parser': 7.24.8 - '@babel/types': 7.24.9 + '@babel/parser': 7.25.0 + '@babel/types': 7.25.0 assert-never: 1.3.0 babel-walk: 3.0.0-canary-5 @@ -13192,7 +13187,7 @@ snapshots: xml2js@0.6.2: dependencies: - sax: 1.4.1 + sax: 1.2.1 xmlbuilder: 11.0.1 xmlbuilder@11.0.1: {} From a7556ad8133f3f06d9924780e62639d1e8dc0de3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=80=81=E5=91=A8=E9=83=A8=E8=90=BD?= Date: Sat, 27 Jul 2024 23:43:50 +0800 Subject: [PATCH 42/43] chore: replace archived vscode plugin --- .vscode/extensions.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.vscode/extensions.json b/.vscode/extensions.json index e12d180b76..382052742e 100644 --- a/.vscode/extensions.json +++ b/.vscode/extensions.json @@ -15,7 +15,7 @@ "biomejs.biome", "rust-lang.rust-analyzer", "vadimcn.vscode-lldb", - "serayuzgur.crates", + "fill-labs.dependi", "tamasfe.even-better-toml", "aaron-bond.better-comments" ] From af8c6bffb864590e0a2e4efa3abbd48273236ad2 Mon Sep 17 00:00:00 2001 From: naskya Date: Sun, 28 Jul 2024 01:28:03 +0900 Subject: [PATCH 43/43] v20240728 --- docs/api-change.md | 2 +- docs/changelog.md | 2 +- package.json | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/api-change.md b/docs/api-change.md index 38d259a764..15fd3113b5 100644 --- a/docs/api-change.md +++ b/docs/api-change.md @@ -2,7 +2,7 @@ Breaking changes are indicated by the :warning: icon. -## Unreleased +## v20240728 - Added `name`, `category`, `aliases`, `license` optional parameters to `admin/emoji/add` endpoint. - Added `name` optional parameter to `drive/files/upload-from-url` endpoint. diff --git a/docs/changelog.md b/docs/changelog.md index 61d76b0373..3c88bb75c0 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -7,7 +7,7 @@ This changelog is not an exhaustive list. Code refactorings, minor bug fixes, do - Server administrators must check [notice-for-admins.md](https://firefish.dev/firefish/firefish/-/blob/main/docs/notice-for-admins.md) as well. - Third-party client/bot developers may want to check [api-change.md](https://firefish.dev/firefish/firefish/-/blob/main/docs/api-change.md) as well. -## Unreleased +## [v20240728](https://firefish.dev/firefish/firefish/-/merge_requests/11211/commits) - Improve `admin/emoji/add` API - Fix bugs diff --git a/package.json b/package.json index 36623033f2..d98bbb1326 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "firefish", - "version": "20240725", + "version": "20240728", "repository": { "type": "git", "url": "https://firefish.dev/firefish/firefish.git"