mirror of
https://github.com/kokonect-link/cherrypick
synced 2024-12-21 10:08:19 +09:00
Merge branch 'develop' into feat-13070
This commit is contained in:
commit
93f301742f
@ -1,5 +1,11 @@
|
|||||||
|
# misskey settings
|
||||||
|
# MISSKEY_URL=https://example.tld/
|
||||||
|
|
||||||
# db settings
|
# db settings
|
||||||
POSTGRES_PASSWORD=example-misskey-pass
|
POSTGRES_PASSWORD=example-misskey-pass
|
||||||
|
# DATABASE_PASSWORD=${POSTGRES_PASSWORD}
|
||||||
POSTGRES_USER=example-misskey-user
|
POSTGRES_USER=example-misskey-user
|
||||||
|
# DATABASE_USER=${POSTGRES_USER}
|
||||||
POSTGRES_DB=misskey
|
POSTGRES_DB=misskey
|
||||||
|
# DATABASE_DB=${POSTGRES_DB}
|
||||||
DATABASE_URL="postgres://${POSTGRES_USER}:${POSTGRES_PASSWORD}@db:5432/${POSTGRES_DB}"
|
DATABASE_URL="postgres://${POSTGRES_USER}:${POSTGRES_PASSWORD}@db:5432/${POSTGRES_DB}"
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
#───┘ URL └─────────────────────────────────────────────────────
|
#───┘ URL └─────────────────────────────────────────────────────
|
||||||
|
|
||||||
# Final accessible URL seen by a user.
|
# Final accessible URL seen by a user.
|
||||||
|
# You can set url from an environment variable instead.
|
||||||
url: https://example.tld/
|
url: https://example.tld/
|
||||||
|
|
||||||
# ONCE YOU HAVE STARTED THE INSTANCE, DO NOT CHANGE THE
|
# ONCE YOU HAVE STARTED THE INSTANCE, DO NOT CHANGE THE
|
||||||
@ -38,9 +39,11 @@ db:
|
|||||||
port: 5432
|
port: 5432
|
||||||
|
|
||||||
# Database name
|
# Database name
|
||||||
|
# You can set db from an environment variable instead.
|
||||||
db: misskey
|
db: misskey
|
||||||
|
|
||||||
# Auth
|
# Auth
|
||||||
|
# You can set user and pass from environment variables instead.
|
||||||
user: example-misskey-user
|
user: example-misskey-user
|
||||||
pass: example-misskey-pass
|
pass: example-misskey-pass
|
||||||
|
|
||||||
@ -161,12 +164,12 @@ id: 'aidx'
|
|||||||
#clusterLimit: 1
|
#clusterLimit: 1
|
||||||
|
|
||||||
# Job concurrency per worker
|
# Job concurrency per worker
|
||||||
# deliverJobConcurrency: 128
|
# deliverJobConcurrency: 16
|
||||||
# inboxJobConcurrency: 16
|
# inboxJobConcurrency: 4
|
||||||
|
|
||||||
# Job rate limiter
|
# Job rate limiter
|
||||||
# deliverJobPerSec: 128
|
# deliverJobPerSec: 128
|
||||||
# inboxJobPerSec: 32
|
# inboxJobPerSec: 64
|
||||||
|
|
||||||
# Job attempts
|
# Job attempts
|
||||||
# deliverJobMaxAttempts: 12
|
# deliverJobMaxAttempts: 12
|
||||||
|
@ -230,15 +230,15 @@ id: 'aidx'
|
|||||||
#clusterLimit: 1
|
#clusterLimit: 1
|
||||||
|
|
||||||
# Job concurrency per worker
|
# Job concurrency per worker
|
||||||
#deliverJobConcurrency: 128
|
#deliverJobConcurrency: 16
|
||||||
#inboxJobConcurrency: 16
|
#inboxJobConcurrency: 4
|
||||||
#relationshipJobConcurrency: 16
|
#relationshipJobConcurrency: 16
|
||||||
# What's relationshipJob?:
|
# What's relationshipJob?:
|
||||||
# Follow, unfollow, block and unblock(ings) while following-imports, etc. or account migrations.
|
# Follow, unfollow, block and unblock(ings) while following-imports, etc. or account migrations.
|
||||||
|
|
||||||
# Job rate limiter
|
# Job rate limiter
|
||||||
#deliverJobPerSec: 128
|
#deliverJobPerSec: 1024
|
||||||
#inboxJobPerSec: 32
|
#inboxJobPerSec: 64
|
||||||
#relationshipJobPerSec: 64
|
#relationshipJobPerSec: 64
|
||||||
|
|
||||||
# Job attempts
|
# Job attempts
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
version: '3.8'
|
|
||||||
|
|
||||||
services:
|
services:
|
||||||
app:
|
app:
|
||||||
build:
|
build:
|
||||||
@ -8,6 +6,7 @@ services:
|
|||||||
|
|
||||||
volumes:
|
volumes:
|
||||||
- ../:/workspace:cached
|
- ../:/workspace:cached
|
||||||
|
- node_modules:/workspace/node_modules
|
||||||
|
|
||||||
command: sleep infinity
|
command: sleep infinity
|
||||||
|
|
||||||
@ -46,6 +45,7 @@ services:
|
|||||||
volumes:
|
volumes:
|
||||||
postgres-data:
|
postgres-data:
|
||||||
redis-data:
|
redis-data:
|
||||||
|
node_modules:
|
||||||
|
|
||||||
networks:
|
networks:
|
||||||
internal_network:
|
internal_network:
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "Misskey",
|
"name": "Misskey",
|
||||||
"dockerComposeFile": "docker-compose.yml",
|
"dockerComposeFile": "compose.yml",
|
||||||
"service": "app",
|
"service": "app",
|
||||||
"workspaceFolder": "/workspace",
|
"workspaceFolder": "/workspace",
|
||||||
"features": {
|
"features": {
|
||||||
@ -10,7 +10,7 @@
|
|||||||
"ghcr.io/devcontainers-contrib/features/corepack:1": {}
|
"ghcr.io/devcontainers-contrib/features/corepack:1": {}
|
||||||
},
|
},
|
||||||
"forwardPorts": [3000],
|
"forwardPorts": [3000],
|
||||||
"postCreateCommand": "sudo chmod 755 .devcontainer/init.sh && .devcontainer/init.sh",
|
"postCreateCommand": "/bin/bash .devcontainer/init.sh",
|
||||||
"customizations": {
|
"customizations": {
|
||||||
"vscode": {
|
"vscode": {
|
||||||
"extensions": [
|
"extensions": [
|
||||||
|
@ -157,12 +157,12 @@ id: 'aidx'
|
|||||||
#clusterLimit: 1
|
#clusterLimit: 1
|
||||||
|
|
||||||
# Job concurrency per worker
|
# Job concurrency per worker
|
||||||
# deliverJobConcurrency: 128
|
# deliverJobConcurrency: 16
|
||||||
# inboxJobConcurrency: 16
|
# inboxJobConcurrency: 4
|
||||||
|
|
||||||
# Job rate limiter
|
# Job rate limiter
|
||||||
# deliverJobPerSec: 128
|
# deliverJobPerSec: 1024
|
||||||
# inboxJobPerSec: 32
|
# inboxJobPerSec: 64
|
||||||
|
|
||||||
# Job attempts
|
# Job attempts
|
||||||
# deliverJobMaxAttempts: 12
|
# deliverJobMaxAttempts: 12
|
||||||
|
@ -2,7 +2,8 @@
|
|||||||
|
|
||||||
set -xe
|
set -xe
|
||||||
|
|
||||||
sudo chown -R node /workspace
|
sudo chown node node_modules
|
||||||
|
git config --global --add safe.directory /workspace
|
||||||
git submodule update --init
|
git submodule update --init
|
||||||
corepack install
|
corepack install
|
||||||
corepack enable
|
corepack enable
|
||||||
|
@ -7,12 +7,11 @@ Dockerfile
|
|||||||
build/
|
build/
|
||||||
built/
|
built/
|
||||||
db/
|
db/
|
||||||
docker-compose.yml
|
.devcontainer/compose.yml
|
||||||
node_modules/
|
node_modules/
|
||||||
packages/*/node_modules
|
packages/*/node_modules
|
||||||
redis/
|
redis/
|
||||||
files/
|
files/
|
||||||
misskey-assets/
|
|
||||||
fluent-emojis/
|
fluent-emojis/
|
||||||
.pnp.*
|
.pnp.*
|
||||||
|
|
||||||
@ -28,4 +27,4 @@ fluent-emojis/
|
|||||||
|
|
||||||
.idea/
|
.idea/
|
||||||
packages/*/.vscode/
|
packages/*/.vscode/
|
||||||
packages/backend/test/docker-compose.yml
|
packages/backend/test/compose.yml
|
||||||
|
8
.github/ISSUE_TEMPLATE/01_bug-report.yml
vendored
8
.github/ISSUE_TEMPLATE/01_bug-report.yml
vendored
@ -53,8 +53,8 @@ body:
|
|||||||
Examples:
|
Examples:
|
||||||
* Model and OS of the device(s): MacBook Pro (14inch, 2021), macOS Ventura 13.4
|
* Model and OS of the device(s): MacBook Pro (14inch, 2021), macOS Ventura 13.4
|
||||||
* Browser: Chrome 113.0.5672.126
|
* Browser: Chrome 113.0.5672.126
|
||||||
* Server URL: misskey.io
|
* Server URL: misskey.example.com
|
||||||
* Misskey: 13.x.x
|
* Misskey: 2024.x.x
|
||||||
value: |
|
value: |
|
||||||
* Model and OS of the device(s):
|
* Model and OS of the device(s):
|
||||||
* Browser:
|
* Browser:
|
||||||
@ -74,11 +74,11 @@ body:
|
|||||||
|
|
||||||
Examples:
|
Examples:
|
||||||
* Installation Method or Hosting Service: docker compose, k8s/docker, systemd, "Misskey install shell script", development environment
|
* Installation Method or Hosting Service: docker compose, k8s/docker, systemd, "Misskey install shell script", development environment
|
||||||
* Misskey: 13.x.x
|
* Misskey: 2024.x.x
|
||||||
* Node: 20.x.x
|
* Node: 20.x.x
|
||||||
* PostgreSQL: 15.x.x
|
* PostgreSQL: 15.x.x
|
||||||
* Redis: 7.x.x
|
* Redis: 7.x.x
|
||||||
* OS and Architecture: Ubuntu 22.04.2 LTS aarch64
|
* OS and Architecture: Ubuntu 24.04.2 LTS aarch64
|
||||||
value: |
|
value: |
|
||||||
* Installation Method or Hosting Service:
|
* Installation Method or Hosting Service:
|
||||||
* Misskey:
|
* Misskey:
|
||||||
|
4
.github/ISSUE_TEMPLATE/config.yml
vendored
4
.github/ISSUE_TEMPLATE/config.yml
vendored
@ -2,3 +2,7 @@ contact_links:
|
|||||||
- name: 💬 Misskey official Discord
|
- name: 💬 Misskey official Discord
|
||||||
url: https://discord.gg/Wp8gVStHW3
|
url: https://discord.gg/Wp8gVStHW3
|
||||||
about: Chat freely about Misskey
|
about: Chat freely about Misskey
|
||||||
|
# 仮
|
||||||
|
- name: 💬 Start discussion
|
||||||
|
url: https://github.com/misskey-dev/misskey/discussions
|
||||||
|
about: The official forum to join conversation and ask question
|
||||||
|
5
.github/workflows/api-misskey-js.yml
vendored
5
.github/workflows/api-misskey-js.yml
vendored
@ -4,10 +4,11 @@ on:
|
|||||||
push:
|
push:
|
||||||
paths:
|
paths:
|
||||||
- packages/misskey-js/**
|
- packages/misskey-js/**
|
||||||
|
- .github/workflows/api-misskey-js.yml
|
||||||
pull_request:
|
pull_request:
|
||||||
paths:
|
paths:
|
||||||
- packages/misskey-js/**
|
- packages/misskey-js/**
|
||||||
|
- .github/workflows/api-misskey-js.yml
|
||||||
jobs:
|
jobs:
|
||||||
report:
|
report:
|
||||||
|
|
||||||
@ -20,7 +21,7 @@ jobs:
|
|||||||
- run: corepack enable
|
- run: corepack enable
|
||||||
|
|
||||||
- name: Setup Node.js
|
- name: Setup Node.js
|
||||||
uses: actions/setup-node@v4.0.2
|
uses: actions/setup-node@v4.0.3
|
||||||
with:
|
with:
|
||||||
node-version-file: '.node-version'
|
node-version-file: '.node-version'
|
||||||
cache: 'pnpm'
|
cache: 'pnpm'
|
||||||
|
2
.github/workflows/changelog-check.yml
vendored
2
.github/workflows/changelog-check.yml
vendored
@ -14,7 +14,7 @@ jobs:
|
|||||||
- name: Checkout head
|
- name: Checkout head
|
||||||
uses: actions/checkout@v4.1.1
|
uses: actions/checkout@v4.1.1
|
||||||
- name: Setup Node.js
|
- name: Setup Node.js
|
||||||
uses: actions/setup-node@v4.0.2
|
uses: actions/setup-node@v4.0.3
|
||||||
with:
|
with:
|
||||||
node-version-file: '.node-version'
|
node-version-file: '.node-version'
|
||||||
|
|
||||||
|
@ -28,7 +28,7 @@ jobs:
|
|||||||
|
|
||||||
- name: setup node
|
- name: setup node
|
||||||
id: setup-node
|
id: setup-node
|
||||||
uses: actions/setup-node@v4.0.2
|
uses: actions/setup-node@v4.0.3
|
||||||
with:
|
with:
|
||||||
node-version-file: '.node-version'
|
node-version-file: '.node-version'
|
||||||
cache: pnpm
|
cache: pnpm
|
||||||
|
@ -6,12 +6,13 @@ on:
|
|||||||
paths:
|
paths:
|
||||||
- packages/misskey-js/package.json
|
- packages/misskey-js/package.json
|
||||||
- package.json
|
- package.json
|
||||||
|
- .github/workflows/check-misskey-js-version.yml
|
||||||
pull_request:
|
pull_request:
|
||||||
branches: [ develop ]
|
branches: [ develop ]
|
||||||
paths:
|
paths:
|
||||||
- packages/misskey-js/package.json
|
- packages/misskey-js/package.json
|
||||||
- package.json
|
- package.json
|
||||||
|
- .github/workflows/check-misskey-js-version.yml
|
||||||
jobs:
|
jobs:
|
||||||
check-version:
|
check-version:
|
||||||
# ルートの package.json と packages/misskey-js/package.json のバージョンが一致しているかを確認する
|
# ルートの package.json と packages/misskey-js/package.json のバージョンが一致しているかを確認する
|
||||||
|
2
.github/workflows/docker-develop.yml
vendored
2
.github/workflows/docker-develop.yml
vendored
@ -37,7 +37,7 @@ jobs:
|
|||||||
password: ${{ secrets.DOCKER_PASSWORD }}
|
password: ${{ secrets.DOCKER_PASSWORD }}
|
||||||
- name: Build and push by digest
|
- name: Build and push by digest
|
||||||
id: build
|
id: build
|
||||||
uses: docker/build-push-action@v5
|
uses: docker/build-push-action@v6
|
||||||
with:
|
with:
|
||||||
context: .
|
context: .
|
||||||
push: true
|
push: true
|
||||||
|
2
.github/workflows/docker.yml
vendored
2
.github/workflows/docker.yml
vendored
@ -48,7 +48,7 @@ jobs:
|
|||||||
password: ${{ secrets.DOCKER_PASSWORD }}
|
password: ${{ secrets.DOCKER_PASSWORD }}
|
||||||
- name: Build and Push to Docker Hub
|
- name: Build and Push to Docker Hub
|
||||||
id: build
|
id: build
|
||||||
uses: docker/build-push-action@v5
|
uses: docker/build-push-action@v6
|
||||||
with:
|
with:
|
||||||
context: .
|
context: .
|
||||||
push: true
|
push: true
|
||||||
|
8
.github/workflows/dockle.yml
vendored
8
.github/workflows/dockle.yml
vendored
@ -13,14 +13,16 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
env:
|
env:
|
||||||
DOCKER_CONTENT_TRUST: 1
|
DOCKER_CONTENT_TRUST: 1
|
||||||
|
DOCKLE_VERSION: 0.4.14
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4.1.1
|
- uses: actions/checkout@v4.1.1
|
||||||
- run: |
|
- name: Download and install dockle v${{ env.DOCKLE_VERSION }}
|
||||||
curl -L -o dockle.deb "https://github.com/goodwithtech/dockle/releases/download/v0.4.10/dockle_0.4.10_Linux-64bit.deb"
|
run: |
|
||||||
|
curl -L -o dockle.deb "https://github.com/goodwithtech/dockle/releases/download/v${DOCKLE_VERSION}/dockle_${DOCKLE_VERSION}_Linux-64bit.deb"
|
||||||
sudo dpkg -i dockle.deb
|
sudo dpkg -i dockle.deb
|
||||||
- run: |
|
- run: |
|
||||||
cp .config/docker_example.env .config/docker.env
|
cp .config/docker_example.env .config/docker.env
|
||||||
cp ./docker-compose_example.yml ./docker-compose.yml
|
cp ./compose_example.yml ./compose.yml
|
||||||
- run: |
|
- run: |
|
||||||
docker compose up -d web
|
docker compose up -d web
|
||||||
docker tag "$(docker compose images web | awk 'OFS=":" {print $4}' | tail -n +2)" misskey-web:latest
|
docker tag "$(docker compose images web | awk 'OFS=":" {print $4}' | tail -n +2)" misskey-web:latest
|
||||||
|
4
.github/workflows/get-api-diff.yml
vendored
4
.github/workflows/get-api-diff.yml
vendored
@ -9,7 +9,7 @@ on:
|
|||||||
paths:
|
paths:
|
||||||
- packages/backend/**
|
- packages/backend/**
|
||||||
- .github/workflows/get-api-diff.yml
|
- .github/workflows/get-api-diff.yml
|
||||||
|
- .github/workflows/get-api-diff.yml
|
||||||
jobs:
|
jobs:
|
||||||
get-from-misskey:
|
get-from-misskey:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
@ -34,7 +34,7 @@ jobs:
|
|||||||
- name: Install pnpm
|
- name: Install pnpm
|
||||||
uses: pnpm/action-setup@v4
|
uses: pnpm/action-setup@v4
|
||||||
- name: Use Node.js ${{ matrix.node-version }}
|
- name: Use Node.js ${{ matrix.node-version }}
|
||||||
uses: actions/setup-node@v4.0.2
|
uses: actions/setup-node@v4.0.3
|
||||||
with:
|
with:
|
||||||
node-version: ${{ matrix.node-version }}
|
node-version: ${{ matrix.node-version }}
|
||||||
cache: 'pnpm'
|
cache: 'pnpm'
|
||||||
|
24
.github/workflows/lint.yml
vendored
24
.github/workflows/lint.yml
vendored
@ -10,15 +10,16 @@ on:
|
|||||||
- packages/frontend/**
|
- packages/frontend/**
|
||||||
- packages/sw/**
|
- packages/sw/**
|
||||||
- packages/misskey-js/**
|
- packages/misskey-js/**
|
||||||
- packages/shared/.eslintrc.js
|
- packages/shared/eslint.config.js
|
||||||
|
- .github/workflows/lint.yml
|
||||||
pull_request:
|
pull_request:
|
||||||
paths:
|
paths:
|
||||||
- packages/backend/**
|
- packages/backend/**
|
||||||
- packages/frontend/**
|
- packages/frontend/**
|
||||||
- packages/sw/**
|
- packages/sw/**
|
||||||
- packages/misskey-js/**
|
- packages/misskey-js/**
|
||||||
- packages/shared/.eslintrc.js
|
- packages/shared/eslint.config.js
|
||||||
|
- .github/workflows/lint.yml
|
||||||
jobs:
|
jobs:
|
||||||
pnpm_install:
|
pnpm_install:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
@ -28,7 +29,7 @@ jobs:
|
|||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
submodules: true
|
submodules: true
|
||||||
- uses: pnpm/action-setup@v4
|
- uses: pnpm/action-setup@v4
|
||||||
- uses: actions/setup-node@v4.0.2
|
- uses: actions/setup-node@v4.0.3
|
||||||
with:
|
with:
|
||||||
node-version-file: '.node-version'
|
node-version-file: '.node-version'
|
||||||
cache: 'pnpm'
|
cache: 'pnpm'
|
||||||
@ -39,6 +40,8 @@ jobs:
|
|||||||
needs: [pnpm_install]
|
needs: [pnpm_install]
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
continue-on-error: true
|
continue-on-error: true
|
||||||
|
env:
|
||||||
|
eslint-cache-version: v1
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
workspace:
|
workspace:
|
||||||
@ -52,13 +55,20 @@ jobs:
|
|||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
submodules: true
|
submodules: true
|
||||||
- uses: pnpm/action-setup@v4
|
- uses: pnpm/action-setup@v4
|
||||||
- uses: actions/setup-node@v4.0.2
|
- uses: actions/setup-node@v4.0.3
|
||||||
with:
|
with:
|
||||||
node-version-file: '.node-version'
|
node-version-file: '.node-version'
|
||||||
cache: 'pnpm'
|
cache: 'pnpm'
|
||||||
- run: corepack enable
|
- run: corepack enable
|
||||||
- run: pnpm i --frozen-lockfile
|
- run: pnpm i --frozen-lockfile
|
||||||
- run: pnpm --filter ${{ matrix.workspace }} run eslint
|
- name: Restore eslint cache
|
||||||
|
uses: actions/cache@v4.0.2
|
||||||
|
with:
|
||||||
|
path: node_modules/.cache/eslint
|
||||||
|
key: eslint-${{ env.eslint-cache-version }}-${{ hashFiles('/pnpm-lock.yaml') }}-${{ github.ref_name }}-${{ github.sha }}
|
||||||
|
restore-keys: |
|
||||||
|
eslint-${{ env.eslint-cache-version }}-${{ hashFiles('/pnpm-lock.yaml') }}-
|
||||||
|
- run: pnpm --filter ${{ matrix.workspace }} run eslint --cache --cache-location node_modules/.cache/eslint --cache-strategy content
|
||||||
|
|
||||||
typecheck:
|
typecheck:
|
||||||
needs: [pnpm_install]
|
needs: [pnpm_install]
|
||||||
@ -75,7 +85,7 @@ jobs:
|
|||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
submodules: true
|
submodules: true
|
||||||
- uses: pnpm/action-setup@v4
|
- uses: pnpm/action-setup@v4
|
||||||
- uses: actions/setup-node@v4.0.2
|
- uses: actions/setup-node@v4.0.3
|
||||||
with:
|
with:
|
||||||
node-version-file: '.node-version'
|
node-version-file: '.node-version'
|
||||||
cache: 'pnpm'
|
cache: 'pnpm'
|
||||||
|
5
.github/workflows/locale.yml
vendored
5
.github/workflows/locale.yml
vendored
@ -4,10 +4,11 @@ on:
|
|||||||
push:
|
push:
|
||||||
paths:
|
paths:
|
||||||
- locales/**
|
- locales/**
|
||||||
|
- .github/workflows/locale.yml
|
||||||
pull_request:
|
pull_request:
|
||||||
paths:
|
paths:
|
||||||
- locales/**
|
- locales/**
|
||||||
|
- .github/workflows/locale.yml
|
||||||
jobs:
|
jobs:
|
||||||
locale_verify:
|
locale_verify:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
@ -18,7 +19,7 @@ jobs:
|
|||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
submodules: true
|
submodules: true
|
||||||
- uses: pnpm/action-setup@v4
|
- uses: pnpm/action-setup@v4
|
||||||
- uses: actions/setup-node@v4.0.2
|
- uses: actions/setup-node@v4.0.3
|
||||||
with:
|
with:
|
||||||
node-version-file: '.node-version'
|
node-version-file: '.node-version'
|
||||||
cache: 'pnpm'
|
cache: 'pnpm'
|
||||||
|
2
.github/workflows/on-release-created.yml
vendored
2
.github/workflows/on-release-created.yml
vendored
@ -26,7 +26,7 @@ jobs:
|
|||||||
- name: Install pnpm
|
- name: Install pnpm
|
||||||
uses: pnpm/action-setup@v4
|
uses: pnpm/action-setup@v4
|
||||||
- name: Use Node.js ${{ matrix.node-version }}
|
- name: Use Node.js ${{ matrix.node-version }}
|
||||||
uses: actions/setup-node@v4.0.2
|
uses: actions/setup-node@v4.0.3
|
||||||
with:
|
with:
|
||||||
node-version: ${{ matrix.node-version }}
|
node-version: ${{ matrix.node-version }}
|
||||||
cache: 'pnpm'
|
cache: 'pnpm'
|
||||||
|
19
.github/workflows/release-edit-with-push.yml
vendored
19
.github/workflows/release-edit-with-push.yml
vendored
@ -3,10 +3,10 @@ name: "Release Manager: sync changelog with PR"
|
|||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- release/**
|
- develop
|
||||||
paths:
|
paths:
|
||||||
- 'CHANGELOG.md'
|
- 'CHANGELOG.md'
|
||||||
|
# - .github/workflows/release-edit-with-push.yml
|
||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
@ -20,24 +20,29 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
# headがrelease/かつopenのPRを1つ取得
|
# headが$GITHUB_REF_NAME, baseが$STABLE_BRANCHかつopenのPRを1つ取得
|
||||||
- name: Get PR
|
- name: Get PR
|
||||||
run: |
|
run: |
|
||||||
echo "pr_number=$(gh pr list --limit 1 --head "$GITHUB_REF_NAME" --json number --jq '.[] | .number')" >> $GITHUB_OUTPUT
|
echo "pr_number=$(gh pr list --limit 1 --search "head:$GITHUB_REF_NAME base:$STABLE_BRANCH is:open" --json number --jq '.[] | .number')" >> $GITHUB_OUTPUT
|
||||||
id: get_pr
|
id: get_pr
|
||||||
|
env:
|
||||||
|
STABLE_BRANCH: ${{ vars.STABLE_BRANCH }}
|
||||||
- name: Get target version
|
- name: Get target version
|
||||||
uses: misskey-dev/release-manager-actions/.github/actions/get-target-version@v1
|
if: steps.get_pr.outputs.pr_number != ''
|
||||||
|
uses: misskey-dev/release-manager-actions/.github/actions/get-target-version@v2
|
||||||
id: v
|
id: v
|
||||||
# CHANGELOG.mdの内容を取得
|
# CHANGELOG.mdの内容を取得
|
||||||
- name: Get changelog
|
- name: Get changelog
|
||||||
uses: misskey-dev/release-manager-actions/.github/actions/get-changelog@v1
|
if: steps.get_pr.outputs.pr_number != ''
|
||||||
|
uses: misskey-dev/release-manager-actions/.github/actions/get-changelog@v2
|
||||||
with:
|
with:
|
||||||
version: ${{ steps.v.outputs.target_version }}
|
version: ${{ steps.v.outputs.target_version }}
|
||||||
id: changelog
|
id: changelog
|
||||||
# PRのnotesを更新
|
# PRのnotesを更新
|
||||||
- name: Update PR
|
- name: Update PR
|
||||||
|
if: steps.get_pr.outputs.pr_number != ''
|
||||||
run: |
|
run: |
|
||||||
gh pr edit "$PR_NUMBER" --body "$CHANGELOG"
|
gh pr edit "$PR_NUMBER" --body "$CHANGELOG"
|
||||||
env:
|
env:
|
||||||
CHANGELOG: ${{ steps.changelog.outputs.changelog }}
|
|
||||||
PR_NUMBER: ${{ steps.get_pr.outputs.pr_number }}
|
PR_NUMBER: ${{ steps.get_pr.outputs.pr_number }}
|
||||||
|
CHANGELOG: ${{ steps.changelog.outputs.changelog }}
|
||||||
|
20
.github/workflows/release-with-dispatch.yml
vendored
20
.github/workflows/release-with-dispatch.yml
vendored
@ -33,18 +33,21 @@ jobs:
|
|||||||
pr_number: ${{ steps.get_pr.outputs.pr_number }}
|
pr_number: ${{ steps.get_pr.outputs.pr_number }}
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
# headがrelease/かつopenのPRを1つ取得
|
# headが$GITHUB_REF_NAME, baseが$STABLE_BRANCHかつopenのPRを1つ取得
|
||||||
- name: Get PRs
|
- name: Get PRs
|
||||||
run: |
|
run: |
|
||||||
echo "pr_number=$(gh pr list --limit 1 --search "head:release/ is:open" --json number --jq '.[] | .number')" >> $GITHUB_OUTPUT
|
echo "pr_number=$(gh pr list --limit 1 --search "head:$GITHUB_REF_NAME base:$STABLE_BRANCH is:open" --json number --jq '.[] | .number')" >> $GITHUB_OUTPUT
|
||||||
id: get_pr
|
id: get_pr
|
||||||
|
env:
|
||||||
|
STABLE_BRANCH: ${{ vars.STABLE_BRANCH }}
|
||||||
|
|
||||||
merge:
|
merge:
|
||||||
uses: misskey-dev/release-manager-actions/.github/workflows/merge.yml@v1
|
uses: misskey-dev/release-manager-actions/.github/workflows/merge.yml@v2
|
||||||
needs: get-pr
|
needs: get-pr
|
||||||
if: ${{ needs.get-pr.outputs.pr_number != '' && inputs.merge == true }}
|
if: ${{ needs.get-pr.outputs.pr_number != '' && inputs.merge == true }}
|
||||||
with:
|
with:
|
||||||
pr_number: ${{ needs.get-pr.outputs.pr_number }}
|
pr_number: ${{ needs.get-pr.outputs.pr_number }}
|
||||||
|
user: 'github-actions[bot]'
|
||||||
package_jsons_to_rewrite: ${{ vars.PACKAGE_JSONS_TO_REWRITE }}
|
package_jsons_to_rewrite: ${{ vars.PACKAGE_JSONS_TO_REWRITE }}
|
||||||
# Text to prepend to the changelog
|
# Text to prepend to the changelog
|
||||||
# The first line must be `## Unreleased`
|
# The first line must be `## Unreleased`
|
||||||
@ -65,15 +68,14 @@ jobs:
|
|||||||
secrets:
|
secrets:
|
||||||
RELEASE_APP_ID: ${{ secrets.RELEASE_APP_ID }}
|
RELEASE_APP_ID: ${{ secrets.RELEASE_APP_ID }}
|
||||||
RELEASE_APP_PRIVATE_KEY: ${{ secrets.RELEASE_APP_PRIVATE_KEY }}
|
RELEASE_APP_PRIVATE_KEY: ${{ secrets.RELEASE_APP_PRIVATE_KEY }}
|
||||||
RULESET_EDIT_APP_ID: ${{ secrets.RULESET_EDIT_APP_ID }}
|
|
||||||
RULESET_EDIT_APP_PRIVATE_KEY: ${{ secrets.RULESET_EDIT_APP_PRIVATE_KEY }}
|
|
||||||
|
|
||||||
create-prerelease:
|
create-prerelease:
|
||||||
uses: misskey-dev/release-manager-actions/.github/workflows/create-prerelease.yml@v1
|
uses: misskey-dev/release-manager-actions/.github/workflows/create-prerelease.yml@v2
|
||||||
needs: get-pr
|
needs: get-pr
|
||||||
if: ${{ needs.get-pr.outputs.pr_number != '' && inputs.merge != true }}
|
if: ${{ needs.get-pr.outputs.pr_number != '' && inputs.merge != true }}
|
||||||
with:
|
with:
|
||||||
pr_number: ${{ needs.get-pr.outputs.pr_number }}
|
pr_number: ${{ needs.get-pr.outputs.pr_number }}
|
||||||
|
user: 'github-actions[bot]'
|
||||||
package_jsons_to_rewrite: ${{ vars.PACKAGE_JSONS_TO_REWRITE }}
|
package_jsons_to_rewrite: ${{ vars.PACKAGE_JSONS_TO_REWRITE }}
|
||||||
use_external_app_to_release: ${{ vars.USE_RELEASE_APP == 'true' }}
|
use_external_app_to_release: ${{ vars.USE_RELEASE_APP == 'true' }}
|
||||||
indent: ${{ vars.INDENT }}
|
indent: ${{ vars.INDENT }}
|
||||||
@ -82,10 +84,11 @@ jobs:
|
|||||||
RELEASE_APP_PRIVATE_KEY: ${{ secrets.RELEASE_APP_PRIVATE_KEY }}
|
RELEASE_APP_PRIVATE_KEY: ${{ secrets.RELEASE_APP_PRIVATE_KEY }}
|
||||||
|
|
||||||
create-target:
|
create-target:
|
||||||
uses: misskey-dev/release-manager-actions/.github/workflows/create-target.yml@v1
|
uses: misskey-dev/release-manager-actions/.github/workflows/create-target.yml@v2
|
||||||
needs: get-pr
|
needs: get-pr
|
||||||
if: ${{ needs.get-pr.outputs.pr_number == '' }}
|
if: ${{ needs.get-pr.outputs.pr_number == '' }}
|
||||||
with:
|
with:
|
||||||
|
user: 'github-actions[bot]'
|
||||||
# The script for version increment.
|
# The script for version increment.
|
||||||
# process.env.CURRENT_VERSION: The current version.
|
# process.env.CURRENT_VERSION: The current version.
|
||||||
#
|
#
|
||||||
@ -118,8 +121,7 @@ jobs:
|
|||||||
package_jsons_to_rewrite: ${{ vars.PACKAGE_JSONS_TO_REWRITE }}
|
package_jsons_to_rewrite: ${{ vars.PACKAGE_JSONS_TO_REWRITE }}
|
||||||
use_external_app_to_release: ${{ vars.USE_RELEASE_APP == 'true' }}
|
use_external_app_to_release: ${{ vars.USE_RELEASE_APP == 'true' }}
|
||||||
indent: ${{ vars.INDENT }}
|
indent: ${{ vars.INDENT }}
|
||||||
|
stable_branch: ${{ vars.STABLE_BRANCH }}
|
||||||
secrets:
|
secrets:
|
||||||
RELEASE_APP_ID: ${{ secrets.RELEASE_APP_ID }}
|
RELEASE_APP_ID: ${{ secrets.RELEASE_APP_ID }}
|
||||||
RELEASE_APP_PRIVATE_KEY: ${{ secrets.RELEASE_APP_PRIVATE_KEY }}
|
RELEASE_APP_PRIVATE_KEY: ${{ secrets.RELEASE_APP_PRIVATE_KEY }}
|
||||||
RULESET_EDIT_APP_ID: ${{ secrets.RULESET_EDIT_APP_ID }}
|
|
||||||
RULESET_EDIT_APP_PRIVATE_KEY: ${{ secrets.RULESET_EDIT_APP_PRIVATE_KEY }}
|
|
||||||
|
13
.github/workflows/release-with-ready.yml
vendored
13
.github/workflows/release-with-ready.yml
vendored
@ -16,23 +16,26 @@ jobs:
|
|||||||
check:
|
check:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
outputs:
|
outputs:
|
||||||
ref: ${{ steps.get_pr.outputs.ref }}
|
head: ${{ steps.get_pr.outputs.head }}
|
||||||
|
base: ${{ steps.get_pr.outputs.base }}
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
# PR情報を取得
|
# PR情報を取得
|
||||||
- name: Get PR
|
- name: Get PR
|
||||||
run: |
|
run: |
|
||||||
pr_json=$(gh pr view "$PR_NUMBER" --json isDraft,headRefName)
|
pr_json=$(gh pr view "$PR_NUMBER" --json isDraft,headRefName,baseRefName)
|
||||||
echo "ref=$(echo $pr_json | jq -r '.headRefName')" >> $GITHUB_OUTPUT
|
echo "head=$(echo $pr_json | jq -r '.headRefName')" >> $GITHUB_OUTPUT
|
||||||
|
echo "base=$(echo $pr_json | jq -r '.baseRefName')" >> $GITHUB_OUTPUT
|
||||||
id: get_pr
|
id: get_pr
|
||||||
env:
|
env:
|
||||||
PR_NUMBER: ${{ github.event.pull_request.number }}
|
PR_NUMBER: ${{ github.event.pull_request.number }}
|
||||||
release:
|
release:
|
||||||
uses: misskey-dev/release-manager-actions/.github/workflows/create-prerelease.yml@v1
|
uses: misskey-dev/release-manager-actions/.github/workflows/create-prerelease.yml@v2
|
||||||
needs: check
|
needs: check
|
||||||
if: startsWith(needs.check.outputs.ref, 'release/')
|
if: needs.check.outputs.head == github.event.repository.default_branch && needs.check.outputs.base == vars.STABLE_BRANCH
|
||||||
with:
|
with:
|
||||||
pr_number: ${{ github.event.pull_request.number }}
|
pr_number: ${{ github.event.pull_request.number }}
|
||||||
|
user: 'github-actions[bot]'
|
||||||
package_jsons_to_rewrite: ${{ vars.PACKAGE_JSONS_TO_REWRITE }}
|
package_jsons_to_rewrite: ${{ vars.PACKAGE_JSONS_TO_REWRITE }}
|
||||||
use_external_app_to_release: ${{ vars.USE_RELEASE_APP == 'true' }}
|
use_external_app_to_release: ${{ vars.USE_RELEASE_APP == 'true' }}
|
||||||
indent: ${{ vars.INDENT }}
|
indent: ${{ vars.INDENT }}
|
||||||
|
4
.github/workflows/storybook.yml
vendored
4
.github/workflows/storybook.yml
vendored
@ -36,7 +36,7 @@ jobs:
|
|||||||
- name: Install pnpm
|
- name: Install pnpm
|
||||||
uses: pnpm/action-setup@v4
|
uses: pnpm/action-setup@v4
|
||||||
- name: Use Node.js 20.x
|
- name: Use Node.js 20.x
|
||||||
uses: actions/setup-node@v4.0.2
|
uses: actions/setup-node@v4.0.3
|
||||||
with:
|
with:
|
||||||
node-version-file: '.node-version'
|
node-version-file: '.node-version'
|
||||||
cache: 'pnpm'
|
cache: 'pnpm'
|
||||||
@ -88,7 +88,7 @@ jobs:
|
|||||||
if [ "$BRANCH" = "misskey-dev:$HEAD_REF" ]; then
|
if [ "$BRANCH" = "misskey-dev:$HEAD_REF" ]; then
|
||||||
BRANCH="$HEAD_REF"
|
BRANCH="$HEAD_REF"
|
||||||
fi
|
fi
|
||||||
pnpm --filter frontend chromatic --exit-once-uploaded -d storybook-static --branch-name $BRANCH $(echo "$CHROMATIC_PARAMETER")
|
pnpm --filter frontend chromatic --exit-once-uploaded -d storybook-static --branch-name "$BRANCH" $(echo "$CHROMATIC_PARAMETER")
|
||||||
env:
|
env:
|
||||||
HEAD_REF: ${{ github.event.pull_request.head.ref }}
|
HEAD_REF: ${{ github.event.pull_request.head.ref }}
|
||||||
CHROMATIC_PROJECT_TOKEN: ${{ secrets.CHROMATIC_PROJECT_TOKEN }}
|
CHROMATIC_PROJECT_TOKEN: ${{ secrets.CHROMATIC_PROJECT_TOKEN }}
|
||||||
|
7
.github/workflows/test-backend.yml
vendored
7
.github/workflows/test-backend.yml
vendored
@ -9,12 +9,13 @@ on:
|
|||||||
- packages/backend/**
|
- packages/backend/**
|
||||||
# for permissions
|
# for permissions
|
||||||
- packages/misskey-js/**
|
- packages/misskey-js/**
|
||||||
|
- .github/workflows/test-backend.yml
|
||||||
pull_request:
|
pull_request:
|
||||||
paths:
|
paths:
|
||||||
- packages/backend/**
|
- packages/backend/**
|
||||||
# for permissions
|
# for permissions
|
||||||
- packages/misskey-js/**
|
- packages/misskey-js/**
|
||||||
|
- .github/workflows/test-backend.yml
|
||||||
jobs:
|
jobs:
|
||||||
unit:
|
unit:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
@ -45,7 +46,7 @@ jobs:
|
|||||||
- name: Install FFmpeg
|
- name: Install FFmpeg
|
||||||
uses: FedericoCarboni/setup-ffmpeg@v3
|
uses: FedericoCarboni/setup-ffmpeg@v3
|
||||||
- name: Use Node.js ${{ matrix.node-version }}
|
- name: Use Node.js ${{ matrix.node-version }}
|
||||||
uses: actions/setup-node@v4.0.2
|
uses: actions/setup-node@v4.0.3
|
||||||
with:
|
with:
|
||||||
node-version: ${{ matrix.node-version }}
|
node-version: ${{ matrix.node-version }}
|
||||||
cache: 'pnpm'
|
cache: 'pnpm'
|
||||||
@ -92,7 +93,7 @@ jobs:
|
|||||||
- name: Install pnpm
|
- name: Install pnpm
|
||||||
uses: pnpm/action-setup@v4
|
uses: pnpm/action-setup@v4
|
||||||
- name: Use Node.js ${{ matrix.node-version }}
|
- name: Use Node.js ${{ matrix.node-version }}
|
||||||
uses: actions/setup-node@v4.0.2
|
uses: actions/setup-node@v4.0.3
|
||||||
with:
|
with:
|
||||||
node-version: ${{ matrix.node-version }}
|
node-version: ${{ matrix.node-version }}
|
||||||
cache: 'pnpm'
|
cache: 'pnpm'
|
||||||
|
8
.github/workflows/test-frontend.yml
vendored
8
.github/workflows/test-frontend.yml
vendored
@ -11,7 +11,7 @@ on:
|
|||||||
- packages/misskey-js/**
|
- packages/misskey-js/**
|
||||||
# for e2e
|
# for e2e
|
||||||
- packages/backend/**
|
- packages/backend/**
|
||||||
|
- .github/workflows/test-frontend.yml
|
||||||
pull_request:
|
pull_request:
|
||||||
paths:
|
paths:
|
||||||
- packages/frontend/**
|
- packages/frontend/**
|
||||||
@ -19,7 +19,7 @@ on:
|
|||||||
- packages/misskey-js/**
|
- packages/misskey-js/**
|
||||||
# for e2e
|
# for e2e
|
||||||
- packages/backend/**
|
- packages/backend/**
|
||||||
|
- .github/workflows/test-frontend.yml
|
||||||
jobs:
|
jobs:
|
||||||
vitest:
|
vitest:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
@ -35,7 +35,7 @@ jobs:
|
|||||||
- name: Install pnpm
|
- name: Install pnpm
|
||||||
uses: pnpm/action-setup@v4
|
uses: pnpm/action-setup@v4
|
||||||
- name: Use Node.js ${{ matrix.node-version }}
|
- name: Use Node.js ${{ matrix.node-version }}
|
||||||
uses: actions/setup-node@v4.0.2
|
uses: actions/setup-node@v4.0.3
|
||||||
with:
|
with:
|
||||||
node-version: ${{ matrix.node-version }}
|
node-version: ${{ matrix.node-version }}
|
||||||
cache: 'pnpm'
|
cache: 'pnpm'
|
||||||
@ -90,7 +90,7 @@ jobs:
|
|||||||
- name: Install pnpm
|
- name: Install pnpm
|
||||||
uses: pnpm/action-setup@v4
|
uses: pnpm/action-setup@v4
|
||||||
- name: Use Node.js ${{ matrix.node-version }}
|
- name: Use Node.js ${{ matrix.node-version }}
|
||||||
uses: actions/setup-node@v4.0.2
|
uses: actions/setup-node@v4.0.3
|
||||||
with:
|
with:
|
||||||
node-version: ${{ matrix.node-version }}
|
node-version: ${{ matrix.node-version }}
|
||||||
cache: 'pnpm'
|
cache: 'pnpm'
|
||||||
|
5
.github/workflows/test-misskey-js.yml
vendored
5
.github/workflows/test-misskey-js.yml
vendored
@ -8,11 +8,12 @@ on:
|
|||||||
branches: [ develop ]
|
branches: [ develop ]
|
||||||
paths:
|
paths:
|
||||||
- packages/misskey-js/**
|
- packages/misskey-js/**
|
||||||
|
- .github/workflows/test-misskey-js.yml
|
||||||
pull_request:
|
pull_request:
|
||||||
branches: [ develop ]
|
branches: [ develop ]
|
||||||
paths:
|
paths:
|
||||||
- packages/misskey-js/**
|
- packages/misskey-js/**
|
||||||
|
- .github/workflows/test-misskey-js.yml
|
||||||
jobs:
|
jobs:
|
||||||
test:
|
test:
|
||||||
|
|
||||||
@ -30,7 +31,7 @@ jobs:
|
|||||||
- run: corepack enable
|
- run: corepack enable
|
||||||
|
|
||||||
- name: Setup Node.js ${{ matrix.node-version }}
|
- name: Setup Node.js ${{ matrix.node-version }}
|
||||||
uses: actions/setup-node@v4.0.2
|
uses: actions/setup-node@v4.0.3
|
||||||
with:
|
with:
|
||||||
node-version: ${{ matrix.node-version }}
|
node-version: ${{ matrix.node-version }}
|
||||||
cache: 'pnpm'
|
cache: 'pnpm'
|
||||||
|
2
.github/workflows/test-production.yml
vendored
2
.github/workflows/test-production.yml
vendored
@ -25,7 +25,7 @@ jobs:
|
|||||||
- name: Install pnpm
|
- name: Install pnpm
|
||||||
uses: pnpm/action-setup@v4
|
uses: pnpm/action-setup@v4
|
||||||
- name: Use Node.js ${{ matrix.node-version }}
|
- name: Use Node.js ${{ matrix.node-version }}
|
||||||
uses: actions/setup-node@v4.0.2
|
uses: actions/setup-node@v4.0.3
|
||||||
with:
|
with:
|
||||||
node-version: ${{ matrix.node-version }}
|
node-version: ${{ matrix.node-version }}
|
||||||
cache: 'pnpm'
|
cache: 'pnpm'
|
||||||
|
5
.github/workflows/validate-api-json.yml
vendored
5
.github/workflows/validate-api-json.yml
vendored
@ -7,10 +7,11 @@ on:
|
|||||||
- develop
|
- develop
|
||||||
paths:
|
paths:
|
||||||
- packages/backend/**
|
- packages/backend/**
|
||||||
|
- .github/workflows/validate-api-json.yml
|
||||||
pull_request:
|
pull_request:
|
||||||
paths:
|
paths:
|
||||||
- packages/backend/**
|
- packages/backend/**
|
||||||
|
- .github/workflows/validate-api-json.yml
|
||||||
jobs:
|
jobs:
|
||||||
validate-api-json:
|
validate-api-json:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
@ -26,7 +27,7 @@ jobs:
|
|||||||
- name: Install pnpm
|
- name: Install pnpm
|
||||||
uses: pnpm/action-setup@v4
|
uses: pnpm/action-setup@v4
|
||||||
- name: Use Node.js ${{ matrix.node-version }}
|
- name: Use Node.js ${{ matrix.node-version }}
|
||||||
uses: actions/setup-node@v4.0.2
|
uses: actions/setup-node@v4.0.3
|
||||||
with:
|
with:
|
||||||
node-version: ${{ matrix.node-version }}
|
node-version: ${{ matrix.node-version }}
|
||||||
cache: 'pnpm'
|
cache: 'pnpm'
|
||||||
|
5
.gitignore
vendored
5
.gitignore
vendored
@ -35,8 +35,8 @@ coverage
|
|||||||
!/.config/example.yml
|
!/.config/example.yml
|
||||||
!/.config/docker_example.yml
|
!/.config/docker_example.yml
|
||||||
!/.config/docker_example.env
|
!/.config/docker_example.env
|
||||||
docker-compose.yml
|
.devcontainer/compose.yml
|
||||||
!/.devcontainer/docker-compose.yml
|
!/.devcontainer/compose.yml
|
||||||
|
|
||||||
# misskey
|
# misskey
|
||||||
/build
|
/build
|
||||||
@ -59,6 +59,7 @@ ormconfig.json
|
|||||||
temp
|
temp
|
||||||
/packages/frontend/src/**/*.stories.ts
|
/packages/frontend/src/**/*.stories.ts
|
||||||
tsdoc-metadata.json
|
tsdoc-metadata.json
|
||||||
|
misskey-assets
|
||||||
|
|
||||||
# blender backups
|
# blender backups
|
||||||
*.blend1
|
*.blend1
|
||||||
|
3
.gitmodules
vendored
3
.gitmodules
vendored
@ -1,6 +1,3 @@
|
|||||||
[submodule "misskey-assets"]
|
|
||||||
path = misskey-assets
|
|
||||||
url = https://github.com/misskey-dev/assets.git
|
|
||||||
[submodule "fluent-emojis"]
|
[submodule "fluent-emojis"]
|
||||||
path = fluent-emojis
|
path = fluent-emojis
|
||||||
url = https://github.com/misskey-dev/emojis.git
|
url = https://github.com/misskey-dev/emojis.git
|
||||||
|
83
CHANGELOG.md
83
CHANGELOG.md
@ -1,14 +1,91 @@
|
|||||||
## Unreleased
|
## 2024.7.0
|
||||||
|
|
||||||
|
### Note
|
||||||
|
- デッキUIの新着ノートをサウンドで通知する機能の追加(v2024.5.0)に伴い、以前から動作しなくなっていたクライアント設定内の「アンテナ受信」「チャンネル通知」サウンドを削除しました。
|
||||||
|
- Streaming APIにて入力が不正な場合にはそのメッセージを無視するようになりました。 #14251
|
||||||
|
|
||||||
### General
|
### General
|
||||||
|
- Feat: 通報を受けた際、または解決した際に、予め登録した宛先に通知を飛ばせるように(mail or webhook) #13705
|
||||||
|
- Feat: ユーザーのアイコン/バナーの変更可否をロールで設定可能に
|
||||||
|
- 変更不可となっていても、設定済みのものを解除してデフォルト画像に戻すことは出来ます
|
||||||
|
- Feat: 連合に使うHTTP SignaturesがEd25519鍵に対応するように #13464
|
||||||
|
- Ed25519署名に対応するサーバーが増えると、deliverで要求されるサーバーリソースが削減されます
|
||||||
|
- ジョブキューのconfig設定のデフォルト値を変更しました。
|
||||||
|
default.ymlでジョブキューの並列度を設定している場合は、従前よりもconcurrencyの値をより下げるとパフォーマンスが改善する可能性があります。
|
||||||
|
* deliverJobConcurrency: 16 (←128)
|
||||||
|
* deliverJobPerSec: 1024 (←128)
|
||||||
|
* inboxJobConcurrency: 4 (←16)
|
||||||
|
* inboxJobPerSec: 64 (←32)
|
||||||
- Feat: リバーシでリアクションを送りあえるように
|
- Feat: リバーシでリアクションを送りあえるように
|
||||||
|
- Fix: 配信停止したインスタンス一覧が見れなくなる問題を修正
|
||||||
|
- Fix: Dockerコンテナの立ち上げ時に`pnpm`のインストールで固まることがある問題
|
||||||
|
- Fix: デフォルトテーマに無効なテーマコードを入力するとUIが使用できなくなる問題を修正
|
||||||
|
|
||||||
### Client
|
### Client
|
||||||
-
|
- Enhance: 内蔵APIドキュメントのデザイン・パフォーマンスを改善
|
||||||
|
- Enhance: 非ログイン時に他サーバーに遷移するアクションを追加
|
||||||
|
- Enhance: 非ログイン時のハイライトTLのデザインを改善
|
||||||
|
- Enhance: フロントエンドのアクセシビリティ改善
|
||||||
|
(Based on https://github.com/taiyme/misskey/pull/226)
|
||||||
|
- Enhance: サーバー情報ページ・お問い合わせページを改善
|
||||||
|
(Cherry-picked from https://github.com/taiyme/misskey/pull/238)
|
||||||
|
- Enhance: AiScriptを0.19.0にアップデート
|
||||||
|
- Enhance: Allow negative delay for MFM animation elements (`tada`, `jelly`, `twitch`, `shake`, `spin`, `jump`, `bounce`, `rainbow`)
|
||||||
|
- Enhance: センシティブなメディアを開く際に確認ダイアログを出せるように
|
||||||
|
- Fix: `/about#federation` ページなどで各インスタンスのチャートが表示されなくなっていた問題を修正
|
||||||
|
- Fix: ユーザーページの追加情報のラベルを投稿者のサーバーの絵文字で表示する (#13968)
|
||||||
|
- Fix: リバーシの対局を正しく共有できないことがある問題を修正
|
||||||
|
- Fix: コントロールパネルでベースロールのポリシーを編集してもUI上では変更が反映されない問題を修正
|
||||||
|
- Fix: アンテナの編集画面のボタンに隙間を追加
|
||||||
|
- Fix: テーマプレビューが見れない問題を修正
|
||||||
|
- Fix: ショートカットキーが連打できる問題を修正
|
||||||
|
(Cherry-picked from https://github.com/taiyme/misskey/pull/234)
|
||||||
|
- Fix: MkSignin.vueのcredentialRequestからReactivityを削除(ProxyがPasskey認証処理に渡ることを避けるため)
|
||||||
|
- Fix: 「アニメーション画像を再生しない」がオンのときでもサーバーのバナー画像・背景画像がアニメーションしてしまう問題を修正
|
||||||
|
(Cherry-picked from https://activitypub.software/TransFem-org/Sharkey/-/merge_requests/574)
|
||||||
|
- Fix: Twitchの埋め込みが開けない問題を修正
|
||||||
|
- Fix: 子メニューの高さがウィンドウからはみ出ることがある問題を修正
|
||||||
|
- Fix: 個人宛てのダイアログ形式のお知らせが即時表示されない問題を修正
|
||||||
|
- Fix: 一部の画像がセンシティブ指定されているときに画面に何も表示されないことがあるのを修正
|
||||||
|
|
||||||
### Server
|
### Server
|
||||||
-
|
- Feat: レートリミット制限に引っかかったときに`Retry-After`ヘッダーを返すように (#13949)
|
||||||
|
- Enhance: エンドポイント`clips/update`の必須項目を`clipId`のみに
|
||||||
|
- Enhance: エンドポイント`admin/roles/update`の必須項目を`roleId`のみに
|
||||||
|
- Enhance: エンドポイント`pages/update`の必須項目を`pageId`のみに
|
||||||
|
- Enhance: エンドポイント`gallery/posts/update`の必須項目を`postId`のみに
|
||||||
|
- Enhance: エンドポイント`i/webhook/update`の必須項目を`webhookId`のみに
|
||||||
|
- Enhance: エンドポイント`admin/ad/update`の必須項目を`id`のみに
|
||||||
|
- Enhance: `default.yml`内の`url`, `db.db`, `db.user`, `db.pass`を環境変数から読み込めるように
|
||||||
|
- Fix: チャート生成時にinstance.suspensionStateに置き換えられたinstance.isSuspendedが参照されてしまう問題を修正
|
||||||
|
- Fix: ユーザーのフィードページのMFMをHTMLに展開するように (#14006)
|
||||||
|
- Fix: アンテナ・クリップ・リスト・ウェブフックがロールポリシーの上限より一つ多く作れてしまうのを修正 (#14036)
|
||||||
|
- Fix: notRespondingSinceが実装される前に不通になったインスタンスが自動的に配信停止にならない (#14059)
|
||||||
|
- Fix: FTT有効時、タイムライン用エンドポイントで`sinceId`にキャッシュ内最古のものより古いものを指定した場合に正しく結果が返ってこない問題を修正
|
||||||
|
- Fix: 自分以外のクリップ内のノート個数が見えることがあるのを修正
|
||||||
|
- Fix: 空文字列のリアクションはフォールバックされるように
|
||||||
|
- Fix: リノートにリアクションできないように
|
||||||
|
- Fix: ユーザー名の前後に空白文字列がある場合は省略するように
|
||||||
|
- Fix: プロフィール編集時に名前を空白文字列のみにできる問題を修正
|
||||||
|
- Fix: ユーザ名のサジェスト時に表示される内容と順番を調整(以下の順番になります) #14149
|
||||||
|
1. フォロー中かつアクティブなユーザ
|
||||||
|
2. フォロー中かつ非アクティブなユーザ
|
||||||
|
3. フォローしていないアクティブなユーザ
|
||||||
|
4. フォローしていない非アクティブなユーザ
|
||||||
|
|
||||||
|
また、自分自身のアカウントもサジェストされるようになりました。
|
||||||
|
- Fix: 一般ユーザーから見たユーザーのバッジの一覧に公開されていないものが含まれることがある問題を修正
|
||||||
|
(Cherry-picked from https://github.com/MisskeyIO/misskey/pull/652)
|
||||||
|
- Fix: ユーザーのリアクション一覧でミュート/ブロックが機能していなかった問題を修正
|
||||||
|
- Fix: エラーメッセージの誤字を修正 (#14213)
|
||||||
|
- Fix: ソーシャルタイムラインにローカルタイムラインに表示される自分へのリプライが表示されない問題を修正
|
||||||
|
- Fix: リノートのミュートが適用されるまでに時間がかかることがある問題を修正
|
||||||
|
(Cherry-picked from https://github.com/Type4ny-Project/Type4ny/commit/e9601029b52e0ad43d9131b555b614e56c84ebc1)
|
||||||
|
- Fix: Steaming APIが不正なデータを受けた場合の動作が不安定である問題 #14251
|
||||||
|
|
||||||
|
### Misskey.js
|
||||||
|
- Feat: `/drive/files/create` のリクエストに対応(`multipart/form-data`に対応)
|
||||||
|
- Feat: `/admin/role/create` のロールポリシーの型を修正
|
||||||
|
|
||||||
## 2024.5.0
|
## 2024.5.0
|
||||||
|
|
||||||
|
@ -106,6 +106,38 @@ If your language is not listed in Crowdin, please open an issue.
|
|||||||
![Crowdin](https://d322cqt584bo4o.cloudfront.net/misskey/localized.svg)
|
![Crowdin](https://d322cqt584bo4o.cloudfront.net/misskey/localized.svg)
|
||||||
|
|
||||||
## Development
|
## Development
|
||||||
|
### Setup
|
||||||
|
Before developing, you have to set up environment. Misskey requires Redis, PostgreSQL, and FFmpeg.
|
||||||
|
|
||||||
|
You would want to install Meilisearch to experiment related features. Technically, meilisearch is not strict requirement, but some features and tests require it.
|
||||||
|
|
||||||
|
There are a few ways to proceed.
|
||||||
|
|
||||||
|
#### Use system-wide software
|
||||||
|
You could install them in system-wide (such as from package manager).
|
||||||
|
|
||||||
|
#### Use `docker compose`
|
||||||
|
You could obtain middleware container by typing `docker compose -f $PROJECT_ROOT/compose.local-db.yml up -d`.
|
||||||
|
|
||||||
|
#### Use Devcontainer
|
||||||
|
Devcontainer also has necessary setting. This method can be done by connecting from VSCode.
|
||||||
|
|
||||||
|
Instead of running `pnpm` locally, you can use Dev Container to set up your development environment.
|
||||||
|
To use Dev Container, open the project directory on VSCode with Dev Containers installed.
|
||||||
|
**Note:** If you are using Windows, please clone the repository with WSL. Using Git for Windows will result in broken files due to the difference in how newlines are handled.
|
||||||
|
|
||||||
|
It will run the following command automatically inside the container.
|
||||||
|
``` bash
|
||||||
|
git submodule update --init
|
||||||
|
pnpm install --frozen-lockfile
|
||||||
|
cp .devcontainer/devcontainer.yml .config/default.yml
|
||||||
|
pnpm build
|
||||||
|
pnpm migrate
|
||||||
|
```
|
||||||
|
|
||||||
|
After finishing the migration, you can proceed.
|
||||||
|
|
||||||
|
### Start developing
|
||||||
During development, it is useful to use the
|
During development, it is useful to use the
|
||||||
|
|
||||||
```
|
```
|
||||||
@ -135,26 +167,6 @@ MK_DEV_PREFER=backend pnpm dev
|
|||||||
- To change the port of Vite, specify with `VITE_PORT` environment variable.
|
- To change the port of Vite, specify with `VITE_PORT` environment variable.
|
||||||
- HMR may not work in some environments such as Windows.
|
- HMR may not work in some environments such as Windows.
|
||||||
|
|
||||||
### Dev Container
|
|
||||||
Instead of running `pnpm` locally, you can use Dev Container to set up your development environment.
|
|
||||||
To use Dev Container, open the project directory on VSCode with Dev Containers installed.
|
|
||||||
**Note:** If you are using Windows, please clone the repository with WSL. Using Git for Windows will result in broken files due to the difference in how newlines are handled.
|
|
||||||
|
|
||||||
It will run the following command automatically inside the container.
|
|
||||||
``` bash
|
|
||||||
git submodule update --init
|
|
||||||
pnpm install --frozen-lockfile
|
|
||||||
cp .devcontainer/devcontainer.yml .config/default.yml
|
|
||||||
pnpm build
|
|
||||||
pnpm migrate
|
|
||||||
```
|
|
||||||
|
|
||||||
After finishing the migration, run the `pnpm dev` command to start the development server.
|
|
||||||
|
|
||||||
``` bash
|
|
||||||
pnpm dev
|
|
||||||
```
|
|
||||||
|
|
||||||
## Testing
|
## Testing
|
||||||
- Test codes are located in [`/packages/backend/test`](/packages/backend/test).
|
- Test codes are located in [`/packages/backend/test`](/packages/backend/test).
|
||||||
|
|
||||||
@ -165,7 +177,7 @@ cp .github/misskey/test.yml .config/
|
|||||||
```
|
```
|
||||||
Prepare DB/Redis for testing.
|
Prepare DB/Redis for testing.
|
||||||
```
|
```
|
||||||
docker compose -f packages/backend/test/docker-compose.yml up
|
docker compose -f packages/backend/test/compose.yml up
|
||||||
```
|
```
|
||||||
Alternatively, prepare an empty (data can be erased) DB and edit `.config/test.yml`.
|
Alternatively, prepare an empty (data can be erased) DB and edit `.config/test.yml`.
|
||||||
|
|
||||||
@ -185,7 +197,7 @@ TODO
|
|||||||
## Environment Variable
|
## Environment Variable
|
||||||
|
|
||||||
- `MISSKEY_CONFIG_YML`: Specify the file path of config.yml instead of default.yml (e.g. `2nd.yml`).
|
- `MISSKEY_CONFIG_YML`: Specify the file path of config.yml instead of default.yml (e.g. `2nd.yml`).
|
||||||
- `MISSKEY_WEBFINGER_USE_HTTP`: If it's set true, WebFinger requests will be http instead of https, useful for testing federation between servers in localhost. NEVER USE IN PRODUCTION.
|
- `MISSKEY_USE_HTTP`: If it's set true, federation requests (like nodeinfo and webfinger) will be http instead of https, useful for testing federation between servers in localhost. NEVER USE IN PRODUCTION. (was `MISSKEY_WEBFINGER_USE_HTTP`)
|
||||||
|
|
||||||
## Continuous integration
|
## Continuous integration
|
||||||
Misskey uses GitHub Actions for executing automated tests.
|
Misskey uses GitHub Actions for executing automated tests.
|
||||||
|
@ -82,6 +82,10 @@ RUN apt-get update \
|
|||||||
USER misskey
|
USER misskey
|
||||||
WORKDIR /misskey
|
WORKDIR /misskey
|
||||||
|
|
||||||
|
# add package.json to add pnpm
|
||||||
|
COPY --chown=misskey:misskey ./package.json ./package.json
|
||||||
|
RUN corepack install
|
||||||
|
|
||||||
COPY --chown=misskey:misskey --from=target-builder /misskey/node_modules ./node_modules
|
COPY --chown=misskey:misskey --from=target-builder /misskey/node_modules ./node_modules
|
||||||
COPY --chown=misskey:misskey --from=target-builder /misskey/packages/backend/node_modules ./packages/backend/node_modules
|
COPY --chown=misskey:misskey --from=target-builder /misskey/packages/backend/node_modules ./packages/backend/node_modules
|
||||||
COPY --chown=misskey:misskey --from=target-builder /misskey/packages/misskey-js/node_modules ./packages/misskey-js/node_modules
|
COPY --chown=misskey:misskey --from=target-builder /misskey/packages/misskey-js/node_modules ./packages/misskey-js/node_modules
|
||||||
|
@ -178,12 +178,12 @@ id: "aidx"
|
|||||||
#clusterLimit: 1
|
#clusterLimit: 1
|
||||||
|
|
||||||
# Job concurrency per worker
|
# Job concurrency per worker
|
||||||
# deliverJobConcurrency: 128
|
# deliverJobConcurrency: 16
|
||||||
# inboxJobConcurrency: 16
|
# inboxJobConcurrency: 4
|
||||||
|
|
||||||
# Job rate limiter
|
# Job rate limiter
|
||||||
# deliverJobPerSec: 128
|
# deliverJobPerSec: 1024
|
||||||
# inboxJobPerSec: 32
|
# inboxJobPerSec: 64
|
||||||
|
|
||||||
# Job attempts
|
# Job attempts
|
||||||
# deliverJobMaxAttempts: 12
|
# deliverJobMaxAttempts: 12
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
version: "3"
|
|
||||||
|
|
||||||
# このconfigは、 dockerでMisskey本体を起動せず、 redisとpostgresql などだけを起動します
|
# このconfigは、 dockerでMisskey本体を起動せず、 redisとpostgresql などだけを起動します
|
||||||
|
|
||||||
services:
|
services:
|
@ -1,5 +1,3 @@
|
|||||||
version: "3"
|
|
||||||
|
|
||||||
services:
|
services:
|
||||||
web:
|
web:
|
||||||
build: .
|
build: .
|
||||||
@ -19,6 +17,8 @@ services:
|
|||||||
networks:
|
networks:
|
||||||
- internal_network
|
- internal_network
|
||||||
- external_network
|
- external_network
|
||||||
|
# env_file:
|
||||||
|
# - .config/docker.env
|
||||||
volumes:
|
volumes:
|
||||||
- ./files:/misskey/files
|
- ./files:/misskey/files
|
||||||
- ./.config:/misskey/.config:ro
|
- ./.config:/misskey/.config:ro
|
148
locales/index.d.ts
vendored
148
locales/index.d.ts
vendored
@ -736,6 +736,22 @@ export interface Locale extends ILocale {
|
|||||||
* リモートで表示
|
* リモートで表示
|
||||||
*/
|
*/
|
||||||
"showOnRemote": string;
|
"showOnRemote": string;
|
||||||
|
/**
|
||||||
|
* リモートで続行
|
||||||
|
*/
|
||||||
|
"continueOnRemote": string;
|
||||||
|
/**
|
||||||
|
* Misskey Hubからサーバーを選択
|
||||||
|
*/
|
||||||
|
"chooseServerOnMisskeyHub": string;
|
||||||
|
/**
|
||||||
|
* サーバーのドメインを直接指定
|
||||||
|
*/
|
||||||
|
"specifyServerHost": string;
|
||||||
|
/**
|
||||||
|
* ドメインを入力してください
|
||||||
|
*/
|
||||||
|
"inputHostName": string;
|
||||||
/**
|
/**
|
||||||
* 全般
|
* 全般
|
||||||
*/
|
*/
|
||||||
@ -1921,9 +1937,13 @@ export interface Locale extends ILocale {
|
|||||||
*/
|
*/
|
||||||
"onlyOneFileCanBeAttached": string;
|
"onlyOneFileCanBeAttached": string;
|
||||||
/**
|
/**
|
||||||
* 続行する前に、サインアップまたはサインインが必要です
|
* 続行する前に、登録またはログインが必要です
|
||||||
*/
|
*/
|
||||||
"signinRequired": string;
|
"signinRequired": string;
|
||||||
|
/**
|
||||||
|
* 続行するには、お使いのサーバーに移動するか、このサーバーに登録・ログインする必要があります
|
||||||
|
*/
|
||||||
|
"signinOrContinueOnRemote": string;
|
||||||
/**
|
/**
|
||||||
* 招待
|
* 招待
|
||||||
*/
|
*/
|
||||||
@ -4984,6 +5004,18 @@ export interface Locale extends ILocale {
|
|||||||
* お問い合わせ
|
* お問い合わせ
|
||||||
*/
|
*/
|
||||||
"inquiry": string;
|
"inquiry": string;
|
||||||
|
/**
|
||||||
|
* もう一度お試しください。
|
||||||
|
*/
|
||||||
|
"tryAgain": string;
|
||||||
|
/**
|
||||||
|
* センシティブなメディアを表示するとき確認する
|
||||||
|
*/
|
||||||
|
"confirmWhenRevealingSensitiveMedia": string;
|
||||||
|
/**
|
||||||
|
* センシティブなメディアです。表示しますか?
|
||||||
|
*/
|
||||||
|
"sensitiveMediaRevealConfirm": string;
|
||||||
"_delivery": {
|
"_delivery": {
|
||||||
/**
|
/**
|
||||||
* 配信状態
|
* 配信状態
|
||||||
@ -6594,6 +6626,10 @@ export interface Locale extends ILocale {
|
|||||||
* ファイルにNSFWを常に付与
|
* ファイルにNSFWを常に付与
|
||||||
*/
|
*/
|
||||||
"alwaysMarkNsfw": string;
|
"alwaysMarkNsfw": string;
|
||||||
|
/**
|
||||||
|
* アイコンとバナーの更新を許可
|
||||||
|
*/
|
||||||
|
"canUpdateBioMedia": string;
|
||||||
/**
|
/**
|
||||||
* ノートのピン留めの最大数
|
* ノートのピン留めの最大数
|
||||||
*/
|
*/
|
||||||
@ -7515,14 +7551,6 @@ export interface Locale extends ILocale {
|
|||||||
* 通知
|
* 通知
|
||||||
*/
|
*/
|
||||||
"notification": string;
|
"notification": string;
|
||||||
/**
|
|
||||||
* アンテナ受信
|
|
||||||
*/
|
|
||||||
"antenna": string;
|
|
||||||
/**
|
|
||||||
* チャンネル通知
|
|
||||||
*/
|
|
||||||
"channel": string;
|
|
||||||
/**
|
/**
|
||||||
* リアクション選択時
|
* リアクション選択時
|
||||||
*/
|
*/
|
||||||
@ -9305,6 +9333,10 @@ export interface Locale extends ILocale {
|
|||||||
* Webhookを作成
|
* Webhookを作成
|
||||||
*/
|
*/
|
||||||
"createWebhook": string;
|
"createWebhook": string;
|
||||||
|
/**
|
||||||
|
* Webhookを編集
|
||||||
|
*/
|
||||||
|
"modifyWebhook": string;
|
||||||
/**
|
/**
|
||||||
* 名前
|
* 名前
|
||||||
*/
|
*/
|
||||||
@ -9351,6 +9383,72 @@ export interface Locale extends ILocale {
|
|||||||
*/
|
*/
|
||||||
"mention": string;
|
"mention": string;
|
||||||
};
|
};
|
||||||
|
"_systemEvents": {
|
||||||
|
/**
|
||||||
|
* ユーザーから通報があったとき
|
||||||
|
*/
|
||||||
|
"abuseReport": string;
|
||||||
|
/**
|
||||||
|
* ユーザーからの通報を処理したとき
|
||||||
|
*/
|
||||||
|
"abuseReportResolved": string;
|
||||||
|
};
|
||||||
|
/**
|
||||||
|
* Webhookを削除しますか?
|
||||||
|
*/
|
||||||
|
"deleteConfirm": string;
|
||||||
|
};
|
||||||
|
"_abuseReport": {
|
||||||
|
"_notificationRecipient": {
|
||||||
|
/**
|
||||||
|
* 通報の通知先を追加
|
||||||
|
*/
|
||||||
|
"createRecipient": string;
|
||||||
|
/**
|
||||||
|
* 通報の通知先を編集
|
||||||
|
*/
|
||||||
|
"modifyRecipient": string;
|
||||||
|
/**
|
||||||
|
* 通知先の種類
|
||||||
|
*/
|
||||||
|
"recipientType": string;
|
||||||
|
"_recipientType": {
|
||||||
|
/**
|
||||||
|
* メール
|
||||||
|
*/
|
||||||
|
"mail": string;
|
||||||
|
/**
|
||||||
|
* Webhook
|
||||||
|
*/
|
||||||
|
"webhook": string;
|
||||||
|
"_captions": {
|
||||||
|
/**
|
||||||
|
* モデレーター権限を持つユーザーのメールアドレスに通知を送ります(通報を受けた時のみ)
|
||||||
|
*/
|
||||||
|
"mail": string;
|
||||||
|
/**
|
||||||
|
* 指定したSystemWebhookに通知を送ります(通報を受けた時と通報を解決した時にそれぞれ発信)
|
||||||
|
*/
|
||||||
|
"webhook": string;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
/**
|
||||||
|
* キーワード
|
||||||
|
*/
|
||||||
|
"keywords": string;
|
||||||
|
/**
|
||||||
|
* 通知先ユーザー
|
||||||
|
*/
|
||||||
|
"notifiedUser": string;
|
||||||
|
/**
|
||||||
|
* 使用するWebhook
|
||||||
|
*/
|
||||||
|
"notifiedWebhook": string;
|
||||||
|
/**
|
||||||
|
* 通知先を削除しますか?
|
||||||
|
*/
|
||||||
|
"deleteConfirm": string;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
"_moderationLogTypes": {
|
"_moderationLogTypes": {
|
||||||
/**
|
/**
|
||||||
@ -9497,6 +9595,30 @@ export interface Locale extends ILocale {
|
|||||||
* ユーザーのバナーを解除
|
* ユーザーのバナーを解除
|
||||||
*/
|
*/
|
||||||
"unsetUserBanner": string;
|
"unsetUserBanner": string;
|
||||||
|
/**
|
||||||
|
* SystemWebhookを作成
|
||||||
|
*/
|
||||||
|
"createSystemWebhook": string;
|
||||||
|
/**
|
||||||
|
* SystemWebhookを更新
|
||||||
|
*/
|
||||||
|
"updateSystemWebhook": string;
|
||||||
|
/**
|
||||||
|
* SystemWebhookを削除
|
||||||
|
*/
|
||||||
|
"deleteSystemWebhook": string;
|
||||||
|
/**
|
||||||
|
* 通報の通知先を作成
|
||||||
|
*/
|
||||||
|
"createAbuseReportNotificationRecipient": string;
|
||||||
|
/**
|
||||||
|
* 通報の通知先を更新
|
||||||
|
*/
|
||||||
|
"updateAbuseReportNotificationRecipient": string;
|
||||||
|
/**
|
||||||
|
* 通報の通知先を削除
|
||||||
|
*/
|
||||||
|
"deleteAbuseReportNotificationRecipient": string;
|
||||||
};
|
};
|
||||||
"_fileViewer": {
|
"_fileViewer": {
|
||||||
/**
|
/**
|
||||||
@ -9667,7 +9789,7 @@ export interface Locale extends ILocale {
|
|||||||
"_dataSaver": {
|
"_dataSaver": {
|
||||||
"_media": {
|
"_media": {
|
||||||
/**
|
/**
|
||||||
* メディアの読み込み
|
* メディアの読み込みを無効化
|
||||||
*/
|
*/
|
||||||
"title": string;
|
"title": string;
|
||||||
/**
|
/**
|
||||||
@ -9677,7 +9799,7 @@ export interface Locale extends ILocale {
|
|||||||
};
|
};
|
||||||
"_avatar": {
|
"_avatar": {
|
||||||
/**
|
/**
|
||||||
* アイコン画像
|
* アイコン画像のアニメーションを無効化
|
||||||
*/
|
*/
|
||||||
"title": string;
|
"title": string;
|
||||||
/**
|
/**
|
||||||
@ -9687,7 +9809,7 @@ export interface Locale extends ILocale {
|
|||||||
};
|
};
|
||||||
"_urlPreview": {
|
"_urlPreview": {
|
||||||
/**
|
/**
|
||||||
* URLプレビューのサムネイル
|
* URLプレビューのサムネイルを非表示
|
||||||
*/
|
*/
|
||||||
"title": string;
|
"title": string;
|
||||||
/**
|
/**
|
||||||
@ -9697,7 +9819,7 @@ export interface Locale extends ILocale {
|
|||||||
};
|
};
|
||||||
"_code": {
|
"_code": {
|
||||||
/**
|
/**
|
||||||
* コードハイライト
|
* コードハイライトを非表示
|
||||||
*/
|
*/
|
||||||
"title": string;
|
"title": string;
|
||||||
/**
|
/**
|
||||||
|
@ -52,7 +52,11 @@ const primaries = {
|
|||||||
const clean = (text) => text.replace(new RegExp(String.fromCodePoint(0x08), 'g'), '');
|
const clean = (text) => text.replace(new RegExp(String.fromCodePoint(0x08), 'g'), '');
|
||||||
|
|
||||||
export function build() {
|
export function build() {
|
||||||
const locales = languages.reduce((a, c) => (a[c] = yaml.load(clean(fs.readFileSync(new URL(`${c}.yml`, import.meta.url), 'utf-8'))) || {}, a), {});
|
// vitestの挙動を調整するため、一度ローカル変数化する必要がある
|
||||||
|
// https://github.com/vitest-dev/vitest/issues/3988#issuecomment-1686599577
|
||||||
|
// https://github.com/misskey-dev/misskey/pull/14057#issuecomment-2192833785
|
||||||
|
const metaUrl = import.meta.url;
|
||||||
|
const locales = languages.reduce((a, c) => (a[c] = yaml.load(clean(fs.readFileSync(new URL(`${c}.yml`, metaUrl), 'utf-8'))) || {}, a), {});
|
||||||
|
|
||||||
// 空文字列が入ることがあり、フォールバックが動作しなくなるのでプロパティごと消す
|
// 空文字列が入ることがあり、フォールバックが動作しなくなるのでプロパティごと消す
|
||||||
const removeEmpty = (obj) => {
|
const removeEmpty = (obj) => {
|
||||||
|
@ -180,6 +180,10 @@ addAccount: "アカウントを追加"
|
|||||||
reloadAccountsList: "アカウントリストの情報を更新"
|
reloadAccountsList: "アカウントリストの情報を更新"
|
||||||
loginFailed: "ログインに失敗しました"
|
loginFailed: "ログインに失敗しました"
|
||||||
showOnRemote: "リモートで表示"
|
showOnRemote: "リモートで表示"
|
||||||
|
continueOnRemote: "リモートで続行"
|
||||||
|
chooseServerOnMisskeyHub: "Misskey Hubからサーバーを選択"
|
||||||
|
specifyServerHost: "サーバーのドメインを直接指定"
|
||||||
|
inputHostName: "ドメインを入力してください"
|
||||||
general: "全般"
|
general: "全般"
|
||||||
wallpaper: "壁紙"
|
wallpaper: "壁紙"
|
||||||
setWallpaper: "壁紙を設定"
|
setWallpaper: "壁紙を設定"
|
||||||
@ -476,7 +480,8 @@ attachAsFileQuestion: "クリップボードのテキストが長いです。テ
|
|||||||
noMessagesYet: "まだチャットはありません"
|
noMessagesYet: "まだチャットはありません"
|
||||||
newMessageExists: "新しいメッセージがあります"
|
newMessageExists: "新しいメッセージがあります"
|
||||||
onlyOneFileCanBeAttached: "メッセージに添付できるファイルはひとつです"
|
onlyOneFileCanBeAttached: "メッセージに添付できるファイルはひとつです"
|
||||||
signinRequired: "続行する前に、サインアップまたはサインインが必要です"
|
signinRequired: "続行する前に、登録またはログインが必要です"
|
||||||
|
signinOrContinueOnRemote: "続行するには、お使いのサーバーに移動するか、このサーバーに登録・ログインする必要があります"
|
||||||
invitations: "招待"
|
invitations: "招待"
|
||||||
invitationCode: "招待コード"
|
invitationCode: "招待コード"
|
||||||
checking: "確認しています"
|
checking: "確認しています"
|
||||||
@ -1242,6 +1247,9 @@ keepOriginalFilenameDescription: "この設定をオフにすると、アップ
|
|||||||
noDescription: "説明文はありません"
|
noDescription: "説明文はありません"
|
||||||
alwaysConfirmFollow: "フォローの際常に確認する"
|
alwaysConfirmFollow: "フォローの際常に確認する"
|
||||||
inquiry: "お問い合わせ"
|
inquiry: "お問い合わせ"
|
||||||
|
tryAgain: "もう一度お試しください。"
|
||||||
|
confirmWhenRevealingSensitiveMedia: "センシティブなメディアを表示するとき確認する"
|
||||||
|
sensitiveMediaRevealConfirm: "センシティブなメディアです。表示しますか?"
|
||||||
|
|
||||||
_delivery:
|
_delivery:
|
||||||
status: "配信状態"
|
status: "配信状態"
|
||||||
@ -1705,6 +1713,7 @@ _role:
|
|||||||
canManageAvatarDecorations: "アバターデコレーションの管理"
|
canManageAvatarDecorations: "アバターデコレーションの管理"
|
||||||
driveCapacity: "ドライブ容量"
|
driveCapacity: "ドライブ容量"
|
||||||
alwaysMarkNsfw: "ファイルにNSFWを常に付与"
|
alwaysMarkNsfw: "ファイルにNSFWを常に付与"
|
||||||
|
canUpdateBioMedia: "アイコンとバナーの更新を許可"
|
||||||
pinMax: "ノートのピン留めの最大数"
|
pinMax: "ノートのピン留めの最大数"
|
||||||
antennaMax: "アンテナの作成可能数"
|
antennaMax: "アンテナの作成可能数"
|
||||||
wordMuteMax: "ワードミュートの最大文字数"
|
wordMuteMax: "ワードミュートの最大文字数"
|
||||||
@ -1971,8 +1980,6 @@ _sfx:
|
|||||||
note: "ノート"
|
note: "ノート"
|
||||||
noteMy: "ノート(自分)"
|
noteMy: "ノート(自分)"
|
||||||
notification: "通知"
|
notification: "通知"
|
||||||
antenna: "アンテナ受信"
|
|
||||||
channel: "チャンネル通知"
|
|
||||||
reaction: "リアクション選択時"
|
reaction: "リアクション選択時"
|
||||||
|
|
||||||
_soundSettings:
|
_soundSettings:
|
||||||
@ -2468,6 +2475,7 @@ _drivecleaner:
|
|||||||
|
|
||||||
_webhookSettings:
|
_webhookSettings:
|
||||||
createWebhook: "Webhookを作成"
|
createWebhook: "Webhookを作成"
|
||||||
|
modifyWebhook: "Webhookを編集"
|
||||||
name: "名前"
|
name: "名前"
|
||||||
secret: "シークレット"
|
secret: "シークレット"
|
||||||
events: "Webhookを実行するタイミング"
|
events: "Webhookを実行するタイミング"
|
||||||
@ -2480,6 +2488,26 @@ _webhookSettings:
|
|||||||
renote: "Renoteされたとき"
|
renote: "Renoteされたとき"
|
||||||
reaction: "リアクションがあったとき"
|
reaction: "リアクションがあったとき"
|
||||||
mention: "メンションされたとき"
|
mention: "メンションされたとき"
|
||||||
|
_systemEvents:
|
||||||
|
abuseReport: "ユーザーから通報があったとき"
|
||||||
|
abuseReportResolved: "ユーザーからの通報を処理したとき"
|
||||||
|
deleteConfirm: "Webhookを削除しますか?"
|
||||||
|
|
||||||
|
_abuseReport:
|
||||||
|
_notificationRecipient:
|
||||||
|
createRecipient: "通報の通知先を追加"
|
||||||
|
modifyRecipient: "通報の通知先を編集"
|
||||||
|
recipientType: "通知先の種類"
|
||||||
|
_recipientType:
|
||||||
|
mail: "メール"
|
||||||
|
webhook: "Webhook"
|
||||||
|
_captions:
|
||||||
|
mail: "モデレーター権限を持つユーザーのメールアドレスに通知を送ります(通報を受けた時のみ)"
|
||||||
|
webhook: "指定したSystemWebhookに通知を送ります(通報を受けた時と通報を解決した時にそれぞれ発信)"
|
||||||
|
keywords: "キーワード"
|
||||||
|
notifiedUser: "通知先ユーザー"
|
||||||
|
notifiedWebhook: "使用するWebhook"
|
||||||
|
deleteConfirm: "通知先を削除しますか?"
|
||||||
|
|
||||||
_moderationLogTypes:
|
_moderationLogTypes:
|
||||||
createRole: "ロールを作成"
|
createRole: "ロールを作成"
|
||||||
@ -2518,6 +2546,12 @@ _moderationLogTypes:
|
|||||||
deleteAvatarDecoration: "アイコンデコレーションを削除"
|
deleteAvatarDecoration: "アイコンデコレーションを削除"
|
||||||
unsetUserAvatar: "ユーザーのアイコンを解除"
|
unsetUserAvatar: "ユーザーのアイコンを解除"
|
||||||
unsetUserBanner: "ユーザーのバナーを解除"
|
unsetUserBanner: "ユーザーのバナーを解除"
|
||||||
|
createSystemWebhook: "SystemWebhookを作成"
|
||||||
|
updateSystemWebhook: "SystemWebhookを更新"
|
||||||
|
deleteSystemWebhook: "SystemWebhookを削除"
|
||||||
|
createAbuseReportNotificationRecipient: "通報の通知先を作成"
|
||||||
|
updateAbuseReportNotificationRecipient: "通報の通知先を更新"
|
||||||
|
deleteAbuseReportNotificationRecipient: "通報の通知先を削除"
|
||||||
|
|
||||||
_fileViewer:
|
_fileViewer:
|
||||||
title: "ファイルの詳細"
|
title: "ファイルの詳細"
|
||||||
@ -2572,16 +2606,16 @@ _externalResourceInstaller:
|
|||||||
|
|
||||||
_dataSaver:
|
_dataSaver:
|
||||||
_media:
|
_media:
|
||||||
title: "メディアの読み込み"
|
title: "メディアの読み込みを無効化"
|
||||||
description: "画像・動画が自動で読み込まれるのを防止します。隠れている画像・動画はタップすると読み込まれます。"
|
description: "画像・動画が自動で読み込まれるのを防止します。隠れている画像・動画はタップすると読み込まれます。"
|
||||||
_avatar:
|
_avatar:
|
||||||
title: "アイコン画像"
|
title: "アイコン画像のアニメーションを無効化"
|
||||||
description: "アイコン画像のアニメーションが停止します。アニメーション画像は通常の画像よりファイルサイズが大きいことがあるので、データ通信量をさらに削減できます。"
|
description: "アイコン画像のアニメーションが停止します。アニメーション画像は通常の画像よりファイルサイズが大きいことがあるので、データ通信量をさらに削減できます。"
|
||||||
_urlPreview:
|
_urlPreview:
|
||||||
title: "URLプレビューのサムネイル"
|
title: "URLプレビューのサムネイルを非表示"
|
||||||
description: "URLプレビューのサムネイル画像が読み込まれなくなります。"
|
description: "URLプレビューのサムネイル画像が読み込まれなくなります。"
|
||||||
_code:
|
_code:
|
||||||
title: "コードハイライト"
|
title: "コードハイライトを非表示"
|
||||||
description: "MFMなどでコードハイライト記法が使われている場合、タップするまで読み込まれなくなります。コードハイライトではハイライトする言語ごとにその定義ファイルを読み込む必要がありますが、それらが自動で読み込まれなくなるため、通信量の削減が見込めます。"
|
description: "MFMなどでコードハイライト記法が使われている場合、タップするまで読み込まれなくなります。コードハイライトではハイライトする言語ごとにその定義ファイルを読み込む必要がありますが、それらが自動で読み込まれなくなるため、通信量の削減が見込めます。"
|
||||||
|
|
||||||
_hemisphere:
|
_hemisphere:
|
||||||
|
@ -1 +0,0 @@
|
|||||||
Subproject commit 0179793ec891856d6f37a3be16ba4c22f67a81b5
|
|
24
package.json
24
package.json
@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "misskey",
|
"name": "misskey",
|
||||||
"version": "2024.5.0",
|
"version": "2024.7.0-beta.1",
|
||||||
"codename": "nasubi",
|
"codename": "nasubi",
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/misskey-dev/misskey.git"
|
"url": "https://github.com/misskey-dev/misskey.git"
|
||||||
},
|
},
|
||||||
"packageManager": "pnpm@9.0.6",
|
"packageManager": "pnpm@9.5.0",
|
||||||
"workspaces": [
|
"workspaces": [
|
||||||
"packages/frontend",
|
"packages/frontend",
|
||||||
"packages/backend",
|
"packages/backend",
|
||||||
@ -55,20 +55,22 @@
|
|||||||
"js-yaml": "4.1.0",
|
"js-yaml": "4.1.0",
|
||||||
"postcss": "8.4.38",
|
"postcss": "8.4.38",
|
||||||
"tar": "6.2.1",
|
"tar": "6.2.1",
|
||||||
"terser": "5.30.3",
|
"terser": "5.31.1",
|
||||||
"typescript": "5.4.5",
|
"typescript": "5.5.3",
|
||||||
"esbuild": "0.20.2",
|
"esbuild": "0.22.0",
|
||||||
"glob": "10.3.12"
|
"glob": "10.3.12"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/node": "20.12.7",
|
"@misskey-dev/eslint-plugin": "2.0.2",
|
||||||
"@typescript-eslint/eslint-plugin": "7.7.1",
|
"@types/node": "20.14.9",
|
||||||
"@typescript-eslint/parser": "7.7.1",
|
"@typescript-eslint/eslint-plugin": "7.15.0",
|
||||||
|
"@typescript-eslint/parser": "7.15.0",
|
||||||
"cross-env": "7.0.3",
|
"cross-env": "7.0.3",
|
||||||
"cypress": "13.7.3",
|
"cypress": "13.13.0",
|
||||||
"eslint": "8.57.0",
|
"eslint": "9.6.0",
|
||||||
|
"globals": "15.7.0",
|
||||||
"ncp": "2.0.0",
|
"ncp": "2.0.0",
|
||||||
"start-server-and-test": "2.0.3"
|
"start-server-and-test": "2.0.4"
|
||||||
},
|
},
|
||||||
"optionalDependencies": {
|
"optionalDependencies": {
|
||||||
"@tensorflow/tfjs-core": "4.4.0"
|
"@tensorflow/tfjs-core": "4.4.0"
|
||||||
|
@ -1,4 +0,0 @@
|
|||||||
node_modules
|
|
||||||
/built
|
|
||||||
/.eslintrc.js
|
|
||||||
/@types/**/*
|
|
@ -1,32 +0,0 @@
|
|||||||
module.exports = {
|
|
||||||
parserOptions: {
|
|
||||||
tsconfigRootDir: __dirname,
|
|
||||||
project: ['./tsconfig.json', './test/tsconfig.json'],
|
|
||||||
},
|
|
||||||
extends: [
|
|
||||||
'../shared/.eslintrc.js',
|
|
||||||
],
|
|
||||||
rules: {
|
|
||||||
'import/order': ['warn', {
|
|
||||||
'groups': ['builtin', 'external', 'internal', 'parent', 'sibling', 'index', 'object', 'type'],
|
|
||||||
'pathGroups': [
|
|
||||||
{
|
|
||||||
'pattern': '@/**',
|
|
||||||
'group': 'external',
|
|
||||||
'position': 'after'
|
|
||||||
}
|
|
||||||
],
|
|
||||||
}],
|
|
||||||
'no-restricted-globals': [
|
|
||||||
'error',
|
|
||||||
{
|
|
||||||
'name': '__dirname',
|
|
||||||
'message': 'Not in ESModule. Use `import.meta.url` instead.'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
'name': '__filename',
|
|
||||||
'message': 'Not in ESModule. Use `import.meta.url` instead.'
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
};
|
|
20
packages/backend/assets/api-doc.html
Normal file
20
packages/backend/assets/api-doc.html
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>Misskey API</title>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
<style>
|
||||||
|
body {
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<script
|
||||||
|
id="api-reference"
|
||||||
|
data-url="/api.json"></script>
|
||||||
|
<script src="https://cdn.jsdelivr.net/npm/@scalar/api-reference"></script>
|
||||||
|
</body>
|
||||||
|
</html>
|
@ -1,24 +0,0 @@
|
|||||||
<!DOCTYPE html>
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<title>Misskey API</title>
|
|
||||||
<!-- needed for adaptive design -->
|
|
||||||
<meta charset="utf-8"/>
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
||||||
<link href="https://fonts.googleapis.com/css?family=Montserrat:300,400,700|Roboto:300,400,700" rel="stylesheet">
|
|
||||||
|
|
||||||
<!--
|
|
||||||
ReDoc doesn't change outer page styles
|
|
||||||
-->
|
|
||||||
<style>
|
|
||||||
body {
|
|
||||||
margin: 0;
|
|
||||||
padding: 0;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<redoc spec-url="/api.json" expand-responses="200" expand-single-schema-field="true"></redoc>
|
|
||||||
<script src="https://cdn.redoc.ly/redoc/v2.1.3/bundles/redoc.standalone.js" integrity="sha256-u4DgqzYXoArvNF/Ymw3puKexfOC6lYfw0sfmeliBJ1I=" crossorigin="anonymous"></script>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
46
packages/backend/eslint.config.js
Normal file
46
packages/backend/eslint.config.js
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
import tsParser from '@typescript-eslint/parser';
|
||||||
|
import sharedConfig from '../shared/eslint.config.js';
|
||||||
|
|
||||||
|
export default [
|
||||||
|
...sharedConfig,
|
||||||
|
{
|
||||||
|
ignores: ['**/node_modules', 'built', '@types/**/*', 'migration'],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
files: ['**/*.ts', '**/*.tsx'],
|
||||||
|
languageOptions: {
|
||||||
|
parserOptions: {
|
||||||
|
parser: tsParser,
|
||||||
|
project: ['./tsconfig.json', './test/tsconfig.json'],
|
||||||
|
sourceType: 'module',
|
||||||
|
tsconfigRootDir: import.meta.dirname,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
rules: {
|
||||||
|
'import/order': ['warn', {
|
||||||
|
groups: [
|
||||||
|
'builtin',
|
||||||
|
'external',
|
||||||
|
'internal',
|
||||||
|
'parent',
|
||||||
|
'sibling',
|
||||||
|
'index',
|
||||||
|
'object',
|
||||||
|
'type',
|
||||||
|
],
|
||||||
|
pathGroups: [{
|
||||||
|
pattern: '@/**',
|
||||||
|
group: 'external',
|
||||||
|
position: 'after',
|
||||||
|
}],
|
||||||
|
}],
|
||||||
|
'no-restricted-globals': ['error', {
|
||||||
|
name: '__dirname',
|
||||||
|
message: 'Not in ESModule. Use `import.meta.url` instead.',
|
||||||
|
}, {
|
||||||
|
name: '__filename',
|
||||||
|
message: 'Not in ESModule. Use `import.meta.url` instead.',
|
||||||
|
}],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
];
|
39
packages/backend/migration/1708980134301-APMultipleKeys.js
Normal file
39
packages/backend/migration/1708980134301-APMultipleKeys.js
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
/*
|
||||||
|
* SPDX-FileCopyrightText: syuilo and misskey-project
|
||||||
|
* SPDX-License-Identifier: AGPL-3.0-only
|
||||||
|
*/
|
||||||
|
|
||||||
|
export class APMultipleKeys1708980134301 {
|
||||||
|
name = 'APMultipleKeys1708980134301'
|
||||||
|
|
||||||
|
async up(queryRunner) {
|
||||||
|
await queryRunner.query(`DROP INDEX "public"."IDX_171e64971c780ebd23fae140bb"`);
|
||||||
|
await queryRunner.query(`ALTER TABLE "user_keypair" ADD "ed25519PublicKey" character varying(128)`);
|
||||||
|
await queryRunner.query(`ALTER TABLE "user_keypair" ADD "ed25519PrivateKey" character varying(128)`);
|
||||||
|
await queryRunner.query(`ALTER TABLE "user_publickey" DROP CONSTRAINT "FK_10c146e4b39b443ede016f6736d"`);
|
||||||
|
await queryRunner.query(`ALTER TABLE "user_publickey" DROP CONSTRAINT "PK_10c146e4b39b443ede016f6736d"`);
|
||||||
|
await queryRunner.query(`ALTER TABLE "user_publickey" ADD CONSTRAINT "PK_0db6a5fdb992323449edc8ee421" PRIMARY KEY ("userId", "keyId")`);
|
||||||
|
await queryRunner.query(`ALTER TABLE "user_publickey" DROP CONSTRAINT "PK_0db6a5fdb992323449edc8ee421"`);
|
||||||
|
await queryRunner.query(`ALTER TABLE "user_publickey" ADD CONSTRAINT "PK_171e64971c780ebd23fae140bba" PRIMARY KEY ("keyId")`);
|
||||||
|
await queryRunner.query(`ALTER TABLE "user_publickey" ADD CONSTRAINT "UQ_10c146e4b39b443ede016f6736d" UNIQUE ("userId")`);
|
||||||
|
await queryRunner.query(`CREATE INDEX "IDX_10c146e4b39b443ede016f6736" ON "user_publickey" ("userId") `);
|
||||||
|
await queryRunner.query(`ALTER TABLE "user_publickey" ADD CONSTRAINT "FK_10c146e4b39b443ede016f6736d" FOREIGN KEY ("userId") REFERENCES "user"("id") ON DELETE CASCADE ON UPDATE NO ACTION`);
|
||||||
|
}
|
||||||
|
|
||||||
|
async down(queryRunner) {
|
||||||
|
await queryRunner.query(`ALTER TABLE "user_publickey" DROP CONSTRAINT "FK_10c146e4b39b443ede016f6736d"`);
|
||||||
|
await queryRunner.query(`DROP INDEX "public"."IDX_10c146e4b39b443ede016f6736"`);
|
||||||
|
await queryRunner.query(`ALTER TABLE "user_publickey" DROP CONSTRAINT "UQ_10c146e4b39b443ede016f6736d"`);
|
||||||
|
await queryRunner.query(`ALTER TABLE "user_publickey" DROP CONSTRAINT "PK_171e64971c780ebd23fae140bba"`);
|
||||||
|
await queryRunner.query(`ALTER TABLE "user_publickey" ADD CONSTRAINT "PK_0db6a5fdb992323449edc8ee421" PRIMARY KEY ("userId", "keyId")`);
|
||||||
|
await queryRunner.query(`ALTER TABLE "user_publickey" DROP CONSTRAINT "PK_0db6a5fdb992323449edc8ee421"`);
|
||||||
|
await queryRunner.query(`ALTER TABLE "user_publickey" ADD CONSTRAINT "PK_10c146e4b39b443ede016f6736d" PRIMARY KEY ("userId")`);
|
||||||
|
await queryRunner.query(`ALTER TABLE "user_publickey" ADD CONSTRAINT "FK_10c146e4b39b443ede016f6736d" FOREIGN KEY ("userId") REFERENCES "user"("id") ON DELETE CASCADE ON UPDATE NO ACTION`);
|
||||||
|
await queryRunner.query(`ALTER TABLE "user_profile" ALTER COLUMN "followersVisibility" DROP DEFAULT`);
|
||||||
|
await queryRunner.query(`ALTER TABLE "user_profile" ALTER COLUMN "followersVisibility" TYPE "public"."user_profile_followersVisibility_enum_old" USING "followersVisibility"::"text"::"public"."user_profile_followersVisibility_enum_old"`);
|
||||||
|
await queryRunner.query(`ALTER TABLE "user_profile" ALTER COLUMN "followersVisibility" SET DEFAULT 'public'`);
|
||||||
|
await queryRunner.query(`ALTER TABLE "user_keypair" DROP COLUMN "ed25519PrivateKey"`);
|
||||||
|
await queryRunner.query(`ALTER TABLE "user_keypair" DROP COLUMN "ed25519PublicKey"`);
|
||||||
|
await queryRunner.query(`CREATE UNIQUE INDEX "IDX_171e64971c780ebd23fae140bb" ON "user_publickey" ("keyId") `);
|
||||||
|
}
|
||||||
|
}
|
16
packages/backend/migration/1709242519122-HttpSignImplLv.js
Normal file
16
packages/backend/migration/1709242519122-HttpSignImplLv.js
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
/*
|
||||||
|
* SPDX-FileCopyrightText: syuilo and misskey-project
|
||||||
|
* SPDX-License-Identifier: AGPL-3.0-only
|
||||||
|
*/
|
||||||
|
|
||||||
|
export class HttpSignImplLv1709242519122 {
|
||||||
|
name = 'HttpSignImplLv1709242519122'
|
||||||
|
|
||||||
|
async up(queryRunner) {
|
||||||
|
await queryRunner.query(`ALTER TABLE "instance" ADD "httpMessageSignaturesImplementationLevel" character varying(16) NOT NULL DEFAULT '00'`);
|
||||||
|
}
|
||||||
|
|
||||||
|
async down(queryRunner) {
|
||||||
|
await queryRunner.query(`ALTER TABLE "instance" DROP COLUMN "httpMessageSignaturesImplementationLevel"`);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,16 @@
|
|||||||
|
/*
|
||||||
|
* SPDX-FileCopyrightText: syuilo and misskey-project
|
||||||
|
* SPDX-License-Identifier: AGPL-3.0-only
|
||||||
|
*/
|
||||||
|
|
||||||
|
export class APMultipleKeys1709269211718 {
|
||||||
|
name = 'APMultipleKeys1709269211718'
|
||||||
|
|
||||||
|
async up(queryRunner) {
|
||||||
|
await queryRunner.query(`ALTER TABLE "user_publickey" DROP CONSTRAINT "UQ_10c146e4b39b443ede016f6736d"`);
|
||||||
|
}
|
||||||
|
|
||||||
|
async down(queryRunner) {
|
||||||
|
await queryRunner.query(`ALTER TABLE "user_publickey" ADD CONSTRAINT "UQ_10c146e4b39b443ede016f6736d" UNIQUE ("userId")`);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,62 @@
|
|||||||
|
/*
|
||||||
|
* SPDX-FileCopyrightText: syuilo and misskey-project
|
||||||
|
* SPDX-License-Identifier: AGPL-3.0-only
|
||||||
|
*/
|
||||||
|
|
||||||
|
export class AbuseReportNotification1713656541000 {
|
||||||
|
name = 'AbuseReportNotification1713656541000'
|
||||||
|
|
||||||
|
async up(queryRunner) {
|
||||||
|
await queryRunner.query(`
|
||||||
|
CREATE TABLE "system_webhook" (
|
||||||
|
"id" varchar(32) NOT NULL,
|
||||||
|
"isActive" boolean NOT NULL DEFAULT true,
|
||||||
|
"updatedAt" timestamp with time zone NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
"latestSentAt" timestamp with time zone NULL DEFAULT NULL,
|
||||||
|
"latestStatus" integer NULL DEFAULT NULL,
|
||||||
|
"name" varchar(255) NOT NULL,
|
||||||
|
"on" varchar(128) [] NOT NULL DEFAULT '{}'::character varying[],
|
||||||
|
"url" varchar(1024) NOT NULL,
|
||||||
|
"secret" varchar(1024) NOT NULL,
|
||||||
|
CONSTRAINT "PK_system_webhook_id" PRIMARY KEY ("id")
|
||||||
|
);
|
||||||
|
CREATE INDEX "IDX_system_webhook_isActive" ON "system_webhook" ("isActive");
|
||||||
|
CREATE INDEX "IDX_system_webhook_on" ON "system_webhook" USING gin ("on");
|
||||||
|
|
||||||
|
CREATE TABLE "abuse_report_notification_recipient" (
|
||||||
|
"id" varchar(32) NOT NULL,
|
||||||
|
"isActive" boolean NOT NULL DEFAULT true,
|
||||||
|
"updatedAt" timestamp with time zone NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
"name" varchar(255) NOT NULL,
|
||||||
|
"method" varchar(64) NOT NULL,
|
||||||
|
"userId" varchar(32) NULL DEFAULT NULL,
|
||||||
|
"systemWebhookId" varchar(32) NULL DEFAULT NULL,
|
||||||
|
CONSTRAINT "PK_abuse_report_notification_recipient_id" PRIMARY KEY ("id"),
|
||||||
|
CONSTRAINT "FK_abuse_report_notification_recipient_userId1" FOREIGN KEY ("userId") REFERENCES "user"("id") ON DELETE CASCADE ON UPDATE NO ACTION,
|
||||||
|
CONSTRAINT "FK_abuse_report_notification_recipient_userId2" FOREIGN KEY ("userId") REFERENCES "user_profile"("userId") ON DELETE CASCADE ON UPDATE NO ACTION,
|
||||||
|
CONSTRAINT "FK_abuse_report_notification_recipient_systemWebhookId" FOREIGN KEY ("systemWebhookId") REFERENCES "system_webhook"("id") ON DELETE CASCADE ON UPDATE NO ACTION
|
||||||
|
);
|
||||||
|
CREATE INDEX "IDX_abuse_report_notification_recipient_isActive" ON "abuse_report_notification_recipient" ("isActive");
|
||||||
|
CREATE INDEX "IDX_abuse_report_notification_recipient_method" ON "abuse_report_notification_recipient" ("method");
|
||||||
|
CREATE INDEX "IDX_abuse_report_notification_recipient_userId" ON "abuse_report_notification_recipient" ("userId");
|
||||||
|
CREATE INDEX "IDX_abuse_report_notification_recipient_systemWebhookId" ON "abuse_report_notification_recipient" ("systemWebhookId");
|
||||||
|
`);
|
||||||
|
}
|
||||||
|
|
||||||
|
async down(queryRunner) {
|
||||||
|
await queryRunner.query(`
|
||||||
|
ALTER TABLE "abuse_report_notification_recipient" DROP CONSTRAINT "FK_abuse_report_notification_recipient_userId1";
|
||||||
|
ALTER TABLE "abuse_report_notification_recipient" DROP CONSTRAINT "FK_abuse_report_notification_recipient_userId2";
|
||||||
|
ALTER TABLE "abuse_report_notification_recipient" DROP CONSTRAINT "FK_abuse_report_notification_recipient_systemWebhookId";
|
||||||
|
DROP INDEX "IDX_abuse_report_notification_recipient_isActive";
|
||||||
|
DROP INDEX "IDX_abuse_report_notification_recipient_method";
|
||||||
|
DROP INDEX "IDX_abuse_report_notification_recipient_userId";
|
||||||
|
DROP INDEX "IDX_abuse_report_notification_recipient_systemWebhookId";
|
||||||
|
DROP TABLE "abuse_report_notification_recipient";
|
||||||
|
|
||||||
|
DROP INDEX "IDX_system_webhook_isActive";
|
||||||
|
DROP INDEX "IDX_system_webhook_on";
|
||||||
|
DROP TABLE "system_webhook";
|
||||||
|
`);
|
||||||
|
}
|
||||||
|
}
|
@ -4,7 +4,7 @@
|
|||||||
"private": true,
|
"private": true,
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": "^20.10.0"
|
"node": "^20.10.0 || ^22.0.0"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"start": "node ./built/boot/entry.js",
|
"start": "node ./built/boot/entry.js",
|
||||||
@ -65,43 +65,43 @@
|
|||||||
"utf-8-validate": "6.0.3"
|
"utf-8-validate": "6.0.3"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@aws-sdk/client-s3": "3.412.0",
|
"@aws-sdk/client-s3": "3.600.0",
|
||||||
"@aws-sdk/lib-storage": "3.412.0",
|
"@aws-sdk/lib-storage": "3.600.0",
|
||||||
"@bull-board/api": "5.17.0",
|
"@bull-board/api": "5.20.5",
|
||||||
"@bull-board/fastify": "5.17.0",
|
"@bull-board/fastify": "5.20.5",
|
||||||
"@bull-board/ui": "5.17.0",
|
"@bull-board/ui": "5.20.5",
|
||||||
"@discordapp/twemoji": "15.0.3",
|
"@discordapp/twemoji": "15.0.3",
|
||||||
"@fastify/accepts": "4.3.0",
|
"@fastify/accepts": "4.3.0",
|
||||||
"@fastify/cookie": "9.3.1",
|
"@fastify/cookie": "9.3.1",
|
||||||
"@fastify/cors": "9.0.1",
|
"@fastify/cors": "9.0.1",
|
||||||
"@fastify/express": "3.0.0",
|
"@fastify/express": "3.0.0",
|
||||||
"@fastify/http-proxy": "9.5.0",
|
"@fastify/http-proxy": "9.5.0",
|
||||||
"@fastify/multipart": "8.2.0",
|
"@fastify/multipart": "8.3.0",
|
||||||
"@fastify/static": "7.0.3",
|
"@fastify/static": "7.0.4",
|
||||||
"@fastify/view": "9.1.0",
|
"@fastify/view": "9.1.0",
|
||||||
|
"@misskey-dev/node-http-message-signatures": "0.0.10",
|
||||||
"@misskey-dev/sharp-read-bmp": "1.2.0",
|
"@misskey-dev/sharp-read-bmp": "1.2.0",
|
||||||
"@misskey-dev/summaly": "5.1.0",
|
"@misskey-dev/summaly": "5.1.0",
|
||||||
"@napi-rs/canvas": "^0.1.52",
|
"@napi-rs/canvas": "^0.1.53",
|
||||||
"@nestjs/common": "10.3.8",
|
"@nestjs/common": "10.3.10",
|
||||||
"@nestjs/core": "10.3.8",
|
"@nestjs/core": "10.3.10",
|
||||||
"@nestjs/testing": "10.3.8",
|
"@nestjs/testing": "10.3.10",
|
||||||
"@peertube/http-signature": "1.7.0",
|
"@sentry/node": "8.13.0",
|
||||||
"@sentry/node": "^8.5.0",
|
"@sentry/profiling-node": "8.13.0",
|
||||||
"@sentry/profiling-node": "^8.5.0",
|
|
||||||
"@simplewebauthn/server": "10.0.0",
|
"@simplewebauthn/server": "10.0.0",
|
||||||
"@sinonjs/fake-timers": "11.2.2",
|
"@sinonjs/fake-timers": "11.2.2",
|
||||||
"@smithy/node-http-handler": "2.5.0",
|
"@smithy/node-http-handler": "2.5.0",
|
||||||
"@swc/cli": "0.3.12",
|
"@swc/cli": "0.3.12",
|
||||||
"@swc/core": "1.4.17",
|
"@swc/core": "1.6.6",
|
||||||
"@twemoji/parser": "15.1.1",
|
"@twemoji/parser": "15.1.1",
|
||||||
"accepts": "1.3.8",
|
"accepts": "1.3.8",
|
||||||
"ajv": "8.13.0",
|
"ajv": "8.16.0",
|
||||||
"archiver": "7.0.1",
|
"archiver": "7.0.1",
|
||||||
"async-mutex": "0.5.0",
|
"async-mutex": "0.5.0",
|
||||||
"bcryptjs": "2.4.3",
|
"bcryptjs": "2.4.3",
|
||||||
"blurhash": "2.0.5",
|
"blurhash": "2.0.5",
|
||||||
"body-parser": "1.20.2",
|
"body-parser": "1.20.2",
|
||||||
"bullmq": "5.7.8",
|
"bullmq": "5.8.3",
|
||||||
"cacheable-lookup": "7.0.0",
|
"cacheable-lookup": "7.0.0",
|
||||||
"cbor": "9.0.2",
|
"cbor": "9.0.2",
|
||||||
"chalk": "5.3.0",
|
"chalk": "5.3.0",
|
||||||
@ -112,27 +112,27 @@
|
|||||||
"content-disposition": "0.5.4",
|
"content-disposition": "0.5.4",
|
||||||
"date-fns": "2.30.0",
|
"date-fns": "2.30.0",
|
||||||
"deep-email-validator": "0.1.21",
|
"deep-email-validator": "0.1.21",
|
||||||
"fastify": "4.26.2",
|
"fastify": "4.28.1",
|
||||||
"fastify-raw-body": "4.3.0",
|
"fastify-raw-body": "4.3.0",
|
||||||
"feed": "4.2.2",
|
"feed": "4.2.2",
|
||||||
"file-type": "19.0.0",
|
"file-type": "19.0.0",
|
||||||
"fluent-ffmpeg": "2.1.2",
|
"fluent-ffmpeg": "2.1.3",
|
||||||
"form-data": "4.0.0",
|
"form-data": "4.0.0",
|
||||||
"got": "14.2.1",
|
"got": "14.4.1",
|
||||||
"happy-dom": "10.0.3",
|
"happy-dom": "10.0.3",
|
||||||
"hpagent": "1.2.0",
|
"hpagent": "1.2.0",
|
||||||
"htmlescape": "1.1.1",
|
"htmlescape": "1.1.1",
|
||||||
"http-link-header": "1.1.3",
|
"http-link-header": "1.1.3",
|
||||||
"ioredis": "5.4.1",
|
"ioredis": "5.4.1",
|
||||||
"ip-cidr": "3.1.0",
|
"ip-cidr": "4.0.1",
|
||||||
"ipaddr.js": "2.2.0",
|
"ipaddr.js": "2.2.0",
|
||||||
"is-svg": "5.0.0",
|
"is-svg": "5.0.1",
|
||||||
"js-yaml": "4.1.0",
|
"js-yaml": "4.1.0",
|
||||||
"jsdom": "24.0.0",
|
"jsdom": "24.1.0",
|
||||||
"json5": "2.2.3",
|
"json5": "2.2.3",
|
||||||
"jsonld": "8.3.2",
|
"jsonld": "8.3.2",
|
||||||
"jsrsasign": "11.1.0",
|
"jsrsasign": "11.1.0",
|
||||||
"meilisearch": "0.38.0",
|
"meilisearch": "0.41.0",
|
||||||
"mfm-js": "0.24.0",
|
"mfm-js": "0.24.0",
|
||||||
"microformats-parser": "2.0.2",
|
"microformats-parser": "2.0.2",
|
||||||
"mime-types": "2.1.35",
|
"mime-types": "2.1.35",
|
||||||
@ -142,24 +142,24 @@
|
|||||||
"nanoid": "5.0.7",
|
"nanoid": "5.0.7",
|
||||||
"nested-property": "4.0.0",
|
"nested-property": "4.0.0",
|
||||||
"node-fetch": "3.3.2",
|
"node-fetch": "3.3.2",
|
||||||
"nodemailer": "6.9.13",
|
"nodemailer": "6.9.14",
|
||||||
"nsfwjs": "2.4.2",
|
"nsfwjs": "2.4.2",
|
||||||
"oauth": "0.10.0",
|
"oauth": "0.10.0",
|
||||||
"oauth2orize": "1.12.0",
|
"oauth2orize": "1.12.0",
|
||||||
"oauth2orize-pkce": "0.1.2",
|
"oauth2orize-pkce": "0.1.2",
|
||||||
"os-utils": "0.0.14",
|
"os-utils": "0.0.14",
|
||||||
"otpauth": "9.2.3",
|
"otpauth": "9.3.1",
|
||||||
"parse5": "7.1.2",
|
"parse5": "7.1.2",
|
||||||
"pg": "8.11.5",
|
"pg": "8.12.0",
|
||||||
"pkce-challenge": "4.1.0",
|
"pkce-challenge": "4.1.0",
|
||||||
"probe-image-size": "7.2.3",
|
"probe-image-size": "7.2.3",
|
||||||
"promise-limit": "2.7.0",
|
"promise-limit": "2.7.0",
|
||||||
"pug": "3.0.2",
|
"pug": "3.0.3",
|
||||||
"punycode": "2.3.1",
|
"punycode": "2.3.1",
|
||||||
"qrcode": "1.5.3",
|
"qrcode": "1.5.3",
|
||||||
"random-seed": "0.3.0",
|
"random-seed": "0.3.0",
|
||||||
"ratelimiter": "3.4.1",
|
"ratelimiter": "3.4.1",
|
||||||
"re2": "1.20.10",
|
"re2": "1.21.3",
|
||||||
"redis-lock": "0.1.4",
|
"redis-lock": "0.1.4",
|
||||||
"reflect-metadata": "0.2.2",
|
"reflect-metadata": "0.2.2",
|
||||||
"rename": "1.0.4",
|
"rename": "1.0.4",
|
||||||
@ -167,27 +167,26 @@
|
|||||||
"rxjs": "7.8.1",
|
"rxjs": "7.8.1",
|
||||||
"sanitize-html": "2.13.0",
|
"sanitize-html": "2.13.0",
|
||||||
"secure-json-parse": "2.7.0",
|
"secure-json-parse": "2.7.0",
|
||||||
"sharp": "0.33.3",
|
"sharp": "0.33.4",
|
||||||
"slacc": "0.0.10",
|
"slacc": "0.0.10",
|
||||||
"strict-event-emitter-types": "2.0.0",
|
"strict-event-emitter-types": "2.0.0",
|
||||||
"stringz": "2.1.0",
|
"stringz": "2.1.0",
|
||||||
"systeminformation": "5.22.7",
|
"systeminformation": "5.22.11",
|
||||||
"tinycolor2": "1.6.0",
|
"tinycolor2": "1.6.0",
|
||||||
"tmp": "0.2.3",
|
"tmp": "0.2.3",
|
||||||
"tsc-alias": "1.8.8",
|
"tsc-alias": "1.8.10",
|
||||||
"tsconfig-paths": "4.2.0",
|
"tsconfig-paths": "4.2.0",
|
||||||
"typeorm": "0.3.20",
|
"typeorm": "0.3.20",
|
||||||
"typescript": "5.4.5",
|
"typescript": "5.5.3",
|
||||||
"ulid": "2.3.0",
|
"ulid": "2.3.0",
|
||||||
"vary": "1.1.2",
|
"vary": "1.1.2",
|
||||||
"web-push": "3.6.7",
|
"web-push": "3.6.7",
|
||||||
"ws": "8.17.0",
|
"ws": "8.17.1",
|
||||||
"xev": "3.0.2"
|
"xev": "3.0.2"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@jest/globals": "29.7.0",
|
"@jest/globals": "29.7.0",
|
||||||
"@misskey-dev/eslint-plugin": "1.0.0",
|
"@nestjs/platform-express": "10.3.10",
|
||||||
"@nestjs/platform-express": "10.3.8",
|
|
||||||
"@simplewebauthn/types": "10.0.0",
|
"@simplewebauthn/types": "10.0.0",
|
||||||
"@swc/jest": "0.2.36",
|
"@swc/jest": "0.2.36",
|
||||||
"@types/accepts": "1.3.7",
|
"@types/accepts": "1.3.7",
|
||||||
@ -197,22 +196,21 @@
|
|||||||
"@types/color-convert": "2.0.3",
|
"@types/color-convert": "2.0.3",
|
||||||
"@types/content-disposition": "0.5.8",
|
"@types/content-disposition": "0.5.8",
|
||||||
"@types/fluent-ffmpeg": "2.1.24",
|
"@types/fluent-ffmpeg": "2.1.24",
|
||||||
"@types/htmlescape": "^1.1.3",
|
"@types/htmlescape": "1.1.3",
|
||||||
"@types/http-link-header": "1.0.5",
|
"@types/http-link-header": "1.0.7",
|
||||||
"@types/jest": "29.5.12",
|
"@types/jest": "29.5.12",
|
||||||
"@types/js-yaml": "4.0.9",
|
"@types/js-yaml": "4.0.9",
|
||||||
"@types/jsdom": "21.1.6",
|
"@types/jsdom": "21.1.7",
|
||||||
"@types/jsonld": "1.5.13",
|
"@types/jsonld": "1.5.14",
|
||||||
"@types/jsrsasign": "10.5.14",
|
"@types/jsrsasign": "10.5.14",
|
||||||
"@types/mime-types": "2.1.4",
|
"@types/mime-types": "2.1.4",
|
||||||
"@types/ms": "0.7.34",
|
"@types/ms": "0.7.34",
|
||||||
"@types/node": "20.12.7",
|
"@types/node": "20.14.9",
|
||||||
"@types/node-fetch": "3.0.3",
|
|
||||||
"@types/nodemailer": "6.4.15",
|
"@types/nodemailer": "6.4.15",
|
||||||
"@types/oauth": "0.9.4",
|
"@types/oauth": "0.9.5",
|
||||||
"@types/oauth2orize": "1.11.5",
|
"@types/oauth2orize": "1.11.5",
|
||||||
"@types/oauth2orize-pkce": "0.1.2",
|
"@types/oauth2orize-pkce": "0.1.2",
|
||||||
"@types/pg": "8.11.5",
|
"@types/pg": "8.11.6",
|
||||||
"@types/pug": "2.0.10",
|
"@types/pug": "2.0.10",
|
||||||
"@types/punycode": "2.1.4",
|
"@types/punycode": "2.1.4",
|
||||||
"@types/qrcode": "1.5.5",
|
"@types/qrcode": "1.5.5",
|
||||||
@ -228,18 +226,17 @@
|
|||||||
"@types/vary": "1.1.3",
|
"@types/vary": "1.1.3",
|
||||||
"@types/web-push": "3.6.3",
|
"@types/web-push": "3.6.3",
|
||||||
"@types/ws": "8.5.10",
|
"@types/ws": "8.5.10",
|
||||||
"@typescript-eslint/eslint-plugin": "7.7.1",
|
"@typescript-eslint/eslint-plugin": "7.15.0",
|
||||||
"@typescript-eslint/parser": "7.7.1",
|
"@typescript-eslint/parser": "7.15.0",
|
||||||
"aws-sdk-client-mock": "3.0.1",
|
"aws-sdk-client-mock": "4.0.1",
|
||||||
"cross-env": "7.0.3",
|
"cross-env": "7.0.3",
|
||||||
"eslint": "8.57.0",
|
|
||||||
"eslint-plugin-import": "2.29.1",
|
"eslint-plugin-import": "2.29.1",
|
||||||
"execa": "8.0.1",
|
"execa": "9.2.0",
|
||||||
"fkill": "^9.0.0",
|
"fkill": "9.0.0",
|
||||||
"jest": "29.7.0",
|
"jest": "29.7.0",
|
||||||
"jest-mock": "29.7.0",
|
"jest-mock": "29.7.0",
|
||||||
"nodemon": "3.1.0",
|
"nodemon": "3.1.4",
|
||||||
"pid-port": "1.0.0",
|
"pid-port": "1.0.0",
|
||||||
"simple-oauth2": "5.0.0"
|
"simple-oauth2": "5.0.1"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -30,6 +30,7 @@ function execStart() {
|
|||||||
|
|
||||||
async function killProc() {
|
async function killProc() {
|
||||||
if (backendProcess) {
|
if (backendProcess) {
|
||||||
|
backendProcess.catch(() => {}); // backendProcess.kill()によって発生する例外を無視するためにcatch()を呼び出す
|
||||||
backendProcess.kill();
|
backendProcess.kill();
|
||||||
await new Promise(resolve => backendProcess.on('exit', resolve));
|
await new Promise(resolve => backendProcess.on('exit', resolve));
|
||||||
backendProcess = undefined;
|
backendProcess = undefined;
|
||||||
@ -46,6 +47,7 @@ async function killProc() {
|
|||||||
],
|
],
|
||||||
{
|
{
|
||||||
stdio: [process.stdin, process.stdout, process.stderr, 'ipc'],
|
stdio: [process.stdin, process.stdout, process.stderr, 'ipc'],
|
||||||
|
serialization: "json",
|
||||||
})
|
})
|
||||||
.on('message', async (message) => {
|
.on('message', async (message) => {
|
||||||
if (message.type === 'exit') {
|
if (message.type === 'exit') {
|
||||||
|
82
packages/backend/src/@types/http-signature.d.ts
vendored
82
packages/backend/src/@types/http-signature.d.ts
vendored
@ -1,82 +0,0 @@
|
|||||||
/*
|
|
||||||
* SPDX-FileCopyrightText: syuilo and misskey-project
|
|
||||||
* SPDX-License-Identifier: AGPL-3.0-only
|
|
||||||
*/
|
|
||||||
|
|
||||||
declare module '@peertube/http-signature' {
|
|
||||||
import type { IncomingMessage, ClientRequest } from 'node:http';
|
|
||||||
|
|
||||||
interface ISignature {
|
|
||||||
keyId: string;
|
|
||||||
algorithm: string;
|
|
||||||
headers: string[];
|
|
||||||
signature: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface IOptions {
|
|
||||||
headers?: string[];
|
|
||||||
algorithm?: string;
|
|
||||||
strict?: boolean;
|
|
||||||
authorizationHeaderName?: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface IParseRequestOptions extends IOptions {
|
|
||||||
clockSkew?: number;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface IParsedSignature {
|
|
||||||
scheme: string;
|
|
||||||
params: ISignature;
|
|
||||||
signingString: string;
|
|
||||||
algorithm: string;
|
|
||||||
keyId: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
type RequestSignerConstructorOptions =
|
|
||||||
IRequestSignerConstructorOptionsFromProperties |
|
|
||||||
IRequestSignerConstructorOptionsFromFunction;
|
|
||||||
|
|
||||||
interface IRequestSignerConstructorOptionsFromProperties {
|
|
||||||
keyId: string;
|
|
||||||
key: string | Buffer;
|
|
||||||
algorithm?: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface IRequestSignerConstructorOptionsFromFunction {
|
|
||||||
sign?: (data: string, cb: (err: any, sig: ISignature) => void) => void;
|
|
||||||
}
|
|
||||||
|
|
||||||
class RequestSigner {
|
|
||||||
constructor(options: RequestSignerConstructorOptions);
|
|
||||||
|
|
||||||
public writeHeader(header: string, value: string): string;
|
|
||||||
|
|
||||||
public writeDateHeader(): string;
|
|
||||||
|
|
||||||
public writeTarget(method: string, path: string): void;
|
|
||||||
|
|
||||||
public sign(cb: (err: any, authz: string) => void): void;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface ISignRequestOptions extends IOptions {
|
|
||||||
keyId: string;
|
|
||||||
key: string;
|
|
||||||
httpVersion?: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
export function parse(request: IncomingMessage, options?: IParseRequestOptions): IParsedSignature;
|
|
||||||
export function parseRequest(request: IncomingMessage, options?: IParseRequestOptions): IParsedSignature;
|
|
||||||
|
|
||||||
export function sign(request: ClientRequest, options: ISignRequestOptions): boolean;
|
|
||||||
export function signRequest(request: ClientRequest, options: ISignRequestOptions): boolean;
|
|
||||||
export function createSigner(): RequestSigner;
|
|
||||||
export function isSigner(obj: any): obj is RequestSigner;
|
|
||||||
|
|
||||||
export function sshKeyToPEM(key: string): string;
|
|
||||||
export function sshKeyFingerprint(key: string): string;
|
|
||||||
export function pemToRsaSSHKey(pem: string, comment: string): string;
|
|
||||||
|
|
||||||
export function verify(parsedSignature: IParsedSignature, pubkey: string | Buffer): boolean;
|
|
||||||
export function verifySignature(parsedSignature: IParsedSignature, pubkey: string | Buffer): boolean;
|
|
||||||
export function verifyHMAC(parsedSignature: IParsedSignature, secret: string): boolean;
|
|
||||||
}
|
|
@ -7,7 +7,7 @@ import { LoggerService } from '@nestjs/common';
|
|||||||
import Logger from '@/logger.js';
|
import Logger from '@/logger.js';
|
||||||
|
|
||||||
const logger = new Logger('core', 'cyan');
|
const logger = new Logger('core', 'cyan');
|
||||||
const nestLogger = logger.createSubLogger('nest', 'green', false);
|
const nestLogger = logger.createSubLogger('nest', 'green');
|
||||||
|
|
||||||
export class NestLogger implements LoggerService {
|
export class NestLogger implements LoggerService {
|
||||||
/**
|
/**
|
||||||
|
@ -25,7 +25,7 @@ Error.stackTraceLimit = Infinity;
|
|||||||
EventEmitter.defaultMaxListeners = 128;
|
EventEmitter.defaultMaxListeners = 128;
|
||||||
|
|
||||||
const logger = new Logger('core', 'cyan');
|
const logger = new Logger('core', 'cyan');
|
||||||
const clusterLogger = logger.createSubLogger('cluster', 'orange', false);
|
const clusterLogger = logger.createSubLogger('cluster', 'orange');
|
||||||
const ev = new Xev();
|
const ev = new Xev();
|
||||||
|
|
||||||
//#region Events
|
//#region Events
|
||||||
|
@ -25,7 +25,7 @@ const _dirname = dirname(_filename);
|
|||||||
const meta = JSON.parse(fs.readFileSync(`${_dirname}/../../../../built/meta.json`, 'utf-8'));
|
const meta = JSON.parse(fs.readFileSync(`${_dirname}/../../../../built/meta.json`, 'utf-8'));
|
||||||
|
|
||||||
const logger = new Logger('core', 'cyan');
|
const logger = new Logger('core', 'cyan');
|
||||||
const bootLogger = logger.createSubLogger('boot', 'magenta', false);
|
const bootLogger = logger.createSubLogger('boot', 'magenta');
|
||||||
|
|
||||||
const themeColor = chalk.hex('#86b300');
|
const themeColor = chalk.hex('#86b300');
|
||||||
|
|
||||||
|
@ -4,13 +4,36 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import cluster from 'node:cluster';
|
import cluster from 'node:cluster';
|
||||||
|
import * as Sentry from '@sentry/node';
|
||||||
|
import { nodeProfilingIntegration } from '@sentry/profiling-node';
|
||||||
import { envOption } from '@/env.js';
|
import { envOption } from '@/env.js';
|
||||||
|
import { loadConfig } from '@/config.js';
|
||||||
import { jobQueue, server } from './common.js';
|
import { jobQueue, server } from './common.js';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Init worker process
|
* Init worker process
|
||||||
*/
|
*/
|
||||||
export async function workerMain() {
|
export async function workerMain() {
|
||||||
|
const config = loadConfig();
|
||||||
|
|
||||||
|
if (config.sentryForBackend) {
|
||||||
|
Sentry.init({
|
||||||
|
integrations: [
|
||||||
|
...(config.sentryForBackend.enableNodeProfiling ? [nodeProfilingIntegration()] : []),
|
||||||
|
],
|
||||||
|
|
||||||
|
// Performance Monitoring
|
||||||
|
tracesSampleRate: 1.0, // Capture 100% of the transactions
|
||||||
|
|
||||||
|
// Set sampling rate for profiling - this is relative to tracesSampleRate
|
||||||
|
profilesSampleRate: 1.0,
|
||||||
|
|
||||||
|
maxBreadcrumbs: 0,
|
||||||
|
|
||||||
|
...config.sentryForBackend.options,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
if (envOption.onlyServer) {
|
if (envOption.onlyServer) {
|
||||||
await server();
|
await server();
|
||||||
} else if (envOption.onlyQueue) {
|
} else if (envOption.onlyQueue) {
|
||||||
|
@ -23,7 +23,7 @@ type RedisOptionsSource = Partial<RedisOptions> & {
|
|||||||
* 設定ファイルの型
|
* 設定ファイルの型
|
||||||
*/
|
*/
|
||||||
type Source = {
|
type Source = {
|
||||||
url: string;
|
url?: string;
|
||||||
port?: number;
|
port?: number;
|
||||||
socket?: string;
|
socket?: string;
|
||||||
chmodSocket?: string;
|
chmodSocket?: string;
|
||||||
@ -31,9 +31,9 @@ type Source = {
|
|||||||
db: {
|
db: {
|
||||||
host: string;
|
host: string;
|
||||||
port: number;
|
port: number;
|
||||||
db: string;
|
db?: string;
|
||||||
user: string;
|
user?: string;
|
||||||
pass: string;
|
pass?: string;
|
||||||
disableCache?: boolean;
|
disableCache?: boolean;
|
||||||
extra?: { [x: string]: string };
|
extra?: { [x: string]: string };
|
||||||
};
|
};
|
||||||
@ -202,13 +202,17 @@ export function loadConfig(): Config {
|
|||||||
: { 'src/_boot_.ts': { file: 'src/_boot_.ts' } };
|
: { 'src/_boot_.ts': { file: 'src/_boot_.ts' } };
|
||||||
const config = yaml.load(fs.readFileSync(path, 'utf-8')) as Source;
|
const config = yaml.load(fs.readFileSync(path, 'utf-8')) as Source;
|
||||||
|
|
||||||
const url = tryCreateUrl(config.url);
|
const url = tryCreateUrl(config.url ?? process.env.MISSKEY_URL ?? '');
|
||||||
const version = meta.version;
|
const version = meta.version;
|
||||||
const host = url.host;
|
const host = url.host;
|
||||||
const hostname = url.hostname;
|
const hostname = url.hostname;
|
||||||
const scheme = url.protocol.replace(/:$/, '');
|
const scheme = url.protocol.replace(/:$/, '');
|
||||||
const wsScheme = scheme.replace('http', 'ws');
|
const wsScheme = scheme.replace('http', 'ws');
|
||||||
|
|
||||||
|
const dbDb = config.db.db ?? process.env.DATABASE_DB ?? '';
|
||||||
|
const dbUser = config.db.user ?? process.env.DATABASE_USER ?? '';
|
||||||
|
const dbPass = config.db.pass ?? process.env.DATABASE_PASSWORD ?? '';
|
||||||
|
|
||||||
const externalMediaProxy = config.mediaProxy ?
|
const externalMediaProxy = config.mediaProxy ?
|
||||||
config.mediaProxy.endsWith('/') ? config.mediaProxy.substring(0, config.mediaProxy.length - 1) : config.mediaProxy
|
config.mediaProxy.endsWith('/') ? config.mediaProxy.substring(0, config.mediaProxy.length - 1) : config.mediaProxy
|
||||||
: null;
|
: null;
|
||||||
@ -231,7 +235,7 @@ export function loadConfig(): Config {
|
|||||||
apiUrl: `${scheme}://${host}/api`,
|
apiUrl: `${scheme}://${host}/api`,
|
||||||
authUrl: `${scheme}://${host}/auth`,
|
authUrl: `${scheme}://${host}/auth`,
|
||||||
driveUrl: `${scheme}://${host}/files`,
|
driveUrl: `${scheme}://${host}/files`,
|
||||||
db: config.db,
|
db: { ...config.db, db: dbDb, user: dbUser, pass: dbPass },
|
||||||
dbReplications: config.dbReplications,
|
dbReplications: config.dbReplications,
|
||||||
dbSlaves: config.dbSlaves,
|
dbSlaves: config.dbSlaves,
|
||||||
meilisearch: config.meilisearch,
|
meilisearch: config.meilisearch,
|
||||||
@ -259,7 +263,7 @@ export function loadConfig(): Config {
|
|||||||
deliverJobMaxAttempts: config.deliverJobMaxAttempts,
|
deliverJobMaxAttempts: config.deliverJobMaxAttempts,
|
||||||
inboxJobMaxAttempts: config.inboxJobMaxAttempts,
|
inboxJobMaxAttempts: config.inboxJobMaxAttempts,
|
||||||
proxyRemoteFiles: config.proxyRemoteFiles,
|
proxyRemoteFiles: config.proxyRemoteFiles,
|
||||||
signToActivityPubGet: config.signToActivityPubGet,
|
signToActivityPubGet: config.signToActivityPubGet ?? true,
|
||||||
mediaProxy: externalMediaProxy ?? internalMediaProxy,
|
mediaProxy: externalMediaProxy ?? internalMediaProxy,
|
||||||
externalMediaProxyEnabled: externalMediaProxy !== null && externalMediaProxy !== internalMediaProxy,
|
externalMediaProxyEnabled: externalMediaProxy !== null && externalMediaProxy !== internalMediaProxy,
|
||||||
videoThumbnailGenerator: config.videoThumbnailGenerator ?
|
videoThumbnailGenerator: config.videoThumbnailGenerator ?
|
||||||
|
@ -3,11 +3,17 @@
|
|||||||
* SPDX-License-Identifier: AGPL-3.0-only
|
* SPDX-License-Identifier: AGPL-3.0-only
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
// dummy
|
||||||
export const MAX_NOTE_TEXT_LENGTH = 3000;
|
export const MAX_NOTE_TEXT_LENGTH = 3000;
|
||||||
|
|
||||||
export const USER_ONLINE_THRESHOLD = 1000 * 60 * 10; // 10min
|
export const USER_ONLINE_THRESHOLD = 1000 * 60 * 10; // 10min
|
||||||
export const USER_ACTIVE_THRESHOLD = 1000 * 60 * 60 * 24 * 3; // 3days
|
export const USER_ACTIVE_THRESHOLD = 1000 * 60 * 60 * 24 * 3; // 3days
|
||||||
|
|
||||||
|
export const REMOTE_USER_CACHE_TTL = 1000 * 60 * 60 * 3; // 3hours
|
||||||
|
export const REMOTE_USER_MOVE_COOLDOWN = 1000 * 60 * 60 * 24 * 14; // 14days
|
||||||
|
|
||||||
|
export const REMOTE_SERVER_CACHE_TTL = 1000 * 60 * 60 * 3; // 3hours
|
||||||
|
|
||||||
//#region hard limits
|
//#region hard limits
|
||||||
// If you change DB_* values, you must also change the DB schema.
|
// If you change DB_* values, you must also change the DB schema.
|
||||||
|
|
||||||
|
405
packages/backend/src/core/AbuseReportNotificationService.ts
Normal file
405
packages/backend/src/core/AbuseReportNotificationService.ts
Normal file
@ -0,0 +1,405 @@
|
|||||||
|
/*
|
||||||
|
* SPDX-FileCopyrightText: syuilo and misskey-project
|
||||||
|
* SPDX-License-Identifier: AGPL-3.0-only
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { Inject, Injectable, type OnApplicationShutdown } from '@nestjs/common';
|
||||||
|
import { Brackets, In, IsNull, Not } from 'typeorm';
|
||||||
|
import * as Redis from 'ioredis';
|
||||||
|
import sanitizeHtml from 'sanitize-html';
|
||||||
|
import { DI } from '@/di-symbols.js';
|
||||||
|
import { bindThis } from '@/decorators.js';
|
||||||
|
import { GlobalEvents, GlobalEventService } from '@/core/GlobalEventService.js';
|
||||||
|
import type {
|
||||||
|
AbuseReportNotificationRecipientRepository,
|
||||||
|
MiAbuseReportNotificationRecipient,
|
||||||
|
MiAbuseUserReport,
|
||||||
|
MiUser,
|
||||||
|
} from '@/models/_.js';
|
||||||
|
import { EmailService } from '@/core/EmailService.js';
|
||||||
|
import { MetaService } from '@/core/MetaService.js';
|
||||||
|
import { RoleService } from '@/core/RoleService.js';
|
||||||
|
import { RecipientMethod } from '@/models/AbuseReportNotificationRecipient.js';
|
||||||
|
import { ModerationLogService } from '@/core/ModerationLogService.js';
|
||||||
|
import { SystemWebhookService } from '@/core/SystemWebhookService.js';
|
||||||
|
import { IdService } from './IdService.js';
|
||||||
|
|
||||||
|
@Injectable()
|
||||||
|
export class AbuseReportNotificationService implements OnApplicationShutdown {
|
||||||
|
constructor(
|
||||||
|
@Inject(DI.abuseReportNotificationRecipientRepository)
|
||||||
|
private abuseReportNotificationRecipientRepository: AbuseReportNotificationRecipientRepository,
|
||||||
|
@Inject(DI.redisForSub)
|
||||||
|
private redisForSub: Redis.Redis,
|
||||||
|
private idService: IdService,
|
||||||
|
private roleService: RoleService,
|
||||||
|
private systemWebhookService: SystemWebhookService,
|
||||||
|
private emailService: EmailService,
|
||||||
|
private metaService: MetaService,
|
||||||
|
private moderationLogService: ModerationLogService,
|
||||||
|
private globalEventService: GlobalEventService,
|
||||||
|
) {
|
||||||
|
this.redisForSub.on('message', this.onMessage);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 管理者用Redisイベントを用いて{@link abuseReports}の内容を管理者各位に通知する.
|
||||||
|
* 通知先ユーザは{@link RoleService.getModeratorIds}の取得結果に依る.
|
||||||
|
*
|
||||||
|
* @see RoleService.getModeratorIds
|
||||||
|
* @see GlobalEventService.publishAdminStream
|
||||||
|
*/
|
||||||
|
@bindThis
|
||||||
|
public async notifyAdminStream(abuseReports: MiAbuseUserReport[]) {
|
||||||
|
if (abuseReports.length <= 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const moderatorIds = await this.roleService.getModeratorIds(true, true);
|
||||||
|
|
||||||
|
for (const moderatorId of moderatorIds) {
|
||||||
|
for (const abuseReport of abuseReports) {
|
||||||
|
this.globalEventService.publishAdminStream(
|
||||||
|
moderatorId,
|
||||||
|
'newAbuseUserReport',
|
||||||
|
{
|
||||||
|
id: abuseReport.id,
|
||||||
|
targetUserId: abuseReport.targetUserId,
|
||||||
|
reporterId: abuseReport.reporterId,
|
||||||
|
comment: abuseReport.comment,
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Mailを用いて{@link abuseReports}の内容を管理者各位に通知する.
|
||||||
|
* メールアドレスの送信先は以下の通り.
|
||||||
|
* - モデレータ権限所有者ユーザ(設定画面からメールアドレスの設定を行っているユーザに限る)
|
||||||
|
* - metaテーブルに設定されているメールアドレス
|
||||||
|
*
|
||||||
|
* @see EmailService.sendEmail
|
||||||
|
*/
|
||||||
|
@bindThis
|
||||||
|
public async notifyMail(abuseReports: MiAbuseUserReport[]) {
|
||||||
|
if (abuseReports.length <= 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const recipientEMailAddresses = await this.fetchEMailRecipients().then(it => it
|
||||||
|
.filter(it => it.isActive && it.userProfile?.emailVerified)
|
||||||
|
.map(it => it.userProfile?.email)
|
||||||
|
.filter(x => x != null),
|
||||||
|
);
|
||||||
|
|
||||||
|
// 送信先の鮮度を保つため、毎回取得する
|
||||||
|
const meta = await this.metaService.fetch(true);
|
||||||
|
recipientEMailAddresses.push(
|
||||||
|
...(meta.email ? [meta.email] : []),
|
||||||
|
);
|
||||||
|
|
||||||
|
if (recipientEMailAddresses.length <= 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const mailAddress of recipientEMailAddresses) {
|
||||||
|
await Promise.all(
|
||||||
|
abuseReports.map(it => {
|
||||||
|
// TODO: 送信処理はJobQueue化したい
|
||||||
|
return this.emailService.sendEmail(
|
||||||
|
mailAddress,
|
||||||
|
'New Abuse Report',
|
||||||
|
sanitizeHtml(it.comment),
|
||||||
|
sanitizeHtml(it.comment),
|
||||||
|
);
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* SystemWebhookを用いて{@link abuseReports}の内容を管理者各位に通知する.
|
||||||
|
* ここではJobQueueへのエンキューのみを行うため、即時実行されない.
|
||||||
|
*
|
||||||
|
* @see SystemWebhookService.enqueueSystemWebhook
|
||||||
|
*/
|
||||||
|
@bindThis
|
||||||
|
public async notifySystemWebhook(
|
||||||
|
abuseReports: MiAbuseUserReport[],
|
||||||
|
type: 'abuseReport' | 'abuseReportResolved',
|
||||||
|
) {
|
||||||
|
if (abuseReports.length <= 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const recipientWebhookIds = await this.fetchWebhookRecipients()
|
||||||
|
.then(it => it
|
||||||
|
.filter(it => it.isActive && it.systemWebhookId && it.method === 'webhook')
|
||||||
|
.map(it => it.systemWebhookId)
|
||||||
|
.filter(x => x != null));
|
||||||
|
for (const webhookId of recipientWebhookIds) {
|
||||||
|
await Promise.all(
|
||||||
|
abuseReports.map(it => {
|
||||||
|
return this.systemWebhookService.enqueueSystemWebhook(
|
||||||
|
webhookId,
|
||||||
|
type,
|
||||||
|
it,
|
||||||
|
);
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通報の通知先一覧を取得する.
|
||||||
|
*
|
||||||
|
* @param {Object} [params] クエリの取得条件
|
||||||
|
* @param {Object} [params.method] 取得する通知先の通知方法
|
||||||
|
* @param {Object} [opts] 動作時の詳細なオプション
|
||||||
|
* @param {boolean} [opts.removeUnauthorized] 副作用としてモデレータ権限を持たない送信先ユーザをDBから削除するかどうか(default: true)
|
||||||
|
* @param {boolean} [opts.joinUser] 通知先のユーザ情報をJOINするかどうか(default: false)
|
||||||
|
* @param {boolean} [opts.joinSystemWebhook] 通知先のSystemWebhook情報をJOINするかどうか(default: false)
|
||||||
|
* @see removeUnauthorizedRecipientUsers
|
||||||
|
*/
|
||||||
|
@bindThis
|
||||||
|
public async fetchRecipients(
|
||||||
|
params?: {
|
||||||
|
ids?: MiAbuseReportNotificationRecipient['id'][],
|
||||||
|
method?: RecipientMethod[],
|
||||||
|
},
|
||||||
|
opts?: {
|
||||||
|
removeUnauthorized?: boolean,
|
||||||
|
joinUser?: boolean,
|
||||||
|
joinSystemWebhook?: boolean,
|
||||||
|
},
|
||||||
|
): Promise<MiAbuseReportNotificationRecipient[]> {
|
||||||
|
const query = this.abuseReportNotificationRecipientRepository.createQueryBuilder('recipient');
|
||||||
|
|
||||||
|
if (opts?.joinUser) {
|
||||||
|
query.innerJoinAndSelect('user', 'user', 'recipient.userId = user.id');
|
||||||
|
query.innerJoinAndSelect('recipient.userProfile', 'userProfile');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (opts?.joinSystemWebhook) {
|
||||||
|
query.innerJoinAndSelect('recipient.systemWebhook', 'systemWebhook');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (params?.ids) {
|
||||||
|
query.andWhere({ id: In(params.ids) });
|
||||||
|
}
|
||||||
|
|
||||||
|
if (params?.method) {
|
||||||
|
query.andWhere(new Brackets(qb => {
|
||||||
|
if (params.method?.includes('email')) {
|
||||||
|
qb.orWhere({ method: 'email', userId: Not(IsNull()) });
|
||||||
|
}
|
||||||
|
if (params.method?.includes('webhook')) {
|
||||||
|
qb.orWhere({ method: 'webhook', userId: IsNull() });
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
|
const recipients = await query.getMany();
|
||||||
|
if (recipients.length <= 0) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
// アサイン有効期限切れはイベントで拾えないので、このタイミングでチェック及び削除(オプション)
|
||||||
|
return (opts?.removeUnauthorized ?? true)
|
||||||
|
? await this.removeUnauthorizedRecipientUsers(recipients)
|
||||||
|
: recipients;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* EMailの通知先一覧を取得する.
|
||||||
|
* リレーション先の{@link MiUser}および{@link MiUserProfile}も同時に取得する.
|
||||||
|
*
|
||||||
|
* @param {Object} [opts]
|
||||||
|
* @param {boolean} [opts.removeUnauthorized] 副作用としてモデレータ権限を持たない送信先ユーザをDBから削除するかどうか(default: true)
|
||||||
|
* @see removeUnauthorizedRecipientUsers
|
||||||
|
*/
|
||||||
|
@bindThis
|
||||||
|
public async fetchEMailRecipients(opts?: {
|
||||||
|
removeUnauthorized?: boolean
|
||||||
|
}): Promise<MiAbuseReportNotificationRecipient[]> {
|
||||||
|
return this.fetchRecipients({ method: ['email'] }, { joinUser: true, ...opts });
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Webhookの通知先一覧を取得する.
|
||||||
|
* リレーション先の{@link MiSystemWebhook}も同時に取得する.
|
||||||
|
*/
|
||||||
|
@bindThis
|
||||||
|
public fetchWebhookRecipients(): Promise<MiAbuseReportNotificationRecipient[]> {
|
||||||
|
return this.fetchRecipients({ method: ['webhook'] }, { joinSystemWebhook: true });
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通知先を作成する.
|
||||||
|
*/
|
||||||
|
@bindThis
|
||||||
|
public async createRecipient(
|
||||||
|
params: {
|
||||||
|
isActive: MiAbuseReportNotificationRecipient['isActive'];
|
||||||
|
name: MiAbuseReportNotificationRecipient['name'];
|
||||||
|
method: MiAbuseReportNotificationRecipient['method'];
|
||||||
|
userId: MiAbuseReportNotificationRecipient['userId'];
|
||||||
|
systemWebhookId: MiAbuseReportNotificationRecipient['systemWebhookId'];
|
||||||
|
},
|
||||||
|
updater: MiUser,
|
||||||
|
): Promise<MiAbuseReportNotificationRecipient> {
|
||||||
|
const id = this.idService.gen();
|
||||||
|
await this.abuseReportNotificationRecipientRepository.insert({
|
||||||
|
...params,
|
||||||
|
id,
|
||||||
|
});
|
||||||
|
|
||||||
|
const created = await this.abuseReportNotificationRecipientRepository.findOneByOrFail({ id: id });
|
||||||
|
|
||||||
|
this.moderationLogService
|
||||||
|
.log(updater, 'createAbuseReportNotificationRecipient', {
|
||||||
|
recipientId: id,
|
||||||
|
recipient: created,
|
||||||
|
})
|
||||||
|
.then();
|
||||||
|
|
||||||
|
return created;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通知先を更新する.
|
||||||
|
*/
|
||||||
|
@bindThis
|
||||||
|
public async updateRecipient(
|
||||||
|
params: {
|
||||||
|
id: MiAbuseReportNotificationRecipient['id'];
|
||||||
|
isActive: MiAbuseReportNotificationRecipient['isActive'];
|
||||||
|
name: MiAbuseReportNotificationRecipient['name'];
|
||||||
|
method: MiAbuseReportNotificationRecipient['method'];
|
||||||
|
userId: MiAbuseReportNotificationRecipient['userId'];
|
||||||
|
systemWebhookId: MiAbuseReportNotificationRecipient['systemWebhookId'];
|
||||||
|
},
|
||||||
|
updater: MiUser,
|
||||||
|
): Promise<MiAbuseReportNotificationRecipient> {
|
||||||
|
const beforeEntity = await this.abuseReportNotificationRecipientRepository.findOneByOrFail({ id: params.id });
|
||||||
|
|
||||||
|
await this.abuseReportNotificationRecipientRepository.update(params.id, {
|
||||||
|
isActive: params.isActive,
|
||||||
|
updatedAt: new Date(),
|
||||||
|
name: params.name,
|
||||||
|
method: params.method,
|
||||||
|
userId: params.userId,
|
||||||
|
systemWebhookId: params.systemWebhookId,
|
||||||
|
});
|
||||||
|
|
||||||
|
const afterEntity = await this.abuseReportNotificationRecipientRepository.findOneByOrFail({ id: params.id });
|
||||||
|
|
||||||
|
this.moderationLogService
|
||||||
|
.log(updater, 'updateAbuseReportNotificationRecipient', {
|
||||||
|
recipientId: params.id,
|
||||||
|
before: beforeEntity,
|
||||||
|
after: afterEntity,
|
||||||
|
})
|
||||||
|
.then();
|
||||||
|
|
||||||
|
return afterEntity;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通知先を削除する.
|
||||||
|
*/
|
||||||
|
@bindThis
|
||||||
|
public async deleteRecipient(
|
||||||
|
id: MiAbuseReportNotificationRecipient['id'],
|
||||||
|
updater: MiUser,
|
||||||
|
) {
|
||||||
|
const entity = await this.abuseReportNotificationRecipientRepository.findBy({ id });
|
||||||
|
|
||||||
|
await this.abuseReportNotificationRecipientRepository.delete(id);
|
||||||
|
|
||||||
|
this.moderationLogService
|
||||||
|
.log(updater, 'deleteAbuseReportNotificationRecipient', {
|
||||||
|
recipientId: id,
|
||||||
|
recipient: entity,
|
||||||
|
})
|
||||||
|
.then();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* モデレータ権限を持たない(*1)通知先ユーザを削除する.
|
||||||
|
*
|
||||||
|
* *1: 以下の両方を満たすものの事を言う
|
||||||
|
* - 通知先にユーザIDが設定されている
|
||||||
|
* - 付与ロールにモデレータ権限がない or アサインの有効期限が切れている
|
||||||
|
*
|
||||||
|
* @param recipients 通知先一覧の配列
|
||||||
|
* @returns {@lisk recipients}からモデレータ権限を持たない通知先を削除した配列
|
||||||
|
*/
|
||||||
|
@bindThis
|
||||||
|
private async removeUnauthorizedRecipientUsers(recipients: MiAbuseReportNotificationRecipient[]): Promise<MiAbuseReportNotificationRecipient[]> {
|
||||||
|
const userRecipients = recipients.filter(it => it.userId !== null);
|
||||||
|
const recipientUserIds = new Set(userRecipients.map(it => it.userId).filter(x => x != null));
|
||||||
|
if (recipientUserIds.size <= 0) {
|
||||||
|
// ユーザが通知先として設定されていない場合、この関数での処理を行うべきレコードが無い
|
||||||
|
return recipients;
|
||||||
|
}
|
||||||
|
|
||||||
|
// モデレータ権限の有無で通知先設定を振り分ける
|
||||||
|
const authorizedUserIds = await this.roleService.getModeratorIds(true, true);
|
||||||
|
const authorizedUserRecipients = Array.of<MiAbuseReportNotificationRecipient>();
|
||||||
|
const unauthorizedUserRecipients = Array.of<MiAbuseReportNotificationRecipient>();
|
||||||
|
for (const recipient of userRecipients) {
|
||||||
|
// eslint-disable-next-line
|
||||||
|
if (authorizedUserIds.includes(recipient.userId!)) {
|
||||||
|
authorizedUserRecipients.push(recipient);
|
||||||
|
} else {
|
||||||
|
unauthorizedUserRecipients.push(recipient);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// モデレータ権限を持たない通知先をDBから削除する
|
||||||
|
if (unauthorizedUserRecipients.length > 0) {
|
||||||
|
await this.abuseReportNotificationRecipientRepository.delete(unauthorizedUserRecipients.map(it => it.id));
|
||||||
|
}
|
||||||
|
const nonUserRecipients = recipients.filter(it => it.userId === null);
|
||||||
|
return [...nonUserRecipients, ...authorizedUserRecipients].sort((a, b) => a.id.localeCompare(b.id));
|
||||||
|
}
|
||||||
|
|
||||||
|
@bindThis
|
||||||
|
private async onMessage(_: string, data: string): Promise<void> {
|
||||||
|
const obj = JSON.parse(data);
|
||||||
|
if (obj.channel !== 'internal') {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const { type } = obj.message as GlobalEvents['internal']['payload'];
|
||||||
|
switch (type) {
|
||||||
|
case 'roleUpdated':
|
||||||
|
case 'roleDeleted':
|
||||||
|
case 'userRoleUnassigned': {
|
||||||
|
// 場合によってはキャッシュ更新よりも先にここが呼ばれてしまう可能性があるのでnextTickで遅延実行
|
||||||
|
process.nextTick(async () => {
|
||||||
|
const recipients = await this.abuseReportNotificationRecipientRepository.findBy({
|
||||||
|
userId: Not(IsNull()),
|
||||||
|
});
|
||||||
|
await this.removeUnauthorizedRecipientUsers(recipients);
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default: {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@bindThis
|
||||||
|
public dispose(): void {
|
||||||
|
this.redisForSub.off('message', this.onMessage);
|
||||||
|
}
|
||||||
|
|
||||||
|
@bindThis
|
||||||
|
public onApplicationShutdown(signal?: string | undefined): void {
|
||||||
|
this.dispose();
|
||||||
|
}
|
||||||
|
}
|
128
packages/backend/src/core/AbuseReportService.ts
Normal file
128
packages/backend/src/core/AbuseReportService.ts
Normal file
@ -0,0 +1,128 @@
|
|||||||
|
/*
|
||||||
|
* SPDX-FileCopyrightText: syuilo and misskey-project
|
||||||
|
* SPDX-License-Identifier: AGPL-3.0-only
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { Inject, Injectable } from '@nestjs/common';
|
||||||
|
import { In } from 'typeorm';
|
||||||
|
import { DI } from '@/di-symbols.js';
|
||||||
|
import { bindThis } from '@/decorators.js';
|
||||||
|
import type { AbuseUserReportsRepository, MiAbuseUserReport, MiUser, UsersRepository } from '@/models/_.js';
|
||||||
|
import { AbuseReportNotificationService } from '@/core/AbuseReportNotificationService.js';
|
||||||
|
import { QueueService } from '@/core/QueueService.js';
|
||||||
|
import { InstanceActorService } from '@/core/InstanceActorService.js';
|
||||||
|
import { ApRendererService } from '@/core/activitypub/ApRendererService.js';
|
||||||
|
import { ModerationLogService } from '@/core/ModerationLogService.js';
|
||||||
|
import { IdService } from './IdService.js';
|
||||||
|
|
||||||
|
@Injectable()
|
||||||
|
export class AbuseReportService {
|
||||||
|
constructor(
|
||||||
|
@Inject(DI.abuseUserReportsRepository)
|
||||||
|
private abuseUserReportsRepository: AbuseUserReportsRepository,
|
||||||
|
@Inject(DI.usersRepository)
|
||||||
|
private usersRepository: UsersRepository,
|
||||||
|
private idService: IdService,
|
||||||
|
private abuseReportNotificationService: AbuseReportNotificationService,
|
||||||
|
private queueService: QueueService,
|
||||||
|
private instanceActorService: InstanceActorService,
|
||||||
|
private apRendererService: ApRendererService,
|
||||||
|
private moderationLogService: ModerationLogService,
|
||||||
|
) {
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ユーザからの通報をDBに記録し、その内容を下記の手段で管理者各位に通知する.
|
||||||
|
* - 管理者用Redisイベント
|
||||||
|
* - EMail(モデレータ権限所有者ユーザ+metaテーブルに設定されているメールアドレス)
|
||||||
|
* - SystemWebhook
|
||||||
|
*
|
||||||
|
* @param params 通報内容. もし複数件の通報に対応した時のために、あらかじめ複数件を処理できる前提で考える
|
||||||
|
* @see AbuseReportNotificationService.notify
|
||||||
|
*/
|
||||||
|
@bindThis
|
||||||
|
public async report(params: {
|
||||||
|
targetUserId: MiAbuseUserReport['targetUserId'],
|
||||||
|
targetUserHost: MiAbuseUserReport['targetUserHost'],
|
||||||
|
reporterId: MiAbuseUserReport['reporterId'],
|
||||||
|
reporterHost: MiAbuseUserReport['reporterHost'],
|
||||||
|
comment: string,
|
||||||
|
}[]) {
|
||||||
|
const entities = params.map(param => {
|
||||||
|
return {
|
||||||
|
id: this.idService.gen(),
|
||||||
|
targetUserId: param.targetUserId,
|
||||||
|
targetUserHost: param.targetUserHost,
|
||||||
|
reporterId: param.reporterId,
|
||||||
|
reporterHost: param.reporterHost,
|
||||||
|
comment: param.comment,
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
const reports = Array.of<MiAbuseUserReport>();
|
||||||
|
for (const entity of entities) {
|
||||||
|
const report = await this.abuseUserReportsRepository.insertOne(entity);
|
||||||
|
reports.push(report);
|
||||||
|
}
|
||||||
|
|
||||||
|
return Promise.all([
|
||||||
|
this.abuseReportNotificationService.notifyAdminStream(reports),
|
||||||
|
this.abuseReportNotificationService.notifySystemWebhook(reports, 'abuseReport'),
|
||||||
|
this.abuseReportNotificationService.notifyMail(reports),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通報を解決し、その内容を下記の手段で管理者各位に通知する.
|
||||||
|
* - SystemWebhook
|
||||||
|
*
|
||||||
|
* @param params 通報内容. もし複数件の通報に対応した時のために、あらかじめ複数件を処理できる前提で考える
|
||||||
|
* @param operator 通報を処理したユーザ
|
||||||
|
* @see AbuseReportNotificationService.notify
|
||||||
|
*/
|
||||||
|
@bindThis
|
||||||
|
public async resolve(
|
||||||
|
params: {
|
||||||
|
reportId: string;
|
||||||
|
forward: boolean;
|
||||||
|
}[],
|
||||||
|
operator: MiUser,
|
||||||
|
) {
|
||||||
|
const paramsMap = new Map(params.map(it => [it.reportId, it]));
|
||||||
|
const reports = await this.abuseUserReportsRepository.findBy({
|
||||||
|
id: In(params.map(it => it.reportId)),
|
||||||
|
});
|
||||||
|
|
||||||
|
for (const report of reports) {
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
||||||
|
const ps = paramsMap.get(report.id)!;
|
||||||
|
|
||||||
|
await this.abuseUserReportsRepository.update(report.id, {
|
||||||
|
resolved: true,
|
||||||
|
assigneeId: operator.id,
|
||||||
|
forwarded: ps.forward && report.targetUserHost !== null,
|
||||||
|
});
|
||||||
|
|
||||||
|
if (ps.forward && report.targetUserHost != null) {
|
||||||
|
const actor = await this.instanceActorService.getInstanceActor();
|
||||||
|
const targetUser = await this.usersRepository.findOneByOrFail({ id: report.targetUserId });
|
||||||
|
|
||||||
|
// eslint-disable-next-line
|
||||||
|
const flag = this.apRendererService.renderFlag(actor, targetUser.uri!, report.comment);
|
||||||
|
const contextAssignedFlag = this.apRendererService.addContext(flag);
|
||||||
|
this.queueService.deliver(actor, contextAssignedFlag, targetUser.inbox, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.moderationLogService
|
||||||
|
.log(operator, 'resolveAbuseReport', {
|
||||||
|
reportId: report.id,
|
||||||
|
report: report,
|
||||||
|
forwarded: ps.forward && report.targetUserHost !== null,
|
||||||
|
})
|
||||||
|
.then();
|
||||||
|
}
|
||||||
|
|
||||||
|
return this.abuseUserReportsRepository.findBy({ id: In(reports.map(it => it.id)) })
|
||||||
|
.then(reports => this.abuseReportNotificationService.notifySystemWebhook(reports, 'abuseReportResolved'));
|
||||||
|
}
|
||||||
|
}
|
@ -3,7 +3,8 @@
|
|||||||
* SPDX-License-Identifier: AGPL-3.0-only
|
* SPDX-License-Identifier: AGPL-3.0-only
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { Inject, Injectable } from '@nestjs/common';
|
import { Inject, Injectable, OnModuleInit } from '@nestjs/common';
|
||||||
|
import { ModuleRef } from '@nestjs/core';
|
||||||
import { DI } from '@/di-symbols.js';
|
import { DI } from '@/di-symbols.js';
|
||||||
import type { UsersRepository } from '@/models/_.js';
|
import type { UsersRepository } from '@/models/_.js';
|
||||||
import type { MiUser } from '@/models/User.js';
|
import type { MiUser } from '@/models/User.js';
|
||||||
@ -12,30 +13,44 @@ import { RelayService } from '@/core/RelayService.js';
|
|||||||
import { ApDeliverManagerService } from '@/core/activitypub/ApDeliverManagerService.js';
|
import { ApDeliverManagerService } from '@/core/activitypub/ApDeliverManagerService.js';
|
||||||
import { UserEntityService } from '@/core/entities/UserEntityService.js';
|
import { UserEntityService } from '@/core/entities/UserEntityService.js';
|
||||||
import { bindThis } from '@/decorators.js';
|
import { bindThis } from '@/decorators.js';
|
||||||
|
import type { PrivateKeyWithPem } from '@misskey-dev/node-http-message-signatures';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class AccountUpdateService {
|
export class AccountUpdateService implements OnModuleInit {
|
||||||
|
private apDeliverManagerService: ApDeliverManagerService;
|
||||||
constructor(
|
constructor(
|
||||||
|
private moduleRef: ModuleRef,
|
||||||
|
|
||||||
@Inject(DI.usersRepository)
|
@Inject(DI.usersRepository)
|
||||||
private usersRepository: UsersRepository,
|
private usersRepository: UsersRepository,
|
||||||
|
|
||||||
private userEntityService: UserEntityService,
|
private userEntityService: UserEntityService,
|
||||||
private apRendererService: ApRendererService,
|
private apRendererService: ApRendererService,
|
||||||
private apDeliverManagerService: ApDeliverManagerService,
|
|
||||||
private relayService: RelayService,
|
private relayService: RelayService,
|
||||||
) {
|
) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async onModuleInit() {
|
||||||
|
this.apDeliverManagerService = this.moduleRef.get(ApDeliverManagerService.name);
|
||||||
|
}
|
||||||
|
|
||||||
@bindThis
|
@bindThis
|
||||||
public async publishToFollowers(userId: MiUser['id']) {
|
/**
|
||||||
|
* Deliver account update to followers
|
||||||
|
* @param userId user id
|
||||||
|
* @param deliverKey optional. Private key to sign the deliver.
|
||||||
|
*/
|
||||||
|
public async publishToFollowers(userId: MiUser['id'], deliverKey?: PrivateKeyWithPem) {
|
||||||
const user = await this.usersRepository.findOneBy({ id: userId });
|
const user = await this.usersRepository.findOneBy({ id: userId });
|
||||||
if (user == null) throw new Error('user not found');
|
if (user == null) throw new Error('user not found');
|
||||||
|
|
||||||
// フォロワーがリモートユーザーかつ投稿者がローカルユーザーならUpdateを配信
|
// フォロワーがリモートユーザーかつ投稿者がローカルユーザーならUpdateを配信
|
||||||
if (this.userEntityService.isLocalUser(user)) {
|
if (this.userEntityService.isLocalUser(user)) {
|
||||||
const content = this.apRendererService.addContext(this.apRendererService.renderUpdate(await this.apRendererService.renderPerson(user), user));
|
const content = this.apRendererService.addContext(this.apRendererService.renderUpdate(await this.apRendererService.renderPerson(user), user));
|
||||||
this.apDeliverManagerService.deliverToFollowers(user, content);
|
await Promise.allSettled([
|
||||||
this.relayService.deliverToRelays(user, content);
|
this.apDeliverManagerService.deliverToFollowers(user, content, deliverKey),
|
||||||
|
this.relayService.deliverToRelays(user, content, deliverKey),
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -41,7 +41,7 @@ export class ClipService {
|
|||||||
const currentCount = await this.clipsRepository.countBy({
|
const currentCount = await this.clipsRepository.countBy({
|
||||||
userId: me.id,
|
userId: me.id,
|
||||||
});
|
});
|
||||||
if (currentCount > (await this.roleService.getUserPolicies(me.id)).clipLimit) {
|
if (currentCount >= (await this.roleService.getUserPolicies(me.id)).clipLimit) {
|
||||||
throw new ClipService.TooManyClipsError();
|
throw new ClipService.TooManyClipsError();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -102,7 +102,7 @@ export class ClipService {
|
|||||||
const currentCount = await this.clipNotesRepository.countBy({
|
const currentCount = await this.clipNotesRepository.countBy({
|
||||||
clipId: clip.id,
|
clipId: clip.id,
|
||||||
});
|
});
|
||||||
if (currentCount > (await this.roleService.getUserPolicies(me.id)).noteEachClipsLimit) {
|
if (currentCount >= (await this.roleService.getUserPolicies(me.id)).noteEachClipsLimit) {
|
||||||
throw new ClipService.TooManyClipNotesError();
|
throw new ClipService.TooManyClipNotesError();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,6 +5,14 @@
|
|||||||
|
|
||||||
import { Module } from '@nestjs/common';
|
import { Module } from '@nestjs/common';
|
||||||
import { FanoutTimelineEndpointService } from '@/core/FanoutTimelineEndpointService.js';
|
import { FanoutTimelineEndpointService } from '@/core/FanoutTimelineEndpointService.js';
|
||||||
|
import { AbuseReportService } from '@/core/AbuseReportService.js';
|
||||||
|
import { SystemWebhookEntityService } from '@/core/entities/SystemWebhookEntityService.js';
|
||||||
|
import {
|
||||||
|
AbuseReportNotificationRecipientEntityService,
|
||||||
|
} from '@/core/entities/AbuseReportNotificationRecipientEntityService.js';
|
||||||
|
import { AbuseReportNotificationService } from '@/core/AbuseReportNotificationService.js';
|
||||||
|
import { SystemWebhookService } from '@/core/SystemWebhookService.js';
|
||||||
|
import { UserSearchService } from '@/core/UserSearchService.js';
|
||||||
import { AccountMoveService } from './AccountMoveService.js';
|
import { AccountMoveService } from './AccountMoveService.js';
|
||||||
import { AccountUpdateService } from './AccountUpdateService.js';
|
import { AccountUpdateService } from './AccountUpdateService.js';
|
||||||
import { AiService } from './AiService.js';
|
import { AiService } from './AiService.js';
|
||||||
@ -53,10 +61,11 @@ import { UserFollowingService } from './UserFollowingService.js';
|
|||||||
import { UserKeypairService } from './UserKeypairService.js';
|
import { UserKeypairService } from './UserKeypairService.js';
|
||||||
import { UserListService } from './UserListService.js';
|
import { UserListService } from './UserListService.js';
|
||||||
import { UserMutingService } from './UserMutingService.js';
|
import { UserMutingService } from './UserMutingService.js';
|
||||||
|
import { UserRenoteMutingService } from './UserRenoteMutingService.js';
|
||||||
import { UserSuspendService } from './UserSuspendService.js';
|
import { UserSuspendService } from './UserSuspendService.js';
|
||||||
import { UserAuthService } from './UserAuthService.js';
|
import { UserAuthService } from './UserAuthService.js';
|
||||||
import { VideoProcessingService } from './VideoProcessingService.js';
|
import { VideoProcessingService } from './VideoProcessingService.js';
|
||||||
import { WebhookService } from './WebhookService.js';
|
import { UserWebhookService } from './UserWebhookService.js';
|
||||||
import { ProxyAccountService } from './ProxyAccountService.js';
|
import { ProxyAccountService } from './ProxyAccountService.js';
|
||||||
import { UtilityService } from './UtilityService.js';
|
import { UtilityService } from './UtilityService.js';
|
||||||
import { FileInfoService } from './FileInfoService.js';
|
import { FileInfoService } from './FileInfoService.js';
|
||||||
@ -144,6 +153,8 @@ import type { Provider } from '@nestjs/common';
|
|||||||
|
|
||||||
//#region 文字列ベースでのinjection用(循環参照対応のため)
|
//#region 文字列ベースでのinjection用(循環参照対応のため)
|
||||||
const $LoggerService: Provider = { provide: 'LoggerService', useExisting: LoggerService };
|
const $LoggerService: Provider = { provide: 'LoggerService', useExisting: LoggerService };
|
||||||
|
const $AbuseReportService: Provider = { provide: 'AbuseReportService', useExisting: AbuseReportService };
|
||||||
|
const $AbuseReportNotificationService: Provider = { provide: 'AbuseReportNotificationService', useExisting: AbuseReportNotificationService };
|
||||||
const $AccountMoveService: Provider = { provide: 'AccountMoveService', useExisting: AccountMoveService };
|
const $AccountMoveService: Provider = { provide: 'AccountMoveService', useExisting: AccountMoveService };
|
||||||
const $AccountUpdateService: Provider = { provide: 'AccountUpdateService', useExisting: AccountUpdateService };
|
const $AccountUpdateService: Provider = { provide: 'AccountUpdateService', useExisting: AccountUpdateService };
|
||||||
const $AiService: Provider = { provide: 'AiService', useExisting: AiService };
|
const $AiService: Provider = { provide: 'AiService', useExisting: AiService };
|
||||||
@ -193,10 +204,13 @@ const $UserFollowingService: Provider = { provide: 'UserFollowingService', useEx
|
|||||||
const $UserKeypairService: Provider = { provide: 'UserKeypairService', useExisting: UserKeypairService };
|
const $UserKeypairService: Provider = { provide: 'UserKeypairService', useExisting: UserKeypairService };
|
||||||
const $UserListService: Provider = { provide: 'UserListService', useExisting: UserListService };
|
const $UserListService: Provider = { provide: 'UserListService', useExisting: UserListService };
|
||||||
const $UserMutingService: Provider = { provide: 'UserMutingService', useExisting: UserMutingService };
|
const $UserMutingService: Provider = { provide: 'UserMutingService', useExisting: UserMutingService };
|
||||||
|
const $UserRenoteMutingService: Provider = { provide: 'UserRenoteMutingService', useExisting: UserRenoteMutingService };
|
||||||
|
const $UserSearchService: Provider = { provide: 'UserSearchService', useExisting: UserSearchService };
|
||||||
const $UserSuspendService: Provider = { provide: 'UserSuspendService', useExisting: UserSuspendService };
|
const $UserSuspendService: Provider = { provide: 'UserSuspendService', useExisting: UserSuspendService };
|
||||||
const $UserAuthService: Provider = { provide: 'UserAuthService', useExisting: UserAuthService };
|
const $UserAuthService: Provider = { provide: 'UserAuthService', useExisting: UserAuthService };
|
||||||
const $VideoProcessingService: Provider = { provide: 'VideoProcessingService', useExisting: VideoProcessingService };
|
const $VideoProcessingService: Provider = { provide: 'VideoProcessingService', useExisting: VideoProcessingService };
|
||||||
const $WebhookService: Provider = { provide: 'WebhookService', useExisting: WebhookService };
|
const $UserWebhookService: Provider = { provide: 'UserWebhookService', useExisting: UserWebhookService };
|
||||||
|
const $SystemWebhookService: Provider = { provide: 'SystemWebhookService', useExisting: SystemWebhookService };
|
||||||
const $UtilityService: Provider = { provide: 'UtilityService', useExisting: UtilityService };
|
const $UtilityService: Provider = { provide: 'UtilityService', useExisting: UtilityService };
|
||||||
const $FileInfoService: Provider = { provide: 'FileInfoService', useExisting: FileInfoService };
|
const $FileInfoService: Provider = { provide: 'FileInfoService', useExisting: FileInfoService };
|
||||||
const $SearchService: Provider = { provide: 'SearchService', useExisting: SearchService };
|
const $SearchService: Provider = { provide: 'SearchService', useExisting: SearchService };
|
||||||
@ -225,6 +239,7 @@ const $ChartManagementService: Provider = { provide: 'ChartManagementService', u
|
|||||||
|
|
||||||
const $AbuseUserReportEntityService: Provider = { provide: 'AbuseUserReportEntityService', useExisting: AbuseUserReportEntityService };
|
const $AbuseUserReportEntityService: Provider = { provide: 'AbuseUserReportEntityService', useExisting: AbuseUserReportEntityService };
|
||||||
const $AnnouncementEntityService: Provider = { provide: 'AnnouncementEntityService', useExisting: AnnouncementEntityService };
|
const $AnnouncementEntityService: Provider = { provide: 'AnnouncementEntityService', useExisting: AnnouncementEntityService };
|
||||||
|
const $AbuseReportNotificationRecipientEntityService: Provider = { provide: 'AbuseReportNotificationRecipientEntityService', useExisting: AbuseReportNotificationRecipientEntityService };
|
||||||
const $AntennaEntityService: Provider = { provide: 'AntennaEntityService', useExisting: AntennaEntityService };
|
const $AntennaEntityService: Provider = { provide: 'AntennaEntityService', useExisting: AntennaEntityService };
|
||||||
const $AppEntityService: Provider = { provide: 'AppEntityService', useExisting: AppEntityService };
|
const $AppEntityService: Provider = { provide: 'AppEntityService', useExisting: AppEntityService };
|
||||||
const $AuthSessionEntityService: Provider = { provide: 'AuthSessionEntityService', useExisting: AuthSessionEntityService };
|
const $AuthSessionEntityService: Provider = { provide: 'AuthSessionEntityService', useExisting: AuthSessionEntityService };
|
||||||
@ -258,6 +273,7 @@ const $FlashLikeEntityService: Provider = { provide: 'FlashLikeEntityService', u
|
|||||||
const $RoleEntityService: Provider = { provide: 'RoleEntityService', useExisting: RoleEntityService };
|
const $RoleEntityService: Provider = { provide: 'RoleEntityService', useExisting: RoleEntityService };
|
||||||
const $ReversiGameEntityService: Provider = { provide: 'ReversiGameEntityService', useExisting: ReversiGameEntityService };
|
const $ReversiGameEntityService: Provider = { provide: 'ReversiGameEntityService', useExisting: ReversiGameEntityService };
|
||||||
const $MetaEntityService: Provider = { provide: 'MetaEntityService', useExisting: MetaEntityService };
|
const $MetaEntityService: Provider = { provide: 'MetaEntityService', useExisting: MetaEntityService };
|
||||||
|
const $SystemWebhookEntityService: Provider = { provide: 'SystemWebhookEntityService', useExisting: SystemWebhookEntityService };
|
||||||
|
|
||||||
const $ApAudienceService: Provider = { provide: 'ApAudienceService', useExisting: ApAudienceService };
|
const $ApAudienceService: Provider = { provide: 'ApAudienceService', useExisting: ApAudienceService };
|
||||||
const $ApDbResolverService: Provider = { provide: 'ApDbResolverService', useExisting: ApDbResolverService };
|
const $ApDbResolverService: Provider = { provide: 'ApDbResolverService', useExisting: ApDbResolverService };
|
||||||
@ -285,6 +301,8 @@ const $ApQuestionService: Provider = { provide: 'ApQuestionService', useExisting
|
|||||||
],
|
],
|
||||||
providers: [
|
providers: [
|
||||||
LoggerService,
|
LoggerService,
|
||||||
|
AbuseReportService,
|
||||||
|
AbuseReportNotificationService,
|
||||||
AccountMoveService,
|
AccountMoveService,
|
||||||
AccountUpdateService,
|
AccountUpdateService,
|
||||||
AiService,
|
AiService,
|
||||||
@ -334,10 +352,13 @@ const $ApQuestionService: Provider = { provide: 'ApQuestionService', useExisting
|
|||||||
UserKeypairService,
|
UserKeypairService,
|
||||||
UserListService,
|
UserListService,
|
||||||
UserMutingService,
|
UserMutingService,
|
||||||
|
UserRenoteMutingService,
|
||||||
|
UserSearchService,
|
||||||
UserSuspendService,
|
UserSuspendService,
|
||||||
UserAuthService,
|
UserAuthService,
|
||||||
VideoProcessingService,
|
VideoProcessingService,
|
||||||
WebhookService,
|
UserWebhookService,
|
||||||
|
SystemWebhookService,
|
||||||
UtilityService,
|
UtilityService,
|
||||||
FileInfoService,
|
FileInfoService,
|
||||||
SearchService,
|
SearchService,
|
||||||
@ -366,6 +387,7 @@ const $ApQuestionService: Provider = { provide: 'ApQuestionService', useExisting
|
|||||||
|
|
||||||
AbuseUserReportEntityService,
|
AbuseUserReportEntityService,
|
||||||
AnnouncementEntityService,
|
AnnouncementEntityService,
|
||||||
|
AbuseReportNotificationRecipientEntityService,
|
||||||
AntennaEntityService,
|
AntennaEntityService,
|
||||||
AppEntityService,
|
AppEntityService,
|
||||||
AuthSessionEntityService,
|
AuthSessionEntityService,
|
||||||
@ -399,6 +421,7 @@ const $ApQuestionService: Provider = { provide: 'ApQuestionService', useExisting
|
|||||||
RoleEntityService,
|
RoleEntityService,
|
||||||
ReversiGameEntityService,
|
ReversiGameEntityService,
|
||||||
MetaEntityService,
|
MetaEntityService,
|
||||||
|
SystemWebhookEntityService,
|
||||||
|
|
||||||
ApAudienceService,
|
ApAudienceService,
|
||||||
ApDbResolverService,
|
ApDbResolverService,
|
||||||
@ -422,6 +445,8 @@ const $ApQuestionService: Provider = { provide: 'ApQuestionService', useExisting
|
|||||||
|
|
||||||
//#region 文字列ベースでのinjection用(循環参照対応のため)
|
//#region 文字列ベースでのinjection用(循環参照対応のため)
|
||||||
$LoggerService,
|
$LoggerService,
|
||||||
|
$AbuseReportService,
|
||||||
|
$AbuseReportNotificationService,
|
||||||
$AccountMoveService,
|
$AccountMoveService,
|
||||||
$AccountUpdateService,
|
$AccountUpdateService,
|
||||||
$AiService,
|
$AiService,
|
||||||
@ -471,10 +496,13 @@ const $ApQuestionService: Provider = { provide: 'ApQuestionService', useExisting
|
|||||||
$UserKeypairService,
|
$UserKeypairService,
|
||||||
$UserListService,
|
$UserListService,
|
||||||
$UserMutingService,
|
$UserMutingService,
|
||||||
|
$UserRenoteMutingService,
|
||||||
|
$UserSearchService,
|
||||||
$UserSuspendService,
|
$UserSuspendService,
|
||||||
$UserAuthService,
|
$UserAuthService,
|
||||||
$VideoProcessingService,
|
$VideoProcessingService,
|
||||||
$WebhookService,
|
$UserWebhookService,
|
||||||
|
$SystemWebhookService,
|
||||||
$UtilityService,
|
$UtilityService,
|
||||||
$FileInfoService,
|
$FileInfoService,
|
||||||
$SearchService,
|
$SearchService,
|
||||||
@ -503,6 +531,7 @@ const $ApQuestionService: Provider = { provide: 'ApQuestionService', useExisting
|
|||||||
|
|
||||||
$AbuseUserReportEntityService,
|
$AbuseUserReportEntityService,
|
||||||
$AnnouncementEntityService,
|
$AnnouncementEntityService,
|
||||||
|
$AbuseReportNotificationRecipientEntityService,
|
||||||
$AntennaEntityService,
|
$AntennaEntityService,
|
||||||
$AppEntityService,
|
$AppEntityService,
|
||||||
$AuthSessionEntityService,
|
$AuthSessionEntityService,
|
||||||
@ -536,6 +565,7 @@ const $ApQuestionService: Provider = { provide: 'ApQuestionService', useExisting
|
|||||||
$RoleEntityService,
|
$RoleEntityService,
|
||||||
$ReversiGameEntityService,
|
$ReversiGameEntityService,
|
||||||
$MetaEntityService,
|
$MetaEntityService,
|
||||||
|
$SystemWebhookEntityService,
|
||||||
|
|
||||||
$ApAudienceService,
|
$ApAudienceService,
|
||||||
$ApDbResolverService,
|
$ApDbResolverService,
|
||||||
@ -560,6 +590,8 @@ const $ApQuestionService: Provider = { provide: 'ApQuestionService', useExisting
|
|||||||
exports: [
|
exports: [
|
||||||
QueueModule,
|
QueueModule,
|
||||||
LoggerService,
|
LoggerService,
|
||||||
|
AbuseReportService,
|
||||||
|
AbuseReportNotificationService,
|
||||||
AccountMoveService,
|
AccountMoveService,
|
||||||
AccountUpdateService,
|
AccountUpdateService,
|
||||||
AiService,
|
AiService,
|
||||||
@ -609,10 +641,13 @@ const $ApQuestionService: Provider = { provide: 'ApQuestionService', useExisting
|
|||||||
UserKeypairService,
|
UserKeypairService,
|
||||||
UserListService,
|
UserListService,
|
||||||
UserMutingService,
|
UserMutingService,
|
||||||
|
UserRenoteMutingService,
|
||||||
|
UserSearchService,
|
||||||
UserSuspendService,
|
UserSuspendService,
|
||||||
UserAuthService,
|
UserAuthService,
|
||||||
VideoProcessingService,
|
VideoProcessingService,
|
||||||
WebhookService,
|
UserWebhookService,
|
||||||
|
SystemWebhookService,
|
||||||
UtilityService,
|
UtilityService,
|
||||||
FileInfoService,
|
FileInfoService,
|
||||||
SearchService,
|
SearchService,
|
||||||
@ -640,6 +675,7 @@ const $ApQuestionService: Provider = { provide: 'ApQuestionService', useExisting
|
|||||||
|
|
||||||
AbuseUserReportEntityService,
|
AbuseUserReportEntityService,
|
||||||
AnnouncementEntityService,
|
AnnouncementEntityService,
|
||||||
|
AbuseReportNotificationRecipientEntityService,
|
||||||
AntennaEntityService,
|
AntennaEntityService,
|
||||||
AppEntityService,
|
AppEntityService,
|
||||||
AuthSessionEntityService,
|
AuthSessionEntityService,
|
||||||
@ -673,6 +709,7 @@ const $ApQuestionService: Provider = { provide: 'ApQuestionService', useExisting
|
|||||||
RoleEntityService,
|
RoleEntityService,
|
||||||
ReversiGameEntityService,
|
ReversiGameEntityService,
|
||||||
MetaEntityService,
|
MetaEntityService,
|
||||||
|
SystemWebhookEntityService,
|
||||||
|
|
||||||
ApAudienceService,
|
ApAudienceService,
|
||||||
ApDbResolverService,
|
ApDbResolverService,
|
||||||
@ -696,6 +733,8 @@ const $ApQuestionService: Provider = { provide: 'ApQuestionService', useExisting
|
|||||||
|
|
||||||
//#region 文字列ベースでのinjection用(循環参照対応のため)
|
//#region 文字列ベースでのinjection用(循環参照対応のため)
|
||||||
$LoggerService,
|
$LoggerService,
|
||||||
|
$AbuseReportService,
|
||||||
|
$AbuseReportNotificationService,
|
||||||
$AccountMoveService,
|
$AccountMoveService,
|
||||||
$AccountUpdateService,
|
$AccountUpdateService,
|
||||||
$AiService,
|
$AiService,
|
||||||
@ -745,10 +784,13 @@ const $ApQuestionService: Provider = { provide: 'ApQuestionService', useExisting
|
|||||||
$UserKeypairService,
|
$UserKeypairService,
|
||||||
$UserListService,
|
$UserListService,
|
||||||
$UserMutingService,
|
$UserMutingService,
|
||||||
|
$UserRenoteMutingService,
|
||||||
|
$UserSearchService,
|
||||||
$UserSuspendService,
|
$UserSuspendService,
|
||||||
$UserAuthService,
|
$UserAuthService,
|
||||||
$VideoProcessingService,
|
$VideoProcessingService,
|
||||||
$WebhookService,
|
$UserWebhookService,
|
||||||
|
$SystemWebhookService,
|
||||||
$UtilityService,
|
$UtilityService,
|
||||||
$FileInfoService,
|
$FileInfoService,
|
||||||
$SearchService,
|
$SearchService,
|
||||||
@ -776,6 +818,7 @@ const $ApQuestionService: Provider = { provide: 'ApQuestionService', useExisting
|
|||||||
|
|
||||||
$AbuseUserReportEntityService,
|
$AbuseUserReportEntityService,
|
||||||
$AnnouncementEntityService,
|
$AnnouncementEntityService,
|
||||||
|
$AbuseReportNotificationRecipientEntityService,
|
||||||
$AntennaEntityService,
|
$AntennaEntityService,
|
||||||
$AppEntityService,
|
$AppEntityService,
|
||||||
$AuthSessionEntityService,
|
$AuthSessionEntityService,
|
||||||
@ -809,6 +852,7 @@ const $ApQuestionService: Provider = { provide: 'ApQuestionService', useExisting
|
|||||||
$RoleEntityService,
|
$RoleEntityService,
|
||||||
$ReversiGameEntityService,
|
$ReversiGameEntityService,
|
||||||
$MetaEntityService,
|
$MetaEntityService,
|
||||||
|
$SystemWebhookEntityService,
|
||||||
|
|
||||||
$ApAudienceService,
|
$ApAudienceService,
|
||||||
$ApDbResolverService,
|
$ApDbResolverService,
|
||||||
|
@ -7,7 +7,7 @@ import { randomUUID } from 'node:crypto';
|
|||||||
import { Inject, Injectable } from '@nestjs/common';
|
import { Inject, Injectable } from '@nestjs/common';
|
||||||
import bcrypt from 'bcryptjs';
|
import bcrypt from 'bcryptjs';
|
||||||
import { IsNull, DataSource } from 'typeorm';
|
import { IsNull, DataSource } from 'typeorm';
|
||||||
import { genRsaKeyPair } from '@/misc/gen-key-pair.js';
|
import { genRSAAndEd25519KeyPair } from '@/misc/gen-key-pair.js';
|
||||||
import { MiUser } from '@/models/User.js';
|
import { MiUser } from '@/models/User.js';
|
||||||
import { MiUserProfile } from '@/models/UserProfile.js';
|
import { MiUserProfile } from '@/models/UserProfile.js';
|
||||||
import { IdService } from '@/core/IdService.js';
|
import { IdService } from '@/core/IdService.js';
|
||||||
@ -38,7 +38,7 @@ export class CreateSystemUserService {
|
|||||||
// Generate secret
|
// Generate secret
|
||||||
const secret = generateNativeUserToken();
|
const secret = generateNativeUserToken();
|
||||||
|
|
||||||
const keyPair = await genRsaKeyPair();
|
const keyPair = await genRSAAndEd25519KeyPair();
|
||||||
|
|
||||||
let account!: MiUser;
|
let account!: MiUser;
|
||||||
|
|
||||||
@ -64,9 +64,8 @@ export class CreateSystemUserService {
|
|||||||
}).then(x => transactionalEntityManager.findOneByOrFail(MiUser, x.identifiers[0]));
|
}).then(x => transactionalEntityManager.findOneByOrFail(MiUser, x.identifiers[0]));
|
||||||
|
|
||||||
await transactionalEntityManager.insert(MiUserKeypair, {
|
await transactionalEntityManager.insert(MiUserKeypair, {
|
||||||
publicKey: keyPair.publicKey,
|
|
||||||
privateKey: keyPair.privateKey,
|
|
||||||
userId: account.id,
|
userId: account.id,
|
||||||
|
...keyPair,
|
||||||
});
|
});
|
||||||
|
|
||||||
await transactionalEntityManager.insert(MiUserProfile, {
|
await transactionalEntityManager.insert(MiUserProfile, {
|
||||||
|
@ -16,6 +16,7 @@ import type { UserProfilesRepository } from '@/models/_.js';
|
|||||||
import { LoggerService } from '@/core/LoggerService.js';
|
import { LoggerService } from '@/core/LoggerService.js';
|
||||||
import { bindThis } from '@/decorators.js';
|
import { bindThis } from '@/decorators.js';
|
||||||
import { HttpRequestService } from '@/core/HttpRequestService.js';
|
import { HttpRequestService } from '@/core/HttpRequestService.js';
|
||||||
|
import { QueueService } from '@/core/QueueService.js';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class EmailService {
|
export class EmailService {
|
||||||
@ -32,6 +33,7 @@ export class EmailService {
|
|||||||
private loggerService: LoggerService,
|
private loggerService: LoggerService,
|
||||||
private utilityService: UtilityService,
|
private utilityService: UtilityService,
|
||||||
private httpRequestService: HttpRequestService,
|
private httpRequestService: HttpRequestService,
|
||||||
|
private queueService: QueueService,
|
||||||
) {
|
) {
|
||||||
this.logger = this.loggerService.getLogger('email');
|
this.logger = this.loggerService.getLogger('email');
|
||||||
}
|
}
|
||||||
|
@ -55,9 +55,6 @@ export class FanoutTimelineEndpointService {
|
|||||||
|
|
||||||
@bindThis
|
@bindThis
|
||||||
private async getMiNotes(ps: TimelineOptions): Promise<MiNote[]> {
|
private async getMiNotes(ps: TimelineOptions): Promise<MiNote[]> {
|
||||||
let noteIds: string[];
|
|
||||||
let shouldFallbackToDb = false;
|
|
||||||
|
|
||||||
// 呼び出し元と以下の処理をシンプルにするためにdbFallbackを置き換える
|
// 呼び出し元と以下の処理をシンプルにするためにdbFallbackを置き換える
|
||||||
if (!ps.useDbFallback) ps.dbFallback = () => Promise.resolve([]);
|
if (!ps.useDbFallback) ps.dbFallback = () => Promise.resolve([]);
|
||||||
|
|
||||||
@ -67,12 +64,11 @@ export class FanoutTimelineEndpointService {
|
|||||||
const redisResult = await this.fanoutTimelineService.getMulti(ps.redisTimelines, ps.untilId, ps.sinceId);
|
const redisResult = await this.fanoutTimelineService.getMulti(ps.redisTimelines, ps.untilId, ps.sinceId);
|
||||||
|
|
||||||
// TODO: いい感じにgetMulti内でソート済だからuniqするときにredisResultが全てソート済なのを利用して再ソートを避けたい
|
// TODO: いい感じにgetMulti内でソート済だからuniqするときにredisResultが全てソート済なのを利用して再ソートを避けたい
|
||||||
const redisResultIds = Array.from(new Set(redisResult.flat(1)));
|
const redisResultIds = Array.from(new Set(redisResult.flat(1))).sort(idCompare);
|
||||||
|
|
||||||
redisResultIds.sort(idCompare);
|
let noteIds = redisResultIds.slice(0, ps.limit);
|
||||||
noteIds = redisResultIds.slice(0, ps.limit);
|
const oldestNoteId = ascending ? redisResultIds[0] : redisResultIds[redisResultIds.length - 1];
|
||||||
|
const shouldFallbackToDb = noteIds.length === 0 || ps.sinceId != null && ps.sinceId < oldestNoteId;
|
||||||
shouldFallbackToDb = shouldFallbackToDb || (noteIds.length === 0);
|
|
||||||
|
|
||||||
if (!shouldFallbackToDb) {
|
if (!shouldFallbackToDb) {
|
||||||
let filter = ps.noteFilter ?? (_note => true);
|
let filter = ps.noteFilter ?? (_note => true);
|
||||||
|
@ -40,6 +40,7 @@ export class FederatedInstanceService implements OnApplicationShutdown {
|
|||||||
firstRetrievedAt: new Date(parsed.firstRetrievedAt),
|
firstRetrievedAt: new Date(parsed.firstRetrievedAt),
|
||||||
latestRequestReceivedAt: parsed.latestRequestReceivedAt ? new Date(parsed.latestRequestReceivedAt) : null,
|
latestRequestReceivedAt: parsed.latestRequestReceivedAt ? new Date(parsed.latestRequestReceivedAt) : null,
|
||||||
infoUpdatedAt: parsed.infoUpdatedAt ? new Date(parsed.infoUpdatedAt) : null,
|
infoUpdatedAt: parsed.infoUpdatedAt ? new Date(parsed.infoUpdatedAt) : null,
|
||||||
|
notRespondingSince: parsed.notRespondingSince ? new Date(parsed.notRespondingSince) : null,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
@ -15,6 +15,7 @@ import { LoggerService } from '@/core/LoggerService.js';
|
|||||||
import { HttpRequestService } from '@/core/HttpRequestService.js';
|
import { HttpRequestService } from '@/core/HttpRequestService.js';
|
||||||
import { bindThis } from '@/decorators.js';
|
import { bindThis } from '@/decorators.js';
|
||||||
import { FederatedInstanceService } from '@/core/FederatedInstanceService.js';
|
import { FederatedInstanceService } from '@/core/FederatedInstanceService.js';
|
||||||
|
import { REMOTE_SERVER_CACHE_TTL } from '@/const.js';
|
||||||
import type { DOMWindow } from 'jsdom';
|
import type { DOMWindow } from 'jsdom';
|
||||||
|
|
||||||
type NodeInfo = {
|
type NodeInfo = {
|
||||||
@ -24,6 +25,7 @@ type NodeInfo = {
|
|||||||
version?: unknown;
|
version?: unknown;
|
||||||
};
|
};
|
||||||
metadata?: {
|
metadata?: {
|
||||||
|
httpMessageSignaturesImplementationLevel?: unknown,
|
||||||
name?: unknown;
|
name?: unknown;
|
||||||
nodeName?: unknown;
|
nodeName?: unknown;
|
||||||
nodeDescription?: unknown;
|
nodeDescription?: unknown;
|
||||||
@ -39,6 +41,7 @@ type NodeInfo = {
|
|||||||
@Injectable()
|
@Injectable()
|
||||||
export class FetchInstanceMetadataService {
|
export class FetchInstanceMetadataService {
|
||||||
private logger: Logger;
|
private logger: Logger;
|
||||||
|
private httpColon = 'https://';
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private httpRequestService: HttpRequestService,
|
private httpRequestService: HttpRequestService,
|
||||||
@ -48,6 +51,7 @@ export class FetchInstanceMetadataService {
|
|||||||
private redisClient: Redis.Redis,
|
private redisClient: Redis.Redis,
|
||||||
) {
|
) {
|
||||||
this.logger = this.loggerService.getLogger('metadata', 'cyan');
|
this.logger = this.loggerService.getLogger('metadata', 'cyan');
|
||||||
|
this.httpColon = process.env.MISSKEY_USE_HTTP?.toLowerCase() === 'true' ? 'http://' : 'https://';
|
||||||
}
|
}
|
||||||
|
|
||||||
@bindThis
|
@bindThis
|
||||||
@ -59,7 +63,7 @@ export class FetchInstanceMetadataService {
|
|||||||
return await this.redisClient.set(
|
return await this.redisClient.set(
|
||||||
`fetchInstanceMetadata:mutex:v2:${host}`, '1',
|
`fetchInstanceMetadata:mutex:v2:${host}`, '1',
|
||||||
'EX', 30, // 30秒したら自動でロック解除 https://github.com/misskey-dev/misskey/issues/13506#issuecomment-1975375395
|
'EX', 30, // 30秒したら自動でロック解除 https://github.com/misskey-dev/misskey/issues/13506#issuecomment-1975375395
|
||||||
'GET' // 古い値を返す(なかったらnull)
|
'GET', // 古い値を返す(なかったらnull)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -73,23 +77,24 @@ export class FetchInstanceMetadataService {
|
|||||||
public async fetchInstanceMetadata(instance: MiInstance, force = false): Promise<void> {
|
public async fetchInstanceMetadata(instance: MiInstance, force = false): Promise<void> {
|
||||||
const host = instance.host;
|
const host = instance.host;
|
||||||
|
|
||||||
|
if (!force) {
|
||||||
|
// キャッシュ有効チェックはロック取得前に行う
|
||||||
|
const _instance = await this.federatedInstanceService.fetch(host);
|
||||||
|
const now = Date.now();
|
||||||
|
if (_instance && _instance.infoUpdatedAt != null && (now - _instance.infoUpdatedAt.getTime() < REMOTE_SERVER_CACHE_TTL)) {
|
||||||
|
this.logger.debug(`Skip because updated recently ${_instance.infoUpdatedAt.toJSON()}`);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// finallyでunlockされてしまうのでtry内でロックチェックをしない
|
// finallyでunlockされてしまうのでtry内でロックチェックをしない
|
||||||
// (returnであってもfinallyは実行される)
|
// (returnであってもfinallyは実行される)
|
||||||
if (!force && await this.tryLock(host) === '1') {
|
if (await this.tryLock(host) === '1') {
|
||||||
// 1が返ってきていたらロックされているという意味なので、何もしない
|
// 1が返ってきていたら他にロックされているという意味なので、何もしない
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (!force) {
|
|
||||||
const _instance = await this.federatedInstanceService.fetch(host);
|
|
||||||
const now = Date.now();
|
|
||||||
if (_instance && _instance.infoUpdatedAt && (now - _instance.infoUpdatedAt.getTime() < 1000 * 60 * 60 * 24)) {
|
|
||||||
// unlock at the finally caluse
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
this.logger.info(`Fetching metadata of ${instance.host} ...`);
|
this.logger.info(`Fetching metadata of ${instance.host} ...`);
|
||||||
|
|
||||||
const [info, dom, manifest] = await Promise.all([
|
const [info, dom, manifest] = await Promise.all([
|
||||||
@ -118,6 +123,14 @@ export class FetchInstanceMetadataService {
|
|||||||
updates.openRegistrations = info.openRegistrations;
|
updates.openRegistrations = info.openRegistrations;
|
||||||
updates.maintainerName = info.metadata ? info.metadata.maintainer ? (info.metadata.maintainer.name ?? null) : null : null;
|
updates.maintainerName = info.metadata ? info.metadata.maintainer ? (info.metadata.maintainer.name ?? null) : null : null;
|
||||||
updates.maintainerEmail = info.metadata ? info.metadata.maintainer ? (info.metadata.maintainer.email ?? null) : null : null;
|
updates.maintainerEmail = info.metadata ? info.metadata.maintainer ? (info.metadata.maintainer.email ?? null) : null : null;
|
||||||
|
if (info.metadata && info.metadata.httpMessageSignaturesImplementationLevel && (
|
||||||
|
info.metadata.httpMessageSignaturesImplementationLevel === '01' ||
|
||||||
|
info.metadata.httpMessageSignaturesImplementationLevel === '11'
|
||||||
|
)) {
|
||||||
|
updates.httpMessageSignaturesImplementationLevel = info.metadata.httpMessageSignaturesImplementationLevel;
|
||||||
|
} else {
|
||||||
|
updates.httpMessageSignaturesImplementationLevel = '00';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (name) updates.name = name;
|
if (name) updates.name = name;
|
||||||
@ -129,6 +142,12 @@ export class FetchInstanceMetadataService {
|
|||||||
await this.federatedInstanceService.update(instance.id, updates);
|
await this.federatedInstanceService.update(instance.id, updates);
|
||||||
|
|
||||||
this.logger.succ(`Successfuly updated metadata of ${instance.host}`);
|
this.logger.succ(`Successfuly updated metadata of ${instance.host}`);
|
||||||
|
this.logger.debug('Updated metadata:', {
|
||||||
|
info: !!info,
|
||||||
|
dom: !!dom,
|
||||||
|
manifest: !!manifest,
|
||||||
|
updates,
|
||||||
|
});
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
this.logger.error(`Failed to update metadata of ${instance.host}: ${e}`);
|
this.logger.error(`Failed to update metadata of ${instance.host}: ${e}`);
|
||||||
} finally {
|
} finally {
|
||||||
@ -141,7 +160,7 @@ export class FetchInstanceMetadataService {
|
|||||||
this.logger.info(`Fetching nodeinfo of ${instance.host} ...`);
|
this.logger.info(`Fetching nodeinfo of ${instance.host} ...`);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const wellknown = await this.httpRequestService.getJson('https://' + instance.host + '/.well-known/nodeinfo')
|
const wellknown = await this.httpRequestService.getJson(this.httpColon + instance.host + '/.well-known/nodeinfo')
|
||||||
.catch(err => {
|
.catch(err => {
|
||||||
if (err.statusCode === 404) {
|
if (err.statusCode === 404) {
|
||||||
throw new Error('No nodeinfo provided');
|
throw new Error('No nodeinfo provided');
|
||||||
@ -184,7 +203,7 @@ export class FetchInstanceMetadataService {
|
|||||||
private async fetchDom(instance: MiInstance): Promise<DOMWindow['document']> {
|
private async fetchDom(instance: MiInstance): Promise<DOMWindow['document']> {
|
||||||
this.logger.info(`Fetching HTML of ${instance.host} ...`);
|
this.logger.info(`Fetching HTML of ${instance.host} ...`);
|
||||||
|
|
||||||
const url = 'https://' + instance.host;
|
const url = this.httpColon + instance.host;
|
||||||
|
|
||||||
const html = await this.httpRequestService.getHtml(url);
|
const html = await this.httpRequestService.getHtml(url);
|
||||||
|
|
||||||
@ -196,7 +215,7 @@ export class FetchInstanceMetadataService {
|
|||||||
|
|
||||||
@bindThis
|
@bindThis
|
||||||
private async fetchManifest(instance: MiInstance): Promise<Record<string, unknown> | null> {
|
private async fetchManifest(instance: MiInstance): Promise<Record<string, unknown> | null> {
|
||||||
const url = 'https://' + instance.host;
|
const url = this.httpColon + instance.host;
|
||||||
|
|
||||||
const manifestUrl = url + '/manifest.json';
|
const manifestUrl = url + '/manifest.json';
|
||||||
|
|
||||||
@ -207,7 +226,7 @@ export class FetchInstanceMetadataService {
|
|||||||
|
|
||||||
@bindThis
|
@bindThis
|
||||||
private async fetchFaviconUrl(instance: MiInstance, doc: DOMWindow['document'] | null): Promise<string | null> {
|
private async fetchFaviconUrl(instance: MiInstance, doc: DOMWindow['document'] | null): Promise<string | null> {
|
||||||
const url = 'https://' + instance.host;
|
const url = this.httpColon + instance.host;
|
||||||
|
|
||||||
if (doc) {
|
if (doc) {
|
||||||
// https://github.com/misskey-dev/misskey/pull/8220#issuecomment-1025104043
|
// https://github.com/misskey-dev/misskey/pull/8220#issuecomment-1025104043
|
||||||
@ -234,12 +253,12 @@ export class FetchInstanceMetadataService {
|
|||||||
@bindThis
|
@bindThis
|
||||||
private async fetchIconUrl(instance: MiInstance, doc: DOMWindow['document'] | null, manifest: Record<string, any> | null): Promise<string | null> {
|
private async fetchIconUrl(instance: MiInstance, doc: DOMWindow['document'] | null, manifest: Record<string, any> | null): Promise<string | null> {
|
||||||
if (manifest && manifest.icons && manifest.icons.length > 0 && manifest.icons[0].src) {
|
if (manifest && manifest.icons && manifest.icons.length > 0 && manifest.icons[0].src) {
|
||||||
const url = 'https://' + instance.host;
|
const url = this.httpColon + instance.host;
|
||||||
return (new URL(manifest.icons[0].src, url)).href;
|
return (new URL(manifest.icons[0].src, url)).href;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (doc) {
|
if (doc) {
|
||||||
const url = 'https://' + instance.host;
|
const url = this.httpColon + instance.host;
|
||||||
|
|
||||||
// https://github.com/misskey-dev/misskey/pull/8220#issuecomment-1025104043
|
// https://github.com/misskey-dev/misskey/pull/8220#issuecomment-1025104043
|
||||||
const links = Array.from(doc.getElementsByTagName('link')).reverse();
|
const links = Array.from(doc.getElementsByTagName('link')).reverse();
|
||||||
|
@ -18,6 +18,7 @@ import type { MiAbuseUserReport } from '@/models/AbuseUserReport.js';
|
|||||||
import type { MiSignin } from '@/models/Signin.js';
|
import type { MiSignin } from '@/models/Signin.js';
|
||||||
import type { MiPage } from '@/models/Page.js';
|
import type { MiPage } from '@/models/Page.js';
|
||||||
import type { MiWebhook } from '@/models/Webhook.js';
|
import type { MiWebhook } from '@/models/Webhook.js';
|
||||||
|
import type { MiSystemWebhook } from '@/models/SystemWebhook.js';
|
||||||
import type { MiMeta } from '@/models/Meta.js';
|
import type { MiMeta } from '@/models/Meta.js';
|
||||||
import { MiAvatarDecoration, MiReversiGame, MiRole, MiRoleAssignment } from '@/models/_.js';
|
import { MiAvatarDecoration, MiReversiGame, MiRole, MiRoleAssignment } from '@/models/_.js';
|
||||||
import type { Packed } from '@/misc/json-schema.js';
|
import type { Packed } from '@/misc/json-schema.js';
|
||||||
@ -212,6 +213,10 @@ type SerializedAll<T> = {
|
|||||||
[K in keyof T]: Serialized<T[K]>;
|
[K in keyof T]: Serialized<T[K]>;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
type UndefinedAsNullAll<T> = {
|
||||||
|
[K in keyof T]: T[K] extends undefined ? null : T[K];
|
||||||
|
}
|
||||||
|
|
||||||
export interface InternalEventTypes {
|
export interface InternalEventTypes {
|
||||||
userChangeSuspendedState: { id: MiUser['id']; isSuspended: MiUser['isSuspended']; };
|
userChangeSuspendedState: { id: MiUser['id']; isSuspended: MiUser['isSuspended']; };
|
||||||
userChangeDeletedState: { id: MiUser['id']; isDeleted: MiUser['isDeleted']; };
|
userChangeDeletedState: { id: MiUser['id']; isDeleted: MiUser['isDeleted']; };
|
||||||
@ -231,6 +236,9 @@ export interface InternalEventTypes {
|
|||||||
webhookCreated: MiWebhook;
|
webhookCreated: MiWebhook;
|
||||||
webhookDeleted: MiWebhook;
|
webhookDeleted: MiWebhook;
|
||||||
webhookUpdated: MiWebhook;
|
webhookUpdated: MiWebhook;
|
||||||
|
systemWebhookCreated: MiSystemWebhook;
|
||||||
|
systemWebhookDeleted: MiSystemWebhook;
|
||||||
|
systemWebhookUpdated: MiSystemWebhook;
|
||||||
antennaCreated: MiAntenna;
|
antennaCreated: MiAntenna;
|
||||||
antennaDeleted: MiAntenna;
|
antennaDeleted: MiAntenna;
|
||||||
antennaUpdated: MiAntenna;
|
antennaUpdated: MiAntenna;
|
||||||
@ -245,45 +253,48 @@ export interface InternalEventTypes {
|
|||||||
unmute: { muterId: MiUser['id']; muteeId: MiUser['id']; };
|
unmute: { muterId: MiUser['id']; muteeId: MiUser['id']; };
|
||||||
userListMemberAdded: { userListId: MiUserList['id']; memberId: MiUser['id']; };
|
userListMemberAdded: { userListId: MiUserList['id']; memberId: MiUser['id']; };
|
||||||
userListMemberRemoved: { userListId: MiUserList['id']; memberId: MiUser['id']; };
|
userListMemberRemoved: { userListId: MiUserList['id']; memberId: MiUser['id']; };
|
||||||
|
userKeypairUpdated: { userId: MiUser['id']; };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type EventTypesToEventPayload<T> = EventUnionFromDictionary<UndefinedAsNullAll<SerializedAll<T>>>;
|
||||||
|
|
||||||
// name/messages(spec) pairs dictionary
|
// name/messages(spec) pairs dictionary
|
||||||
export type GlobalEvents = {
|
export type GlobalEvents = {
|
||||||
internal: {
|
internal: {
|
||||||
name: 'internal';
|
name: 'internal';
|
||||||
payload: EventUnionFromDictionary<SerializedAll<InternalEventTypes>>;
|
payload: EventTypesToEventPayload<InternalEventTypes>;
|
||||||
};
|
};
|
||||||
broadcast: {
|
broadcast: {
|
||||||
name: 'broadcast';
|
name: 'broadcast';
|
||||||
payload: EventUnionFromDictionary<SerializedAll<BroadcastTypes>>;
|
payload: EventTypesToEventPayload<BroadcastTypes>;
|
||||||
};
|
};
|
||||||
main: {
|
main: {
|
||||||
name: `mainStream:${MiUser['id']}`;
|
name: `mainStream:${MiUser['id']}`;
|
||||||
payload: EventUnionFromDictionary<SerializedAll<MainEventTypes>>;
|
payload: EventTypesToEventPayload<MainEventTypes>;
|
||||||
};
|
};
|
||||||
drive: {
|
drive: {
|
||||||
name: `driveStream:${MiUser['id']}`;
|
name: `driveStream:${MiUser['id']}`;
|
||||||
payload: EventUnionFromDictionary<SerializedAll<DriveEventTypes>>;
|
payload: EventTypesToEventPayload<DriveEventTypes>;
|
||||||
};
|
};
|
||||||
note: {
|
note: {
|
||||||
name: `noteStream:${MiNote['id']}`;
|
name: `noteStream:${MiNote['id']}`;
|
||||||
payload: EventUnionFromDictionary<SerializedAll<NoteStreamEventTypes>>;
|
payload: EventTypesToEventPayload<NoteStreamEventTypes>;
|
||||||
};
|
};
|
||||||
userList: {
|
userList: {
|
||||||
name: `userListStream:${MiUserList['id']}`;
|
name: `userListStream:${MiUserList['id']}`;
|
||||||
payload: EventUnionFromDictionary<SerializedAll<UserListEventTypes>>;
|
payload: EventTypesToEventPayload<UserListEventTypes>;
|
||||||
};
|
};
|
||||||
roleTimeline: {
|
roleTimeline: {
|
||||||
name: `roleTimelineStream:${MiRole['id']}`;
|
name: `roleTimelineStream:${MiRole['id']}`;
|
||||||
payload: EventUnionFromDictionary<SerializedAll<RoleTimelineEventTypes>>;
|
payload: EventTypesToEventPayload<RoleTimelineEventTypes>;
|
||||||
};
|
};
|
||||||
antenna: {
|
antenna: {
|
||||||
name: `antennaStream:${MiAntenna['id']}`;
|
name: `antennaStream:${MiAntenna['id']}`;
|
||||||
payload: EventUnionFromDictionary<SerializedAll<AntennaEventTypes>>;
|
payload: EventTypesToEventPayload<AntennaEventTypes>;
|
||||||
};
|
};
|
||||||
admin: {
|
admin: {
|
||||||
name: `adminStream:${MiUser['id']}`;
|
name: `adminStream:${MiUser['id']}`;
|
||||||
payload: EventUnionFromDictionary<SerializedAll<AdminEventTypes>>;
|
payload: EventTypesToEventPayload<AdminEventTypes>;
|
||||||
};
|
};
|
||||||
notes: {
|
notes: {
|
||||||
name: 'notesStream';
|
name: 'notesStream';
|
||||||
@ -291,11 +302,11 @@ export type GlobalEvents = {
|
|||||||
};
|
};
|
||||||
reversi: {
|
reversi: {
|
||||||
name: `reversiStream:${MiUser['id']}`;
|
name: `reversiStream:${MiUser['id']}`;
|
||||||
payload: EventUnionFromDictionary<SerializedAll<ReversiEventTypes>>;
|
payload: EventTypesToEventPayload<ReversiEventTypes>;
|
||||||
};
|
};
|
||||||
reversiGame: {
|
reversiGame: {
|
||||||
name: `reversiGameStream:${MiReversiGame['id']}`;
|
name: `reversiGameStream:${MiReversiGame['id']}`;
|
||||||
payload: EventUnionFromDictionary<SerializedAll<ReversiGameEventTypes>>;
|
payload: EventTypesToEventPayload<ReversiGameEventTypes>;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -70,7 +70,7 @@ export class HttpRequestService {
|
|||||||
localAddress: config.outgoingAddress,
|
localAddress: config.outgoingAddress,
|
||||||
});
|
});
|
||||||
|
|
||||||
const maxSockets = Math.max(256, config.deliverJobConcurrency ?? 128);
|
const maxSockets = Math.max(256, config.deliverJobConcurrency ?? 16);
|
||||||
|
|
||||||
this.httpAgent = config.proxy
|
this.httpAgent = config.proxy
|
||||||
? new HttpProxyAgent({
|
? new HttpProxyAgent({
|
||||||
|
@ -15,7 +15,7 @@ export class LoggerService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@bindThis
|
@bindThis
|
||||||
public getLogger(domain: string, color?: KEYWORD | undefined, store?: boolean) {
|
public getLogger(domain: string, color?: KEYWORD | undefined) {
|
||||||
return new Logger(domain, color, store);
|
return new Logger(domain, color);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,10 +13,12 @@ import { intersperse } from '@/misc/prelude/array.js';
|
|||||||
import { normalizeForSearch } from '@/misc/normalize-for-search.js';
|
import { normalizeForSearch } from '@/misc/normalize-for-search.js';
|
||||||
import type { IMentionedRemoteUsers } from '@/models/Note.js';
|
import type { IMentionedRemoteUsers } from '@/models/Note.js';
|
||||||
import { bindThis } from '@/decorators.js';
|
import { bindThis } from '@/decorators.js';
|
||||||
import * as TreeAdapter from '../../node_modules/parse5/dist/tree-adapters/default.js';
|
import type { DefaultTreeAdapterMap } from 'parse5';
|
||||||
import type * as mfm from 'mfm-js';
|
import type * as mfm from 'mfm-js';
|
||||||
|
|
||||||
const treeAdapter = TreeAdapter.defaultTreeAdapter;
|
const treeAdapter = parse5.defaultTreeAdapter;
|
||||||
|
type Node = DefaultTreeAdapterMap['node'];
|
||||||
|
type ChildNode = DefaultTreeAdapterMap['childNode'];
|
||||||
|
|
||||||
const urlRegex = /^https?:\/\/[\w\/:%#@$&?!()\[\]~.,=+\-]+/;
|
const urlRegex = /^https?:\/\/[\w\/:%#@$&?!()\[\]~.,=+\-]+/;
|
||||||
const urlRegexFull = /^https?:\/\/[\w\/:%#@$&?!()\[\]~.,=+\-]+$/;
|
const urlRegexFull = /^https?:\/\/[\w\/:%#@$&?!()\[\]~.,=+\-]+$/;
|
||||||
@ -46,7 +48,7 @@ export class MfmService {
|
|||||||
|
|
||||||
return text.trim();
|
return text.trim();
|
||||||
|
|
||||||
function getText(node: TreeAdapter.Node): string {
|
function getText(node: Node): string {
|
||||||
if (treeAdapter.isTextNode(node)) return node.value;
|
if (treeAdapter.isTextNode(node)) return node.value;
|
||||||
if (!treeAdapter.isElementNode(node)) return '';
|
if (!treeAdapter.isElementNode(node)) return '';
|
||||||
if (node.nodeName === 'br') return '\n';
|
if (node.nodeName === 'br') return '\n';
|
||||||
@ -58,7 +60,7 @@ export class MfmService {
|
|||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
function appendChildren(childNodes: TreeAdapter.ChildNode[]): void {
|
function appendChildren(childNodes: ChildNode[]): void {
|
||||||
if (childNodes) {
|
if (childNodes) {
|
||||||
for (const n of childNodes) {
|
for (const n of childNodes) {
|
||||||
analyze(n);
|
analyze(n);
|
||||||
@ -66,14 +68,16 @@ export class MfmService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function analyze(node: TreeAdapter.Node) {
|
function analyze(node: Node) {
|
||||||
if (treeAdapter.isTextNode(node)) {
|
if (treeAdapter.isTextNode(node)) {
|
||||||
text += node.value;
|
text += node.value;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Skip comment or document type node
|
// Skip comment or document type node
|
||||||
if (!treeAdapter.isElementNode(node)) return;
|
if (!treeAdapter.isElementNode(node)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
switch (node.nodeName) {
|
switch (node.nodeName) {
|
||||||
case 'br': {
|
case 'br': {
|
||||||
@ -81,8 +85,7 @@ export class MfmService {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case 'a':
|
case 'a': {
|
||||||
{
|
|
||||||
const txt = getText(node);
|
const txt = getText(node);
|
||||||
const rel = node.attrs.find(x => x.name === 'rel');
|
const rel = node.attrs.find(x => x.name === 'rel');
|
||||||
const href = node.attrs.find(x => x.name === 'href');
|
const href = node.attrs.find(x => x.name === 'href');
|
||||||
@ -130,8 +133,7 @@ export class MfmService {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case 'h1':
|
case 'h1': {
|
||||||
{
|
|
||||||
text += '【';
|
text += '【';
|
||||||
appendChildren(node.childNodes);
|
appendChildren(node.childNodes);
|
||||||
text += '】\n';
|
text += '】\n';
|
||||||
@ -139,16 +141,14 @@ export class MfmService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
case 'b':
|
case 'b':
|
||||||
case 'strong':
|
case 'strong': {
|
||||||
{
|
|
||||||
text += '**';
|
text += '**';
|
||||||
appendChildren(node.childNodes);
|
appendChildren(node.childNodes);
|
||||||
text += '**';
|
text += '**';
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case 'small':
|
case 'small': {
|
||||||
{
|
|
||||||
text += '<small>';
|
text += '<small>';
|
||||||
appendChildren(node.childNodes);
|
appendChildren(node.childNodes);
|
||||||
text += '</small>';
|
text += '</small>';
|
||||||
@ -156,8 +156,7 @@ export class MfmService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
case 's':
|
case 's':
|
||||||
case 'del':
|
case 'del': {
|
||||||
{
|
|
||||||
text += '~~';
|
text += '~~';
|
||||||
appendChildren(node.childNodes);
|
appendChildren(node.childNodes);
|
||||||
text += '~~';
|
text += '~~';
|
||||||
@ -165,8 +164,7 @@ export class MfmService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
case 'i':
|
case 'i':
|
||||||
case 'em':
|
case 'em': {
|
||||||
{
|
|
||||||
text += '<i>';
|
text += '<i>';
|
||||||
appendChildren(node.childNodes);
|
appendChildren(node.childNodes);
|
||||||
text += '</i>';
|
text += '</i>';
|
||||||
@ -207,8 +205,7 @@ export class MfmService {
|
|||||||
case 'h3':
|
case 'h3':
|
||||||
case 'h4':
|
case 'h4':
|
||||||
case 'h5':
|
case 'h5':
|
||||||
case 'h6':
|
case 'h6': {
|
||||||
{
|
|
||||||
text += '\n\n';
|
text += '\n\n';
|
||||||
appendChildren(node.childNodes);
|
appendChildren(node.childNodes);
|
||||||
break;
|
break;
|
||||||
@ -221,8 +218,7 @@ export class MfmService {
|
|||||||
case 'article':
|
case 'article':
|
||||||
case 'li':
|
case 'li':
|
||||||
case 'dt':
|
case 'dt':
|
||||||
case 'dd':
|
case 'dd': {
|
||||||
{
|
|
||||||
text += '\n';
|
text += '\n';
|
||||||
appendChildren(node.childNodes);
|
appendChildren(node.childNodes);
|
||||||
break;
|
break;
|
||||||
|
@ -38,7 +38,7 @@ import InstanceChart from '@/core/chart/charts/instance.js';
|
|||||||
import ActiveUsersChart from '@/core/chart/charts/active-users.js';
|
import ActiveUsersChart from '@/core/chart/charts/active-users.js';
|
||||||
import { GlobalEventService } from '@/core/GlobalEventService.js';
|
import { GlobalEventService } from '@/core/GlobalEventService.js';
|
||||||
import { NotificationService } from '@/core/NotificationService.js';
|
import { NotificationService } from '@/core/NotificationService.js';
|
||||||
import { WebhookService } from '@/core/WebhookService.js';
|
import { UserWebhookService } from '@/core/UserWebhookService.js';
|
||||||
import { HashtagService } from '@/core/HashtagService.js';
|
import { HashtagService } from '@/core/HashtagService.js';
|
||||||
import { AntennaService } from '@/core/AntennaService.js';
|
import { AntennaService } from '@/core/AntennaService.js';
|
||||||
import { QueueService } from '@/core/QueueService.js';
|
import { QueueService } from '@/core/QueueService.js';
|
||||||
@ -59,7 +59,6 @@ import { UtilityService } from '@/core/UtilityService.js';
|
|||||||
import { UserBlockingService } from '@/core/UserBlockingService.js';
|
import { UserBlockingService } from '@/core/UserBlockingService.js';
|
||||||
import { isReply } from '@/misc/is-reply.js';
|
import { isReply } from '@/misc/is-reply.js';
|
||||||
import { trackPromise } from '@/misc/promise-tracker.js';
|
import { trackPromise } from '@/misc/promise-tracker.js';
|
||||||
import { isNotNull } from '@/misc/is-not-null.js';
|
|
||||||
import { IdentifiableError } from '@/misc/identifiable-error.js';
|
import { IdentifiableError } from '@/misc/identifiable-error.js';
|
||||||
|
|
||||||
type NotificationType = 'reply' | 'renote' | 'quote' | 'mention';
|
type NotificationType = 'reply' | 'renote' | 'quote' | 'mention';
|
||||||
@ -205,7 +204,7 @@ export class NoteCreateService implements OnApplicationShutdown {
|
|||||||
private federatedInstanceService: FederatedInstanceService,
|
private federatedInstanceService: FederatedInstanceService,
|
||||||
private hashtagService: HashtagService,
|
private hashtagService: HashtagService,
|
||||||
private antennaService: AntennaService,
|
private antennaService: AntennaService,
|
||||||
private webhookService: WebhookService,
|
private webhookService: UserWebhookService,
|
||||||
private featuredService: FeaturedService,
|
private featuredService: FeaturedService,
|
||||||
private remoteUserResolveService: RemoteUserResolveService,
|
private remoteUserResolveService: RemoteUserResolveService,
|
||||||
private apDeliverManagerService: ApDeliverManagerService,
|
private apDeliverManagerService: ApDeliverManagerService,
|
||||||
@ -606,7 +605,7 @@ export class NoteCreateService implements OnApplicationShutdown {
|
|||||||
this.webhookService.getActiveWebhooks().then(webhooks => {
|
this.webhookService.getActiveWebhooks().then(webhooks => {
|
||||||
webhooks = webhooks.filter(x => x.userId === user.id && x.on.includes('note'));
|
webhooks = webhooks.filter(x => x.userId === user.id && x.on.includes('note'));
|
||||||
for (const webhook of webhooks) {
|
for (const webhook of webhooks) {
|
||||||
this.queueService.webhookDeliver(webhook, 'note', {
|
this.queueService.userWebhookDeliver(webhook, 'note', {
|
||||||
note: noteObj,
|
note: noteObj,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -633,7 +632,7 @@ export class NoteCreateService implements OnApplicationShutdown {
|
|||||||
|
|
||||||
const webhooks = (await this.webhookService.getActiveWebhooks()).filter(x => x.userId === data.reply!.userId && x.on.includes('reply'));
|
const webhooks = (await this.webhookService.getActiveWebhooks()).filter(x => x.userId === data.reply!.userId && x.on.includes('reply'));
|
||||||
for (const webhook of webhooks) {
|
for (const webhook of webhooks) {
|
||||||
this.queueService.webhookDeliver(webhook, 'reply', {
|
this.queueService.userWebhookDeliver(webhook, 'reply', {
|
||||||
note: noteObj,
|
note: noteObj,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -656,7 +655,7 @@ export class NoteCreateService implements OnApplicationShutdown {
|
|||||||
|
|
||||||
const webhooks = (await this.webhookService.getActiveWebhooks()).filter(x => x.userId === data.renote!.userId && x.on.includes('renote'));
|
const webhooks = (await this.webhookService.getActiveWebhooks()).filter(x => x.userId === data.renote!.userId && x.on.includes('renote'));
|
||||||
for (const webhook of webhooks) {
|
for (const webhook of webhooks) {
|
||||||
this.queueService.webhookDeliver(webhook, 'renote', {
|
this.queueService.userWebhookDeliver(webhook, 'renote', {
|
||||||
note: noteObj,
|
note: noteObj,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -788,7 +787,7 @@ export class NoteCreateService implements OnApplicationShutdown {
|
|||||||
|
|
||||||
const webhooks = (await this.webhookService.getActiveWebhooks()).filter(x => x.userId === u.id && x.on.includes('mention'));
|
const webhooks = (await this.webhookService.getActiveWebhooks()).filter(x => x.userId === u.id && x.on.includes('mention'));
|
||||||
for (const webhook of webhooks) {
|
for (const webhook of webhooks) {
|
||||||
this.queueService.webhookDeliver(webhook, 'mention', {
|
this.queueService.userWebhookDeliver(webhook, 'mention', {
|
||||||
note: detailPackedNote,
|
note: detailPackedNote,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -839,7 +838,7 @@ export class NoteCreateService implements OnApplicationShutdown {
|
|||||||
const mentions = extractMentions(tokens);
|
const mentions = extractMentions(tokens);
|
||||||
let mentionedUsers = (await Promise.all(mentions.map(m =>
|
let mentionedUsers = (await Promise.all(mentions.map(m =>
|
||||||
this.remoteUserResolveService.resolveUser(m.username, m.host ?? user.host).catch(() => null),
|
this.remoteUserResolveService.resolveUser(m.username, m.host ?? user.host).catch(() => null),
|
||||||
))).filter(isNotNull);
|
))).filter(x => x != null);
|
||||||
|
|
||||||
// Drop duplicate users
|
// Drop duplicate users
|
||||||
mentionedUsers = mentionedUsers.filter((u, i, self) =>
|
mentionedUsers = mentionedUsers.filter((u, i, self) =>
|
||||||
|
@ -7,10 +7,17 @@ import { Inject, Module, OnApplicationShutdown } from '@nestjs/common';
|
|||||||
import * as Bull from 'bullmq';
|
import * as Bull from 'bullmq';
|
||||||
import { DI } from '@/di-symbols.js';
|
import { DI } from '@/di-symbols.js';
|
||||||
import type { Config } from '@/config.js';
|
import type { Config } from '@/config.js';
|
||||||
import { QUEUE, baseQueueOptions } from '@/queue/const.js';
|
import { baseQueueOptions, QUEUE } from '@/queue/const.js';
|
||||||
import { allSettled } from '@/misc/promise-tracker.js';
|
import { allSettled } from '@/misc/promise-tracker.js';
|
||||||
|
import {
|
||||||
|
DeliverJobData,
|
||||||
|
EndedPollNotificationJobData,
|
||||||
|
InboxJobData,
|
||||||
|
RelationshipJobData,
|
||||||
|
UserWebhookDeliverJobData,
|
||||||
|
SystemWebhookDeliverJobData,
|
||||||
|
} from '../queue/types.js';
|
||||||
import type { Provider } from '@nestjs/common';
|
import type { Provider } from '@nestjs/common';
|
||||||
import type { DeliverJobData, InboxJobData, EndedPollNotificationJobData, WebhookDeliverJobData, RelationshipJobData } from '../queue/types.js';
|
|
||||||
|
|
||||||
export type SystemQueue = Bull.Queue<Record<string, unknown>>;
|
export type SystemQueue = Bull.Queue<Record<string, unknown>>;
|
||||||
export type EndedPollNotificationQueue = Bull.Queue<EndedPollNotificationJobData>;
|
export type EndedPollNotificationQueue = Bull.Queue<EndedPollNotificationJobData>;
|
||||||
@ -19,7 +26,8 @@ export type InboxQueue = Bull.Queue<InboxJobData>;
|
|||||||
export type DbQueue = Bull.Queue;
|
export type DbQueue = Bull.Queue;
|
||||||
export type RelationshipQueue = Bull.Queue<RelationshipJobData>;
|
export type RelationshipQueue = Bull.Queue<RelationshipJobData>;
|
||||||
export type ObjectStorageQueue = Bull.Queue;
|
export type ObjectStorageQueue = Bull.Queue;
|
||||||
export type WebhookDeliverQueue = Bull.Queue<WebhookDeliverJobData>;
|
export type UserWebhookDeliverQueue = Bull.Queue<UserWebhookDeliverJobData>;
|
||||||
|
export type SystemWebhookDeliverQueue = Bull.Queue<SystemWebhookDeliverJobData>;
|
||||||
|
|
||||||
const $system: Provider = {
|
const $system: Provider = {
|
||||||
provide: 'queue:system',
|
provide: 'queue:system',
|
||||||
@ -63,9 +71,15 @@ const $objectStorage: Provider = {
|
|||||||
inject: [DI.config],
|
inject: [DI.config],
|
||||||
};
|
};
|
||||||
|
|
||||||
const $webhookDeliver: Provider = {
|
const $userWebhookDeliver: Provider = {
|
||||||
provide: 'queue:webhookDeliver',
|
provide: 'queue:userWebhookDeliver',
|
||||||
useFactory: (config: Config) => new Bull.Queue(QUEUE.WEBHOOK_DELIVER, baseQueueOptions(config, QUEUE.WEBHOOK_DELIVER)),
|
useFactory: (config: Config) => new Bull.Queue(QUEUE.USER_WEBHOOK_DELIVER, baseQueueOptions(config, QUEUE.USER_WEBHOOK_DELIVER)),
|
||||||
|
inject: [DI.config],
|
||||||
|
};
|
||||||
|
|
||||||
|
const $systemWebhookDeliver: Provider = {
|
||||||
|
provide: 'queue:systemWebhookDeliver',
|
||||||
|
useFactory: (config: Config) => new Bull.Queue(QUEUE.SYSTEM_WEBHOOK_DELIVER, baseQueueOptions(config, QUEUE.SYSTEM_WEBHOOK_DELIVER)),
|
||||||
inject: [DI.config],
|
inject: [DI.config],
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -80,7 +94,8 @@ const $webhookDeliver: Provider = {
|
|||||||
$db,
|
$db,
|
||||||
$relationship,
|
$relationship,
|
||||||
$objectStorage,
|
$objectStorage,
|
||||||
$webhookDeliver,
|
$userWebhookDeliver,
|
||||||
|
$systemWebhookDeliver,
|
||||||
],
|
],
|
||||||
exports: [
|
exports: [
|
||||||
$system,
|
$system,
|
||||||
@ -90,7 +105,8 @@ const $webhookDeliver: Provider = {
|
|||||||
$db,
|
$db,
|
||||||
$relationship,
|
$relationship,
|
||||||
$objectStorage,
|
$objectStorage,
|
||||||
$webhookDeliver,
|
$userWebhookDeliver,
|
||||||
|
$systemWebhookDeliver,
|
||||||
],
|
],
|
||||||
})
|
})
|
||||||
export class QueueModule implements OnApplicationShutdown {
|
export class QueueModule implements OnApplicationShutdown {
|
||||||
@ -102,7 +118,8 @@ export class QueueModule implements OnApplicationShutdown {
|
|||||||
@Inject('queue:db') public dbQueue: DbQueue,
|
@Inject('queue:db') public dbQueue: DbQueue,
|
||||||
@Inject('queue:relationship') public relationshipQueue: RelationshipQueue,
|
@Inject('queue:relationship') public relationshipQueue: RelationshipQueue,
|
||||||
@Inject('queue:objectStorage') public objectStorageQueue: ObjectStorageQueue,
|
@Inject('queue:objectStorage') public objectStorageQueue: ObjectStorageQueue,
|
||||||
@Inject('queue:webhookDeliver') public webhookDeliverQueue: WebhookDeliverQueue,
|
@Inject('queue:userWebhookDeliver') public userWebhookDeliverQueue: UserWebhookDeliverQueue,
|
||||||
|
@Inject('queue:systemWebhookDeliver') public systemWebhookDeliverQueue: SystemWebhookDeliverQueue,
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
public async dispose(): Promise<void> {
|
public async dispose(): Promise<void> {
|
||||||
@ -117,7 +134,8 @@ export class QueueModule implements OnApplicationShutdown {
|
|||||||
this.dbQueue.close(),
|
this.dbQueue.close(),
|
||||||
this.relationshipQueue.close(),
|
this.relationshipQueue.close(),
|
||||||
this.objectStorageQueue.close(),
|
this.objectStorageQueue.close(),
|
||||||
this.webhookDeliverQueue.close(),
|
this.userWebhookDeliverQueue.close(),
|
||||||
|
this.systemWebhookDeliverQueue.close(),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,15 +8,32 @@ import { Inject, Injectable } from '@nestjs/common';
|
|||||||
import type { IActivity } from '@/core/activitypub/type.js';
|
import type { IActivity } from '@/core/activitypub/type.js';
|
||||||
import type { MiDriveFile } from '@/models/DriveFile.js';
|
import type { MiDriveFile } from '@/models/DriveFile.js';
|
||||||
import type { MiWebhook, webhookEventTypes } from '@/models/Webhook.js';
|
import type { MiWebhook, webhookEventTypes } from '@/models/Webhook.js';
|
||||||
|
import type { MiSystemWebhook, SystemWebhookEventType } from '@/models/SystemWebhook.js';
|
||||||
import type { Config } from '@/config.js';
|
import type { Config } from '@/config.js';
|
||||||
import { DI } from '@/di-symbols.js';
|
import { DI } from '@/di-symbols.js';
|
||||||
import { bindThis } from '@/decorators.js';
|
import { bindThis } from '@/decorators.js';
|
||||||
import type { Antenna } from '@/server/api/endpoints/i/import-antennas.js';
|
import type { Antenna } from '@/server/api/endpoints/i/import-antennas.js';
|
||||||
import type { DbQueue, DeliverQueue, EndedPollNotificationQueue, InboxQueue, ObjectStorageQueue, RelationshipQueue, SystemQueue, WebhookDeliverQueue } from './QueueModule.js';
|
import type {
|
||||||
import type { DbJobData, DeliverJobData, RelationshipJobData, ThinUser } from '../queue/types.js';
|
DbJobData,
|
||||||
import type httpSignature from '@peertube/http-signature';
|
DeliverJobData,
|
||||||
|
RelationshipJobData,
|
||||||
|
SystemWebhookDeliverJobData,
|
||||||
|
ThinUser,
|
||||||
|
UserWebhookDeliverJobData,
|
||||||
|
} from '../queue/types.js';
|
||||||
|
import type {
|
||||||
|
DbQueue,
|
||||||
|
DeliverQueue,
|
||||||
|
EndedPollNotificationQueue,
|
||||||
|
InboxQueue,
|
||||||
|
ObjectStorageQueue,
|
||||||
|
RelationshipQueue,
|
||||||
|
SystemQueue,
|
||||||
|
UserWebhookDeliverQueue,
|
||||||
|
SystemWebhookDeliverQueue,
|
||||||
|
} from './QueueModule.js';
|
||||||
|
import { genRFC3230DigestHeader, type PrivateKeyWithPem, type ParsedSignature } from '@misskey-dev/node-http-message-signatures';
|
||||||
import type * as Bull from 'bullmq';
|
import type * as Bull from 'bullmq';
|
||||||
import { ApRequestCreator } from '@/core/activitypub/ApRequestService.js';
|
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class QueueService {
|
export class QueueService {
|
||||||
@ -31,7 +48,8 @@ export class QueueService {
|
|||||||
@Inject('queue:db') public dbQueue: DbQueue,
|
@Inject('queue:db') public dbQueue: DbQueue,
|
||||||
@Inject('queue:relationship') public relationshipQueue: RelationshipQueue,
|
@Inject('queue:relationship') public relationshipQueue: RelationshipQueue,
|
||||||
@Inject('queue:objectStorage') public objectStorageQueue: ObjectStorageQueue,
|
@Inject('queue:objectStorage') public objectStorageQueue: ObjectStorageQueue,
|
||||||
@Inject('queue:webhookDeliver') public webhookDeliverQueue: WebhookDeliverQueue,
|
@Inject('queue:userWebhookDeliver') public userWebhookDeliverQueue: UserWebhookDeliverQueue,
|
||||||
|
@Inject('queue:systemWebhookDeliver') public systemWebhookDeliverQueue: SystemWebhookDeliverQueue,
|
||||||
) {
|
) {
|
||||||
this.systemQueue.add('tickCharts', {
|
this.systemQueue.add('tickCharts', {
|
||||||
}, {
|
}, {
|
||||||
@ -71,21 +89,21 @@ export class QueueService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@bindThis
|
@bindThis
|
||||||
public deliver(user: ThinUser, content: IActivity | null, to: string | null, isSharedInbox: boolean) {
|
public async deliver(user: ThinUser, content: IActivity | null, to: string | null, isSharedInbox: boolean, privateKey?: PrivateKeyWithPem) {
|
||||||
if (content == null) return null;
|
if (content == null) return null;
|
||||||
if (to == null) return null;
|
if (to == null) return null;
|
||||||
|
|
||||||
const contentBody = JSON.stringify(content);
|
const contentBody = JSON.stringify(content);
|
||||||
const digest = ApRequestCreator.createDigest(contentBody);
|
|
||||||
|
|
||||||
const data: DeliverJobData = {
|
const data: DeliverJobData = {
|
||||||
user: {
|
user: {
|
||||||
id: user.id,
|
id: user.id,
|
||||||
},
|
},
|
||||||
content: contentBody,
|
content: contentBody,
|
||||||
digest,
|
digest: await genRFC3230DigestHeader(contentBody, 'SHA-256'),
|
||||||
to,
|
to,
|
||||||
isSharedInbox,
|
isSharedInbox,
|
||||||
|
privateKey: privateKey && { keyId: privateKey.keyId, privateKeyPem: privateKey.privateKeyPem },
|
||||||
};
|
};
|
||||||
|
|
||||||
return this.deliverQueue.add(to, data, {
|
return this.deliverQueue.add(to, data, {
|
||||||
@ -103,13 +121,13 @@ export class QueueService {
|
|||||||
* @param user `{ id: string; }` この関数ではThinUserに変換しないので前もって変換してください
|
* @param user `{ id: string; }` この関数ではThinUserに変換しないので前もって変換してください
|
||||||
* @param content IActivity | null
|
* @param content IActivity | null
|
||||||
* @param inboxes `Map<string, boolean>` / key: to (inbox url), value: isSharedInbox (whether it is sharedInbox)
|
* @param inboxes `Map<string, boolean>` / key: to (inbox url), value: isSharedInbox (whether it is sharedInbox)
|
||||||
|
* @param forceMainKey boolean | undefined, force to use main (rsa) key
|
||||||
* @returns void
|
* @returns void
|
||||||
*/
|
*/
|
||||||
@bindThis
|
@bindThis
|
||||||
public async deliverMany(user: ThinUser, content: IActivity | null, inboxes: Map<string, boolean>) {
|
public async deliverMany(user: ThinUser, content: IActivity | null, inboxes: Map<string, boolean>, privateKey?: PrivateKeyWithPem) {
|
||||||
if (content == null) return null;
|
if (content == null) return null;
|
||||||
const contentBody = JSON.stringify(content);
|
const contentBody = JSON.stringify(content);
|
||||||
const digest = ApRequestCreator.createDigest(contentBody);
|
|
||||||
|
|
||||||
const opts = {
|
const opts = {
|
||||||
attempts: this.config.deliverJobMaxAttempts ?? 12,
|
attempts: this.config.deliverJobMaxAttempts ?? 12,
|
||||||
@ -125,9 +143,9 @@ export class QueueService {
|
|||||||
data: {
|
data: {
|
||||||
user,
|
user,
|
||||||
content: contentBody,
|
content: contentBody,
|
||||||
digest,
|
|
||||||
to: d[0],
|
to: d[0],
|
||||||
isSharedInbox: d[1],
|
isSharedInbox: d[1],
|
||||||
|
privateKey: privateKey && { keyId: privateKey.keyId, privateKeyPem: privateKey.privateKeyPem },
|
||||||
} as DeliverJobData,
|
} as DeliverJobData,
|
||||||
opts,
|
opts,
|
||||||
})));
|
})));
|
||||||
@ -136,7 +154,7 @@ export class QueueService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@bindThis
|
@bindThis
|
||||||
public inbox(activity: IActivity, signature: httpSignature.IParsedSignature) {
|
public inbox(activity: IActivity, signature: ParsedSignature | null) {
|
||||||
const data = {
|
const data = {
|
||||||
activity: activity,
|
activity: activity,
|
||||||
signature,
|
signature,
|
||||||
@ -431,9 +449,13 @@ export class QueueService {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see UserWebhookDeliverJobData
|
||||||
|
* @see WebhookDeliverProcessorService
|
||||||
|
*/
|
||||||
@bindThis
|
@bindThis
|
||||||
public webhookDeliver(webhook: MiWebhook, type: typeof webhookEventTypes[number], content: unknown) {
|
public userWebhookDeliver(webhook: MiWebhook, type: typeof webhookEventTypes[number], content: unknown) {
|
||||||
const data = {
|
const data: UserWebhookDeliverJobData = {
|
||||||
type,
|
type,
|
||||||
content,
|
content,
|
||||||
webhookId: webhook.id,
|
webhookId: webhook.id,
|
||||||
@ -444,7 +466,33 @@ export class QueueService {
|
|||||||
eventId: randomUUID(),
|
eventId: randomUUID(),
|
||||||
};
|
};
|
||||||
|
|
||||||
return this.webhookDeliverQueue.add(webhook.id, data, {
|
return this.userWebhookDeliverQueue.add(webhook.id, data, {
|
||||||
|
attempts: 4,
|
||||||
|
backoff: {
|
||||||
|
type: 'custom',
|
||||||
|
},
|
||||||
|
removeOnComplete: true,
|
||||||
|
removeOnFail: true,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see SystemWebhookDeliverJobData
|
||||||
|
* @see WebhookDeliverProcessorService
|
||||||
|
*/
|
||||||
|
@bindThis
|
||||||
|
public systemWebhookDeliver(webhook: MiSystemWebhook, type: SystemWebhookEventType, content: unknown) {
|
||||||
|
const data: SystemWebhookDeliverJobData = {
|
||||||
|
type,
|
||||||
|
content,
|
||||||
|
webhookId: webhook.id,
|
||||||
|
to: webhook.url,
|
||||||
|
secret: webhook.secret,
|
||||||
|
createdAt: Date.now(),
|
||||||
|
eventId: randomUUID(),
|
||||||
|
};
|
||||||
|
|
||||||
|
return this.systemWebhookDeliverQueue.add(webhook.id, data, {
|
||||||
attempts: 4,
|
attempts: 4,
|
||||||
backoff: {
|
backoff: {
|
||||||
type: 'custom',
|
type: 'custom',
|
||||||
|
@ -29,6 +29,7 @@ import { CustomEmojiService } from '@/core/CustomEmojiService.js';
|
|||||||
import { RoleService } from '@/core/RoleService.js';
|
import { RoleService } from '@/core/RoleService.js';
|
||||||
import { FeaturedService } from '@/core/FeaturedService.js';
|
import { FeaturedService } from '@/core/FeaturedService.js';
|
||||||
import { trackPromise } from '@/misc/promise-tracker.js';
|
import { trackPromise } from '@/misc/promise-tracker.js';
|
||||||
|
import { isQuote, isRenote } from '@/misc/is-renote.js';
|
||||||
|
|
||||||
const FALLBACK = '\u2764';
|
const FALLBACK = '\u2764';
|
||||||
const PER_NOTE_REACTION_USER_PAIR_CACHE_MAX = 16;
|
const PER_NOTE_REACTION_USER_PAIR_CACHE_MAX = 16;
|
||||||
@ -117,11 +118,16 @@ export class ReactionService {
|
|||||||
throw new IdentifiableError('68e9d2d1-48bf-42c2-b90a-b20e09fd3d48', 'Note not accessible for you.');
|
throw new IdentifiableError('68e9d2d1-48bf-42c2-b90a-b20e09fd3d48', 'Note not accessible for you.');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Check if note is Renote
|
||||||
|
if (isRenote(note) && !isQuote(note)) {
|
||||||
|
throw new IdentifiableError('12c35529-3c79-4327-b1cc-e2cf63a71925', 'You cannot react to Renote.');
|
||||||
|
}
|
||||||
|
|
||||||
let reaction = _reaction ?? FALLBACK;
|
let reaction = _reaction ?? FALLBACK;
|
||||||
|
|
||||||
if (note.reactionAcceptance === 'likeOnly' || ((note.reactionAcceptance === 'likeOnlyForRemote' || note.reactionAcceptance === 'nonSensitiveOnlyForLocalLikeOnlyForRemote') && (user.host != null))) {
|
if (note.reactionAcceptance === 'likeOnly' || ((note.reactionAcceptance === 'likeOnlyForRemote' || note.reactionAcceptance === 'nonSensitiveOnlyForLocalLikeOnlyForRemote') && (user.host != null))) {
|
||||||
reaction = '\u2764';
|
reaction = '\u2764';
|
||||||
} else if (_reaction) {
|
} else if (_reaction != null) {
|
||||||
const custom = reaction.match(isCustomEmojiRegexp);
|
const custom = reaction.match(isCustomEmojiRegexp);
|
||||||
if (custom) {
|
if (custom) {
|
||||||
const reacterHost = this.utilityService.toPunyNullable(user.host);
|
const reacterHost = this.utilityService.toPunyNullable(user.host);
|
||||||
|
@ -16,6 +16,8 @@ import { ApRendererService } from '@/core/activitypub/ApRendererService.js';
|
|||||||
import { DI } from '@/di-symbols.js';
|
import { DI } from '@/di-symbols.js';
|
||||||
import { deepClone } from '@/misc/clone.js';
|
import { deepClone } from '@/misc/clone.js';
|
||||||
import { bindThis } from '@/decorators.js';
|
import { bindThis } from '@/decorators.js';
|
||||||
|
import { UserKeypairService } from './UserKeypairService.js';
|
||||||
|
import type { PrivateKeyWithPem } from '@misskey-dev/node-http-message-signatures';
|
||||||
|
|
||||||
const ACTOR_USERNAME = 'relay.actor' as const;
|
const ACTOR_USERNAME = 'relay.actor' as const;
|
||||||
|
|
||||||
@ -34,6 +36,7 @@ export class RelayService {
|
|||||||
private queueService: QueueService,
|
private queueService: QueueService,
|
||||||
private createSystemUserService: CreateSystemUserService,
|
private createSystemUserService: CreateSystemUserService,
|
||||||
private apRendererService: ApRendererService,
|
private apRendererService: ApRendererService,
|
||||||
|
private userKeypairService: UserKeypairService,
|
||||||
) {
|
) {
|
||||||
this.relaysCache = new MemorySingleCache<MiRelay[]>(1000 * 60 * 10);
|
this.relaysCache = new MemorySingleCache<MiRelay[]>(1000 * 60 * 10);
|
||||||
}
|
}
|
||||||
@ -111,7 +114,7 @@ export class RelayService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@bindThis
|
@bindThis
|
||||||
public async deliverToRelays(user: { id: MiUser['id']; host: null; }, activity: any): Promise<void> {
|
public async deliverToRelays(user: { id: MiUser['id']; host: null; }, activity: any, privateKey?: PrivateKeyWithPem): Promise<void> {
|
||||||
if (activity == null) return;
|
if (activity == null) return;
|
||||||
|
|
||||||
const relays = await this.relaysCache.fetch(() => this.relaysRepository.findBy({
|
const relays = await this.relaysCache.fetch(() => this.relaysRepository.findBy({
|
||||||
@ -121,11 +124,9 @@ export class RelayService {
|
|||||||
|
|
||||||
const copy = deepClone(activity);
|
const copy = deepClone(activity);
|
||||||
if (!copy.to) copy.to = ['https://www.w3.org/ns/activitystreams#Public'];
|
if (!copy.to) copy.to = ['https://www.w3.org/ns/activitystreams#Public'];
|
||||||
|
privateKey = privateKey ?? await this.userKeypairService.getLocalUserPrivateKeyPem(user.id);
|
||||||
|
const signed = await this.apRendererService.attachLdSignature(copy, privateKey);
|
||||||
|
|
||||||
const signed = await this.apRendererService.attachLdSignature(copy, user);
|
this.queueService.deliverMany(user, signed, new Map(relays.map(({ inbox }) => [inbox, false])), privateKey);
|
||||||
|
|
||||||
for (const relay of relays) {
|
|
||||||
this.queueService.deliver(user, signed, relay.inbox, false);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -47,6 +47,7 @@ export type RolePolicies = {
|
|||||||
canHideAds: boolean;
|
canHideAds: boolean;
|
||||||
driveCapacityMb: number;
|
driveCapacityMb: number;
|
||||||
alwaysMarkNsfw: boolean;
|
alwaysMarkNsfw: boolean;
|
||||||
|
canUpdateBioMedia: boolean;
|
||||||
pinLimit: number;
|
pinLimit: number;
|
||||||
antennaLimit: number;
|
antennaLimit: number;
|
||||||
wordMuteLimit: number;
|
wordMuteLimit: number;
|
||||||
@ -75,6 +76,7 @@ export const DEFAULT_POLICIES: RolePolicies = {
|
|||||||
canHideAds: false,
|
canHideAds: false,
|
||||||
driveCapacityMb: 100,
|
driveCapacityMb: 100,
|
||||||
alwaysMarkNsfw: false,
|
alwaysMarkNsfw: false,
|
||||||
|
canUpdateBioMedia: true,
|
||||||
pinLimit: 5,
|
pinLimit: 5,
|
||||||
antennaLimit: 5,
|
antennaLimit: 5,
|
||||||
wordMuteLimit: 200,
|
wordMuteLimit: 200,
|
||||||
@ -376,6 +378,7 @@ export class RoleService implements OnApplicationShutdown, OnModuleInit {
|
|||||||
canHideAds: calc('canHideAds', vs => vs.some(v => v === true)),
|
canHideAds: calc('canHideAds', vs => vs.some(v => v === true)),
|
||||||
driveCapacityMb: calc('driveCapacityMb', vs => Math.max(...vs)),
|
driveCapacityMb: calc('driveCapacityMb', vs => Math.max(...vs)),
|
||||||
alwaysMarkNsfw: calc('alwaysMarkNsfw', vs => vs.some(v => v === true)),
|
alwaysMarkNsfw: calc('alwaysMarkNsfw', vs => vs.some(v => v === true)),
|
||||||
|
canUpdateBioMedia: calc('canUpdateBioMedia', vs => vs.some(v => v === true)),
|
||||||
pinLimit: calc('pinLimit', vs => Math.max(...vs)),
|
pinLimit: calc('pinLimit', vs => Math.max(...vs)),
|
||||||
antennaLimit: calc('antennaLimit', vs => Math.max(...vs)),
|
antennaLimit: calc('antennaLimit', vs => Math.max(...vs)),
|
||||||
wordMuteLimit: calc('wordMuteLimit', vs => Math.max(...vs)),
|
wordMuteLimit: calc('wordMuteLimit', vs => Math.max(...vs)),
|
||||||
@ -410,14 +413,32 @@ export class RoleService implements OnApplicationShutdown, OnModuleInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@bindThis
|
@bindThis
|
||||||
public async getModeratorIds(includeAdmins = true): Promise<MiUser['id'][]> {
|
public async getModeratorIds(includeAdmins = true, excludeExpire = false): Promise<MiUser['id'][]> {
|
||||||
const roles = await this.rolesCache.fetch(() => this.rolesRepository.findBy({}));
|
const roles = await this.rolesCache.fetch(() => this.rolesRepository.findBy({}));
|
||||||
const moderatorRoles = includeAdmins ? roles.filter(r => r.isModerator || r.isAdministrator) : roles.filter(r => r.isModerator);
|
const moderatorRoles = includeAdmins
|
||||||
const assigns = moderatorRoles.length > 0 ? await this.roleAssignmentsRepository.findBy({
|
? roles.filter(r => r.isModerator || r.isAdministrator)
|
||||||
roleId: In(moderatorRoles.map(r => r.id)),
|
: roles.filter(r => r.isModerator);
|
||||||
}) : [];
|
|
||||||
// TODO: isRootなアカウントも含める
|
// TODO: isRootなアカウントも含める
|
||||||
return assigns.map(a => a.userId);
|
const assigns = moderatorRoles.length > 0
|
||||||
|
? await this.roleAssignmentsRepository.findBy({ roleId: In(moderatorRoles.map(r => r.id)) })
|
||||||
|
: [];
|
||||||
|
|
||||||
|
const now = Date.now();
|
||||||
|
const result = [
|
||||||
|
// Setを経由して重複を除去(ユーザIDは重複する可能性があるので)
|
||||||
|
...new Set(
|
||||||
|
assigns
|
||||||
|
.filter(it =>
|
||||||
|
(excludeExpire)
|
||||||
|
? (it.expiresAt == null || it.expiresAt.getTime() > now)
|
||||||
|
: true,
|
||||||
|
)
|
||||||
|
.map(a => a.userId),
|
||||||
|
),
|
||||||
|
];
|
||||||
|
|
||||||
|
return result.sort((x, y) => x.localeCompare(y));
|
||||||
}
|
}
|
||||||
|
|
||||||
@bindThis
|
@bindThis
|
||||||
|
@ -3,7 +3,6 @@
|
|||||||
* SPDX-License-Identifier: AGPL-3.0-only
|
* SPDX-License-Identifier: AGPL-3.0-only
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { generateKeyPair } from 'node:crypto';
|
|
||||||
import { Inject, Injectable } from '@nestjs/common';
|
import { Inject, Injectable } from '@nestjs/common';
|
||||||
import bcrypt from 'bcryptjs';
|
import bcrypt from 'bcryptjs';
|
||||||
import { DataSource, IsNull } from 'typeorm';
|
import { DataSource, IsNull } from 'typeorm';
|
||||||
@ -21,6 +20,7 @@ import { bindThis } from '@/decorators.js';
|
|||||||
import UsersChart from '@/core/chart/charts/users.js';
|
import UsersChart from '@/core/chart/charts/users.js';
|
||||||
import { UtilityService } from '@/core/UtilityService.js';
|
import { UtilityService } from '@/core/UtilityService.js';
|
||||||
import { MetaService } from '@/core/MetaService.js';
|
import { MetaService } from '@/core/MetaService.js';
|
||||||
|
import { genRSAAndEd25519KeyPair } from '@/misc/gen-key-pair.js';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class SignupService {
|
export class SignupService {
|
||||||
@ -93,22 +93,7 @@ export class SignupService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const keyPair = await new Promise<string[]>((res, rej) =>
|
const keyPair = await genRSAAndEd25519KeyPair();
|
||||||
generateKeyPair('rsa', {
|
|
||||||
modulusLength: 2048,
|
|
||||||
publicKeyEncoding: {
|
|
||||||
type: 'spki',
|
|
||||||
format: 'pem',
|
|
||||||
},
|
|
||||||
privateKeyEncoding: {
|
|
||||||
type: 'pkcs8',
|
|
||||||
format: 'pem',
|
|
||||||
cipher: undefined,
|
|
||||||
passphrase: undefined,
|
|
||||||
},
|
|
||||||
}, (err, publicKey, privateKey) =>
|
|
||||||
err ? rej(err) : res([publicKey, privateKey]),
|
|
||||||
));
|
|
||||||
|
|
||||||
let account!: MiUser;
|
let account!: MiUser;
|
||||||
|
|
||||||
@ -131,9 +116,8 @@ export class SignupService {
|
|||||||
}));
|
}));
|
||||||
|
|
||||||
await transactionalEntityManager.save(new MiUserKeypair({
|
await transactionalEntityManager.save(new MiUserKeypair({
|
||||||
publicKey: keyPair[0],
|
|
||||||
privateKey: keyPair[1],
|
|
||||||
userId: account.id,
|
userId: account.id,
|
||||||
|
...keyPair,
|
||||||
}));
|
}));
|
||||||
|
|
||||||
await transactionalEntityManager.save(new MiUserProfile({
|
await transactionalEntityManager.save(new MiUserProfile({
|
||||||
|
233
packages/backend/src/core/SystemWebhookService.ts
Normal file
233
packages/backend/src/core/SystemWebhookService.ts
Normal file
@ -0,0 +1,233 @@
|
|||||||
|
/*
|
||||||
|
* SPDX-FileCopyrightText: syuilo and misskey-project
|
||||||
|
* SPDX-License-Identifier: AGPL-3.0-only
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { Inject, Injectable } from '@nestjs/common';
|
||||||
|
import * as Redis from 'ioredis';
|
||||||
|
import type { MiUser, SystemWebhooksRepository } from '@/models/_.js';
|
||||||
|
import { DI } from '@/di-symbols.js';
|
||||||
|
import { bindThis } from '@/decorators.js';
|
||||||
|
import { GlobalEvents, GlobalEventService } from '@/core/GlobalEventService.js';
|
||||||
|
import { MiSystemWebhook, type SystemWebhookEventType } from '@/models/SystemWebhook.js';
|
||||||
|
import { IdService } from '@/core/IdService.js';
|
||||||
|
import { QueueService } from '@/core/QueueService.js';
|
||||||
|
import { ModerationLogService } from '@/core/ModerationLogService.js';
|
||||||
|
import { LoggerService } from '@/core/LoggerService.js';
|
||||||
|
import Logger from '@/logger.js';
|
||||||
|
import type { OnApplicationShutdown } from '@nestjs/common';
|
||||||
|
|
||||||
|
@Injectable()
|
||||||
|
export class SystemWebhookService implements OnApplicationShutdown {
|
||||||
|
private logger: Logger;
|
||||||
|
private activeSystemWebhooksFetched = false;
|
||||||
|
private activeSystemWebhooks: MiSystemWebhook[] = [];
|
||||||
|
|
||||||
|
constructor(
|
||||||
|
@Inject(DI.redisForSub)
|
||||||
|
private redisForSub: Redis.Redis,
|
||||||
|
@Inject(DI.systemWebhooksRepository)
|
||||||
|
private systemWebhooksRepository: SystemWebhooksRepository,
|
||||||
|
private idService: IdService,
|
||||||
|
private queueService: QueueService,
|
||||||
|
private moderationLogService: ModerationLogService,
|
||||||
|
private loggerService: LoggerService,
|
||||||
|
private globalEventService: GlobalEventService,
|
||||||
|
) {
|
||||||
|
this.redisForSub.on('message', this.onMessage);
|
||||||
|
this.logger = this.loggerService.getLogger('webhook');
|
||||||
|
}
|
||||||
|
|
||||||
|
@bindThis
|
||||||
|
public async fetchActiveSystemWebhooks() {
|
||||||
|
if (!this.activeSystemWebhooksFetched) {
|
||||||
|
this.activeSystemWebhooks = await this.systemWebhooksRepository.findBy({
|
||||||
|
isActive: true,
|
||||||
|
});
|
||||||
|
this.activeSystemWebhooksFetched = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return this.activeSystemWebhooks;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* SystemWebhook の一覧を取得する.
|
||||||
|
*/
|
||||||
|
@bindThis
|
||||||
|
public async fetchSystemWebhooks(params?: {
|
||||||
|
ids?: MiSystemWebhook['id'][];
|
||||||
|
isActive?: MiSystemWebhook['isActive'];
|
||||||
|
on?: MiSystemWebhook['on'];
|
||||||
|
}): Promise<MiSystemWebhook[]> {
|
||||||
|
const query = this.systemWebhooksRepository.createQueryBuilder('systemWebhook');
|
||||||
|
if (params) {
|
||||||
|
if (params.ids && params.ids.length > 0) {
|
||||||
|
query.andWhere('systemWebhook.id IN (:...ids)', { ids: params.ids });
|
||||||
|
}
|
||||||
|
if (params.isActive !== undefined) {
|
||||||
|
query.andWhere('systemWebhook.isActive = :isActive', { isActive: params.isActive });
|
||||||
|
}
|
||||||
|
if (params.on && params.on.length > 0) {
|
||||||
|
query.andWhere(':on <@ systemWebhook.on', { on: params.on });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return query.getMany();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* SystemWebhook を作成する.
|
||||||
|
*/
|
||||||
|
@bindThis
|
||||||
|
public async createSystemWebhook(
|
||||||
|
params: {
|
||||||
|
isActive: MiSystemWebhook['isActive'];
|
||||||
|
name: MiSystemWebhook['name'];
|
||||||
|
on: MiSystemWebhook['on'];
|
||||||
|
url: MiSystemWebhook['url'];
|
||||||
|
secret: MiSystemWebhook['secret'];
|
||||||
|
},
|
||||||
|
updater: MiUser,
|
||||||
|
): Promise<MiSystemWebhook> {
|
||||||
|
const id = this.idService.gen();
|
||||||
|
await this.systemWebhooksRepository.insert({
|
||||||
|
...params,
|
||||||
|
id,
|
||||||
|
});
|
||||||
|
|
||||||
|
const webhook = await this.systemWebhooksRepository.findOneByOrFail({ id });
|
||||||
|
this.globalEventService.publishInternalEvent('systemWebhookCreated', webhook);
|
||||||
|
this.moderationLogService
|
||||||
|
.log(updater, 'createSystemWebhook', {
|
||||||
|
systemWebhookId: webhook.id,
|
||||||
|
webhook: webhook,
|
||||||
|
})
|
||||||
|
.then();
|
||||||
|
|
||||||
|
return webhook;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* SystemWebhook を更新する.
|
||||||
|
*/
|
||||||
|
@bindThis
|
||||||
|
public async updateSystemWebhook(
|
||||||
|
params: {
|
||||||
|
id: MiSystemWebhook['id'];
|
||||||
|
isActive: MiSystemWebhook['isActive'];
|
||||||
|
name: MiSystemWebhook['name'];
|
||||||
|
on: MiSystemWebhook['on'];
|
||||||
|
url: MiSystemWebhook['url'];
|
||||||
|
secret: MiSystemWebhook['secret'];
|
||||||
|
},
|
||||||
|
updater: MiUser,
|
||||||
|
): Promise<MiSystemWebhook> {
|
||||||
|
const beforeEntity = await this.systemWebhooksRepository.findOneByOrFail({ id: params.id });
|
||||||
|
await this.systemWebhooksRepository.update(beforeEntity.id, {
|
||||||
|
updatedAt: new Date(),
|
||||||
|
isActive: params.isActive,
|
||||||
|
name: params.name,
|
||||||
|
on: params.on,
|
||||||
|
url: params.url,
|
||||||
|
secret: params.secret,
|
||||||
|
});
|
||||||
|
|
||||||
|
const afterEntity = await this.systemWebhooksRepository.findOneByOrFail({ id: beforeEntity.id });
|
||||||
|
this.globalEventService.publishInternalEvent('systemWebhookUpdated', afterEntity);
|
||||||
|
this.moderationLogService
|
||||||
|
.log(updater, 'updateSystemWebhook', {
|
||||||
|
systemWebhookId: beforeEntity.id,
|
||||||
|
before: beforeEntity,
|
||||||
|
after: afterEntity,
|
||||||
|
})
|
||||||
|
.then();
|
||||||
|
|
||||||
|
return afterEntity;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* SystemWebhook を削除する.
|
||||||
|
*/
|
||||||
|
@bindThis
|
||||||
|
public async deleteSystemWebhook(id: MiSystemWebhook['id'], updater: MiUser) {
|
||||||
|
const webhook = await this.systemWebhooksRepository.findOneByOrFail({ id });
|
||||||
|
await this.systemWebhooksRepository.delete(id);
|
||||||
|
|
||||||
|
this.globalEventService.publishInternalEvent('systemWebhookDeleted', webhook);
|
||||||
|
this.moderationLogService
|
||||||
|
.log(updater, 'deleteSystemWebhook', {
|
||||||
|
systemWebhookId: webhook.id,
|
||||||
|
webhook,
|
||||||
|
})
|
||||||
|
.then();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* SystemWebhook をWebhook配送キューに追加する
|
||||||
|
* @see QueueService.systemWebhookDeliver
|
||||||
|
*/
|
||||||
|
@bindThis
|
||||||
|
public async enqueueSystemWebhook(webhook: MiSystemWebhook | MiSystemWebhook['id'], type: SystemWebhookEventType, content: unknown) {
|
||||||
|
const webhookEntity = typeof webhook === 'string'
|
||||||
|
? (await this.fetchActiveSystemWebhooks()).find(a => a.id === webhook)
|
||||||
|
: webhook;
|
||||||
|
if (!webhookEntity || !webhookEntity.isActive) {
|
||||||
|
this.logger.info(`Webhook is not active or not found : ${webhook}`);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!webhookEntity.on.includes(type)) {
|
||||||
|
this.logger.info(`Webhook ${webhookEntity.id} is not listening to ${type}`);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
return this.queueService.systemWebhookDeliver(webhookEntity, type, content);
|
||||||
|
}
|
||||||
|
|
||||||
|
@bindThis
|
||||||
|
private async onMessage(_: string, data: string): Promise<void> {
|
||||||
|
const obj = JSON.parse(data);
|
||||||
|
if (obj.channel !== 'internal') {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const { type, body } = obj.message as GlobalEvents['internal']['payload'];
|
||||||
|
switch (type) {
|
||||||
|
case 'systemWebhookCreated': {
|
||||||
|
if (body.isActive) {
|
||||||
|
this.activeSystemWebhooks.push(MiSystemWebhook.deserialize(body));
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 'systemWebhookUpdated': {
|
||||||
|
if (body.isActive) {
|
||||||
|
const i = this.activeSystemWebhooks.findIndex(a => a.id === body.id);
|
||||||
|
if (i > -1) {
|
||||||
|
this.activeSystemWebhooks[i] = MiSystemWebhook.deserialize(body);
|
||||||
|
} else {
|
||||||
|
this.activeSystemWebhooks.push(MiSystemWebhook.deserialize(body));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
this.activeSystemWebhooks = this.activeSystemWebhooks.filter(a => a.id !== body.id);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 'systemWebhookDeleted': {
|
||||||
|
this.activeSystemWebhooks = this.activeSystemWebhooks.filter(a => a.id !== body.id);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@bindThis
|
||||||
|
public dispose(): void {
|
||||||
|
this.redisForSub.off('message', this.onMessage);
|
||||||
|
}
|
||||||
|
|
||||||
|
@bindThis
|
||||||
|
public onApplicationShutdown(signal?: string | undefined): void {
|
||||||
|
this.dispose();
|
||||||
|
}
|
||||||
|
}
|
@ -16,7 +16,7 @@ import Logger from '@/logger.js';
|
|||||||
import { UserEntityService } from '@/core/entities/UserEntityService.js';
|
import { UserEntityService } from '@/core/entities/UserEntityService.js';
|
||||||
import { ApRendererService } from '@/core/activitypub/ApRendererService.js';
|
import { ApRendererService } from '@/core/activitypub/ApRendererService.js';
|
||||||
import { LoggerService } from '@/core/LoggerService.js';
|
import { LoggerService } from '@/core/LoggerService.js';
|
||||||
import { WebhookService } from '@/core/WebhookService.js';
|
import { UserWebhookService } from '@/core/UserWebhookService.js';
|
||||||
import { bindThis } from '@/decorators.js';
|
import { bindThis } from '@/decorators.js';
|
||||||
import { CacheService } from '@/core/CacheService.js';
|
import { CacheService } from '@/core/CacheService.js';
|
||||||
import { UserFollowingService } from '@/core/UserFollowingService.js';
|
import { UserFollowingService } from '@/core/UserFollowingService.js';
|
||||||
@ -46,7 +46,7 @@ export class UserBlockingService implements OnModuleInit {
|
|||||||
private idService: IdService,
|
private idService: IdService,
|
||||||
private queueService: QueueService,
|
private queueService: QueueService,
|
||||||
private globalEventService: GlobalEventService,
|
private globalEventService: GlobalEventService,
|
||||||
private webhookService: WebhookService,
|
private webhookService: UserWebhookService,
|
||||||
private apRendererService: ApRendererService,
|
private apRendererService: ApRendererService,
|
||||||
private loggerService: LoggerService,
|
private loggerService: LoggerService,
|
||||||
) {
|
) {
|
||||||
@ -121,7 +121,7 @@ export class UserBlockingService implements OnModuleInit {
|
|||||||
|
|
||||||
const webhooks = (await this.webhookService.getActiveWebhooks()).filter(x => x.userId === follower.id && x.on.includes('unfollow'));
|
const webhooks = (await this.webhookService.getActiveWebhooks()).filter(x => x.userId === follower.id && x.on.includes('unfollow'));
|
||||||
for (const webhook of webhooks) {
|
for (const webhook of webhooks) {
|
||||||
this.queueService.webhookDeliver(webhook, 'unfollow', {
|
this.queueService.userWebhookDeliver(webhook, 'unfollow', {
|
||||||
user: packed,
|
user: packed,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -16,7 +16,7 @@ import { isDuplicateKeyValueError } from '@/misc/is-duplicate-key-value-error.js
|
|||||||
import type { Packed } from '@/misc/json-schema.js';
|
import type { Packed } from '@/misc/json-schema.js';
|
||||||
import InstanceChart from '@/core/chart/charts/instance.js';
|
import InstanceChart from '@/core/chart/charts/instance.js';
|
||||||
import { FederatedInstanceService } from '@/core/FederatedInstanceService.js';
|
import { FederatedInstanceService } from '@/core/FederatedInstanceService.js';
|
||||||
import { WebhookService } from '@/core/WebhookService.js';
|
import { UserWebhookService } from '@/core/UserWebhookService.js';
|
||||||
import { NotificationService } from '@/core/NotificationService.js';
|
import { NotificationService } from '@/core/NotificationService.js';
|
||||||
import { DI } from '@/di-symbols.js';
|
import { DI } from '@/di-symbols.js';
|
||||||
import type { FollowingsRepository, FollowRequestsRepository, InstancesRepository, UserProfilesRepository, UsersRepository } from '@/models/_.js';
|
import type { FollowingsRepository, FollowRequestsRepository, InstancesRepository, UserProfilesRepository, UsersRepository } from '@/models/_.js';
|
||||||
@ -82,7 +82,7 @@ export class UserFollowingService implements OnModuleInit {
|
|||||||
private metaService: MetaService,
|
private metaService: MetaService,
|
||||||
private notificationService: NotificationService,
|
private notificationService: NotificationService,
|
||||||
private federatedInstanceService: FederatedInstanceService,
|
private federatedInstanceService: FederatedInstanceService,
|
||||||
private webhookService: WebhookService,
|
private webhookService: UserWebhookService,
|
||||||
private apRendererService: ApRendererService,
|
private apRendererService: ApRendererService,
|
||||||
private accountMoveService: AccountMoveService,
|
private accountMoveService: AccountMoveService,
|
||||||
private fanoutTimelineService: FanoutTimelineService,
|
private fanoutTimelineService: FanoutTimelineService,
|
||||||
@ -331,7 +331,7 @@ export class UserFollowingService implements OnModuleInit {
|
|||||||
|
|
||||||
const webhooks = (await this.webhookService.getActiveWebhooks()).filter(x => x.userId === follower.id && x.on.includes('follow'));
|
const webhooks = (await this.webhookService.getActiveWebhooks()).filter(x => x.userId === follower.id && x.on.includes('follow'));
|
||||||
for (const webhook of webhooks) {
|
for (const webhook of webhooks) {
|
||||||
this.queueService.webhookDeliver(webhook, 'follow', {
|
this.queueService.userWebhookDeliver(webhook, 'follow', {
|
||||||
user: packed,
|
user: packed,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -345,7 +345,7 @@ export class UserFollowingService implements OnModuleInit {
|
|||||||
|
|
||||||
const webhooks = (await this.webhookService.getActiveWebhooks()).filter(x => x.userId === followee.id && x.on.includes('followed'));
|
const webhooks = (await this.webhookService.getActiveWebhooks()).filter(x => x.userId === followee.id && x.on.includes('followed'));
|
||||||
for (const webhook of webhooks) {
|
for (const webhook of webhooks) {
|
||||||
this.queueService.webhookDeliver(webhook, 'followed', {
|
this.queueService.userWebhookDeliver(webhook, 'followed', {
|
||||||
user: packed,
|
user: packed,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -398,7 +398,7 @@ export class UserFollowingService implements OnModuleInit {
|
|||||||
|
|
||||||
const webhooks = (await this.webhookService.getActiveWebhooks()).filter(x => x.userId === follower.id && x.on.includes('unfollow'));
|
const webhooks = (await this.webhookService.getActiveWebhooks()).filter(x => x.userId === follower.id && x.on.includes('unfollow'));
|
||||||
for (const webhook of webhooks) {
|
for (const webhook of webhooks) {
|
||||||
this.queueService.webhookDeliver(webhook, 'unfollow', {
|
this.queueService.userWebhookDeliver(webhook, 'unfollow', {
|
||||||
user: packed,
|
user: packed,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -740,7 +740,7 @@ export class UserFollowingService implements OnModuleInit {
|
|||||||
|
|
||||||
const webhooks = (await this.webhookService.getActiveWebhooks()).filter(x => x.userId === follower.id && x.on.includes('unfollow'));
|
const webhooks = (await this.webhookService.getActiveWebhooks()).filter(x => x.userId === follower.id && x.on.includes('unfollow'));
|
||||||
for (const webhook of webhooks) {
|
for (const webhook of webhooks) {
|
||||||
this.queueService.webhookDeliver(webhook, 'unfollow', {
|
this.queueService.userWebhookDeliver(webhook, 'unfollow', {
|
||||||
user: packedFollowee,
|
user: packedFollowee,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -5,41 +5,184 @@
|
|||||||
|
|
||||||
import { Inject, Injectable, OnApplicationShutdown } from '@nestjs/common';
|
import { Inject, Injectable, OnApplicationShutdown } from '@nestjs/common';
|
||||||
import * as Redis from 'ioredis';
|
import * as Redis from 'ioredis';
|
||||||
|
import { genEd25519KeyPair, importPrivateKey, PrivateKey, PrivateKeyWithPem } from '@misskey-dev/node-http-message-signatures';
|
||||||
import type { MiUser } from '@/models/User.js';
|
import type { MiUser } from '@/models/User.js';
|
||||||
import type { UserKeypairsRepository } from '@/models/_.js';
|
import type { UserKeypairsRepository } from '@/models/_.js';
|
||||||
import { RedisKVCache } from '@/misc/cache.js';
|
import { RedisKVCache, MemoryKVCache } from '@/misc/cache.js';
|
||||||
import type { MiUserKeypair } from '@/models/UserKeypair.js';
|
import type { MiUserKeypair } from '@/models/UserKeypair.js';
|
||||||
import { DI } from '@/di-symbols.js';
|
import { DI } from '@/di-symbols.js';
|
||||||
import { bindThis } from '@/decorators.js';
|
import { bindThis } from '@/decorators.js';
|
||||||
|
import { GlobalEventService, GlobalEvents } from '@/core/GlobalEventService.js';
|
||||||
|
import { UserEntityService } from '@/core/entities/UserEntityService.js';
|
||||||
|
import type { webcrypto } from 'node:crypto';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class UserKeypairService implements OnApplicationShutdown {
|
export class UserKeypairService implements OnApplicationShutdown {
|
||||||
private cache: RedisKVCache<MiUserKeypair>;
|
private keypairEntityCache: RedisKVCache<MiUserKeypair>;
|
||||||
|
private privateKeyObjectCache: MemoryKVCache<webcrypto.CryptoKey>;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
@Inject(DI.redis)
|
@Inject(DI.redis)
|
||||||
private redisClient: Redis.Redis,
|
private redisClient: Redis.Redis,
|
||||||
|
@Inject(DI.redisForSub)
|
||||||
|
private redisForSub: Redis.Redis,
|
||||||
@Inject(DI.userKeypairsRepository)
|
@Inject(DI.userKeypairsRepository)
|
||||||
private userKeypairsRepository: UserKeypairsRepository,
|
private userKeypairsRepository: UserKeypairsRepository,
|
||||||
|
|
||||||
|
private globalEventService: GlobalEventService,
|
||||||
|
private userEntityService: UserEntityService,
|
||||||
) {
|
) {
|
||||||
this.cache = new RedisKVCache<MiUserKeypair>(this.redisClient, 'userKeypair', {
|
this.keypairEntityCache = new RedisKVCache<MiUserKeypair>(this.redisClient, 'userKeypair', {
|
||||||
lifetime: 1000 * 60 * 60 * 24, // 24h
|
lifetime: 1000 * 60 * 60 * 24, // 24h
|
||||||
memoryCacheLifetime: Infinity,
|
memoryCacheLifetime: Infinity,
|
||||||
fetcher: (key) => this.userKeypairsRepository.findOneByOrFail({ userId: key }),
|
fetcher: (key) => this.userKeypairsRepository.findOneByOrFail({ userId: key }),
|
||||||
toRedisConverter: (value) => JSON.stringify(value),
|
toRedisConverter: (value) => JSON.stringify(value),
|
||||||
fromRedisConverter: (value) => JSON.parse(value),
|
fromRedisConverter: (value) => JSON.parse(value),
|
||||||
});
|
});
|
||||||
|
this.privateKeyObjectCache = new MemoryKVCache<webcrypto.CryptoKey>(1000 * 60 * 60 * 1);
|
||||||
|
|
||||||
|
this.redisForSub.on('message', this.onMessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
@bindThis
|
@bindThis
|
||||||
public async getUserKeypair(userId: MiUser['id']): Promise<MiUserKeypair> {
|
public async getUserKeypair(userId: MiUser['id']): Promise<MiUserKeypair> {
|
||||||
return await this.cache.fetch(userId);
|
return await this.keypairEntityCache.fetch(userId);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get private key [Only PrivateKeyWithPem for queue data etc.]
|
||||||
|
* @param userIdOrHint user id or MiUserKeypair
|
||||||
|
* @param preferType
|
||||||
|
* If ed25519-like(`ed25519`, `01`, `11`) is specified, ed25519 keypair will be returned if exists.
|
||||||
|
* Otherwise, main keypair will be returned.
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
|
@bindThis
|
||||||
|
public async getLocalUserPrivateKeyPem(
|
||||||
|
userIdOrHint: MiUser['id'] | MiUserKeypair,
|
||||||
|
preferType?: string,
|
||||||
|
): Promise<PrivateKeyWithPem> {
|
||||||
|
const keypair = typeof userIdOrHint === 'string' ? await this.getUserKeypair(userIdOrHint) : userIdOrHint;
|
||||||
|
if (
|
||||||
|
preferType && ['01', '11', 'ed25519'].includes(preferType.toLowerCase()) &&
|
||||||
|
keypair.ed25519PublicKey != null && keypair.ed25519PrivateKey != null
|
||||||
|
) {
|
||||||
|
return {
|
||||||
|
keyId: `${this.userEntityService.genLocalUserUri(keypair.userId)}#ed25519-key`,
|
||||||
|
privateKeyPem: keypair.ed25519PrivateKey,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
keyId: `${this.userEntityService.genLocalUserUri(keypair.userId)}#main-key`,
|
||||||
|
privateKeyPem: keypair.privateKey,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get private key [Only PrivateKey for ap request]
|
||||||
|
* Using cache due to performance reasons of `crypto.subtle.importKey`
|
||||||
|
* @param userIdOrHint user id, MiUserKeypair, or PrivateKeyWithPem
|
||||||
|
* @param preferType
|
||||||
|
* If ed25519-like(`ed25519`, `01`, `11`) is specified, ed25519 keypair will be returned if exists.
|
||||||
|
* Otherwise, main keypair will be returned. (ignored if userIdOrHint is PrivateKeyWithPem)
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
|
@bindThis
|
||||||
|
public async getLocalUserPrivateKey(
|
||||||
|
userIdOrHint: MiUser['id'] | MiUserKeypair | PrivateKeyWithPem,
|
||||||
|
preferType?: string,
|
||||||
|
): Promise<PrivateKey> {
|
||||||
|
if (typeof userIdOrHint === 'object' && 'privateKeyPem' in userIdOrHint) {
|
||||||
|
// userIdOrHint is PrivateKeyWithPem
|
||||||
|
return {
|
||||||
|
keyId: userIdOrHint.keyId,
|
||||||
|
privateKey: await this.privateKeyObjectCache.fetch(userIdOrHint.keyId, async () => {
|
||||||
|
return await importPrivateKey(userIdOrHint.privateKeyPem);
|
||||||
|
}),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
const userId = typeof userIdOrHint === 'string' ? userIdOrHint : userIdOrHint.userId;
|
||||||
|
const getKeypair = () => typeof userIdOrHint === 'string' ? this.getUserKeypair(userId) : userIdOrHint;
|
||||||
|
|
||||||
|
if (preferType && ['01', '11', 'ed25519'].includes(preferType.toLowerCase())) {
|
||||||
|
const keyId = `${this.userEntityService.genLocalUserUri(userId)}#ed25519-key`;
|
||||||
|
const fetched = await this.privateKeyObjectCache.fetchMaybe(keyId, async () => {
|
||||||
|
const keypair = await getKeypair();
|
||||||
|
if (keypair.ed25519PublicKey != null && keypair.ed25519PrivateKey != null) {
|
||||||
|
return await importPrivateKey(keypair.ed25519PrivateKey);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
});
|
||||||
|
if (fetched) {
|
||||||
|
return {
|
||||||
|
keyId,
|
||||||
|
privateKey: fetched,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const keyId = `${this.userEntityService.genLocalUserUri(userId)}#main-key`;
|
||||||
|
return {
|
||||||
|
keyId,
|
||||||
|
privateKey: await this.privateKeyObjectCache.fetch(keyId, async () => {
|
||||||
|
const keypair = await getKeypair();
|
||||||
|
return await importPrivateKey(keypair.privateKey);
|
||||||
|
}),
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@bindThis
|
||||||
|
public async refresh(userId: MiUser['id']): Promise<void> {
|
||||||
|
return await this.keypairEntityCache.refresh(userId);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If DB has ed25519 keypair, refresh cache and return it.
|
||||||
|
* If not, create, save and return ed25519 keypair.
|
||||||
|
* @param userId user id
|
||||||
|
* @returns MiUserKeypair if keypair is created, void if keypair is already exists
|
||||||
|
*/
|
||||||
|
@bindThis
|
||||||
|
public async refreshAndPrepareEd25519KeyPair(userId: MiUser['id']): Promise<MiUserKeypair | void> {
|
||||||
|
await this.refresh(userId);
|
||||||
|
const keypair = await this.keypairEntityCache.fetch(userId);
|
||||||
|
if (keypair.ed25519PublicKey != null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const ed25519 = await genEd25519KeyPair();
|
||||||
|
await this.userKeypairsRepository.update({ userId }, {
|
||||||
|
ed25519PublicKey: ed25519.publicKey,
|
||||||
|
ed25519PrivateKey: ed25519.privateKey,
|
||||||
|
});
|
||||||
|
this.globalEventService.publishInternalEvent('userKeypairUpdated', { userId });
|
||||||
|
const result = {
|
||||||
|
...keypair,
|
||||||
|
ed25519PublicKey: ed25519.publicKey,
|
||||||
|
ed25519PrivateKey: ed25519.privateKey,
|
||||||
|
};
|
||||||
|
this.keypairEntityCache.set(userId, result);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
@bindThis
|
||||||
|
private async onMessage(_: string, data: string): Promise<void> {
|
||||||
|
const obj = JSON.parse(data);
|
||||||
|
|
||||||
|
if (obj.channel === 'internal') {
|
||||||
|
const { type, body } = obj.message as GlobalEvents['internal']['payload'];
|
||||||
|
switch (type) {
|
||||||
|
case 'userKeypairUpdated': {
|
||||||
|
this.refresh(body.userId);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@bindThis
|
@bindThis
|
||||||
public dispose(): void {
|
public dispose(): void {
|
||||||
this.cache.dispose();
|
this.keypairEntityCache.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
@bindThis
|
@bindThis
|
||||||
|
@ -95,7 +95,7 @@ export class UserListService implements OnApplicationShutdown, OnModuleInit {
|
|||||||
const currentCount = await this.userListMembershipsRepository.countBy({
|
const currentCount = await this.userListMembershipsRepository.countBy({
|
||||||
userListId: list.id,
|
userListId: list.id,
|
||||||
});
|
});
|
||||||
if (currentCount > (await this.roleService.getUserPolicies(me.id)).userEachUserListsLimit) {
|
if (currentCount >= (await this.roleService.getUserPolicies(me.id)).userEachUserListsLimit) {
|
||||||
throw new UserListService.TooManyUsersError();
|
throw new UserListService.TooManyUsersError();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
52
packages/backend/src/core/UserRenoteMutingService.ts
Normal file
52
packages/backend/src/core/UserRenoteMutingService.ts
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
/*
|
||||||
|
* SPDX-FileCopyrightText: syuilo and misskey-project , Type4ny-project
|
||||||
|
* SPDX-License-Identifier: AGPL-3.0-only
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { Inject, Injectable } from '@nestjs/common';
|
||||||
|
import { In } from 'typeorm';
|
||||||
|
import type { RenoteMutingsRepository } from '@/models/_.js';
|
||||||
|
import type { MiRenoteMuting } from '@/models/RenoteMuting.js';
|
||||||
|
|
||||||
|
import { IdService } from '@/core/IdService.js';
|
||||||
|
import type { MiUser } from '@/models/User.js';
|
||||||
|
import { DI } from '@/di-symbols.js';
|
||||||
|
import { bindThis } from '@/decorators.js';
|
||||||
|
import { CacheService } from '@/core/CacheService.js';
|
||||||
|
|
||||||
|
@Injectable()
|
||||||
|
export class UserRenoteMutingService {
|
||||||
|
constructor(
|
||||||
|
@Inject(DI.renoteMutingsRepository)
|
||||||
|
private renoteMutingsRepository: RenoteMutingsRepository,
|
||||||
|
|
||||||
|
private idService: IdService,
|
||||||
|
private cacheService: CacheService,
|
||||||
|
) {
|
||||||
|
}
|
||||||
|
|
||||||
|
@bindThis
|
||||||
|
public async mute(user: MiUser, target: MiUser, expiresAt: Date | null = null): Promise<void> {
|
||||||
|
await this.renoteMutingsRepository.insert({
|
||||||
|
id: this.idService.gen(),
|
||||||
|
muterId: user.id,
|
||||||
|
muteeId: target.id,
|
||||||
|
});
|
||||||
|
|
||||||
|
await this.cacheService.renoteMutingsCache.refresh(user.id);
|
||||||
|
}
|
||||||
|
|
||||||
|
@bindThis
|
||||||
|
public async unmute(mutings: MiRenoteMuting[]): Promise<void> {
|
||||||
|
if (mutings.length === 0) return;
|
||||||
|
|
||||||
|
await this.renoteMutingsRepository.delete({
|
||||||
|
id: In(mutings.map(m => m.id)),
|
||||||
|
});
|
||||||
|
|
||||||
|
const muterIds = [...new Set(mutings.map(m => m.muterId))];
|
||||||
|
for (const muterId of muterIds) {
|
||||||
|
await this.cacheService.renoteMutingsCache.refresh(muterId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
205
packages/backend/src/core/UserSearchService.ts
Normal file
205
packages/backend/src/core/UserSearchService.ts
Normal file
@ -0,0 +1,205 @@
|
|||||||
|
/*
|
||||||
|
* SPDX-FileCopyrightText: syuilo and misskey-project
|
||||||
|
* SPDX-License-Identifier: AGPL-3.0-only
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { Inject, Injectable } from '@nestjs/common';
|
||||||
|
import { Brackets, SelectQueryBuilder } from 'typeorm';
|
||||||
|
import { DI } from '@/di-symbols.js';
|
||||||
|
import { type FollowingsRepository, MiUser, type UsersRepository } from '@/models/_.js';
|
||||||
|
import { bindThis } from '@/decorators.js';
|
||||||
|
import { sqlLikeEscape } from '@/misc/sql-like-escape.js';
|
||||||
|
import type { Config } from '@/config.js';
|
||||||
|
import { UserEntityService } from '@/core/entities/UserEntityService.js';
|
||||||
|
import { Packed } from '@/misc/json-schema.js';
|
||||||
|
|
||||||
|
function defaultActiveThreshold() {
|
||||||
|
return new Date(Date.now() - 1000 * 60 * 60 * 24 * 30);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Injectable()
|
||||||
|
export class UserSearchService {
|
||||||
|
constructor(
|
||||||
|
@Inject(DI.config)
|
||||||
|
private config: Config,
|
||||||
|
@Inject(DI.usersRepository)
|
||||||
|
private usersRepository: UsersRepository,
|
||||||
|
@Inject(DI.followingsRepository)
|
||||||
|
private followingsRepository: FollowingsRepository,
|
||||||
|
private userEntityService: UserEntityService,
|
||||||
|
) {
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ユーザ名とホスト名によるユーザ検索を行う.
|
||||||
|
*
|
||||||
|
* - 検索結果には優先順位がつけられており、以下の順序で検索が行われる.
|
||||||
|
* 1. フォローしているユーザのうち、一定期間以内(※)に更新されたユーザ
|
||||||
|
* 2. フォローしているユーザのうち、一定期間以内に更新されていないユーザ
|
||||||
|
* 3. フォローしていないユーザのうち、一定期間以内に更新されたユーザ
|
||||||
|
* 4. フォローしていないユーザのうち、一定期間以内に更新されていないユーザ
|
||||||
|
* - ログインしていない場合は、以下の順序で検索が行われる.
|
||||||
|
* 1. 一定期間以内に更新されたユーザ
|
||||||
|
* 2. 一定期間以内に更新されていないユーザ
|
||||||
|
* - それぞれの検索結果はユーザ名の昇順でソートされる.
|
||||||
|
* - 動作的には先に登場した検索結果の登場位置が優先される(条件的にユーザIDが重複することはないが).
|
||||||
|
* (1で既にヒットしていた場合、2, 3, 4でヒットしても無視される)
|
||||||
|
* - ユーザ名とホスト名の検索条件はそれぞれ前方一致で検索される.
|
||||||
|
* - ユーザ名の検索は大文字小文字を区別しない.
|
||||||
|
* - ホスト名の検索は大文字小文字を区別しない.
|
||||||
|
* - 検索結果は最大で {@link opts.limit} 件までとなる.
|
||||||
|
*
|
||||||
|
* ※一定期間とは {@link params.activeThreshold} で指定された日時から現在までの期間を指す.
|
||||||
|
*
|
||||||
|
* @param params 検索条件.
|
||||||
|
* @param opts 関数の動作を制御するオプション.
|
||||||
|
* @param me 検索を実行するユーザの情報. 未ログインの場合は指定しない.
|
||||||
|
* @see {@link UserSearchService#buildSearchUserQueries}
|
||||||
|
* @see {@link UserSearchService#buildSearchUserNoLoginQueries}
|
||||||
|
*/
|
||||||
|
@bindThis
|
||||||
|
public async search(
|
||||||
|
params: {
|
||||||
|
username?: string | null,
|
||||||
|
host?: string | null,
|
||||||
|
activeThreshold?: Date,
|
||||||
|
},
|
||||||
|
opts?: {
|
||||||
|
limit?: number,
|
||||||
|
detail?: boolean,
|
||||||
|
},
|
||||||
|
me?: MiUser | null,
|
||||||
|
): Promise<Packed<'User'>[]> {
|
||||||
|
const queries = me ? this.buildSearchUserQueries(me, params) : this.buildSearchUserNoLoginQueries(params);
|
||||||
|
|
||||||
|
let resultSet = new Set<MiUser['id']>();
|
||||||
|
const limit = opts?.limit ?? 10;
|
||||||
|
for (const query of queries) {
|
||||||
|
const ids = await query
|
||||||
|
.select('user.id')
|
||||||
|
.limit(limit - resultSet.size)
|
||||||
|
.orderBy('user.usernameLower', 'ASC')
|
||||||
|
.getRawMany<{ user_id: MiUser['id'] }>()
|
||||||
|
.then(res => res.map(x => x.user_id));
|
||||||
|
|
||||||
|
resultSet = new Set([...resultSet, ...ids]);
|
||||||
|
if (resultSet.size >= limit) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return this.userEntityService.packMany<'UserLite' | 'UserDetailed'>(
|
||||||
|
[...resultSet].slice(0, limit),
|
||||||
|
me,
|
||||||
|
{ schema: opts?.detail ? 'UserDetailed' : 'UserLite' },
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ログイン済みユーザによる検索実行時のクエリ一覧を構築する.
|
||||||
|
* @param me
|
||||||
|
* @param params
|
||||||
|
* @private
|
||||||
|
*/
|
||||||
|
@bindThis
|
||||||
|
private buildSearchUserQueries(
|
||||||
|
me: MiUser,
|
||||||
|
params: {
|
||||||
|
username?: string | null,
|
||||||
|
host?: string | null,
|
||||||
|
activeThreshold?: Date,
|
||||||
|
},
|
||||||
|
) {
|
||||||
|
// デフォルト30日以内に更新されたユーザーをアクティブユーザーとする
|
||||||
|
const activeThreshold = params.activeThreshold ?? defaultActiveThreshold();
|
||||||
|
|
||||||
|
const followingUserQuery = this.followingsRepository.createQueryBuilder('following')
|
||||||
|
.select('following.followeeId')
|
||||||
|
.where('following.followerId = :followerId', { followerId: me.id });
|
||||||
|
|
||||||
|
const activeFollowingUsersQuery = this.generateUserQueryBuilder(params)
|
||||||
|
.andWhere(`user.id IN (${followingUserQuery.getQuery()})`)
|
||||||
|
.andWhere('user.updatedAt > :activeThreshold', { activeThreshold });
|
||||||
|
activeFollowingUsersQuery.setParameters(followingUserQuery.getParameters());
|
||||||
|
|
||||||
|
const inactiveFollowingUsersQuery = this.generateUserQueryBuilder(params)
|
||||||
|
.andWhere(`user.id IN (${followingUserQuery.getQuery()})`)
|
||||||
|
.andWhere(new Brackets(qb => {
|
||||||
|
qb
|
||||||
|
.where('user.updatedAt IS NULL')
|
||||||
|
.orWhere('user.updatedAt <= :activeThreshold', { activeThreshold });
|
||||||
|
}));
|
||||||
|
inactiveFollowingUsersQuery.setParameters(followingUserQuery.getParameters());
|
||||||
|
|
||||||
|
// 自分自身がヒットするとしたらここ
|
||||||
|
const activeUserQuery = this.generateUserQueryBuilder(params)
|
||||||
|
.andWhere(`user.id NOT IN (${followingUserQuery.getQuery()})`)
|
||||||
|
.andWhere('user.updatedAt > :activeThreshold', { activeThreshold });
|
||||||
|
activeUserQuery.setParameters(followingUserQuery.getParameters());
|
||||||
|
|
||||||
|
const inactiveUserQuery = this.generateUserQueryBuilder(params)
|
||||||
|
.andWhere(`user.id NOT IN (${followingUserQuery.getQuery()})`)
|
||||||
|
.andWhere('user.updatedAt <= :activeThreshold', { activeThreshold });
|
||||||
|
inactiveUserQuery.setParameters(followingUserQuery.getParameters());
|
||||||
|
|
||||||
|
return [activeFollowingUsersQuery, inactiveFollowingUsersQuery, activeUserQuery, inactiveUserQuery];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ログインしていないユーザによる検索実行時のクエリ一覧を構築する.
|
||||||
|
* @param params
|
||||||
|
* @private
|
||||||
|
*/
|
||||||
|
@bindThis
|
||||||
|
private buildSearchUserNoLoginQueries(params: {
|
||||||
|
username?: string | null,
|
||||||
|
host?: string | null,
|
||||||
|
activeThreshold?: Date,
|
||||||
|
}) {
|
||||||
|
// デフォルト30日以内に更新されたユーザーをアクティブユーザーとする
|
||||||
|
const activeThreshold = params.activeThreshold ?? defaultActiveThreshold();
|
||||||
|
|
||||||
|
const activeUserQuery = this.generateUserQueryBuilder(params)
|
||||||
|
.andWhere(new Brackets(qb => {
|
||||||
|
qb
|
||||||
|
.where('user.updatedAt IS NULL')
|
||||||
|
.orWhere('user.updatedAt > :activeThreshold', { activeThreshold });
|
||||||
|
}));
|
||||||
|
|
||||||
|
const inactiveUserQuery = this.generateUserQueryBuilder(params)
|
||||||
|
.andWhere('user.updatedAt <= :activeThreshold', { activeThreshold });
|
||||||
|
|
||||||
|
return [activeUserQuery, inactiveUserQuery];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ユーザ検索クエリで共通する抽出条件をあらかじめ設定したクエリビルダを生成する.
|
||||||
|
* @param params
|
||||||
|
* @private
|
||||||
|
*/
|
||||||
|
@bindThis
|
||||||
|
private generateUserQueryBuilder(params: {
|
||||||
|
username?: string | null,
|
||||||
|
host?: string | null,
|
||||||
|
}): SelectQueryBuilder<MiUser> {
|
||||||
|
const userQuery = this.usersRepository.createQueryBuilder('user');
|
||||||
|
|
||||||
|
if (params.username) {
|
||||||
|
userQuery.andWhere('user.usernameLower LIKE :username', { username: sqlLikeEscape(params.username.toLowerCase()) + '%' });
|
||||||
|
}
|
||||||
|
|
||||||
|
if (params.host) {
|
||||||
|
if (params.host === this.config.hostname || params.host === '.') {
|
||||||
|
userQuery.andWhere('user.host IS NULL');
|
||||||
|
} else {
|
||||||
|
userQuery.andWhere('user.host LIKE :host', {
|
||||||
|
host: sqlLikeEscape(params.host.toLowerCase()) + '%',
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
userQuery.andWhere('user.isSuspended = FALSE');
|
||||||
|
|
||||||
|
return userQuery;
|
||||||
|
}
|
||||||
|
}
|
@ -3,27 +3,23 @@
|
|||||||
* SPDX-License-Identifier: AGPL-3.0-only
|
* SPDX-License-Identifier: AGPL-3.0-only
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { Inject, Injectable } from '@nestjs/common';
|
import { Injectable } from '@nestjs/common';
|
||||||
import { Not, IsNull } from 'typeorm';
|
|
||||||
import type { FollowingsRepository } from '@/models/_.js';
|
|
||||||
import type { MiUser } from '@/models/User.js';
|
import type { MiUser } from '@/models/User.js';
|
||||||
import { QueueService } from '@/core/QueueService.js';
|
|
||||||
import { GlobalEventService } from '@/core/GlobalEventService.js';
|
import { GlobalEventService } from '@/core/GlobalEventService.js';
|
||||||
import { DI } from '@/di-symbols.js';
|
|
||||||
import { ApRendererService } from '@/core/activitypub/ApRendererService.js';
|
import { ApRendererService } from '@/core/activitypub/ApRendererService.js';
|
||||||
import { UserEntityService } from '@/core/entities/UserEntityService.js';
|
import { UserEntityService } from '@/core/entities/UserEntityService.js';
|
||||||
import { bindThis } from '@/decorators.js';
|
import { bindThis } from '@/decorators.js';
|
||||||
|
import { UserKeypairService } from './UserKeypairService.js';
|
||||||
|
import { ApDeliverManagerService } from './activitypub/ApDeliverManagerService.js';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class UserSuspendService {
|
export class UserSuspendService {
|
||||||
constructor(
|
constructor(
|
||||||
@Inject(DI.followingsRepository)
|
|
||||||
private followingsRepository: FollowingsRepository,
|
|
||||||
|
|
||||||
private userEntityService: UserEntityService,
|
private userEntityService: UserEntityService,
|
||||||
private queueService: QueueService,
|
|
||||||
private globalEventService: GlobalEventService,
|
private globalEventService: GlobalEventService,
|
||||||
private apRendererService: ApRendererService,
|
private apRendererService: ApRendererService,
|
||||||
|
private userKeypairService: UserKeypairService,
|
||||||
|
private apDeliverManagerService: ApDeliverManagerService,
|
||||||
) {
|
) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -32,28 +28,12 @@ export class UserSuspendService {
|
|||||||
this.globalEventService.publishInternalEvent('userChangeSuspendedState', { id: user.id, isSuspended: true });
|
this.globalEventService.publishInternalEvent('userChangeSuspendedState', { id: user.id, isSuspended: true });
|
||||||
|
|
||||||
if (this.userEntityService.isLocalUser(user)) {
|
if (this.userEntityService.isLocalUser(user)) {
|
||||||
// 知り得る全SharedInboxにDelete配信
|
|
||||||
const content = this.apRendererService.addContext(this.apRendererService.renderDelete(this.userEntityService.genLocalUserUri(user.id), user));
|
const content = this.apRendererService.addContext(this.apRendererService.renderDelete(this.userEntityService.genLocalUserUri(user.id), user));
|
||||||
|
const manager = this.apDeliverManagerService.createDeliverManager(user, content);
|
||||||
const queue: string[] = [];
|
manager.addAllKnowingSharedInboxRecipe();
|
||||||
|
// process deliver時にはキーペアが消去されているはずなので、ここで挿入する
|
||||||
const followings = await this.followingsRepository.find({
|
const privateKey = await this.userKeypairService.getLocalUserPrivateKeyPem(user.id, 'main');
|
||||||
where: [
|
manager.execute({ privateKey });
|
||||||
{ followerSharedInbox: Not(IsNull()) },
|
|
||||||
{ followeeSharedInbox: Not(IsNull()) },
|
|
||||||
],
|
|
||||||
select: ['followerSharedInbox', 'followeeSharedInbox'],
|
|
||||||
});
|
|
||||||
|
|
||||||
const inboxes = followings.map(x => x.followerSharedInbox ?? x.followeeSharedInbox);
|
|
||||||
|
|
||||||
for (const inbox of inboxes) {
|
|
||||||
if (inbox != null && !queue.includes(inbox)) queue.push(inbox);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (const inbox of queue) {
|
|
||||||
this.queueService.deliver(user, content, inbox, true);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -62,28 +42,12 @@ export class UserSuspendService {
|
|||||||
this.globalEventService.publishInternalEvent('userChangeSuspendedState', { id: user.id, isSuspended: false });
|
this.globalEventService.publishInternalEvent('userChangeSuspendedState', { id: user.id, isSuspended: false });
|
||||||
|
|
||||||
if (this.userEntityService.isLocalUser(user)) {
|
if (this.userEntityService.isLocalUser(user)) {
|
||||||
// 知り得る全SharedInboxにUndo Delete配信
|
|
||||||
const content = this.apRendererService.addContext(this.apRendererService.renderUndo(this.apRendererService.renderDelete(this.userEntityService.genLocalUserUri(user.id), user), user));
|
const content = this.apRendererService.addContext(this.apRendererService.renderUndo(this.apRendererService.renderDelete(this.userEntityService.genLocalUserUri(user.id), user), user));
|
||||||
|
const manager = this.apDeliverManagerService.createDeliverManager(user, content);
|
||||||
const queue: string[] = [];
|
manager.addAllKnowingSharedInboxRecipe();
|
||||||
|
// process deliver時にはキーペアが消去されているはずなので、ここで挿入する
|
||||||
const followings = await this.followingsRepository.find({
|
const privateKey = await this.userKeypairService.getLocalUserPrivateKeyPem(user.id, 'main');
|
||||||
where: [
|
manager.execute({ privateKey });
|
||||||
{ followerSharedInbox: Not(IsNull()) },
|
|
||||||
{ followeeSharedInbox: Not(IsNull()) },
|
|
||||||
],
|
|
||||||
select: ['followerSharedInbox', 'followeeSharedInbox'],
|
|
||||||
});
|
|
||||||
|
|
||||||
const inboxes = followings.map(x => x.followerSharedInbox ?? x.followeeSharedInbox);
|
|
||||||
|
|
||||||
for (const inbox of inboxes) {
|
|
||||||
if (inbox != null && !queue.includes(inbox)) queue.push(inbox);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (const inbox of queue) {
|
|
||||||
this.queueService.deliver(user as any, content, inbox, true);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
99
packages/backend/src/core/UserWebhookService.ts
Normal file
99
packages/backend/src/core/UserWebhookService.ts
Normal file
@ -0,0 +1,99 @@
|
|||||||
|
/*
|
||||||
|
* SPDX-FileCopyrightText: syuilo and misskey-project
|
||||||
|
* SPDX-License-Identifier: AGPL-3.0-only
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { Inject, Injectable } from '@nestjs/common';
|
||||||
|
import * as Redis from 'ioredis';
|
||||||
|
import type { WebhooksRepository } from '@/models/_.js';
|
||||||
|
import type { MiWebhook } from '@/models/Webhook.js';
|
||||||
|
import { DI } from '@/di-symbols.js';
|
||||||
|
import { bindThis } from '@/decorators.js';
|
||||||
|
import { GlobalEvents } from '@/core/GlobalEventService.js';
|
||||||
|
import type { OnApplicationShutdown } from '@nestjs/common';
|
||||||
|
|
||||||
|
@Injectable()
|
||||||
|
export class UserWebhookService implements OnApplicationShutdown {
|
||||||
|
private activeWebhooksFetched = false;
|
||||||
|
private activeWebhooks: MiWebhook[] = [];
|
||||||
|
|
||||||
|
constructor(
|
||||||
|
@Inject(DI.redisForSub)
|
||||||
|
private redisForSub: Redis.Redis,
|
||||||
|
@Inject(DI.webhooksRepository)
|
||||||
|
private webhooksRepository: WebhooksRepository,
|
||||||
|
) {
|
||||||
|
this.redisForSub.on('message', this.onMessage);
|
||||||
|
}
|
||||||
|
|
||||||
|
@bindThis
|
||||||
|
public async getActiveWebhooks() {
|
||||||
|
if (!this.activeWebhooksFetched) {
|
||||||
|
this.activeWebhooks = await this.webhooksRepository.findBy({
|
||||||
|
active: true,
|
||||||
|
});
|
||||||
|
this.activeWebhooksFetched = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return this.activeWebhooks;
|
||||||
|
}
|
||||||
|
|
||||||
|
@bindThis
|
||||||
|
private async onMessage(_: string, data: string): Promise<void> {
|
||||||
|
const obj = JSON.parse(data);
|
||||||
|
if (obj.channel !== 'internal') {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const { type, body } = obj.message as GlobalEvents['internal']['payload'];
|
||||||
|
switch (type) {
|
||||||
|
case 'webhookCreated': {
|
||||||
|
if (body.active) {
|
||||||
|
this.activeWebhooks.push({ // TODO: このあたりのデシリアライズ処理は各modelファイル内に関数としてexportしたい
|
||||||
|
...body,
|
||||||
|
latestSentAt: body.latestSentAt ? new Date(body.latestSentAt) : null,
|
||||||
|
user: null, // joinなカラムは通常取ってこないので
|
||||||
|
});
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 'webhookUpdated': {
|
||||||
|
if (body.active) {
|
||||||
|
const i = this.activeWebhooks.findIndex(a => a.id === body.id);
|
||||||
|
if (i > -1) {
|
||||||
|
this.activeWebhooks[i] = { // TODO: このあたりのデシリアライズ処理は各modelファイル内に関数としてexportしたい
|
||||||
|
...body,
|
||||||
|
latestSentAt: body.latestSentAt ? new Date(body.latestSentAt) : null,
|
||||||
|
user: null, // joinなカラムは通常取ってこないので
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
this.activeWebhooks.push({ // TODO: このあたりのデシリアライズ処理は各modelファイル内に関数としてexportしたい
|
||||||
|
...body,
|
||||||
|
latestSentAt: body.latestSentAt ? new Date(body.latestSentAt) : null,
|
||||||
|
user: null, // joinなカラムは通常取ってこないので
|
||||||
|
});
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
this.activeWebhooks = this.activeWebhooks.filter(a => a.id !== body.id);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 'webhookDeleted': {
|
||||||
|
this.activeWebhooks = this.activeWebhooks.filter(a => a.id !== body.id);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@bindThis
|
||||||
|
public dispose(): void {
|
||||||
|
this.redisForSub.off('message', this.onMessage);
|
||||||
|
}
|
||||||
|
|
||||||
|
@bindThis
|
||||||
|
public onApplicationShutdown(signal?: string | undefined): void {
|
||||||
|
this.dispose();
|
||||||
|
}
|
||||||
|
}
|
@ -46,7 +46,7 @@ export class WebfingerService {
|
|||||||
const m = query.match(mRegex);
|
const m = query.match(mRegex);
|
||||||
if (m) {
|
if (m) {
|
||||||
const hostname = m[2];
|
const hostname = m[2];
|
||||||
const useHttp = process.env.MISSKEY_WEBFINGER_USE_HTTP && process.env.MISSKEY_WEBFINGER_USE_HTTP.toLowerCase() === 'true';
|
const useHttp = process.env.MISSKEY_USE_HTTP && process.env.MISSKEY_USE_HTTP.toLowerCase() === 'true';
|
||||||
return `http${useHttp ? '' : 's'}://${hostname}/.well-known/webfinger?${urlQuery({ resource: `acct:${query}` })}`;
|
return `http${useHttp ? '' : 's'}://${hostname}/.well-known/webfinger?${urlQuery({ resource: `acct:${query}` })}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,97 +0,0 @@
|
|||||||
/*
|
|
||||||
* SPDX-FileCopyrightText: syuilo and misskey-project
|
|
||||||
* SPDX-License-Identifier: AGPL-3.0-only
|
|
||||||
*/
|
|
||||||
|
|
||||||
import { Inject, Injectable } from '@nestjs/common';
|
|
||||||
import * as Redis from 'ioredis';
|
|
||||||
import type { WebhooksRepository } from '@/models/_.js';
|
|
||||||
import type { MiWebhook } from '@/models/Webhook.js';
|
|
||||||
import { DI } from '@/di-symbols.js';
|
|
||||||
import { bindThis } from '@/decorators.js';
|
|
||||||
import type { GlobalEvents } from '@/core/GlobalEventService.js';
|
|
||||||
import type { OnApplicationShutdown } from '@nestjs/common';
|
|
||||||
|
|
||||||
@Injectable()
|
|
||||||
export class WebhookService implements OnApplicationShutdown {
|
|
||||||
private webhooksFetched = false;
|
|
||||||
private webhooks: MiWebhook[] = [];
|
|
||||||
|
|
||||||
constructor(
|
|
||||||
@Inject(DI.redisForSub)
|
|
||||||
private redisForSub: Redis.Redis,
|
|
||||||
|
|
||||||
@Inject(DI.webhooksRepository)
|
|
||||||
private webhooksRepository: WebhooksRepository,
|
|
||||||
) {
|
|
||||||
//this.onMessage = this.onMessage.bind(this);
|
|
||||||
this.redisForSub.on('message', this.onMessage);
|
|
||||||
}
|
|
||||||
|
|
||||||
@bindThis
|
|
||||||
public async getActiveWebhooks() {
|
|
||||||
if (!this.webhooksFetched) {
|
|
||||||
this.webhooks = await this.webhooksRepository.findBy({
|
|
||||||
active: true,
|
|
||||||
});
|
|
||||||
this.webhooksFetched = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return this.webhooks;
|
|
||||||
}
|
|
||||||
|
|
||||||
@bindThis
|
|
||||||
private async onMessage(_: string, data: string): Promise<void> {
|
|
||||||
const obj = JSON.parse(data);
|
|
||||||
|
|
||||||
if (obj.channel === 'internal') {
|
|
||||||
const { type, body } = obj.message as GlobalEvents['internal']['payload'];
|
|
||||||
switch (type) {
|
|
||||||
case 'webhookCreated':
|
|
||||||
if (body.active) {
|
|
||||||
this.webhooks.push({ // TODO: このあたりのデシリアライズ処理は各modelファイル内に関数としてexportしたい
|
|
||||||
...body,
|
|
||||||
latestSentAt: body.latestSentAt ? new Date(body.latestSentAt) : null,
|
|
||||||
user: null, // joinなカラムは通常取ってこないので
|
|
||||||
});
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 'webhookUpdated':
|
|
||||||
if (body.active) {
|
|
||||||
const i = this.webhooks.findIndex(a => a.id === body.id);
|
|
||||||
if (i > -1) {
|
|
||||||
this.webhooks[i] = { // TODO: このあたりのデシリアライズ処理は各modelファイル内に関数としてexportしたい
|
|
||||||
...body,
|
|
||||||
latestSentAt: body.latestSentAt ? new Date(body.latestSentAt) : null,
|
|
||||||
user: null, // joinなカラムは通常取ってこないので
|
|
||||||
};
|
|
||||||
} else {
|
|
||||||
this.webhooks.push({ // TODO: このあたりのデシリアライズ処理は各modelファイル内に関数としてexportしたい
|
|
||||||
...body,
|
|
||||||
latestSentAt: body.latestSentAt ? new Date(body.latestSentAt) : null,
|
|
||||||
user: null, // joinなカラムは通常取ってこないので
|
|
||||||
});
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
this.webhooks = this.webhooks.filter(a => a.id !== body.id);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 'webhookDeleted':
|
|
||||||
this.webhooks = this.webhooks.filter(a => a.id !== body.id);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@bindThis
|
|
||||||
public dispose(): void {
|
|
||||||
this.redisForSub.off('message', this.onMessage);
|
|
||||||
}
|
|
||||||
|
|
||||||
@bindThis
|
|
||||||
public onApplicationShutdown(signal?: string | undefined): void {
|
|
||||||
this.dispose();
|
|
||||||
}
|
|
||||||
}
|
|
@ -8,7 +8,6 @@ import promiseLimit from 'promise-limit';
|
|||||||
import type { MiRemoteUser, MiUser } from '@/models/User.js';
|
import type { MiRemoteUser, MiUser } from '@/models/User.js';
|
||||||
import { concat, unique } from '@/misc/prelude/array.js';
|
import { concat, unique } from '@/misc/prelude/array.js';
|
||||||
import { bindThis } from '@/decorators.js';
|
import { bindThis } from '@/decorators.js';
|
||||||
import { isNotNull } from '@/misc/is-not-null.js';
|
|
||||||
import { getApIds } from './type.js';
|
import { getApIds } from './type.js';
|
||||||
import { ApPersonService } from './models/ApPersonService.js';
|
import { ApPersonService } from './models/ApPersonService.js';
|
||||||
import type { ApObject } from './type.js';
|
import type { ApObject } from './type.js';
|
||||||
@ -41,7 +40,7 @@ export class ApAudienceService {
|
|||||||
const limit = promiseLimit<MiUser | null>(2);
|
const limit = promiseLimit<MiUser | null>(2);
|
||||||
const mentionedUsers = (await Promise.all(
|
const mentionedUsers = (await Promise.all(
|
||||||
others.map(id => limit(() => this.apPersonService.resolvePerson(id, resolver).catch(() => null))),
|
others.map(id => limit(() => this.apPersonService.resolvePerson(id, resolver).catch(() => null))),
|
||||||
)).filter(isNotNull);
|
)).filter(x => x != null);
|
||||||
|
|
||||||
if (toGroups.public.length > 0) {
|
if (toGroups.public.length > 0) {
|
||||||
return {
|
return {
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
import { Inject, Injectable, OnApplicationShutdown } from '@nestjs/common';
|
import { Inject, Injectable, OnApplicationShutdown } from '@nestjs/common';
|
||||||
import { DI } from '@/di-symbols.js';
|
import { DI } from '@/di-symbols.js';
|
||||||
import type { NotesRepository, UserPublickeysRepository, UsersRepository } from '@/models/_.js';
|
import type { MiUser, NotesRepository, UserPublickeysRepository, UsersRepository } from '@/models/_.js';
|
||||||
import type { Config } from '@/config.js';
|
import type { Config } from '@/config.js';
|
||||||
import { MemoryKVCache } from '@/misc/cache.js';
|
import { MemoryKVCache } from '@/misc/cache.js';
|
||||||
import type { MiUserPublickey } from '@/models/UserPublickey.js';
|
import type { MiUserPublickey } from '@/models/UserPublickey.js';
|
||||||
@ -13,9 +13,12 @@ import { CacheService } from '@/core/CacheService.js';
|
|||||||
import type { MiNote } from '@/models/Note.js';
|
import type { MiNote } from '@/models/Note.js';
|
||||||
import { bindThis } from '@/decorators.js';
|
import { bindThis } from '@/decorators.js';
|
||||||
import { MiLocalUser, MiRemoteUser } from '@/models/User.js';
|
import { MiLocalUser, MiRemoteUser } from '@/models/User.js';
|
||||||
|
import Logger from '@/logger.js';
|
||||||
import { getApId } from './type.js';
|
import { getApId } from './type.js';
|
||||||
import { ApPersonService } from './models/ApPersonService.js';
|
import { ApPersonService } from './models/ApPersonService.js';
|
||||||
|
import { ApLoggerService } from './ApLoggerService.js';
|
||||||
import type { IObject } from './type.js';
|
import type { IObject } from './type.js';
|
||||||
|
import { UtilityService } from '../UtilityService.js';
|
||||||
|
|
||||||
export type UriParseResult = {
|
export type UriParseResult = {
|
||||||
/** wether the URI was generated by us */
|
/** wether the URI was generated by us */
|
||||||
@ -35,8 +38,8 @@ export type UriParseResult = {
|
|||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class ApDbResolverService implements OnApplicationShutdown {
|
export class ApDbResolverService implements OnApplicationShutdown {
|
||||||
private publicKeyCache: MemoryKVCache<MiUserPublickey | null>;
|
private publicKeyByUserIdCache: MemoryKVCache<MiUserPublickey[] | null>;
|
||||||
private publicKeyByUserIdCache: MemoryKVCache<MiUserPublickey | null>;
|
private logger: Logger;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
@Inject(DI.config)
|
@Inject(DI.config)
|
||||||
@ -53,9 +56,17 @@ export class ApDbResolverService implements OnApplicationShutdown {
|
|||||||
|
|
||||||
private cacheService: CacheService,
|
private cacheService: CacheService,
|
||||||
private apPersonService: ApPersonService,
|
private apPersonService: ApPersonService,
|
||||||
|
private apLoggerService: ApLoggerService,
|
||||||
|
private utilityService: UtilityService,
|
||||||
) {
|
) {
|
||||||
this.publicKeyCache = new MemoryKVCache<MiUserPublickey | null>(Infinity);
|
this.publicKeyByUserIdCache = new MemoryKVCache<MiUserPublickey[] | null>(Infinity);
|
||||||
this.publicKeyByUserIdCache = new MemoryKVCache<MiUserPublickey | null>(Infinity);
|
this.logger = this.apLoggerService.logger.createSubLogger('db-resolver');
|
||||||
|
}
|
||||||
|
|
||||||
|
private punyHost(url: string): string {
|
||||||
|
const urlObj = new URL(url);
|
||||||
|
const host = `${this.utilityService.toPuny(urlObj.hostname)}${urlObj.port.length > 0 ? ':' + urlObj.port : ''}`;
|
||||||
|
return host;
|
||||||
}
|
}
|
||||||
|
|
||||||
@bindThis
|
@bindThis
|
||||||
@ -116,62 +127,141 @@ export class ApDbResolverService implements OnApplicationShutdown {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* AP KeyId => Misskey User and Key
|
|
||||||
*/
|
|
||||||
@bindThis
|
@bindThis
|
||||||
public async getAuthUserFromKeyId(keyId: string): Promise<{
|
private async refreshAndFindKey(userId: MiUser['id'], keyId: string): Promise<MiUserPublickey | null> {
|
||||||
user: MiRemoteUser;
|
this.refreshCacheByUserId(userId);
|
||||||
key: MiUserPublickey;
|
const keys = await this.getPublicKeyByUserId(userId);
|
||||||
} | null> {
|
if (keys == null || !Array.isArray(keys) || keys.length === 0) {
|
||||||
const key = await this.publicKeyCache.fetch(keyId, async () => {
|
this.logger.warn(`No key found (refreshAndFindKey) userId=${userId} keyId=${keyId} keys=${JSON.stringify(keys)}`);
|
||||||
const key = await this.userPublickeysRepository.findOneBy({
|
return null;
|
||||||
keyId,
|
}
|
||||||
});
|
const exactKey = keys.find(x => x.keyId === keyId);
|
||||||
|
if (exactKey) return exactKey;
|
||||||
if (key == null) return null;
|
this.logger.warn(`No exact key found (refreshAndFindKey) userId=${userId} keyId=${keyId} keys=${JSON.stringify(keys)}`);
|
||||||
|
return null;
|
||||||
return key;
|
|
||||||
}, key => key != null);
|
|
||||||
|
|
||||||
if (key == null) return null;
|
|
||||||
|
|
||||||
const user = await this.cacheService.findUserById(key.userId).catch(() => null) as MiRemoteUser | null;
|
|
||||||
if (user == null) return null;
|
|
||||||
if (user.isDeleted) return null;
|
|
||||||
|
|
||||||
return {
|
|
||||||
user,
|
|
||||||
key,
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* AP Actor id => Misskey User and Key
|
* AP Actor id => Misskey User and Key
|
||||||
|
* @param uri AP Actor id
|
||||||
|
* @param keyId Key id to find. If not specified, main key will be selected.
|
||||||
|
* @returns
|
||||||
|
* 1. `null` if the user and key host do not match
|
||||||
|
* 2. `{ user: null, key: null }` if the user is not found
|
||||||
|
* 3. `{ user: MiRemoteUser, key: null }` if key is not found
|
||||||
|
* 4. `{ user: MiRemoteUser, key: MiUserPublickey }` if both are found
|
||||||
*/
|
*/
|
||||||
@bindThis
|
@bindThis
|
||||||
public async getAuthUserFromApId(uri: string): Promise<{
|
public async getAuthUserFromApId(uri: string, keyId?: string): Promise<{
|
||||||
user: MiRemoteUser;
|
user: MiRemoteUser;
|
||||||
key: MiUserPublickey | null;
|
key: MiUserPublickey | null;
|
||||||
} | null> {
|
} | {
|
||||||
const user = await this.apPersonService.resolvePerson(uri) as MiRemoteUser;
|
user: null;
|
||||||
if (user.isDeleted) return null;
|
key: null;
|
||||||
|
} |
|
||||||
|
null> {
|
||||||
|
if (keyId) {
|
||||||
|
if (this.punyHost(uri) !== this.punyHost(keyId)) {
|
||||||
|
/**
|
||||||
|
* keyIdはURL形式かつkeyIdのホストはuriのホストと一致するはず
|
||||||
|
* (ApPersonService.validateActorに由来)
|
||||||
|
*
|
||||||
|
* ただ、Mastodonはリプライ関連で他人のトゥートをHTTP Signature署名して送ってくることがある
|
||||||
|
* そのような署名は有効性に疑問があるので無視することにする
|
||||||
|
* ここではuriとkeyIdのホストが一致しない場合は無視する
|
||||||
|
* ハッシュをなくしたkeyIdとuriの同一性を比べてみてもいいが、`uri#*-key`というkeyIdを設定するのが
|
||||||
|
* 決まりごとというわけでもないため幅を持たせることにする
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* The keyId should be in URL format and its host should match the host of the uri
|
||||||
|
* (derived from ApPersonService.validateActor)
|
||||||
|
*
|
||||||
|
* However, Mastodon sometimes sends toots from other users with HTTP Signature signing for reply-related purposes
|
||||||
|
* Such signatures are of questionable validity, so we choose to ignore them
|
||||||
|
* Here, we ignore cases where the hosts of uri and keyId do not match
|
||||||
|
* We could also compare the equality of keyId without the hash and uri, but since setting a keyId like `uri#*-key`
|
||||||
|
* is not a strict rule, we decide to allow for some flexibility
|
||||||
|
*/
|
||||||
|
this.logger.warn(`actor uri and keyId are not matched uri=${uri} keyId=${keyId}`);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const key = await this.publicKeyByUserIdCache.fetch(
|
const user = await this.apPersonService.resolvePerson(uri, undefined, true) as MiRemoteUser;
|
||||||
user.id,
|
if (user.isDeleted) return { user: null, key: null };
|
||||||
() => this.userPublickeysRepository.findOneBy({ userId: user.id }),
|
|
||||||
|
const keys = await this.getPublicKeyByUserId(user.id);
|
||||||
|
|
||||||
|
if (keys == null || !Array.isArray(keys) || keys.length === 0) {
|
||||||
|
this.logger.warn(`No key found uri=${uri} userId=${user.id} keys=${JSON.stringify(keys)}`);
|
||||||
|
return { user, key: null };
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!keyId) {
|
||||||
|
// Choose the main-like
|
||||||
|
const mainKey = keys.find(x => {
|
||||||
|
try {
|
||||||
|
const url = new URL(x.keyId);
|
||||||
|
const path = url.pathname.split('/').pop()?.toLowerCase();
|
||||||
|
if (url.hash) {
|
||||||
|
if (url.hash.toLowerCase().includes('main')) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
} else if (path?.includes('main') || path === 'publickey') {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
} catch { /* noop */ }
|
||||||
|
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
return { user, key: mainKey ?? keys[0] };
|
||||||
|
}
|
||||||
|
|
||||||
|
const exactKey = keys.find(x => x.keyId === keyId);
|
||||||
|
if (exactKey) return { user, key: exactKey };
|
||||||
|
|
||||||
|
/**
|
||||||
|
* keyIdで見つからない場合、まずはキャッシュを更新して再取得
|
||||||
|
* If not found with keyId, update cache and reacquire
|
||||||
|
*/
|
||||||
|
const cacheRaw = this.publicKeyByUserIdCache.cache.get(user.id);
|
||||||
|
if (cacheRaw && cacheRaw.date > Date.now() - 1000 * 60 * 12) {
|
||||||
|
const exactKey = await this.refreshAndFindKey(user.id, keyId);
|
||||||
|
if (exactKey) return { user, key: exactKey };
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* lastFetchedAtでの更新制限を弱めて再取得
|
||||||
|
* Reacquisition with weakened update limit at lastFetchedAt
|
||||||
|
*/
|
||||||
|
if (user.lastFetchedAt == null || user.lastFetchedAt < new Date(Date.now() - 1000 * 60 * 12)) {
|
||||||
|
this.logger.info(`Fetching user to find public key uri=${uri} userId=${user.id} keyId=${keyId}`);
|
||||||
|
const renewed = await this.apPersonService.fetchPersonWithRenewal(uri, 0);
|
||||||
|
if (renewed == null || renewed.isDeleted) return null;
|
||||||
|
|
||||||
|
return { user, key: await this.refreshAndFindKey(user.id, keyId) };
|
||||||
|
}
|
||||||
|
|
||||||
|
this.logger.warn(`No key found uri=${uri} userId=${user.id} keyId=${keyId}`);
|
||||||
|
return { user, key: null };
|
||||||
|
}
|
||||||
|
|
||||||
|
@bindThis
|
||||||
|
public async getPublicKeyByUserId(userId: MiUser['id']): Promise<MiUserPublickey[] | null> {
|
||||||
|
return await this.publicKeyByUserIdCache.fetch(
|
||||||
|
userId,
|
||||||
|
() => this.userPublickeysRepository.find({ where: { userId } }),
|
||||||
v => v != null,
|
v => v != null,
|
||||||
);
|
);
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
@bindThis
|
||||||
user,
|
public refreshCacheByUserId(userId: MiUser['id']): void {
|
||||||
key,
|
this.publicKeyByUserIdCache.delete(userId);
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@bindThis
|
@bindThis
|
||||||
public dispose(): void {
|
public dispose(): void {
|
||||||
this.publicKeyCache.dispose();
|
|
||||||
this.publicKeyByUserIdCache.dispose();
|
this.publicKeyByUserIdCache.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9,10 +9,14 @@ import { DI } from '@/di-symbols.js';
|
|||||||
import type { FollowingsRepository } from '@/models/_.js';
|
import type { FollowingsRepository } from '@/models/_.js';
|
||||||
import type { MiLocalUser, MiRemoteUser, MiUser } from '@/models/User.js';
|
import type { MiLocalUser, MiRemoteUser, MiUser } from '@/models/User.js';
|
||||||
import { QueueService } from '@/core/QueueService.js';
|
import { QueueService } from '@/core/QueueService.js';
|
||||||
import { UserEntityService } from '@/core/entities/UserEntityService.js';
|
|
||||||
import { bindThis } from '@/decorators.js';
|
import { bindThis } from '@/decorators.js';
|
||||||
import type { IActivity } from '@/core/activitypub/type.js';
|
import type { IActivity } from '@/core/activitypub/type.js';
|
||||||
import { ThinUser } from '@/queue/types.js';
|
import { ThinUser } from '@/queue/types.js';
|
||||||
|
import { AccountUpdateService } from '@/core/AccountUpdateService.js';
|
||||||
|
import type Logger from '@/logger.js';
|
||||||
|
import { UserKeypairService } from '../UserKeypairService.js';
|
||||||
|
import { ApLoggerService } from './ApLoggerService.js';
|
||||||
|
import type { PrivateKeyWithPem } from '@misskey-dev/node-http-message-signatures';
|
||||||
|
|
||||||
interface IRecipe {
|
interface IRecipe {
|
||||||
type: string;
|
type: string;
|
||||||
@ -27,12 +31,19 @@ interface IDirectRecipe extends IRecipe {
|
|||||||
to: MiRemoteUser;
|
to: MiRemoteUser;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
interface IAllKnowingSharedInboxRecipe extends IRecipe {
|
||||||
|
type: 'AllKnowingSharedInbox';
|
||||||
|
}
|
||||||
|
|
||||||
const isFollowers = (recipe: IRecipe): recipe is IFollowersRecipe =>
|
const isFollowers = (recipe: IRecipe): recipe is IFollowersRecipe =>
|
||||||
recipe.type === 'Followers';
|
recipe.type === 'Followers';
|
||||||
|
|
||||||
const isDirect = (recipe: IRecipe): recipe is IDirectRecipe =>
|
const isDirect = (recipe: IRecipe): recipe is IDirectRecipe =>
|
||||||
recipe.type === 'Direct';
|
recipe.type === 'Direct';
|
||||||
|
|
||||||
|
const isAllKnowingSharedInbox = (recipe: IRecipe): recipe is IAllKnowingSharedInboxRecipe =>
|
||||||
|
recipe.type === 'AllKnowingSharedInbox';
|
||||||
|
|
||||||
class DeliverManager {
|
class DeliverManager {
|
||||||
private actor: ThinUser;
|
private actor: ThinUser;
|
||||||
private activity: IActivity | null;
|
private activity: IActivity | null;
|
||||||
@ -40,16 +51,18 @@ class DeliverManager {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
* @param userEntityService
|
* @param userKeypairService
|
||||||
* @param followingsRepository
|
* @param followingsRepository
|
||||||
* @param queueService
|
* @param queueService
|
||||||
* @param actor Actor
|
* @param actor Actor
|
||||||
* @param activity Activity to deliver
|
* @param activity Activity to deliver
|
||||||
*/
|
*/
|
||||||
constructor(
|
constructor(
|
||||||
private userEntityService: UserEntityService,
|
private userKeypairService: UserKeypairService,
|
||||||
private followingsRepository: FollowingsRepository,
|
private followingsRepository: FollowingsRepository,
|
||||||
private queueService: QueueService,
|
private queueService: QueueService,
|
||||||
|
private accountUpdateService: AccountUpdateService,
|
||||||
|
private logger: Logger,
|
||||||
|
|
||||||
actor: { id: MiUser['id']; host: null; },
|
actor: { id: MiUser['id']; host: null; },
|
||||||
activity: IActivity | null,
|
activity: IActivity | null,
|
||||||
@ -91,6 +104,18 @@ class DeliverManager {
|
|||||||
this.addRecipe(recipe);
|
this.addRecipe(recipe);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add recipe for all-knowing shared inbox deliver
|
||||||
|
*/
|
||||||
|
@bindThis
|
||||||
|
public addAllKnowingSharedInboxRecipe(): void {
|
||||||
|
const deliver: IAllKnowingSharedInboxRecipe = {
|
||||||
|
type: 'AllKnowingSharedInbox',
|
||||||
|
};
|
||||||
|
|
||||||
|
this.addRecipe(deliver);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add recipe
|
* Add recipe
|
||||||
* @param recipe Recipe
|
* @param recipe Recipe
|
||||||
@ -104,11 +129,44 @@ class DeliverManager {
|
|||||||
* Execute delivers
|
* Execute delivers
|
||||||
*/
|
*/
|
||||||
@bindThis
|
@bindThis
|
||||||
public async execute(): Promise<void> {
|
public async execute(opts?: { privateKey?: PrivateKeyWithPem }): Promise<void> {
|
||||||
|
//#region MIGRATION
|
||||||
|
if (!opts?.privateKey) {
|
||||||
|
/**
|
||||||
|
* ed25519の署名がなければ追加する
|
||||||
|
*/
|
||||||
|
const created = await this.userKeypairService.refreshAndPrepareEd25519KeyPair(this.actor.id);
|
||||||
|
if (created) {
|
||||||
|
// createdが存在するということは新規作成されたということなので、フォロワーに配信する
|
||||||
|
this.logger.info(`ed25519 key pair created for user ${this.actor.id} and publishing to followers`);
|
||||||
|
// リモートに配信
|
||||||
|
const keyPair = await this.userKeypairService.getLocalUserPrivateKeyPem(created, 'main');
|
||||||
|
await this.accountUpdateService.publishToFollowers(this.actor.id, keyPair);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//#endregion
|
||||||
|
|
||||||
|
//#region collect inboxes by recipes
|
||||||
// The value flags whether it is shared or not.
|
// The value flags whether it is shared or not.
|
||||||
// key: inbox URL, value: whether it is sharedInbox
|
// key: inbox URL, value: whether it is sharedInbox
|
||||||
const inboxes = new Map<string, boolean>();
|
const inboxes = new Map<string, boolean>();
|
||||||
|
|
||||||
|
if (this.recipes.some(r => isAllKnowingSharedInbox(r))) {
|
||||||
|
// all-knowing shared inbox
|
||||||
|
const followings = await this.followingsRepository.find({
|
||||||
|
where: [
|
||||||
|
{ followerSharedInbox: Not(IsNull()) },
|
||||||
|
{ followeeSharedInbox: Not(IsNull()) },
|
||||||
|
],
|
||||||
|
select: ['followerSharedInbox', 'followeeSharedInbox'],
|
||||||
|
});
|
||||||
|
|
||||||
|
for (const following of followings) {
|
||||||
|
if (following.followeeSharedInbox) inboxes.set(following.followeeSharedInbox, true);
|
||||||
|
if (following.followerSharedInbox) inboxes.set(following.followerSharedInbox, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// build inbox list
|
// build inbox list
|
||||||
// Process follower recipes first to avoid duplication when processing direct recipes later.
|
// Process follower recipes first to avoid duplication when processing direct recipes later.
|
||||||
if (this.recipes.some(r => isFollowers(r))) {
|
if (this.recipes.some(r => isFollowers(r))) {
|
||||||
@ -142,39 +200,49 @@ class DeliverManager {
|
|||||||
|
|
||||||
inboxes.set(recipe.to.inbox, false);
|
inboxes.set(recipe.to.inbox, false);
|
||||||
}
|
}
|
||||||
|
//#endregion
|
||||||
|
|
||||||
// deliver
|
// deliver
|
||||||
await this.queueService.deliverMany(this.actor, this.activity, inboxes);
|
await this.queueService.deliverMany(this.actor, this.activity, inboxes, opts?.privateKey);
|
||||||
|
this.logger.info(`Deliver queues dispatched: inboxes=${inboxes.size} actorId=${this.actor.id} activityId=${this.activity?.id}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class ApDeliverManagerService {
|
export class ApDeliverManagerService {
|
||||||
|
private logger: Logger;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
@Inject(DI.followingsRepository)
|
@Inject(DI.followingsRepository)
|
||||||
private followingsRepository: FollowingsRepository,
|
private followingsRepository: FollowingsRepository,
|
||||||
|
|
||||||
private userEntityService: UserEntityService,
|
private userKeypairService: UserKeypairService,
|
||||||
private queueService: QueueService,
|
private queueService: QueueService,
|
||||||
|
private accountUpdateService: AccountUpdateService,
|
||||||
|
private apLoggerService: ApLoggerService,
|
||||||
) {
|
) {
|
||||||
|
this.logger = this.apLoggerService.logger.createSubLogger('deliver-manager');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Deliver activity to followers
|
* Deliver activity to followers
|
||||||
* @param actor
|
* @param actor
|
||||||
* @param activity Activity
|
* @param activity Activity
|
||||||
|
* @param forceMainKey Force to use main (rsa) key
|
||||||
*/
|
*/
|
||||||
@bindThis
|
@bindThis
|
||||||
public async deliverToFollowers(actor: { id: MiLocalUser['id']; host: null; }, activity: IActivity): Promise<void> {
|
public async deliverToFollowers(actor: { id: MiLocalUser['id']; host: null; }, activity: IActivity, privateKey?: PrivateKeyWithPem): Promise<void> {
|
||||||
const manager = new DeliverManager(
|
const manager = new DeliverManager(
|
||||||
this.userEntityService,
|
this.userKeypairService,
|
||||||
this.followingsRepository,
|
this.followingsRepository,
|
||||||
this.queueService,
|
this.queueService,
|
||||||
|
this.accountUpdateService,
|
||||||
|
this.logger,
|
||||||
actor,
|
actor,
|
||||||
activity,
|
activity,
|
||||||
);
|
);
|
||||||
manager.addFollowersRecipe();
|
manager.addFollowersRecipe();
|
||||||
await manager.execute();
|
await manager.execute({ privateKey });
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -186,9 +254,11 @@ export class ApDeliverManagerService {
|
|||||||
@bindThis
|
@bindThis
|
||||||
public async deliverToUser(actor: { id: MiLocalUser['id']; host: null; }, activity: IActivity, to: MiRemoteUser): Promise<void> {
|
public async deliverToUser(actor: { id: MiLocalUser['id']; host: null; }, activity: IActivity, to: MiRemoteUser): Promise<void> {
|
||||||
const manager = new DeliverManager(
|
const manager = new DeliverManager(
|
||||||
this.userEntityService,
|
this.userKeypairService,
|
||||||
this.followingsRepository,
|
this.followingsRepository,
|
||||||
this.queueService,
|
this.queueService,
|
||||||
|
this.accountUpdateService,
|
||||||
|
this.logger,
|
||||||
actor,
|
actor,
|
||||||
activity,
|
activity,
|
||||||
);
|
);
|
||||||
@ -199,10 +269,11 @@ export class ApDeliverManagerService {
|
|||||||
@bindThis
|
@bindThis
|
||||||
public createDeliverManager(actor: { id: MiUser['id']; host: null; }, activity: IActivity | null): DeliverManager {
|
public createDeliverManager(actor: { id: MiUser['id']; host: null; }, activity: IActivity | null): DeliverManager {
|
||||||
return new DeliverManager(
|
return new DeliverManager(
|
||||||
this.userEntityService,
|
this.userKeypairService,
|
||||||
this.followingsRepository,
|
this.followingsRepository,
|
||||||
this.queueService,
|
this.queueService,
|
||||||
|
this.accountUpdateService,
|
||||||
|
this.logger,
|
||||||
actor,
|
actor,
|
||||||
activity,
|
activity,
|
||||||
);
|
);
|
||||||
|
@ -27,8 +27,8 @@ import { QueueService } from '@/core/QueueService.js';
|
|||||||
import type { UsersRepository, NotesRepository, FollowingsRepository, AbuseUserReportsRepository, FollowRequestsRepository } from '@/models/_.js';
|
import type { UsersRepository, NotesRepository, FollowingsRepository, AbuseUserReportsRepository, FollowRequestsRepository } from '@/models/_.js';
|
||||||
import { bindThis } from '@/decorators.js';
|
import { bindThis } from '@/decorators.js';
|
||||||
import type { MiRemoteUser } from '@/models/User.js';
|
import type { MiRemoteUser } from '@/models/User.js';
|
||||||
import { isNotNull } from '@/misc/is-not-null.js';
|
|
||||||
import { GlobalEventService } from '@/core/GlobalEventService.js';
|
import { GlobalEventService } from '@/core/GlobalEventService.js';
|
||||||
|
import { AbuseReportService } from '@/core/AbuseReportService.js';
|
||||||
import { getApHrefNullable, getApId, getApIds, getApType, isAccept, isActor, isAdd, isAnnounce, isBlock, isCollection, isCollectionOrOrderedCollection, isCreate, isDelete, isFlag, isFollow, isLike, isMove, isPost, isReject, isRemove, isTombstone, isUndo, isUpdate, validActor, validPost } from './type.js';
|
import { getApHrefNullable, getApId, getApIds, getApType, isAccept, isActor, isAdd, isAnnounce, isBlock, isCollection, isCollectionOrOrderedCollection, isCreate, isDelete, isFlag, isFollow, isLike, isMove, isPost, isReject, isRemove, isTombstone, isUndo, isUpdate, validActor, validPost } from './type.js';
|
||||||
import { ApNoteService } from './models/ApNoteService.js';
|
import { ApNoteService } from './models/ApNoteService.js';
|
||||||
import { ApLoggerService } from './ApLoggerService.js';
|
import { ApLoggerService } from './ApLoggerService.js';
|
||||||
@ -57,9 +57,6 @@ export class ApInboxService {
|
|||||||
@Inject(DI.followingsRepository)
|
@Inject(DI.followingsRepository)
|
||||||
private followingsRepository: FollowingsRepository,
|
private followingsRepository: FollowingsRepository,
|
||||||
|
|
||||||
@Inject(DI.abuseUserReportsRepository)
|
|
||||||
private abuseUserReportsRepository: AbuseUserReportsRepository,
|
|
||||||
|
|
||||||
@Inject(DI.followRequestsRepository)
|
@Inject(DI.followRequestsRepository)
|
||||||
private followRequestsRepository: FollowRequestsRepository,
|
private followRequestsRepository: FollowRequestsRepository,
|
||||||
|
|
||||||
@ -68,6 +65,7 @@ export class ApInboxService {
|
|||||||
private utilityService: UtilityService,
|
private utilityService: UtilityService,
|
||||||
private idService: IdService,
|
private idService: IdService,
|
||||||
private metaService: MetaService,
|
private metaService: MetaService,
|
||||||
|
private abuseReportService: AbuseReportService,
|
||||||
private userFollowingService: UserFollowingService,
|
private userFollowingService: UserFollowingService,
|
||||||
private apAudienceService: ApAudienceService,
|
private apAudienceService: ApAudienceService,
|
||||||
private reactionService: ReactionService,
|
private reactionService: ReactionService,
|
||||||
@ -116,15 +114,8 @@ export class ApInboxService {
|
|||||||
result = await this.performOneActivity(actor, activity);
|
result = await this.performOneActivity(actor, activity);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ついでにリモートユーザーの情報が古かったら更新しておく
|
// ついでにリモートユーザーの情報が古かったら更新しておく?
|
||||||
if (actor.uri) {
|
// → No, この関数が呼び出される前に署名検証で更新されているはず
|
||||||
if (actor.lastFetchedAt == null || Date.now() - actor.lastFetchedAt.getTime() > 1000 * 60 * 60 * 24) {
|
|
||||||
setImmediate(() => {
|
|
||||||
this.apPersonService.updatePerson(actor.uri);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@bindThis
|
@bindThis
|
||||||
@ -539,20 +530,19 @@ export class ApInboxService {
|
|||||||
const userIds = uris
|
const userIds = uris
|
||||||
.filter(uri => uri.startsWith(this.config.url + '/users/'))
|
.filter(uri => uri.startsWith(this.config.url + '/users/'))
|
||||||
.map(uri => uri.split('/').at(-1))
|
.map(uri => uri.split('/').at(-1))
|
||||||
.filter(isNotNull);
|
.filter(x => x != null);
|
||||||
const users = await this.usersRepository.findBy({
|
const users = await this.usersRepository.findBy({
|
||||||
id: In(userIds),
|
id: In(userIds),
|
||||||
});
|
});
|
||||||
if (users.length < 1) return 'skip';
|
if (users.length < 1) return 'skip';
|
||||||
|
|
||||||
await this.abuseUserReportsRepository.insert({
|
await this.abuseReportService.report([{
|
||||||
id: this.idService.gen(),
|
|
||||||
targetUserId: users[0].id,
|
targetUserId: users[0].id,
|
||||||
targetUserHost: users[0].host,
|
targetUserHost: users[0].host,
|
||||||
reporterId: actor.id,
|
reporterId: actor.id,
|
||||||
reporterHost: actor.host,
|
reporterHost: actor.host,
|
||||||
comment: `${activity.content}\n${JSON.stringify(uris, null, 2)}`,
|
comment: `${activity.content}\n${JSON.stringify(uris, null, 2)}`,
|
||||||
});
|
}]);
|
||||||
|
|
||||||
return 'ok';
|
return 'ok';
|
||||||
}
|
}
|
||||||
|
@ -25,7 +25,7 @@ export class ApMfmService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@bindThis
|
@bindThis
|
||||||
public getNoteHtml(note: MiNote, apAppend?: string) {
|
public getNoteHtml(note: Pick<MiNote, 'text' | 'mentionedRemoteUsers'>, apAppend?: string) {
|
||||||
let noMisskeyContent = false;
|
let noMisskeyContent = false;
|
||||||
const srcMfm = (note.text ?? '') + (apAppend ?? '');
|
const srcMfm = (note.text ?? '') + (apAppend ?? '');
|
||||||
|
|
||||||
|
@ -22,16 +22,15 @@ import { UserKeypairService } from '@/core/UserKeypairService.js';
|
|||||||
import { MfmService } from '@/core/MfmService.js';
|
import { MfmService } from '@/core/MfmService.js';
|
||||||
import { UserEntityService } from '@/core/entities/UserEntityService.js';
|
import { UserEntityService } from '@/core/entities/UserEntityService.js';
|
||||||
import { DriveFileEntityService } from '@/core/entities/DriveFileEntityService.js';
|
import { DriveFileEntityService } from '@/core/entities/DriveFileEntityService.js';
|
||||||
import type { MiUserKeypair } from '@/models/UserKeypair.js';
|
|
||||||
import type { UsersRepository, UserProfilesRepository, NotesRepository, DriveFilesRepository, PollsRepository } from '@/models/_.js';
|
import type { UsersRepository, UserProfilesRepository, NotesRepository, DriveFilesRepository, PollsRepository } from '@/models/_.js';
|
||||||
import { bindThis } from '@/decorators.js';
|
import { bindThis } from '@/decorators.js';
|
||||||
import { CustomEmojiService } from '@/core/CustomEmojiService.js';
|
import { CustomEmojiService } from '@/core/CustomEmojiService.js';
|
||||||
import { isNotNull } from '@/misc/is-not-null.js';
|
|
||||||
import { IdService } from '@/core/IdService.js';
|
import { IdService } from '@/core/IdService.js';
|
||||||
import { JsonLdService } from './JsonLdService.js';
|
import { JsonLdService } from './JsonLdService.js';
|
||||||
import { ApMfmService } from './ApMfmService.js';
|
import { ApMfmService } from './ApMfmService.js';
|
||||||
import { CONTEXT } from './misc/contexts.js';
|
import { CONTEXT } from './misc/contexts.js';
|
||||||
import type { IAccept, IActivity, IAdd, IAnnounce, IApDocument, IApEmoji, IApHashtag, IApImage, IApMention, IBlock, ICreate, IDelete, IFlag, IFollow, IKey, ILike, IMove, IObject, IPost, IQuestion, IReject, IRemove, ITombstone, IUndo, IUpdate } from './type.js';
|
import type { IAccept, IActivity, IAdd, IAnnounce, IApDocument, IApEmoji, IApHashtag, IApImage, IApMention, IBlock, ICreate, IDelete, IFlag, IFollow, IKey, ILike, IMove, IObject, IPost, IQuestion, IReject, IRemove, ITombstone, IUndo, IUpdate } from './type.js';
|
||||||
|
import type { PrivateKeyWithPem } from '@misskey-dev/node-http-message-signatures';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class ApRendererService {
|
export class ApRendererService {
|
||||||
@ -252,15 +251,15 @@ export class ApRendererService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@bindThis
|
@bindThis
|
||||||
public renderKey(user: MiLocalUser, key: MiUserKeypair, postfix?: string): IKey {
|
public renderKey(user: MiLocalUser, publicKey: string, postfix?: string): IKey {
|
||||||
return {
|
return {
|
||||||
id: `${this.config.url}/users/${user.id}${postfix ?? '/publickey'}`,
|
id: `${this.userEntityService.genLocalUserUri(user.id)}${postfix ?? '/publickey'}`,
|
||||||
type: 'Key',
|
type: 'Key',
|
||||||
owner: this.userEntityService.genLocalUserUri(user.id),
|
owner: this.userEntityService.genLocalUserUri(user.id),
|
||||||
publicKeyPem: createPublicKey(key.publicKey).export({
|
publicKeyPem: createPublicKey(publicKey).export({
|
||||||
type: 'spki',
|
type: 'spki',
|
||||||
format: 'pem',
|
format: 'pem',
|
||||||
}),
|
}) as string,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -317,7 +316,7 @@ export class ApRendererService {
|
|||||||
const getPromisedFiles = async (ids: string[]): Promise<MiDriveFile[]> => {
|
const getPromisedFiles = async (ids: string[]): Promise<MiDriveFile[]> => {
|
||||||
if (ids.length === 0) return [];
|
if (ids.length === 0) return [];
|
||||||
const items = await this.driveFilesRepository.findBy({ id: In(ids) });
|
const items = await this.driveFilesRepository.findBy({ id: In(ids) });
|
||||||
return ids.map(id => items.find(item => item.id === id)).filter(isNotNull);
|
return ids.map(id => items.find(item => item.id === id)).filter(x => x != null);
|
||||||
};
|
};
|
||||||
|
|
||||||
let inReplyTo;
|
let inReplyTo;
|
||||||
@ -500,7 +499,10 @@ export class ApRendererService {
|
|||||||
tag,
|
tag,
|
||||||
manuallyApprovesFollowers: user.isLocked,
|
manuallyApprovesFollowers: user.isLocked,
|
||||||
discoverable: user.isExplorable,
|
discoverable: user.isExplorable,
|
||||||
publicKey: this.renderKey(user, keypair, '#main-key'),
|
publicKey: this.renderKey(user, keypair.publicKey, '#main-key'),
|
||||||
|
additionalPublicKeys: [
|
||||||
|
...(keypair.ed25519PublicKey ? [this.renderKey(user, keypair.ed25519PublicKey, '#ed25519-key')] : []),
|
||||||
|
],
|
||||||
isCat: user.isCat,
|
isCat: user.isCat,
|
||||||
attachment: attachment.length ? attachment : undefined,
|
attachment: attachment.length ? attachment : undefined,
|
||||||
};
|
};
|
||||||
@ -623,12 +625,10 @@ export class ApRendererService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@bindThis
|
@bindThis
|
||||||
public async attachLdSignature(activity: any, user: { id: MiUser['id']; host: null; }): Promise<IActivity> {
|
public async attachLdSignature(activity: any, key: PrivateKeyWithPem): Promise<IActivity> {
|
||||||
const keypair = await this.userKeypairService.getUserKeypair(user.id);
|
|
||||||
|
|
||||||
const jsonLd = this.jsonLdService.use();
|
const jsonLd = this.jsonLdService.use();
|
||||||
jsonLd.debug = false;
|
jsonLd.debug = false;
|
||||||
activity = await jsonLd.signRsaSignature2017(activity, keypair.privateKey, `${this.config.url}/users/${user.id}#main-key`);
|
activity = await jsonLd.signRsaSignature2017(activity, key.privateKeyPem, key.keyId);
|
||||||
|
|
||||||
return activity;
|
return activity;
|
||||||
}
|
}
|
||||||
@ -686,7 +686,7 @@ export class ApRendererService {
|
|||||||
if (names.length === 0) return [];
|
if (names.length === 0) return [];
|
||||||
|
|
||||||
const allEmojis = await this.customEmojiService.localEmojisCache.fetch();
|
const allEmojis = await this.customEmojiService.localEmojisCache.fetch();
|
||||||
const emojis = names.map(name => allEmojis.get(name)).filter(isNotNull);
|
const emojis = names.map(name => allEmojis.get(name)).filter(x => x != null);
|
||||||
|
|
||||||
return emojis;
|
return emojis;
|
||||||
}
|
}
|
||||||
|
@ -3,9 +3,9 @@
|
|||||||
* SPDX-License-Identifier: AGPL-3.0-only
|
* SPDX-License-Identifier: AGPL-3.0-only
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import * as crypto from 'node:crypto';
|
|
||||||
import { URL } from 'node:url';
|
import { URL } from 'node:url';
|
||||||
import { Inject, Injectable } from '@nestjs/common';
|
import { Inject, Injectable } from '@nestjs/common';
|
||||||
|
import { genRFC3230DigestHeader, signAsDraftToRequest } from '@misskey-dev/node-http-message-signatures';
|
||||||
import { DI } from '@/di-symbols.js';
|
import { DI } from '@/di-symbols.js';
|
||||||
import type { Config } from '@/config.js';
|
import type { Config } from '@/config.js';
|
||||||
import type { MiUser } from '@/models/User.js';
|
import type { MiUser } from '@/models/User.js';
|
||||||
@ -15,122 +15,61 @@ import { LoggerService } from '@/core/LoggerService.js';
|
|||||||
import { bindThis } from '@/decorators.js';
|
import { bindThis } from '@/decorators.js';
|
||||||
import type Logger from '@/logger.js';
|
import type Logger from '@/logger.js';
|
||||||
import { validateContentTypeSetAsActivityPub } from '@/core/activitypub/misc/validator.js';
|
import { validateContentTypeSetAsActivityPub } from '@/core/activitypub/misc/validator.js';
|
||||||
|
import type { PrivateKeyWithPem, PrivateKey } from '@misskey-dev/node-http-message-signatures';
|
||||||
|
|
||||||
type Request = {
|
export async function createSignedPost(args: { level: string; key: PrivateKey; url: string; body: string; digest?: string, additionalHeaders: Record<string, string> }) {
|
||||||
url: string;
|
|
||||||
method: string;
|
|
||||||
headers: Record<string, string>;
|
|
||||||
};
|
|
||||||
|
|
||||||
type Signed = {
|
|
||||||
request: Request;
|
|
||||||
signingString: string;
|
|
||||||
signature: string;
|
|
||||||
signatureHeader: string;
|
|
||||||
};
|
|
||||||
|
|
||||||
type PrivateKey = {
|
|
||||||
privateKeyPem: string;
|
|
||||||
keyId: string;
|
|
||||||
};
|
|
||||||
|
|
||||||
export class ApRequestCreator {
|
|
||||||
static createSignedPost(args: { key: PrivateKey, url: string, body: string, digest?: string, additionalHeaders: Record<string, string> }): Signed {
|
|
||||||
const u = new URL(args.url);
|
const u = new URL(args.url);
|
||||||
const digestHeader = args.digest ?? this.createDigest(args.body);
|
const request = {
|
||||||
|
|
||||||
const request: Request = {
|
|
||||||
url: u.href,
|
url: u.href,
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: this.#objectAssignWithLcKey({
|
headers: {
|
||||||
'Date': new Date().toUTCString(),
|
'Date': new Date().toUTCString(),
|
||||||
'Host': u.host,
|
'Host': u.host,
|
||||||
'Content-Type': 'application/activity+json',
|
'Content-Type': 'application/activity+json',
|
||||||
'Digest': digestHeader,
|
...args.additionalHeaders,
|
||||||
}, args.additionalHeaders),
|
} as Record<string, string>,
|
||||||
};
|
};
|
||||||
|
|
||||||
const result = this.#signToRequest(request, args.key, ['(request-target)', 'date', 'host', 'digest']);
|
// TODO: httpMessageSignaturesImplementationLevelによって新規格で通信をするようにする
|
||||||
|
const digestHeader = args.digest ?? await genRFC3230DigestHeader(args.body, 'SHA-256');
|
||||||
|
request.headers['Digest'] = digestHeader;
|
||||||
|
|
||||||
|
const result = await signAsDraftToRequest(
|
||||||
|
request,
|
||||||
|
args.key,
|
||||||
|
['(request-target)', 'date', 'host', 'digest'],
|
||||||
|
);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
request,
|
request,
|
||||||
signingString: result.signingString,
|
...result,
|
||||||
signature: result.signature,
|
|
||||||
signatureHeader: result.signatureHeader,
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
static createDigest(body: string) {
|
export async function createSignedGet(args: { level: string; key: PrivateKey; url: string; additionalHeaders: Record<string, string> }) {
|
||||||
return `SHA-256=${crypto.createHash('sha256').update(body).digest('base64')}`;
|
|
||||||
}
|
|
||||||
|
|
||||||
static createSignedGet(args: { key: PrivateKey, url: string, additionalHeaders: Record<string, string> }): Signed {
|
|
||||||
const u = new URL(args.url);
|
const u = new URL(args.url);
|
||||||
|
const request = {
|
||||||
const request: Request = {
|
|
||||||
url: u.href,
|
url: u.href,
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
headers: this.#objectAssignWithLcKey({
|
headers: {
|
||||||
'Accept': 'application/activity+json, application/ld+json; profile="https://www.w3.org/ns/activitystreams"',
|
'Accept': 'application/activity+json, application/ld+json; profile="https://www.w3.org/ns/activitystreams"',
|
||||||
'Date': new Date().toUTCString(),
|
'Date': new Date().toUTCString(),
|
||||||
'Host': new URL(args.url).host,
|
'Host': new URL(args.url).host,
|
||||||
}, args.additionalHeaders),
|
...args.additionalHeaders,
|
||||||
|
} as Record<string, string>,
|
||||||
};
|
};
|
||||||
|
|
||||||
const result = this.#signToRequest(request, args.key, ['(request-target)', 'date', 'host', 'accept']);
|
// TODO: httpMessageSignaturesImplementationLevelによって新規格で通信をするようにする
|
||||||
|
const result = await signAsDraftToRequest(
|
||||||
|
request,
|
||||||
|
args.key,
|
||||||
|
['(request-target)', 'date', 'host', 'accept'],
|
||||||
|
);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
request,
|
request,
|
||||||
signingString: result.signingString,
|
...result,
|
||||||
signature: result.signature,
|
|
||||||
signatureHeader: result.signatureHeader,
|
|
||||||
};
|
};
|
||||||
}
|
|
||||||
|
|
||||||
static #signToRequest(request: Request, key: PrivateKey, includeHeaders: string[]): Signed {
|
|
||||||
const signingString = this.#genSigningString(request, includeHeaders);
|
|
||||||
const signature = crypto.sign('sha256', Buffer.from(signingString), key.privateKeyPem).toString('base64');
|
|
||||||
const signatureHeader = `keyId="${key.keyId}",algorithm="rsa-sha256",headers="${includeHeaders.join(' ')}",signature="${signature}"`;
|
|
||||||
|
|
||||||
request.headers = this.#objectAssignWithLcKey(request.headers, {
|
|
||||||
Signature: signatureHeader,
|
|
||||||
});
|
|
||||||
// node-fetch will generate this for us. if we keep 'Host', it won't change with redirects!
|
|
||||||
delete request.headers['host'];
|
|
||||||
|
|
||||||
return {
|
|
||||||
request,
|
|
||||||
signingString,
|
|
||||||
signature,
|
|
||||||
signatureHeader,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
static #genSigningString(request: Request, includeHeaders: string[]): string {
|
|
||||||
request.headers = this.#lcObjectKey(request.headers);
|
|
||||||
|
|
||||||
const results: string[] = [];
|
|
||||||
|
|
||||||
for (const key of includeHeaders.map(x => x.toLowerCase())) {
|
|
||||||
if (key === '(request-target)') {
|
|
||||||
results.push(`(request-target): ${request.method.toLowerCase()} ${new URL(request.url).pathname}`);
|
|
||||||
} else {
|
|
||||||
results.push(`${key}: ${request.headers[key]}`);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return results.join('\n');
|
|
||||||
}
|
|
||||||
|
|
||||||
static #lcObjectKey(src: Record<string, string>): Record<string, string> {
|
|
||||||
const dst: Record<string, string> = {};
|
|
||||||
for (const key of Object.keys(src).filter(x => x !== '__proto__' && typeof src[x] === 'string')) dst[key.toLowerCase()] = src[key];
|
|
||||||
return dst;
|
|
||||||
}
|
|
||||||
|
|
||||||
static #objectAssignWithLcKey(a: Record<string, string>, b: Record<string, string>): Record<string, string> {
|
|
||||||
return Object.assign(this.#lcObjectKey(a), this.#lcObjectKey(b));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
@ -150,21 +89,28 @@ export class ApRequestService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@bindThis
|
@bindThis
|
||||||
public async signedPost(user: { id: MiUser['id'] }, url: string, object: unknown, digest?: string): Promise<void> {
|
public async signedPost(user: { id: MiUser['id'] }, url: string, object: unknown, level: string, digest?: string, key?: PrivateKeyWithPem): Promise<void> {
|
||||||
const body = typeof object === 'string' ? object : JSON.stringify(object);
|
const body = typeof object === 'string' ? object : JSON.stringify(object);
|
||||||
|
const keyFetched = await this.userKeypairService.getLocalUserPrivateKey(key ?? user.id, level);
|
||||||
const keypair = await this.userKeypairService.getUserKeypair(user.id);
|
const req = await createSignedPost({
|
||||||
|
level,
|
||||||
const req = ApRequestCreator.createSignedPost({
|
key: keyFetched,
|
||||||
key: {
|
|
||||||
privateKeyPem: keypair.privateKey,
|
|
||||||
keyId: `${this.config.url}/users/${user.id}#main-key`,
|
|
||||||
},
|
|
||||||
url,
|
url,
|
||||||
body,
|
body,
|
||||||
digest,
|
|
||||||
additionalHeaders: {
|
additionalHeaders: {
|
||||||
|
'User-Agent': this.config.userAgent,
|
||||||
},
|
},
|
||||||
|
digest,
|
||||||
|
});
|
||||||
|
|
||||||
|
// node-fetch will generate this for us. if we keep 'Host', it won't change with redirects!
|
||||||
|
delete req.request.headers['Host'];
|
||||||
|
|
||||||
|
this.logger.debug('create signed post', {
|
||||||
|
version: 'draft',
|
||||||
|
level,
|
||||||
|
url,
|
||||||
|
keyId: keyFetched.keyId,
|
||||||
});
|
});
|
||||||
|
|
||||||
await this.httpRequestService.send(url, {
|
await this.httpRequestService.send(url, {
|
||||||
@ -180,19 +126,27 @@ export class ApRequestService {
|
|||||||
* @param url URL to fetch
|
* @param url URL to fetch
|
||||||
*/
|
*/
|
||||||
@bindThis
|
@bindThis
|
||||||
public async signedGet(url: string, user: { id: MiUser['id'] }): Promise<unknown> {
|
public async signedGet(url: string, user: { id: MiUser['id'] }, level: string): Promise<unknown> {
|
||||||
const keypair = await this.userKeypairService.getUserKeypair(user.id);
|
const key = await this.userKeypairService.getLocalUserPrivateKey(user.id, level);
|
||||||
|
const req = await createSignedGet({
|
||||||
const req = ApRequestCreator.createSignedGet({
|
level,
|
||||||
key: {
|
key,
|
||||||
privateKeyPem: keypair.privateKey,
|
|
||||||
keyId: `${this.config.url}/users/${user.id}#main-key`,
|
|
||||||
},
|
|
||||||
url,
|
url,
|
||||||
additionalHeaders: {
|
additionalHeaders: {
|
||||||
|
'User-Agent': this.config.userAgent,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// node-fetch will generate this for us. if we keep 'Host', it won't change with redirects!
|
||||||
|
delete req.request.headers['Host'];
|
||||||
|
|
||||||
|
this.logger.debug('create signed get', {
|
||||||
|
version: 'draft',
|
||||||
|
level,
|
||||||
|
url,
|
||||||
|
keyId: key.keyId,
|
||||||
|
});
|
||||||
|
|
||||||
const res = await this.httpRequestService.send(url, {
|
const res = await this.httpRequestService.send(url, {
|
||||||
method: req.request.method,
|
method: req.request.method,
|
||||||
headers: req.request.headers,
|
headers: req.request.headers,
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user