diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 3835b4f3f3..824bdd0f3f 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -5,7 +5,7 @@ "workspaceFolder": "/workspace", "features": { "ghcr.io/devcontainers-contrib/features/pnpm:2": { - "version": "8.8.0" + "version": "8.9.2" }, "ghcr.io/devcontainers/features/node:1": { "version": "20.5.1" diff --git a/.github/workflows/api-cherrypick-js.yml b/.github/workflows/api-cherrypick-js.yml index 50380b96ff..7c688dc30b 100644 --- a/.github/workflows/api-cherrypick-js.yml +++ b/.github/workflows/api-cherrypick-js.yml @@ -9,7 +9,7 @@ jobs: steps: - name: Checkout - uses: actions/checkout@v4.1.0 + uses: actions/checkout@v4.1.1 - run: corepack enable diff --git a/.github/workflows/check_copyright_year.yml b/.github/workflows/check_copyright_year.yml index fb04cf1b00..03dfcd0a0b 100644 --- a/.github/workflows/check_copyright_year.yml +++ b/.github/workflows/check_copyright_year.yml @@ -10,7 +10,7 @@ jobs: check_copyright_year: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4.1.0 + - uses: actions/checkout@v4.1.1 - run: | if [ "$(grep Copyright COPYING | sed -e 's/.*2014-\([0-9]*\) .*/\1/g')" -ne "$(date +%Y)" ]; then echo "Please change copyright year!" diff --git a/.github/workflows/docker-develop.yml b/.github/workflows/docker-develop.yml index 07ad0610c0..860100d277 100644 --- a/.github/workflows/docker-develop.yml +++ b/.github/workflows/docker-develop.yml @@ -12,8 +12,19 @@ jobs: runs-on: ubuntu-latest if: github.repository == 'kokonect-link/cherrypick' steps: + - name: Free Disk Space + uses: jlumbroso/free-disk-space@main + with: + # This might remove tools that are actually needed, if set to "true" but frees about 6 GB + tool-cache: false + # All of these default to true, but feel free to set to "false" if necessary for your workflow + android: true + dotnet: true + haskell: true + large-packages: true + swap-storage: true - name: Check out the repo - uses: actions/checkout@v4.1.0 + uses: actions/checkout@v4.1.1 - name: Set up Docker Buildx id: buildx uses: docker/setup-buildx-action@v3.0.0 diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index a167e55daf..0bd12cb2c5 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -11,8 +11,19 @@ jobs: runs-on: ubuntu-latest steps: + - name: Free Disk Space + uses: jlumbroso/free-disk-space@main + with: + # This might remove tools that are actually needed, if set to "true" but frees about 6 GB + tool-cache: false + # All of these default to true, but feel free to set to "false" if necessary for your workflow + android: true + dotnet: true + haskell: true + large-packages: true + swap-storage: true - name: Check out the repo - uses: actions/checkout@v4.1.0 + uses: actions/checkout@v4.1.1 - name: Set up Docker Buildx id: buildx uses: docker/setup-buildx-action@v3.0.0 diff --git a/.github/workflows/dockle.yml b/.github/workflows/dockle.yml index 12dea81c6f..06d4260fda 100644 --- a/.github/workflows/dockle.yml +++ b/.github/workflows/dockle.yml @@ -14,7 +14,7 @@ jobs: env: DOCKER_CONTENT_TRUST: 1 steps: - - uses: actions/checkout@v4.1.0 + - uses: actions/checkout@v4.1.1 - run: | curl -L -o dockle.deb "https://github.com/goodwithtech/dockle/releases/download/v0.4.10/dockle_0.4.10_Linux-64bit.deb" sudo dpkg -i dockle.deb diff --git a/.github/workflows/get-api-diff.yml b/.github/workflows/get-api-diff.yml new file mode 100644 index 0000000000..ae63cca851 --- /dev/null +++ b/.github/workflows/get-api-diff.yml @@ -0,0 +1,225 @@ +name: Report API Diff + +on: + pull_request: + branches: + - master + - develop + +jobs: + get-base: + runs-on: ubuntu-latest + permissions: + contents: read + + strategy: + matrix: + node-version: [20.5.1] + + services: + db: + image: postgres:13 + ports: + - 5432:5432 + env: + POSTGRES_DB: cherrypick + POSTGRES_HOST_AUTH_METHOD: trust + POSTGRES_USER: example-cherrypick-user + POSTGRESS_PASS: example-cherrypick-pass + redis: + image: redis:7 + ports: + - 6379:6379 + + steps: + - uses: actions/checkout@v4.1.1 + with: + repository: ${{ github.event.pull_request.base.repo.full_name }} + ref: ${{ github.base_ref }} + submodules: true + - name: Install pnpm + uses: pnpm/action-setup@v2 + with: + version: 8 + run_install: false + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v3.8.1 + with: + node-version: ${{ matrix.node-version }} + cache: 'pnpm' + - run: corepack enable + - run: pnpm i --frozen-lockfile + - name: Check pnpm-lock.yaml + run: git diff --exit-code pnpm-lock.yaml + - name: Copy Configure + run: cp .config/example.yml .config/default.yml + - name: Build + run: pnpm build + - name : Migrate + run: pnpm migrate + - name: Launch cherrypick + run: | + screen -S cherrypick -dm pnpm run dev + sleep 30s + - name: Wait for CherryPick to be ready + run: | + MAX_RETRIES=12 + RETRY_DELAY=5 + count=0 + until $(curl --output /dev/null --silent --head --fail http://localhost:3000) || [[ $count -eq $MAX_RETRIES ]]; do + printf '.' + sleep $RETRY_DELAY + count=$((count + 1)) + done + + if [[ $count -eq $MAX_RETRIES ]]; then + echo "Failed to connect to CherryPick after $MAX_RETRIES attempts." + exit 1 + fi + - id: fetch + name: Get api.json from CherryPick + run: | + RESULT=$(curl --retry 5 --retry-delay 5 --retry-max-time 60 http://localhost:3000/api.json) + echo $RESULT > api-base.json + - name: Upload Artifact + uses: actions/upload-artifact@v3 + with: + name: api-artifact + path: api-base.json + - name: Kill CherryPick Job + run: screen -S cherrypick -X quit + + get-head: + runs-on: ubuntu-latest + permissions: + contents: read + + strategy: + matrix: + node-version: [20.5.1] + + services: + db: + image: postgres:13 + ports: + - 5432:5432 + env: + POSTGRES_DB: cherrypick + POSTGRES_HOST_AUTH_METHOD: trust + POSTGRES_USER: example-cherrypick-user + POSTGRESS_PASS: example-cherrypick-pass + redis: + image: redis:7 + ports: + - 6379:6379 + + steps: + - uses: actions/checkout@v4.1.1 + with: + repository: ${{ github.event.pull_request.head.repo.full_name }} + ref: ${{ github.head_ref }} + submodules: true + - name: Install pnpm + uses: pnpm/action-setup@v2 + with: + version: 8 + run_install: false + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v3.8.1 + with: + node-version: ${{ matrix.node-version }} + cache: 'pnpm' + - run: corepack enable + - run: pnpm i --frozen-lockfile + - name: Check pnpm-lock.yaml + run: git diff --exit-code pnpm-lock.yaml + - name: Copy Configure + run: cp .config/example.yml .config/default.yml + - name: Build + run: pnpm build + - name : Migrate + run: pnpm migrate + - name: Launch cherrypick + run: | + screen -S cherrypick -dm pnpm run dev + sleep 30s + - name: Wait for CherryPick to be ready + run: | + MAX_RETRIES=12 + RETRY_DELAY=5 + count=0 + until $(curl --output /dev/null --silent --head --fail http://localhost:3000) || [[ $count -eq $MAX_RETRIES ]]; do + printf '.' + sleep $RETRY_DELAY + count=$((count + 1)) + done + + if [[ $count -eq $MAX_RETRIES ]]; then + echo "Failed to connect to CherryPick after $MAX_RETRIES attempts." + exit 1 + fi + - id: fetch + name: Get api.json from CherryPick + run: | + RESULT=$(curl --retry 5 --retry-delay 5 --retry-max-time 60 http://localhost:3000/api.json) + echo $RESULT > api-head.json + - name: Upload Artifact + uses: actions/upload-artifact@v3 + with: + name: api-artifact + path: api-head.json + - name: Kill CherryPick Job + run: screen -S cherrypick -X quit + + compare-diff: + runs-on: ubuntu-latest + if: success() + needs: [get-base, get-head] + permissions: + pull-requests: write + + steps: + - name: Download Artifact + uses: actions/download-artifact@v3 + with: + name: api-artifact + path: ./artifacts + - name: Output base + run: cat ./artifacts/api-base.json + - name: Output head + run: cat ./artifacts/api-head.json + - name: Arrange json files + run: | + jq '.' ./artifacts/api-base.json > ./api-base.json + jq '.' ./artifacts/api-head.json > ./api-head.json + - name: Get diff of 2 files + run: diff -u --label=base --label=head ./api-base.json ./api-head.json | cat > api.json.diff + - name: Get full diff + run: diff --label=base --label=head --new-line-format='+%L' --old-line-format='-%L' --unchanged-line-format=' %L' ./api-base.json ./api-head.json | cat > api-full.json.diff + - name: Echo full diff + run: cat ./api-full.json.diff + - name: Upload full diff to Artifact + uses: actions/upload-artifact@v3 + with: + name: api-artifact + path: api-full.json.diff + - id: out-diff + name: Build diff Comment + run: | + cat <<- EOF > ./output.md + このPRによるapi.jsonの差分 +
+ 差分はこちら + + \`\`\`diff + $(cat ./api.json.diff) + \`\`\` +
+ + [Get diff files from Workflow Page](https://github.com/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}) + EOF + - name: Write diff comment + uses: thollander/actions-comment-pull-request@v2 + with: + comment_tag: show_diff + filePath: ./output.md diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 76f0cf6e38..0ed67a578d 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -11,7 +11,7 @@ jobs: pnpm_install: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4.1.0 + - uses: actions/checkout@v4.1.1 with: fetch-depth: 0 submodules: true @@ -38,7 +38,7 @@ jobs: - sw - cherrypick-js steps: - - uses: actions/checkout@v4.1.0 + - uses: actions/checkout@v4.1.1 with: fetch-depth: 0 submodules: true @@ -64,7 +64,7 @@ jobs: - backend - cherrypick-js steps: - - uses: actions/checkout@v4.1.0 + - uses: actions/checkout@v4.1.1 with: fetch-depth: 0 submodules: true diff --git a/.github/workflows/pr-preview-deploy.yml b/.github/workflows/pr-preview-deploy.yml index c36ac54593..6e0a2a7182 100644 --- a/.github/workflows/pr-preview-deploy.yml +++ b/.github/workflows/pr-preview-deploy.yml @@ -53,7 +53,7 @@ jobs: # Check out merge commit - name: Fork based /deploy checkout - uses: actions/checkout@v4.1.0 + uses: actions/checkout@v4.1.1 with: ref: 'refs/pull/${{ github.event.client_payload.pull_request.number }}/merge' diff --git a/.github/workflows/test-backend.yml b/.github/workflows/test-backend.yml index d944446f9a..19c90a9e28 100644 --- a/.github/workflows/test-backend.yml +++ b/.github/workflows/test-backend.yml @@ -29,7 +29,7 @@ jobs: - 56312:6379 steps: - - uses: actions/checkout@v4.1.0 + - uses: actions/checkout@v4.1.1 with: submodules: true - name: Install pnpm diff --git a/.github/workflows/test-cherrypick-js.yml b/.github/workflows/test-cherrypick-js.yml index 811fc6485c..b1d24f47ae 100644 --- a/.github/workflows/test-cherrypick-js.yml +++ b/.github/workflows/test-cherrypick-js.yml @@ -21,7 +21,7 @@ jobs: steps: - name: Checkout - uses: actions/checkout@v4.1.0 + uses: actions/checkout@v4.1.1 - run: corepack enable diff --git a/.github/workflows/test-frontend.yml b/.github/workflows/test-frontend.yml index 415de2d1f7..f7ae1574bf 100644 --- a/.github/workflows/test-frontend.yml +++ b/.github/workflows/test-frontend.yml @@ -16,7 +16,7 @@ jobs: node-version: [20.5.1] steps: - - uses: actions/checkout@v4.1.0 + - uses: actions/checkout@v4.1.1 with: submodules: true - name: Install pnpm @@ -68,7 +68,7 @@ jobs: - 56312:6379 steps: - - uses: actions/checkout@v4.1.0 + - uses: actions/checkout@v4.1.1 with: submodules: true # https://github.com/cypress-io/cypress-docker-images/issues/150 diff --git a/.github/workflows/test-production.yml b/.github/workflows/test-production.yml index 6d8183a4da..6399f10255 100644 --- a/.github/workflows/test-production.yml +++ b/.github/workflows/test-production.yml @@ -19,7 +19,7 @@ jobs: node-version: [20.5.1] steps: - - uses: actions/checkout@v4.1.0 + - uses: actions/checkout@v4.1.1 with: submodules: true - name: Install pnpm diff --git a/CHANGELOG.md b/CHANGELOG.md index dd4403f754..28eadd76ae 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,13 +15,26 @@ ## 2023.x.x (unreleased) ### General -- +- Feat: アンテナでローカルの投稿のみ収集できるようになりました +- Feat: サーバーサイレンス機能が追加されました +- Enhance: 新規にフォローした人の返信をデフォルトでTLに追加できるオプションを追加 +- Enhance: HTL/LTL/STLを2023.10.0アップデート以前まで遡れるように +- Enhance: フォロー/フォロー解除したときに過去分のHTLにも含まれる投稿が反映されるように +- Enhance: ローカリゼーションの更新 +- Enhance: 依存関係の更新 ### Client - Enhance: TLの返信表示オプションを記憶するように +- Enhance: 投稿されてから時間が経過しているノートであることを視覚的に分かりやすく ### Server -- +- Enhance: タイムライン取得時のパフォーマンスを向上 +- Enhance: ストリーミングAPIのパフォーマンスを向上 +- Fix: users/notesでDBから参照した際にチャンネル投稿のみ取得される問題を修正 +- Fix: コントロールパネルの設定項目が正しく保存できない問題を修正 +- Fix: 管理者権限のロールを持っていても一部のAPIが使用できないことがある問題を修正 +- Change: ユーザーのisCatがtrueでも、サーバーではnyaizeが行われなくなりました + - isCatな場合、クライアントでnyaize処理を行うことを推奨します ## 2023.10.1 ### General @@ -37,6 +50,7 @@ ## 2023.10.0 ### NOTE - アップデートを行うと、タイムラインが一時的にリセットされます + - アンテナ内のノートも含む - ソフトミュート設定はクライアントではなくサーバー側に保存されるようになったため、アップデートを行うとソフトミュートの設定がリセットされます ### Changes diff --git a/CHANGELOG_CHERRYPICK.md b/CHANGELOG_CHERRYPICK.md index 114476e794..ea6d43ec98 100644 --- a/CHANGELOG_CHERRYPICK.md +++ b/CHANGELOG_CHERRYPICK.md @@ -23,6 +23,35 @@ Misskey의 전체 변경 사항을 확인하려면, [CHANGELOG.md#2023xx](CHANGE # 릴리즈 노트 이 문서는 CherryPick의 변경 사항만 포함합니다. +## 4.4.1 +출시일: 2023/10/21
+기반 Misskey 버전: 2023.10.2
+Misskey의 전체 변경 사항을 확인하려면, [CHANGELOG.md#2023102](CHANGELOG.md#2023102) 문서를 참고하십시오. + +> 버전 관리 방식이 변경되었기 때문에, 기존 버전보다 낮은 것으로 인식되어 업데이트 대화 상자가 표시되지 않을 수 있습니다. +> 또한, 일부 locale이 누락되거나 기능이 정상적으로 작동하지 않는 등의 문제가 발생할 수 있습니다. +> 문제가 발생하면 '설정 - 캐시 비우기'를 진행하거나, 브라우저 캐시를 삭제하십시오. + +### Client +- Feat: 노트 편집 시 토스트 알림을 표시하고 사운드를 재생 +- Feat: PostForm 접두사에 현재 공개 범위 표시 ([tanukey-dev/tanukey@1cc0071](https://github.com/tanukey-dev/tanukey/commit/1cc0071bbd424949d9305bcec554f5d755a73554)) +- Feat: 플러그인 및 테마를 외부 사이트에서 직접 설치할 수 있음 (misskey-dev/misskey#12034) + - 외부 사이트에서 구현해야 합니다. 자세한 내용은 Misskey Hub를 참조하세요. + https://misskey-hub.net/docs/advanced/publish-on-your-website.html +- Enhance: 노트를 편집할 때 편집 중인 노트임을 강조함 +- Enhance: 타임라인에서 새 노트가 20개 이상이면 '20+'로 표기 +- Enhance: 노트를 편집한 시간이 개별적으로 표시됨 +- Fix: '새 노트 알림'을 '노트 수 표시'로 설정했을 때 한국어 이외의 언어에서 내용이 표시되지 않음 +- Fix: 알림에 여는 인용문 사용 (misskey-dev/misskey#12082) + +### Server +- Enhance: '내용 숨기기'로 설정된 노트의 주석도 노트 편집 기록에 표시됨 +- Revert: Perf: 부팅 시 MeiliSearch 설정을 업데이트하지 마십시오 (MisskeyIO/misskey#158) +- Fix: 이모지를 여러 개 추가할 때도 이름의 중복을 확인하도록 +- Fix: 유저 페이지 및 이벤트 검색에서 '미래순'으로 정렬할 수 없음 + +--- + ## 4.4.0 출시일: 2023/10/17
기반 Misskey 버전: 2023.10.1
@@ -229,8 +258,8 @@ Misskey의 전체 변경 사항을 확인하려면, [CHANGELOG.md#202391](CHANGE ### Server - Nodeinfo의 Software 이름을 CherryPick이 아닌 다른 이름으로 변경할 때 관련 주석 추가 - Graceful Shutdown (MisskeyIO/misskey#156) -- Perf : 부팅 시 MeiliSearch 설정을 업데이트하지 마십시오 (MisskeyIO/misskey#158) -- Enhance : 종료 시 DB 연결이 끊어지면 확실하게 종료 (MisskeyIO/misskey#159) +- Perf: 부팅 시 MeiliSearch 설정을 업데이트하지 마십시오 (MisskeyIO/misskey#158) +- Enhance: 종료 시 DB 연결이 끊어지면 확실하게 종료 (MisskeyIO/misskey#159) - Fix: 실행 중인 앱 내에서 ServerStatsService 시작 (misskey-dev/misskey#11342) - Fix: deliver-delayed에서 URL 구문 분석에 실패할 때 모든 것이 꼬이는 문제 수정 (MisskeyIO/misskey#164) - Fix: 대기열에 예상치 못한 데이터가 있는 경우, 엔드포인트 URL 구문 분석 및 오류 로그 생성에 실패하는 문제 수정 (MisskeyIO/misskey#168) diff --git a/cypress/e2e/widgets.cy.js b/cypress/e2e/widgets.cy.js index f5a982eb0a..df6ec8357d 100644 --- a/cypress/e2e/widgets.cy.js +++ b/cypress/e2e/widgets.cy.js @@ -1,3 +1,4 @@ +/* flaky describe('After user signed in', () => { beforeEach(() => { cy.resetState(); @@ -67,3 +68,4 @@ describe('After user signed in', () => { buildWidgetTest('aiscript'); buildWidgetTest('aichan'); }); +*/ diff --git a/locales/de-DE.yml b/locales/de-DE.yml index 3c19a74c11..77cf4bd59c 100644 --- a/locales/de-DE.yml +++ b/locales/de-DE.yml @@ -195,6 +195,7 @@ perHour: "Pro Stunde" perDay: "Pro Tag" stopActivityDelivery: "Senden von Aktivitäten einstellen" blockThisInstance: "Diese Instanz blockieren" +silenceThisInstance: "Instanz stummschalten" operations: "Aktionen" software: "Software" version: "Version" @@ -214,6 +215,8 @@ clearCachedFiles: "Cache leeren" clearCachedFilesConfirm: "Sollen alle im Cache gespeicherten Dateien von anderen Instanzen wirklich gelöscht werden?" blockedInstances: "Blockierte Instanzen" blockedInstancesDescription: "Gib die Hostnamen der Instanzen, welche blockiert werden sollen, durch Zeilenumbrüche getrennt an. Blockierte Instanzen können mit dieser instanz nicht mehr kommunizieren." +silencedInstances: "Stummgeschaltete Instanzen" +silencedInstancesDescription: "Gib die Hostnamen der Instanzen, welche stummgeschaltet werden sollen, durch Zeilenumbrüche getrennt an. Alle Konten dieser Instanzen werden als stummgeschaltet behandelt, können nur noch Follow-Anfragen stellen und wenn nicht gefolgt keine lokalen Konten erwähnen. Blockierte Instanzen sind davon nicht betroffen." muteAndBlock: "Stummschaltungen und Blockierungen" mutedUsers: "Stummgeschaltete Benutzer" blockedUsers: "Blockierte Benutzer" @@ -543,6 +546,7 @@ serverLogs: "Serverprotokolle" deleteAll: "Alle löschen" showFixedPostForm: "Bereich zum Schreiben neuer Notizen am Anfang der Chronik anzeigen" showFixedPostFormInChannel: "Bereich zum Schreiben neuer Notizen am Anfang der Chronik anzeigen (Kanäle)" +withRepliesByDefaultForNewlyFollowed: "Standardmäßig Antworten von neu gefolgten Benutzern in der Chronik anzeigen" newNoteRecived: "Es gibt neue Notizen" sounds: "Töne" sound: "Töne" @@ -806,7 +810,7 @@ active: "Aktiv" offline: "Offline" notRecommended: "Nicht empfohlen" botProtection: "Schutz vor Bots" -instanceBlocking: "Blockierte Instanzen" +instanceBlocking: "Blockierte/Stummgeschaltete Instanzen" selectAccount: "Benutzerkonto auswählen" switchAccount: "Konto wechseln" enabled: "Aktiviert" @@ -2005,6 +2009,7 @@ _exportOrImport: userLists: "Listen" excludeMutingUsers: "Stummgeschaltete Benutzer aussortieren" excludeInactiveUsers: "Inaktive Benutzer aussortieren" + withReplies: "Antworten von importierten Benutzern in der Chronik beinhalten" _charts: federation: "Föderation" apRequest: "Anfragen" diff --git a/locales/en-US.yml b/locales/en-US.yml index 96226f418b..62226be2d3 100644 --- a/locales/en-US.yml +++ b/locales/en-US.yml @@ -1,5 +1,6 @@ --- _lang_: "English" +noteEdited: "Note are now edited." removeModalBgColorForBlur: "Remove modal background color" skipThisVersion: "Skip this release" enableReceivePrerelease: "Get notified of pre-release versions" @@ -248,6 +249,7 @@ perHour: "Per Hour" perDay: "Per Day" stopActivityDelivery: "Stop sending activities" blockThisInstance: "Block this instance" +silenceThisInstance: "Silence this instance" operations: "Operations" software: "Software" version: "Version" @@ -266,7 +268,9 @@ clearQueueConfirmText: "Any undelivered notes remaining in the queue will not be clearCachedFiles: "Clear cache" clearCachedFilesConfirm: "Are you sure that you want to delete all cached remote files?" blockedInstances: "Blocked Instances" -blockedInstancesDescription: "List the hostnames of the instances that you want to block separated by linebreaks. Listed instances will no longer be able to communicate with this instance." +blockedInstancesDescription: "List the hostnames of the instances you want to block separated by linebreaks. Listed instances will no longer be able to communicate with this instance." +silencedInstances: "Silenced instances" +silencedInstancesDescription: "List the hostnames of the instances that you want to silence. All accounts of the listed instances will be treated as silenced, can only make follow requests, and cannot mention local accounts if not followed. This will not affect blocked instances." muteAndBlock: "Mutes and Blocks" mutedUsers: "Muted users" blockedUsers: "Blocked users" @@ -599,7 +603,9 @@ serverLogs: "Server logs" deleteAll: "Delete all" showFixedPostForm: "Display the posting form at the top of the timeline" showFixedPostFormInChannel: "Display the posting form at the top of the timeline (Channels)" +withRepliesByDefaultForNewlyFollowed: "Include replies by newly followed users in the timeline by default" newNoteRecived: "There are new notes" +newNoteRecivedCount: "There are {n} new notes" sounds: "Sounds" sound: "Sounds" vibrations: "Vibrations" @@ -661,7 +667,7 @@ poll: "Poll" useCw: "Hide content" enablePlayer: "Open video player" disablePlayer: "Close video player" -expandTweet: "Expand tweet" +expandTweet: "Expand post" themeEditor: "Theme editor" description: "Description" describeFile: "Add caption" @@ -868,7 +874,7 @@ active: "Active" offline: "Offline" notRecommended: "Not recommended" botProtection: "Bot Protection" -instanceBlocking: "Blocked Instances" +instanceBlocking: "Blocked/Silenced Instances" selectAccount: "Select account" switchAccount: "Switch account" enabled: "Enabled" @@ -1210,8 +1216,8 @@ edited: "Edited" notificationRecieveConfig: "Notification Settings" mutualFollow: "Mutual follow" fileAttachedOnly: "Only notes with files" -showRepliesToOthersInTimeline: "Show replies to others in TL" -hideRepliesToOthersInTimeline: "Hide replies to others from TL" +showRepliesToOthersInTimeline: "Show replies to others in timeline" +hideRepliesToOthersInTimeline: "Hide replies to others from timeline" externalServices: "External Services" impressum: "Impressum" impressumUrl: "Impressum URL" @@ -1973,6 +1979,7 @@ _theme: _sfx: note: "New note" noteMy: "Own note" + noteEdited: "Note Edited" notification: "Notifications" chat: "Chat" chatBg: "Chat (Background)" @@ -2012,7 +2019,7 @@ _2fa: step2Click: "Clicking on this QR code will allow you to register 2FA to your security key or phone authenticator app." step2Uri: "Enter the following URI if you are using a desktop program" step3Title: "Enter an authentication code" - step3: "Enter the token provided by your app to finish setup." + step3: "Enter the authentication code (token) provided by your app to finish setup." setupCompleted: "Setup complete" step4: "From now on, any future login attempts will ask for such a login token." securityKeyNotSupported: "Your browser does not support security keys." @@ -2197,6 +2204,7 @@ _exportOrImport: userLists: "User lists" excludeMutingUsers: "Exclude muted users" excludeInactiveUsers: "Exclude inactive users" + withReplies: "Include replies from imported users in the timeline" _charts: federation: "Federation" apRequest: "Requests" @@ -2353,7 +2361,7 @@ _deck: introduction: "Create the perfect interface for you by arranging columns freely!" introduction2: "Click on the + on the right of the screen to add new colums whenever you want." widgetsIntroduction: "Please select \"Edit widgets\" in the column menu and add a widget." - useSimpleUiForNonRootPages: "Use simplified UI to navigated pages" + useSimpleUiForNonRootPages: "Use simple UI for navigated pages" usedAsMinWidthWhenFlexible: "Minimum width will be used for this when the \"Auto-adjust width\" option is enabled" flexible: "Auto-adjust width" _columns: diff --git a/locales/es-ES.yml b/locales/es-ES.yml index 383f1652a6..a68c24aad7 100644 --- a/locales/es-ES.yml +++ b/locales/es-ES.yml @@ -195,6 +195,7 @@ perHour: "por hora" perDay: "por día" stopActivityDelivery: "Dejar de enviar actividades" blockThisInstance: "Bloquear instancia" +silenceThisInstance: "Silenciar esta instancia" operations: "Operaciones" software: "Software" version: "Versión" @@ -214,6 +215,8 @@ clearCachedFiles: "Limpiar caché" clearCachedFilesConfirm: "¿Desea borrar todos los archivos remotos cacheados?" blockedInstances: "Instancias bloqueadas" blockedInstancesDescription: "Seleccione los hosts de las instancias que desea bloquear, separadas por una linea nueva. Las instancias bloqueadas no podrán comunicarse con esta instancia." +silencedInstances: "Instancias silenciadas" +silencedInstancesDescription: "Listar los hostname de las instancias que quieres silenciar. Todas las cuentas de las instancias listadas serán tratadas como silenciadas, solo podrán hacer peticiones de seguimiento, y no podrán mencionar cuentas locales si no las siguen. Esto no afecta a las instancias bloqueadas." muteAndBlock: "Silenciar y bloquear" mutedUsers: "Usuarios silenciados" blockedUsers: "Usuarios bloqueados" @@ -543,6 +546,7 @@ serverLogs: "Registros del servidor" deleteAll: "Eliminar todos" showFixedPostForm: "Mostrar el formulario de las entradas encima de la línea de tiempo" showFixedPostFormInChannel: "Mostrar el formulario de publicación por encima de la cronología (Canales)" +withRepliesByDefaultForNewlyFollowed: "Incluir por defecto respuestas de usuarios recién seguidos en la línea de tiempo" newNoteRecived: "Tienes una nota nueva" sounds: "Sonidos" sound: "Sonidos" @@ -1135,6 +1139,20 @@ unnotifyNotes: "Dejar de notificar nuevas notas" authentication: "Autenticación" authenticationRequiredToContinue: "Por favor, autentifícate para continuar" dateAndTime: "Fecha y hora" +showRenotes: "Mostrar renotas" +edited: "Editado" +notificationRecieveConfig: "Ajustes de Notificaciones" +mutualFollow: "Os seguís mutuamente" +fileAttachedOnly: "Solo notas con archivos" +showRepliesToOthersInTimeline: "Mostrar respuestas a otros en la línea de tiempo" +hideRepliesToOthersInTimeline: "Ocultar respuestas a otros en la línea de tiempo" +externalServices: "Servicios Externos" +impressum: "Impressum" +impressumUrl: "Impressum URL" +impressumDescription: "En algunos países, como Alemania, la inclusión del operador de datos (el Impressum) es requerido legalmente para sitios web comerciales." +privacyPolicy: "Política de Privacidad" +privacyPolicyUrl: "URL de la Política de Privacidad" +tosAndPrivacyPolicy: "Condiciones de Uso y Política de Privacidad" _announcement: forExistingUsers: "Solo para usuarios registrados" forExistingUsersDescription: "Este anuncio solo se mostrará a aquellos usuarios registrados en el momento de su publicación. Si se deshabilita esta opción, aquellos usuarios que se registren tras su publicación también lo verán." @@ -1484,6 +1502,7 @@ _role: descriptionOfRateLimitFactor: "Límites más bajos son menos restrictivos, más altos menos restrictivos" canHideAds: "Puede ocultar anuncios" canSearchNotes: "Uso de la búsqueda de notas" + canUseTranslator: "Uso de traductor" _condition: isLocal: "Usuario local" isRemote: "Usuario remoto" @@ -1532,6 +1551,10 @@ _ad: reduceFrequencyOfThisAd: "Mostrar menos este anuncio." hide: "No mostrar" timezoneinfo: "El día de la semana está determidado por la zona horaria del servidor." + adsSettings: "Ajustes de anuncios" + notesPerOneAd: "Intervalo de actualización de anuncios en tiempo real (Notas por cada anuncio)" + setZeroToDisable: "Establece este valor a 0 para deshabilitar la actualización de anuncios en tiempo real" + adsTooClose: "El intervalo de anuncios actual puede empeorar la experiencia del usuario por ser demasiado bajo." _forgotPassword: enterEmail: "Ingrese el correo usado para registrar la cuenta. Se enviará un link para resetear la contraseña." ifNoEmail: "Si no utilizó un correo para crear la cuenta, contáctese con el administrador." @@ -1985,6 +2008,7 @@ _exportOrImport: userLists: "Listas" excludeMutingUsers: "Excluir usuarios silenciados" excludeInactiveUsers: "Excluir usuarios inactivos" + withReplies: "Incluir respuestas de los usuarios importados en la línea de tiempo" _charts: federation: "Federación" apRequest: "Pedidos" @@ -2207,3 +2231,14 @@ _moderationLogTypes: unmarkSensitiveDriveFile: "Archivo marcado como no sensible" resolveAbuseReport: "Reporte resuelto" createInvitation: "Generar invitación" + createAd: "Anuncio creado" + deleteAd: "Anuncio eliminado" + updateAd: "Anuncio actualizado" +_fileViewer: + title: "Detalles del archivo" + type: "Tipo de archivo" + size: "Tamaño del archivo" + url: "URL" + uploadedAt: "Subido el" + attachedNotes: "Notas adjuntas" + thisPageCanBeSeenFromTheAuthor: "Esta página solo puede ser vista por el autor." diff --git a/locales/fr-FR.yml b/locales/fr-FR.yml index 968f8b36ee..7af2539402 100644 --- a/locales/fr-FR.yml +++ b/locales/fr-FR.yml @@ -184,7 +184,7 @@ selectUser: "Sélectionner un·e utilisateur·rice" recipient: "Destinataire" annotation: "Commentaires" federation: "Fédération" -instances: "Instance" +instances: "Instances" registeredAt: "Premier contact le" latestRequestReceivedAt: "Dernière requête reçue" latestStatus: "Dernier statut" @@ -194,6 +194,7 @@ perHour: "par heure" perDay: "par jour" stopActivityDelivery: "Arrêter l’envoi de l’activité" blockThisInstance: "Bloquer cette instance" +silenceThisInstance: "Mettre cette instance en sourdine" operations: "Opérations" software: "Logiciel" version: "Version" @@ -213,6 +214,8 @@ clearCachedFiles: "Vider le cache" clearCachedFilesConfirm: "Êtes-vous sûr·e de vouloir vider tout le cache de fichiers distants ?" blockedInstances: "Instances bloquées" blockedInstancesDescription: "Listez les instances que vous désirez bloquer, une par ligne. Ces instances ne seront plus en capacité d'interagir avec votre instance." +silencedInstances: "Instances mises en sourdine" +silencedInstancesDescription: "Énumérer les noms d'hôte des instances à mettre en sourdine. Tous les comptes des instances énumérées seront traités comme mis en sourdine, ne peuvent faire que des demandes de suivi et ne peuvent pas mentionner les comptes locaux s'ils ne sont pas suivis. Cela n'affectera pas les instances bloquées." muteAndBlock: "Masqué·e·s / Bloqué·e·s" mutedUsers: "Utilisateur·rice·s en sourdine" blockedUsers: "Utilisateur·rice·s bloqué·e·s" @@ -384,7 +387,7 @@ antennaSource: "Source de l’antenne" antennaKeywords: "Mots clés à recevoir" antennaExcludeKeywords: "Mots clés à exclure" antennaKeywordsDescription: "Séparer avec des espaces pour la condition AND. Séparer avec un saut de ligne pour une condition OR." -notifyAntenna: "Je souhaite recevoir les notifications des nouvelles notes" +notifyAntenna: "Me notifier pour les nouvelles notes" withFileAntenna: "Notes ayant des attachements uniquement" enableServiceworker: "Activer ServiceWorker" antennaUsersDescription: "Saisissez un seul nom d’utilisateur·rice par ligne" @@ -941,6 +944,7 @@ remoteOnly: "Distant uniquement" failedToUpload: "Échec du transfert" cannotUploadBecauseInappropriate: "Impossible de télécharger le document car il a été déterminé qu'il pouvait contenir un contenu inapproprié." cannotUploadBecauseNoFreeSpace: "Impossible de télécharger en raison d'un manque d'espace libre sur le disque.\n" +cannotUploadBecauseExceedsFileSizeLimit: "Ce fichier ne peut pas être téléchargé parce qu'il dépasse la taille maximale." beta: "Bêta" enableAutoSensitive: "Détermination automatique de NSFW" enableAutoSensitiveDescription: "S'il est disponible, le drapeau NSFW est automatiquement défini sur le média en utilisant l'apprentissage automatique. Même si cette fonction est désactivée, elle peut être réglée automatiquement dans certains cas." @@ -962,12 +966,14 @@ caption: "Libellé" loggedInAsBot: "Connecté actuellement en tant que bot" tools: "Outils" cannotLoad: "Chargement impossible" +numberOfProfileView: "Nombre de vues du profil" like: "J'aime" unlike: "Ne plus aimer" numberOfLikes: "Favoris" show: "Affichage" neverShow: "Ne plus afficher" remindMeLater: "Peut-être plus tard" +didYouLikeMisskey: "Avez-vous aimé Misskey ?" roles: "Rôles" role: "Rôles" noRole: "Aucun rôle" @@ -977,9 +983,13 @@ assign: "Attribuer" unassign: "Retirer" color: "Couleur" manageCustomEmojis: "Gestion des émojis personnalisés" +youCannotCreateAnymore: "Vous avez atteint la limite de création." +cannotPerformTemporary: "Temporairement indisponible" +invalidParamError: "Paramètres invalides" preset: "Préréglage" selectFromPresets: "Sélectionner à partir des préréglages" achievements: "Accomplissements" +gotInvalidResponseError: "Réponse du serveur invalide" thisPostMayBeAnnoying: "Cette note peut gêner d'autres personnes." thisPostMayBeAnnoyingHome: "Publier vers le fil principal" thisPostMayBeAnnoyingCancel: "Annuler" @@ -989,11 +999,15 @@ internalServerError: "Erreur interne du serveur" copyErrorInfo: "Copier les détails de l’erreur" exploreOtherServers: "Trouver une autre instance" disableFederationOk: "Désactiver" +postToTheChannel: "Publier au canal" likeOnly: "Les favoris uniquement" sensitiveWords: "Mots sensibles" notesSearchNotAvailable: "La recherche de notes n'est pas disponible." license: "Licence" myClips: "Mes clips" +retryAllQueuesConfirmText: "Cela peut augmenter temporairement la charge du serveur." +showClipButtonInNoteFooter: "Ajouter « Clip » au menu d'action de la note" +noteIdOrUrl: "Identifiant de la note ou URL" video: "Vidéo" videos: "Vidéos" dataSaver: "Économiseur de données" @@ -1001,6 +1015,7 @@ accountMigration: "Migration de compte" accountMoved: "Cet·te utilisateur·rice a migré son compte vers :" accountMovedShort: "Ce compte a migré" operationForbidden: "Opération non autorisée" +forceShowAds: "Toujours afficher les publicités" addMemo: "Ajouter un mémo" reactionsList: "Réactions" renotesList: "Liste de renotes" @@ -1009,23 +1024,35 @@ leftTop: "En haut à gauche" rightTop: "En haut à droite" leftBottom: "En bas à gauche" rightBottom: "En bas à droite" +stackAxis: "Direction d'empilement" vertical: "Vertical" horizontal: "Latéral" +position: "Position" serverRules: "Règles du serveur" +pleaseAgreeAllToContinue: "Pour continuer, veuillez accepter tous les champs ci-dessus." +continue: "Continuer" +preservedUsernames: "Noms d'utilisateur·rice réservés" archive: "Archive" displayOfNote: "Affichage de la note" +initialAccountSetting: "Réglage initial du profil" youFollowing: "Abonné·e" +preventAiLearning: "Refuser l'usage dans l'apprentissage automatique d'IA générative" options: "Options" later: "Plus tard" goToMisskey: "Retour vers CherryPick" expirationDate: "Date d’expiration" +waitingForMailAuth: "En attente de la vérification de l'adresse courriel" usedAt: "Utilisé le" unused: "Non-utilisé" used: "Utilisé" expired: "Expiré" doYouAgree: "Êtes-vous d’accord ?" +beSureToReadThisAsItIsImportant: "Assurez-vous de le lire ; c'est important." +dialog: "Dialogue" icon: "Avatar" forYou: "Pour vous" +currentAnnouncements: "Annonces actuelles" +pastAnnouncements: "Annonces passées" replies: "Répondre" renotes: "Renoter" loadReplies: "Inclure les réponses" @@ -1614,7 +1641,7 @@ _visibility: _postForm: replyPlaceholder: "Répondre à cette note ..." quotePlaceholder: "Citez cette note ..." - channelPlaceholder: "Publier vers le canal" + channelPlaceholder: "Publier au canal…" _placeholders: a: "Quoi de neuf ?" b: "Il s'est passé quelque chose ?" diff --git a/locales/hr-HR.yml b/locales/hr-HR.yml index ed97d539c0..9cfebdd01a 100644 --- a/locales/hr-HR.yml +++ b/locales/hr-HR.yml @@ -1 +1,5 @@ --- +_lang_: "japanski" +ok: "OK" +gotIt: "Razumijem" +cancel: "otkazati" diff --git a/locales/ht-HT.yml b/locales/ht-HT.yml index ed97d539c0..e3595c79b6 100644 --- a/locales/ht-HT.yml +++ b/locales/ht-HT.yml @@ -1 +1,18 @@ --- +_lang_: "Japonè" +password: "modpas" +ok: "OK" +gotIt: "Konprann" +cancel: "anile" +noThankYou: "Sispann" +instance: "sèvè" +profile: "pwofil" +save: "kenbe" +delete: "efase" +instances: "sèvè" +remove: "efase" +smtpPass: "modpas" +_2fa: + renewTOTPCancel: "Sispann" +_widgets: + profile: "pwofil" diff --git a/locales/index.d.ts b/locales/index.d.ts index 4b6c802f32..0d282a4be2 100644 --- a/locales/index.d.ts +++ b/locales/index.d.ts @@ -3,6 +3,7 @@ // Do not edit this file directly. export interface Locale { "_lang_": string; + "noteEdited": string; "removeModalBgColorForBlur": string; "skipThisVersion": string; "enableReceivePrerelease": string; @@ -251,6 +252,7 @@ export interface Locale { "perDay": string; "stopActivityDelivery": string; "blockThisInstance": string; + "silenceThisInstance": string; "operations": string; "software": string; "version": string; @@ -270,6 +272,8 @@ export interface Locale { "clearCachedFilesConfirm": string; "blockedInstances": string; "blockedInstancesDescription": string; + "silencedInstances": string; + "silencedInstancesDescription": string; "muteAndBlock": string; "mutedUsers": string; "blockedUsers": string; @@ -602,7 +606,9 @@ export interface Locale { "deleteAll": string; "showFixedPostForm": string; "showFixedPostFormInChannel": string; + "withRepliesByDefaultForNewlyFollowed": string; "newNoteRecived": string; + "newNoteRecivedCount": string; "sounds": string; "sound": string; "vibrations": string; @@ -2100,6 +2106,7 @@ export interface Locale { "_sfx": { "note": string; "noteMy": string; + "noteEdited": string; "notification": string; "chat": string; "chatBg": string; @@ -2341,6 +2348,7 @@ export interface Locale { "userLists": string; "excludeMutingUsers": string; "excludeInactiveUsers": string; + "withReplies": string; }; "_charts": { "federation": string; @@ -2621,6 +2629,62 @@ export interface Locale { "resizeCompressLossy": string; "noResizeCompressLossy": string; }; + "_externalResourceInstaller": { + "title": string; + "checkVendorBeforeInstall": string; + "_plugin": { + "title": string; + "metaTitle": string; + }; + "_theme": { + "title": string; + "metaTitle": string; + }; + "_meta": { + "base": string; + }; + "_vendorInfo": { + "title": string; + "endpoint": string; + "hashVerify": string; + "hashVerified": string; + }; + "_errors": { + "_invalidParams": { + "title": string; + "description": string; + }; + "_resourceTypeNotSupported": { + "title": string; + "description": string; + }; + "_failedToFetch": { + "title": string; + "fetchErrorDescription": string; + "parseErrorDescription": string; + }; + "_hashUnmatched": { + "title": string; + "description": string; + }; + "_pluginParseFailed": { + "title": string; + "description": string; + }; + "_pluginInstallFailed": { + "title": string; + "description": string; + }; + "_themeParseFailed": { + "title": string; + "description": string; + }; + "_themeInstallFailed": { + "title": string; + "description": string; + }; + }; + }; } declare const locales: { [lang: string]: Locale; diff --git a/locales/it-IT.yml b/locales/it-IT.yml index da63286320..cd22acaea5 100644 --- a/locales/it-IT.yml +++ b/locales/it-IT.yml @@ -110,14 +110,14 @@ unrenote: "Elimina la Rinota" renoted: "Rinotato!" cantRenote: "È impossibile rinotare questa nota." cantReRenote: "È impossibile rinotare una Rinota." -quote: "Cita" +quote: "Citazione" inChannelRenote: "Rinota nel canale" inChannelQuote: "Cita nel canale" pinnedNote: "Nota in primo piano" pinned: "Fissa sul profilo" you: "Tu" -clickToShow: "Clicca per visualizzare" -sensitive: "Esplicito" +clickToShow: "Contenuto occultato, cliccare solo se si intende vedere" +sensitive: "Allegato esplicito" add: "Aggiungi" reaction: "Reazioni" reactions: "Reazioni" @@ -195,6 +195,7 @@ perHour: "orario" perDay: "giornaliero" stopActivityDelivery: "Interrompi la distribuzione di attività" blockThisInstance: "Blocca questa istanza" +silenceThisInstance: "Silenzia l'istanza" operations: "Operazioni" software: "Software" version: "Versione" @@ -214,6 +215,8 @@ clearCachedFiles: "Svuota cache" clearCachedFilesConfirm: "Vuoi davvero svuotare la cache da tutti i file remoti?" blockedInstances: "Istanze bloccate" blockedInstancesDescription: "Elenca le istanze che vuoi bloccare, una per riga. Esse non potranno più interagire con la tua istanza." +silencedInstances: "Istanze silenziate" +silencedInstancesDescription: "Elenca i nomi host delle istanze che vuoi silenziare. Tutti i profili nelle istanze silenziate vengono trattati come tali. Possono solo inviare richieste di follow e menzionare soltanto i profili locali che seguono. Le istanze bloccate non sono interessate." muteAndBlock: "Silenziati / Bloccati" mutedUsers: "Profili silenziati" blockedUsers: "Profili bloccati" @@ -278,7 +281,7 @@ agreeTo: "Sono d'accordo con {0}" agree: "Accetto" agreeBelow: "Accetto quanto riportato sotto" basicNotesBeforeCreateAccount: "Note importanti" -termsOfService: "Informativa ai sensi degli artt. 13 e 14 del Regolamento UE 2016/679 per la protezione dei dati personali (GDPR)" +termsOfService: "Condizioni d'uso del servizio" start: "Inizia!" home: "Home" remoteUserCaution: "Le informazioni potrebbero essere incomplete poiché questo profilo remoto potrebbe non essere completamente federato." @@ -543,6 +546,7 @@ serverLogs: "Log del server" deleteAll: "Cancella cronologia" showFixedPostForm: "Visualizzare la finestra di pubblicazione in cima alla timeline" showFixedPostFormInChannel: "Per i canali, mostra il modulo di pubblicazione in cima alla timeline" +withRepliesByDefaultForNewlyFollowed: "Quando segui nuovi profili, includi le risposte in TL come impostazione predefinita" newNoteRecived: "Nuove note da leggere" sounds: "Impostazioni suoni" sound: "Suono" @@ -1146,9 +1150,9 @@ externalServices: "Servizi esterni" impressum: "Dichiarazione di proprietà" impressumUrl: "URL della dichiarazione di proprietà" impressumDescription: "La dichiarazione di proprietà, è obbligatoria in alcuni paesi come la Germania (Impressum)." -privacyPolicy: "Informativa sulla privacy" +privacyPolicy: "Informativa privacy ai sensi del Regolamento UE 2016/679 (GDPR)" privacyPolicyUrl: "URL della informativa privacy" -tosAndPrivacyPolicy: "Condizioni d'uso e informativa sulla privacy" +tosAndPrivacyPolicy: "Condizioni d'uso e informativa privacy" _announcement: forExistingUsers: "Solo ai profili attuali" forExistingUsersDescription: "L'annuncio sarà visibile solo ai profili esistenti in questo momento. Se disabilitato, sarà visibile anche ai profili che verranno creati dopo la pubblicazione di questo annuncio." @@ -1962,9 +1966,9 @@ _poll: remainingSeconds: "Rimangono {s} secondi" _visibility: public: "Pubblica" - publicDescription: "Visibile per tutti sul Fediverso" + publicDescription: "Visibilità pubblica" home: "Home" - homeDescription: "Visibile solo sulla timeline locale" + homeDescription: "Visibile solo nella Home" followers: "Follower" followersDescription: "Visibile solo ai tuoi follower" specified: "Nota diretta" @@ -2004,6 +2008,7 @@ _exportOrImport: userLists: "Liste" excludeMutingUsers: "Escludere gli utenti silenziati" excludeInactiveUsers: "Escludere i profili inutilizzati" + withReplies: "Includere le risposte da profili importati nella Timeline" _charts: federation: "Federazione" apRequest: "Richieste" @@ -2173,7 +2178,7 @@ _deck: list: "Liste" channel: "Canale" mentions: "Menzioni" - direct: "Diretta" + direct: "Note Dirette" roleTimeline: "Timeline Ruolo" _dialog: charactersExceeded: "Hai superato il limite di {max} caratteri! ({corrente})" @@ -2229,3 +2234,11 @@ _moderationLogTypes: createAd: "Banner creato" deleteAd: "Banner eliminato" updateAd: "Banner aggiornato" +_fileViewer: + title: "Dettagli del file" + type: "Tipo di file" + size: "Dimensioni file" + url: "URL" + uploadedAt: "Caricato il" + attachedNotes: "Note a cui è allegato" + thisPageCanBeSeenFromTheAuthor: "Questa pagina può essere vista solo da chi ha caricato il file." diff --git a/locales/ja-JP.yml b/locales/ja-JP.yml index ac143a9122..1786847e2d 100644 --- a/locales/ja-JP.yml +++ b/locales/ja-JP.yml @@ -1,5 +1,6 @@ _lang_: "日本語" +noteEdited: "ノートを編集しました。" removeModalBgColorForBlur: "モーダル背景色を削除" skipThisVersion: "このリリースをスキップする" enableReceivePrerelease: "プレリリース版の通知を受け取る" @@ -248,6 +249,7 @@ perHour: "1時間ごと" perDay: "1日ごと" stopActivityDelivery: "アクティビティの配送を停止" blockThisInstance: "このサーバーをブロック" +silenceThisInstance: "サーバーをサイレンス" operations: "操作" software: "ソフトウェア" version: "バージョン" @@ -266,7 +268,9 @@ clearQueueConfirmText: "未配達の投稿は配送されなくなります。 clearCachedFiles: "キャッシュをクリア" clearCachedFilesConfirm: "キャッシュされたリモートファイルをすべて削除しますか?" blockedInstances: "ブロックしたサーバー" -blockedInstancesDescription: "ブロックしたいサーバーのホストを改行で区切って設定します。ブロックされたサーバーは、このサーバーとやり取りできなくなります。サブドメインもブロックされます。" +blockedInstancesDescription: "ブロックしたいサーバーのホストを改行で区切って設定します。ブロックされたサーバーは、このインスタンスとやり取りできなくなります。" +silencedInstances: "サイレンスしたサーバー" +silencedInstancesDescription: "サイレンスしたいサーバーのホストを改行で区切って設定します。サイレンスされたサーバーに所属するアカウントはすべて「サイレンス」として扱われ、フォローがすべてリクエストになり、フォロワーでないローカルアカウントにはメンションできなくなります。ブロックしたインスタンスには影響しません。" muteAndBlock: "ミュートとブロック" mutedUsers: "ミュートしたユーザー" blockedUsers: "ブロックしたユーザー" @@ -599,7 +603,9 @@ serverLogs: "サーバーログ" deleteAll: "全て削除" showFixedPostForm: "タイムライン上部に投稿フォームを表示する" showFixedPostFormInChannel: "タイムライン上部に投稿フォームを表示する(チャンネル)" +withRepliesByDefaultForNewlyFollowed: "フォローする際、デフォルトで返信をTLに含むようにする" newNoteRecived: "新しいノートがあります" +newNoteRecivedCount: "{n}個の新しいノートがあります" sounds: "サウンド" sound: "サウンド" vibrations: "振動" @@ -661,7 +667,7 @@ poll: "アンケート" useCw: "内容を隠す" enablePlayer: "プレイヤーを開く" disablePlayer: "プレイヤーを閉じる" -expandTweet: "ツイートを展開する" +expandTweet: "ポストを展開する" themeEditor: "テーマエディター" description: "説明" describeFile: "キャプションを付ける" @@ -868,7 +874,7 @@ active: "アクティブ" offline: "オフライン" notRecommended: "非推奨" botProtection: "Botプロテクション" -instanceBlocking: "サーバーブロック" +instanceBlocking: "サーバーブロック・サイレンス" selectAccount: "アカウントを選択" switchAccount: "アカウントを切り替え" enabled: "有効" @@ -2014,6 +2020,7 @@ _theme: _sfx: note: "ノート" noteMy: "ノート(自分)" + noteEdited: "ノートを編集" notification: "通知" chat: "チャット" chatBg: "チャット(バックグラウンド)" @@ -2253,6 +2260,7 @@ _exportOrImport: userLists: "リスト" excludeMutingUsers: "ミュートしているユーザーを除外" excludeInactiveUsers: "使われていないアカウントを除外" + withReplies: "インポートした人による返信をTLに含むようにする" _charts: federation: "連合" @@ -2529,3 +2537,46 @@ _imageCompressionMode: noResizeCompress: "縮小せず再圧縮する" resizeCompressLossy: "縮小して非可逆圧縮する" noResizeCompressLossy: "縮小せず非可逆圧縮する" + +_externalResourceInstaller: + title: "外部サイトからインストール" + checkVendorBeforeInstall: "配布元が信頼できるかを確認した上でインストールしてください。" + _plugin: + title: "このプラグインをインストールしますか?" + metaTitle: "プラグイン情報" + _theme: + title: "このテーマをインストールしますか?" + metaTitle: "テーマ情報" + _meta: + base: "基本のカラースキーム" + _vendorInfo: + title: "配布元情報" + endpoint: "参照したエンドポイント" + hashVerify: "ファイル整合性の確認" + hashVerified: "確認済み" + _errors: + _invalidParams: + title: "パラメータが不足しています" + description: "外部サイトからデータを取得するために必要な情報が不足しています。URLをお確かめください。" + _resourceTypeNotSupported: + title: "この外部リソースには対応していません" + description: "この外部サイトから取得したリソースの種別には対応していません。サイト管理者にお問い合わせください。" + _failedToFetch: + title: "データの取得に失敗しました" + fetchErrorDescription: "外部サイトとの通信に失敗しました。もう一度試しても改善しない場合、サイト管理者にお問い合わせください。" + parseErrorDescription: "外部サイトから取得したデータが読み取れませんでした。サイト管理者にお問い合わせください。" + _hashUnmatched: + title: "正しいデータが取得できませんでした" + description: "提供されたデータの整合性の確認に失敗しました。セキュリティ上、インストールは続行できません。サイト管理者にお問い合わせください。" + _pluginParseFailed: + title: "AiScript エラー" + description: "データは取得できたものの、AiScriptの解析時にエラーがあったため読み込めませんでした。プラグインの作者にお問い合わせください。エラーの詳細はJavascriptコンソールをご確認ください。" + _pluginInstallFailed: + title: "プラグインのインストールに失敗しました" + description: "プラグインのインストール中に問題が発生しました。もう一度お試しください。エラーの詳細はJavascriptコンソールをご覧ください。" + _themeParseFailed: + title: "テーマ解析エラー" + description: "データは取得できたものの、テーマファイルの解析時にエラーがあったため読み込めませんでした。テーマの作者にお問い合わせください。エラーの詳細はJavascriptコンソールをご確認ください。" + _themeInstallFailed: + title: "テーマのインストールに失敗しました" + description: "テーマのインストール中に問題が発生しました。もう一度お試しください。エラーの詳細はJavascriptコンソールをご覧ください。" diff --git a/locales/ja-KS.yml b/locales/ja-KS.yml index 82e0c8e709..ef61640e55 100644 --- a/locales/ja-KS.yml +++ b/locales/ja-KS.yml @@ -45,6 +45,7 @@ pin: "ピン留めしとく" unpin: "やっぱピン留めせん" copyContent: "内容をコピー" copyLink: "リンクをコピー" +copyLinkRenote: "リノートのリンクをコピーするで?" delete: "ほかす" deleteAndEdit: "ほかして直す" deleteAndEditConfirm: "このノートをほかしてもっかい直す?このノートへのツッコミ、Renote、返信も全部消えるんやけどそれでもええん?" @@ -194,6 +195,7 @@ perHour: "1時間ごと" perDay: "1日ごと" stopActivityDelivery: "アクティビティの配送をやめる" blockThisInstance: "このサーバーをブロックすんで" +silenceThisInstance: "サーバーサイレンスすんで?" operations: "操作" software: "ソフトウェア" version: "バージョン" @@ -213,6 +215,8 @@ clearCachedFiles: "キャッシュをほかす" clearCachedFilesConfirm: "キャッシュされとるリモートファイルをみんなほかしてええか?" blockedInstances: "ブロックしたサーバー" blockedInstancesDescription: "ブロックしたいサーバーのホストを改行で区切って設定してな。ブロックされてもうたサーバーとはもう金輪際やり取りできひんくなるで。ついでにそのサブドメインもブロックするで。" +silencedInstances: "サーバーサイレンスされてんねん" +silencedInstancesDescription: "サイレンスしたいサーバーのホストを改行で区切って設定すんで。サイレンスされたサーバーに所属するアカウントはすべて「サイレンス」として扱われ、フォローがすべてリクエストになり、フォロワーでないローカルアカウントにはメンションできなくなんねん。ブロックしたインスタンスには影響せーへんで。" muteAndBlock: "ミュートとブロック" mutedUsers: "ミュートしたユーザー" blockedUsers: "ブロックしたユーザー" @@ -410,12 +414,14 @@ aboutMisskey: "CherryPickってなんや?" administrator: "管理者" token: "トークン" 2fa: "二要素認証" +setupOf2fa: "二要素認証のセットアップ" totp: "認証アプリ" totpDescription: "認証アプリ使うてワンタイムパスワードを入れる" moderator: "モデレーター" moderation: "モデレーション" moderationNote: "モデレーションノート" addModerationNote: "モデレーションノートを追加するで" +moderationLogs: "モデログ" nUsersMentioned: "{n}人が投稿" securityKeyAndPasskey: "セキュリティキー・パスキー" securityKey: "セキュリティキー" @@ -540,6 +546,7 @@ serverLogs: "サーバーログ" deleteAll: "全部ほかす" showFixedPostForm: "タイムラインの上の方で投稿できるようにやってくれへん?" showFixedPostFormInChannel: "タイムラインの上の方で投稿できるようにするわ(チャンネル)" +withRepliesByDefaultForNewlyFollowed: "フォローする時、デフォルトで返信をタイムラインに含むようにしよか" newNoteRecived: "新しいノートがあるで" sounds: "サウンド" sound: "サウンド" @@ -598,7 +605,7 @@ poll: "アンケート" useCw: "内容を隠す" enablePlayer: "プレイヤーを開く" disablePlayer: "プレイヤーを閉じる" -expandTweet: "ツイートを展開する" +expandTweet: "ポストを展開する" themeEditor: "テーマエディター" description: "説明" describeFile: "キャプションを付ける" @@ -667,6 +674,7 @@ behavior: "動作" sample: "サンプル" abuseReports: "通報" reportAbuse: "通報" +reportAbuseRenote: "リノート苦情だすで?" reportAbuseOf: "{name}を通報する" fillAbuseReportDescription: "細かい通報理由を書いてなー。対象ノートがある時はそのURLも書いといてなー。" abuseReported: "無事内容が送信されたみたいやで。おおきに〜。" @@ -719,6 +727,7 @@ lockedAccountInfo: "フォローを承認制にしとっても、ノートの公 alwaysMarkSensitive: "デフォルトでメディアを閲覧注意にするで" loadRawImages: "添付画像のサムネイルをオリジナル画質にするで" disableShowingAnimatedImages: "アニメーション画像を再生せんとくで" +highlightSensitiveMedia: "メディアがセンシティブなことをめっっちゃわかりやすく表紙" verificationEmailSent: "無事確認のメールを送れたで。メールに書いてあるリンクにアクセスして、設定を完了してなー。" notSet: "未設定" emailVerified: "メールアドレスは確認されたで" @@ -1035,6 +1044,7 @@ retryAllQueuesConfirmText: "一時的にサーバー重なるかもしれへん enableChartsForRemoteUser: "リモートユーザーのチャートを作る" enableChartsForFederatedInstances: "リモートサーバーのチャートを作る" showClipButtonInNoteFooter: "ノートのアクションにクリップを追加" +reactionsDisplaySize: "リアクションの表示のでかさ" noteIdOrUrl: "ノートIDかURL" video: "動画" videos: "動画" @@ -1121,8 +1131,28 @@ replies: "返事" renotes: "Renote" loadReplies: "返信を見るで" loadConversation: "会話を見るで" +pinnedList: "ピン留めしはったリスト" +keepScreenOn: "デバイスの画面を常にオンにすんで" verifiedLink: "このリンク先の所有者であることが確認されたで。" +notifyNotes: "投稿を通知" +unnotifyNotes: "投稿の通知を解除すんで" +authentication: "認証" authenticationRequiredToContinue: "続けるには認証をやってや。" +dateAndTime: "日時" +showRenotes: "リノートを表示" +edited: "編集し終わってる" +notificationRecieveConfig: "通知を受け取るかの設定" +mutualFollow: "お互いフォローしてんで" +fileAttachedOnly: "ファイル付きのみ" +showRepliesToOthersInTimeline: "タイムラインに他の人への返信とかも含めんで" +hideRepliesToOthersInTimeline: "タイムラインに他の人への返信とかは見ーへんで" +externalServices: "他のサイトのサービス" +impressum: "運営者の情報" +impressumUrl: "運営者の情報URL" +impressumDescription: "ドイツなどのほんま1部の国と地域ではな、表示が義務付けられててん。(Impressum)" +privacyPolicy: "プライバシーポリシー" +privacyPolicyUrl: "プライバシーポリシーURL" +tosAndPrivacyPolicy: "利用規約・プライバシーポリシー" _announcement: forExistingUsers: "もうおるユーザーのみ" forExistingUsersDescription: "有効にすると、このお知らせ作成時点でおるユーザーにのみお知らせが表示されます。無効にすると、このお知らせ作成後にアカウントを作成したユーザーにもお知らせが表示されます。" @@ -1155,6 +1185,8 @@ _serverSettings: appIconUsageExample: "PWAや、スマートフォンのホーム画面にブックマークとして追加された時など" appIconStyleRecommendation: "円形もしくは角丸にクロップされる場合があるさかいに、塗り潰された余白のある背景があるものが推奨されるで。" appIconResolutionMustBe: "解像度は必ず{resolution}である必要があるで。" + manifestJsonOverride: "manifest.jsonのオーバーライド" + shortName: "略称" shortNameDescription: "サーバーの名前が長い時に、代わりに表示することのできるあだ名。" _accountMigration: moveFrom: "別のアカウントからこのアカウントに引っ越す" @@ -1410,6 +1442,9 @@ _achievements: title: "Brain Diver" description: "Brain Diverへのリンクを投稿したった" flavor: "CherryPick-CherryPick La-Tu-Ma" + _smashTestNotificationButton: + title: "テスト過剰" + description: "通知テストをごく短時間のうちに連続して行ったねん" _role: new: "ロールの作成" edit: "ロールの編集" @@ -1467,6 +1502,7 @@ _role: descriptionOfRateLimitFactor: "ちっちゃいほど制限が緩なって、大きいほど制限されるで。" canHideAds: "広告を表示させへん" canSearchNotes: "ノート検索を使わすかどうか" + canUseTranslator: "翻訳機能の利用" _condition: isLocal: "ローカルユーザー" isRemote: "リモートユーザー" @@ -1515,6 +1551,10 @@ _ad: reduceFrequencyOfThisAd: "この広告の表示頻度を下げるで" hide: "表示せん" timezoneinfo: "曜日はサーバーのタイムゾーンを元に指定されるで。" + adsSettings: "広告配信設定" + notesPerOneAd: "リアタイ更新中に広告を出す間隔(ノートの個数な)" + setZeroToDisable: "0でリアタイ更新時の広告配信を無効にすんで" + adsTooClose: "広告を出す間隔がめっちゃ短いから、ユーザー体験が著しく損なわれる可能性があんで。" _forgotPassword: enterEmail: "アカウントに登録したメールアドレスをここに入力してや。そのアドレス宛に、パスワードリセット用のリンクが送られるから待っててな~。" ifNoEmail: "メールアドレスを登録してへんのやったら、管理者まで教えてな~。" @@ -1782,6 +1822,7 @@ _2fa: step1: "ほんなら、{a}や{b}とかの認証アプリを使っとるデバイスにインストールしてな。" step2: "次に、ここにあるQRコードをアプリでスキャンしてな~。" step2Click: "QRコードをクリックすると、今使とる端末に入っとる認証アプリとかキーリングに登録できるで。" + step2Uri: "デスクトップアプリを使う時は次のURIを入れるで" step3Title: "確認コードを入れてーや" step3: "アプリに表示されているトークンを入力して終わりや。" setupCompleted: "設定が完了したで。" @@ -1800,6 +1841,7 @@ _2fa: renewTOTPOk: "もっかい設定する" renewTOTPCancel: "やめとく" checkBackupCodesBeforeCloseThisWizard: "このウィザードを閉じる前に、したのバックアップコードを確認しいや。" + backupCodes: "バックアップコード" backupCodesDescription: "認証アプリが使用できんなった場合、以下のバックアップコードを使ってアカウントにアクセスできるで。これらのコードは必ず安全な場所に置いときや。各コードは一回だけ使用できるで。" backupCodeUsedWarning: "バックアップコードが使用されたで。認証アプリが使えなくなってるん場合、なるべく早く認証アプリを再設定しや。" backupCodesExhaustedWarning: "バックアップコードが全て使用されたで。認証アプリを利用できん場合、これ以上アカウントにアクセスできなくなるで。認証アプリを再登録しや。" @@ -1856,6 +1898,7 @@ _antennaSources: users: "選らんだ一人か複数のユーザーのノート" userList: "選んだリストのユーザーのノート" userGroup: "選んだグループのユーザーのノート" + userBlacklist: "選んだ1人か複数のユーザーのノート" _weekday: sunday: "日曜日" monday: "月曜日" @@ -1955,6 +1998,7 @@ _profile: metadataContent: "内容" changeAvatar: "アバター画像を変更するで" changeBanner: "バナー画像を変更するで" + verifiedLinkDescription: "内容をURLに設定すると、リンク先のwebサイトに自分のプロフのリンクが含まれてる場合に所有者確認済みアイコンを表示させることができるで。" _exportOrImport: allNotes: "全てのノート" favoritedNotes: "お気に入りにしたノート" @@ -1964,6 +2008,7 @@ _exportOrImport: userLists: "リスト" excludeMutingUsers: "ミュートしてるユーザーは入れんとくわ" excludeInactiveUsers: "使われてなさそうなアカウントは入れんとくわ" + withReplies: "インポートした人による返信をTLに含むようにすんで。" _charts: federation: "連合" apRequest: "リクエスト" @@ -2077,14 +2122,17 @@ _notification: yourFollowRequestAccepted: "フォローさせてもろたで" youWereInvitedToGroup: "グループに招待されとるで" pollEnded: "アンケートの結果が出たみたいや" + newNote: "さらの投稿" unreadAntennaNote: "アンテナ {name}" emptyPushNotificationMessage: "プッシュ通知の更新をしといたで" achievementEarned: "実績を獲得しとるで" + testNotification: "通知テスト" checkNotificationBehavior: "通知の表示を確かめるで" sendTestNotification: "テスト通知を送信するで" notificationWillBeDisplayedLikeThis: "通知はこのように表示されるで" _types: all: "すべて" + note: "あんたらの新規投稿" follow: "フォロー" mention: "メンション" reply: "リプライ" @@ -2120,6 +2168,7 @@ _deck: widgetsIntroduction: "カラムのメニューから、「ウィジェットの編集」を選んでウィジェットを追加してなー" useSimpleUiForNonRootPages: "非ルートページは簡易UIで表示" usedAsMinWidthWhenFlexible: "「幅を自動調整」が有効の場合、これが幅の最小値となるで" + flexible: "幅を自動調整" _columns: main: "メイン" widgets: "ウィジェット" @@ -2155,6 +2204,41 @@ _webhookSettings: reaction: "ツッコミがあるとき~!" mention: "メンションがあるとき~!" _moderationLogTypes: + createRole: "ロールを追加すんで" + deleteRole: "ロールほかす" + updateRole: "ロールの更新すんで" + assignRole: "ロールへアサイン" + unassignRole: "ロールのアサインほかす" suspend: "凍結" + unsuspend: "凍結解除" + addCustomEmoji: "自由な絵文字追加されたで" + updateCustomEmoji: "自由な絵文字更新されたで" + deleteCustomEmoji: "自由な絵文字消されたで" + updateServerSettings: "サーバー設定更新すんねん" + updateUserNote: "モデレーションノート更新" + deleteDriveFile: "ファイルをほかす" + deleteNote: "ノートを削除" + createGlobalAnnouncement: "みんなへの通告を作成したで" + createUserAnnouncement: "あんたらへの通告を作成したで" + updateGlobalAnnouncement: "みんなへの通告更新したったで" + updateUserAnnouncement: "あんたらへの通告更新したったで" + deleteGlobalAnnouncement: "みんなへの通告消したったで" + deleteUserAnnouncement: "あんたらへのお知らせを削除" resetPassword: "パスワードをリセット" + suspendRemoteInstance: "リモートサーバーを止めんで" + unsuspendRemoteInstance: "リモートサーバーを再開すんで" + markSensitiveDriveFile: "ファイルをセンシティブ付与" + unmarkSensitiveDriveFile: "ファイルをセンシティブ解除" + resolveAbuseReport: "苦情を解決" createInvitation: "招待コードを作成" + createAd: "広告を作んで" + deleteAd: "広告ほかす" + updateAd: "広告を更新" +_fileViewer: + title: "ファイルの詳しい情報" + type: "ファイルの種類" + size: "ファイルのでかさ" + url: "URL" + uploadedAt: "追加した日" + attachedNotes: "ファイルがついてきてるノート" + thisPageCanBeSeenFromTheAuthor: "このページはこのファイルをアップした人しか見れへんねん。" diff --git a/locales/ko-KR.yml b/locales/ko-KR.yml index 9921e5dfae..f8aa82ef7b 100644 --- a/locales/ko-KR.yml +++ b/locales/ko-KR.yml @@ -1,5 +1,6 @@ --- _lang_: "한국어" +noteEdited: "노트를 편집했어요!" removeModalBgColorForBlur: "모달 배경색 제거" skipThisVersion: "이 릴리즈 건너뛰기" enableReceivePrerelease: "출시 전 버전 알림 받기" @@ -662,7 +663,7 @@ poll: "투표" useCw: "내용 숨기기" enablePlayer: "플레이어 열기" disablePlayer: "플레이어 닫기" -expandTweet: "트윗 확장하기" +expandTweet: "게시물 확장하기" themeEditor: "테마 에디터" description: "설명" describeFile: "캡션 추가" @@ -1954,6 +1955,7 @@ _theme: _sfx: note: "새 노트" noteMy: "내 노트" + noteEdited: "노트 편집" notification: "알림" chat: "대화" chatBg: "대화 (백그라운드)" @@ -2396,3 +2398,45 @@ _imageCompressionMode: noResizeCompress: "해상도를 축소하지 않고 압축" resizeCompressLossy: "해상도 축소 및 손실 압축" noResizeCompressLossy: "해상도를 축소하지 않고 손실 압축" +_externalResourceInstaller: + title: "외부 사이트에서 설치" + checkVendorBeforeInstall: "배포처가 신뢰할 수 있는 곳인지 확인 후 설치하세요." + _plugin: + title: "이 플러그인을 설치할까요?" + metaTitle: "플러그인 정보" + _theme: + title: "이 테마를 설치할까요?" + metaTitle: "테마 정보" + _meta: + base: "기본 색 구성표" + _vendorInfo: + title: "배포처 정보" + endpoint: "참조된 엔드포인트" + hashVerify: "파일 무결성 확인" + hashVerified: "확인됨" + _errors: + _invalidParams: + title: "매개변수가 부족해요" + description: "외부 사이트에서 데이터를 가져오는 데 필요한 정보가 부족해요. URL을 확인해 주세요." + _resourceTypeNotSupported: + title: "이 외부 리소스는 지원되지 않아요" + description: "이 외부 사이트에서 가져온 리소스의 종류는 지원되지 않아요. 사이트 관리자에게 문의해 주세요." + _failedToFetch: + title: "데이터 수집에 실패했어요" + fetchErrorDescription: "외부 사이트와의 통신에 실패했어요. 다시 시도 하거나 사이트 관리자에게 문의해 주세요." + parseErrorDescription: "외부 사이트에서 가져온 데이터를 읽을 수 없어요. 사이트 관리자에게 문의해 주세요." + _hashUnmatched: + title: "올바른 데이터를 얻지 못했어요" + description: "제공된 데이터의 무결성을 확인하지 못했어요. 보안을 위해 설치가 중단되었어요. 사이트 관리자에게 문의해 주세요." + _pluginParseFailed: + title: "AiScript 오류" + description: "데이터는 가져올 수 있었으나, AiScript 구문 분석에서 오류가 발생해 불러오지 못했어요. 플러그인 제작자에게 문의해 주세요. 오류에 대한 자세한 내용은 자바스크립트 콘솔에서 확인할 수 있어요." + _pluginInstallFailed: + title: "플러그인 설치에 실패했어요" + description: "플러그인 설치 중 문제가 발생했어요. 다시 시도해 주세요. 오류에 대한 자세한 내용은 자바스크립트 콘솔을 참조해 주세요." + _themeParseFailed: + title: "테마 분석 오류" + description: "데이터는 가져올 수 있었으나, 테마 파일 분석 중 오류가 발생해 불러오지 못했어요. 테마 제작자에게 문의해 주세요. 오류에 대한 자세한 내용은 자바스크립트 콘솔에서 확인할 수 있어요." + _themeInstallFailed: + title: "테마 설치에 실패했어요" + description: "테마를 설치하는 동안 문제가 발생했어요. 다시 시도해 주세요. 오류에 대한 자세한 내용은 자바스크립트 콘솔을 참고해 주세요." diff --git a/locales/th-TH.yml b/locales/th-TH.yml index abbe604aef..aac08bbf5d 100644 --- a/locales/th-TH.yml +++ b/locales/th-TH.yml @@ -1131,15 +1131,25 @@ keepScreenOn: "เปิดหน้าจอไว้" notifyNotes: "แจ้งเตือนเกี่ยวกับโพสต์ใหม่" unnotifyNotes: "หยุดการแจ้งเตือนเกี่ยวกับโน้ตใหม่" authentication: "การตรวจสอบสิทธิ์" +authenticationRequiredToContinue: "กรุณาตรวจสอบการรับรองความถูกต้องเพื่อดำเนินการต่อ" dateAndTime: "เวลาประทับ" showRenotes: "แสดงรีโน้ต" edited: "แก้ไขแล้ว" notificationRecieveConfig: "การตั้งค่าการแจ้งเตือน" mutualFollow: "ติดตามซึ่งกันและกัน" fileAttachedOnly: "เฉพาะโน้ตที่มีไฟล์เท่านั้น" +showRepliesToOthersInTimeline: "แสดงการตอบกลับไปยังอื่นๆในไทม์ไลน์" +hideRepliesToOthersInTimeline: "ซ่อนการตอบกลับไปยังอื่นๆจากไทม์ไลน์" +externalServices: "บริการภายนอก" +impressum: "อิมเพรสชั่น" +impressumUrl: "URL อิมเพรสชั่น" +privacyPolicy: "นโยบายความเป็นส่วนตัว" +privacyPolicyUrl: "URL นโยบายความเป็นส่วนตัว" +tosAndPrivacyPolicy: "เงื่อนไขในการให้บริการและนโยบายความเป็นส่วนตัว" _announcement: forExistingUsers: "ผู้ใช้งานที่มีอยู่เท่านั้น" forExistingUsersDescription: "การประกาศนี้จะแสดงต่อผู้ใช้ที่มีอยู่ ณ จุดที่เผยแพร่นั้นๆถ้าหากเปิดใช้งาน ถ้าหากปิดใช้งานผู้ที่กำลังสมัครใหม่หลังจากโพสต์แล้วนั้นก็จะเห็นเช่นกัน" + needConfirmationToRead: "จำเป็นต้องยืนยันเพื่อทำเครื่องหมายบอกว่าอ่านแล้ว" needConfirmationToReadDescription: "ข้อความแจ้งแยก ถ้าหากต้องการเพื่อยืนยันว่ากำลังทำเครื่องหมายประกาศนี้ว่าอ่านแล้วจะแสดงขึ้นถ้าหากเปิดใช้งาน การประกาศนั้นจะไม่รวมอยู่ในฟังก์ชั่นว่า \"ทำเครื่องหมายทั้งหมดว่าอ่านแล้ว\"" end: "ประกาศเก็บถาวร" tooManyActiveAnnouncementDescription: "การมีประกาศที่ใช้งานมากเกินไปนั้นอาจจะทำให้ประสบการณ์ของผู้ใช้งานนั้นดูแย่ลง โปรดกรุณาพิจารณาการเก็บประกาศที่ล้าสมัยด้วยนะค่ะ" @@ -1164,6 +1174,8 @@ _serverRules: description: "ชุดของกฎที่จะแสดงก่อนการลงทะเบียนเราขอแนะนำให้ตั้งค่าสรุปข้อกำหนดในการให้บริการ" _serverSettings: iconUrl: "ไอคอน URL" + appIconUsageExample: "E.g. เป็น PWA หรือเมื่อแสดงผลเป็นบุ๊กมาร์กหน้าจอหลักบนโทรศัพท์" + appIconResolutionMustBe: "ความละเอียดขั้นต่ำไว้คือ {resolution}." manifestJsonOverride: "manifest.json โอเวอร์ลาย" shortName: "ชื่อย่อ" _accountMigration: @@ -1530,6 +1542,8 @@ _ad: reduceFrequencyOfThisAd: "แสดงโฆษณานี้ให้น้อยลง" hide: "ไม่ต้องแสดง" timezoneinfo: "วันในสัปดาห์นี้จะถูกกำหนดจากโซนเวลาของเซิร์ฟเวอร์" + adsSettings: "ตั้งค่าการโฆษณา" + setZeroToDisable: "ตั้งค่านี้ให้เป็น 0 เพื่อปิดใช้งานโฆษณาอัปเดตแบบเรียลไทม์" _forgotPassword: enterEmail: "ป้อนที่อยู่อีเมลที่คุณเคยใช้ในการลงทะเบียนไว้ ลิงก์ที่คุณสามารถรีเซ็ตรหัสผ่านได้นั้นจะถูกส่งไปนะ" ifNoEmail: "ถ้าหากคุณไม่ได้ใช้อีเมลระหว่างการลงทะเบียน กรุณาติดต่อผู้ดูแลระบบอินสแตนซ์แทนนะ" @@ -1797,6 +1811,7 @@ _2fa: step1: "ขั้นตอนแรก ติดตั้งแอปยืนยันตัวตน (เช่น {a} หรือ {b}) บนอุปกรณ์ของคุณ" step2: "จากนั้นสแกนรหัส QR ที่แสดงบนหน้าจอนี้" step2Click: "การคลิกที่รหัส QR นี้จะช่วยให้คุณนั้นสามารถลงทะเบียน 2FA กับคีย์ความปลอดภัยหรือแอปตรวจสอบความถูกต้องของโทรศัพท์ได้" + step2Uri: "ป้อนใส่ URL ดังต่อไปนี้ถ้าหากคุณใช้โปรแกรมเดสก์ท็อป" step3Title: "ป้อนรหัสยืนยัน" step3: "ป้อนโทเค็นที่แอปของคุณให้มาเพื่อเสร็จสิ้นการตั้งค่า" setupCompleted: "ตั้งค่าสำเร็จแล้ว" @@ -1815,6 +1830,8 @@ _2fa: renewTOTPOk: "ตั้งค่าคอนฟิกใหม่" renewTOTPCancel: "ไม่เป็นไร" backupCodes: "รหัสสำรองข้อมูล" + backupCodeUsedWarning: "มีการใช้รหัสสำรองแล้ว โปรดกรุณากำหนดค่าการตรวจสอบสิทธิ์แบบสองปัจจัยโดยเร็วที่สุดถ้าหากคุณยังไม่สามารถใช้งานได้อีก" + backupCodesExhaustedWarning: "รหัสสำรองทั้งหมดถูกใช้แล้ว ถ้าหากคุณยังสูญเสียการเข้าถึงแอปการตรวจสอบสิทธิ์แบบสองปัจจัยคุณจะยังไม่สามารถเข้าถึงบัญชีนี้ได้ กรุณากำหนดค่าการรับรองความถูกต้องด้วยการยืนยันสองชั้น" _permissions: "read:account": "ดูข้อมูลบัญชีของคุณ" "write:account": "แก้ไขข้อมูลบัญชีของคุณ" @@ -1978,6 +1995,7 @@ _exportOrImport: userLists: "รายการ" excludeMutingUsers: "ยกเว้นผู้ใช้ที่ปิดเสียง" excludeInactiveUsers: "ยกเว้นผู้ใช้ที่ไม่ได้ใช้งาน" + withReplies: "รวมการตอบกลับจากผู้ใช้ที่นำเข้าไว้ในไทม์ไลน์" _charts: federation: "สหพันธ์" apRequest: "คำขอ" @@ -2203,3 +2221,11 @@ _moderationLogTypes: createAd: "สร้างโฆษณาแล้ว" deleteAd: "ลบโฆษณาออกแล้ว" updateAd: "อัปเดตโฆษณาแล้ว" +_fileViewer: + title: "รายละเอียดไฟล์" + type: "ประเภทไฟล์" + size: "ขนาดไฟล์" + url: "URL" + uploadedAt: "วันที่เข้าร่วม" + attachedNotes: "โน้ตที่แนบมาด้วย" + thisPageCanBeSeenFromTheAuthor: "หน้าเพจนี้จะสามารถปรากฏได้โดยผู้ใช้ที่อัปโหลดไฟล์นี้เท่านั้น" diff --git a/locales/ug-CN.yml b/locales/ug-CN.yml index 65ef841259..e48f64511c 100644 --- a/locales/ug-CN.yml +++ b/locales/ug-CN.yml @@ -1,4 +1,19 @@ --- _lang_: "ياپونچە" +headlineMisskey: "خاتىرە ئارقىلىق ئۇلانغان تور" +monthAndDay: "{day}-{month}" search: "ئىزدەش" +ok: "ماقۇل" +noThankYou: "ئۇنى توختىتىڭ" +profile: "profile" +login: "كىرىش" +loggingIn: "كىرىش" +pin: "pinned" +delete: "ئۆچۈرۈش" +pinned: "pinned" +remove: "ئۆچۈرۈش" searchByGoogle: "ئىزدەش" +_2fa: + renewTOTPCancel: "ئۇنى توختىتىڭ" +_widgets: + profile: "profile" diff --git a/locales/zh-CN.yml b/locales/zh-CN.yml index 73ad738cf2..a79d694397 100644 --- a/locales/zh-CN.yml +++ b/locales/zh-CN.yml @@ -195,6 +195,7 @@ perHour: "每小时" perDay: "每天" stopActivityDelivery: "停止发送活动" blockThisInstance: "阻止此服务器向本服务器推流" +silenceThisInstance: "使服务器静音" operations: "操作" software: "软件" version: "版本" @@ -214,6 +215,8 @@ clearCachedFiles: "清除缓存" clearCachedFilesConfirm: "确定要清除缓存文件?" blockedInstances: "被封锁的服务器" blockedInstancesDescription: "设定要封锁的服务器,以换行来进行分割。被封锁的服务器将无法与本服务器进行交换通讯。子域名也同样会被封锁。" +silencedInstances: "沉默的服务器" +silencedInstancesDescription: "设置要静音的服务器的主机,以换行符分隔。属于静默服务器的所有帐户都将被视为“静默”,所有关注都将成为请求,并且您将无法提及非关注者的本地帐户。被阻止的实例不受影响。" muteAndBlock: "屏蔽/拉黑" mutedUsers: "已屏蔽用户" blockedUsers: "已拉黑的用户" @@ -2216,3 +2219,6 @@ _moderationLogTypes: createAd: "创建了广告" deleteAd: "删除了广告" updateAd: "更新了广告" +_fileViewer: + url: "URL" + uploadedAt: "添加日期" diff --git a/locales/zh-TW.yml b/locales/zh-TW.yml index 4a1c68f3cd..e77d3358a3 100644 --- a/locales/zh-TW.yml +++ b/locales/zh-TW.yml @@ -195,6 +195,7 @@ perHour: "每小時" perDay: "每日" stopActivityDelivery: "停止發送活動" blockThisInstance: "封鎖此伺服器" +silenceThisInstance: "禁言此伺服器" operations: "操作" software: "軟體" version: "版本" @@ -214,6 +215,8 @@ clearCachedFiles: "清除快取資料" clearCachedFilesConfirm: "確定要清除所有遠端暫存資料嗎?" blockedInstances: "已封鎖的伺服器" blockedInstancesDescription: "請逐行輸入需要封鎖的伺服器。已封鎖的伺服器將無法與本伺服器進行通訊。" +silencedInstances: "被禁言的伺服器" +silencedInstancesDescription: "設定要禁言的伺服器主機名稱,以換行分隔。隸屬於禁言伺服器的所有帳戶都將被視為「禁言帳戶」,只能發出「追隨請求」,而且無法提及未追隨的本地帳戶。這不會影響已封鎖的實例。" muteAndBlock: "靜音和封鎖" mutedUsers: "被靜音的使用者" blockedUsers: "被封鎖的使用者" @@ -543,6 +546,7 @@ serverLogs: "伺服器日誌" deleteAll: "刪除所有記錄" showFixedPostForm: "於時間軸頁頂顯示「發送貼文」方框" showFixedPostFormInChannel: "於時間軸頁頂顯示「發送貼文」方框(頻道)" +withRepliesByDefaultForNewlyFollowed: "在追隨其他人後,預設在時間軸納入回覆的貼文" newNoteRecived: "發現新貼文" sounds: "音效" sound: "音效" @@ -1139,8 +1143,8 @@ showRenotes: "顯示轉發貼文" edited: "已編輯" notificationRecieveConfig: "接受通知的設定" mutualFollow: "互相追隨" -fileAttachedOnly: "包含附件" -showRepliesToOthersInTimeline: "在時間軸上顯示給其他人的回覆" +fileAttachedOnly: "顯示包含附件的貼文" +showRepliesToOthersInTimeline: "顯示給其他人的回覆" hideRepliesToOthersInTimeline: "在時間軸上隱藏給其他人的回覆" externalServices: "外部服務" impressum: "營運者資訊" @@ -2005,6 +2009,7 @@ _exportOrImport: userLists: "清單" excludeMutingUsers: "排除被靜音的使用者" excludeInactiveUsers: "排除不活躍帳戶" + withReplies: "將被匯入的追隨中清單的貼文回覆包含在時間軸" _charts: federation: "聯邦宇宙" apRequest: "請求" diff --git a/package.json b/package.json index 8e6284b24c..32d00b6dad 100644 --- a/package.json +++ b/package.json @@ -1,13 +1,13 @@ { "name": "cherrypick", - "version": "4.4.0", - "basedMisskeyVersion": "2023.10.1", + "version": "4.4.1", + "basedMisskeyVersion": "2023.10.2", "codename": "nasubi", "repository": { "type": "git", "url": "https://github.com/kokonect-link/cherrypick.git" }, - "packageManager": "pnpm@8.8.0", + "packageManager": "pnpm@8.9.2", "workspaces": [ "packages/frontend", "packages/backend", @@ -50,14 +50,14 @@ "cssnano": "6.0.1", "js-yaml": "4.1.0", "postcss": "8.4.31", - "terser": "5.21.0", + "terser": "5.22.0", "typescript": "5.2.2" }, "devDependencies": { - "@typescript-eslint/eslint-plugin": "6.7.5", - "@typescript-eslint/parser": "6.7.5", + "@typescript-eslint/eslint-plugin": "6.8.0", + "@typescript-eslint/parser": "6.8.0", "cross-env": "7.0.3", - "cypress": "13.3.0", + "cypress": "13.3.2", "eslint": "8.51.0", "start-server-and-test": "2.0.1" }, diff --git a/packages/backend/migration/1696318192428-noteUpdatedAtHistory.js b/packages/backend/migration/1696318192428-noteUpdatedAtHistory.js new file mode 100644 index 0000000000..70220f3058 --- /dev/null +++ b/packages/backend/migration/1696318192428-noteUpdatedAtHistory.js @@ -0,0 +1,17 @@ +/* + * SPDX-FileCopyrightText: syuilo and other misskey, cherrypick contributors + * SPDX-License-Identifier: AGPL-3.0-only + */ + +export class NoteUpdateAtHistory1696318192428 { + name = 'NoteUpdateAtHistory1696318192428' + + async up(queryRunner) { + await queryRunner.query(`ALTER TABLE "note" ADD "updatedAtHistory" TIMESTAMP WITH TIME ZONE array`); + } + + async down(queryRunner) { + await queryRunner.query(`ALTER TABLE "note" DROP "updatedAtHistory"`); + } + +} diff --git a/packages/backend/migration/1697247230117-InstanceSilence.js b/packages/backend/migration/1697247230117-InstanceSilence.js new file mode 100644 index 0000000000..e257550d0d --- /dev/null +++ b/packages/backend/migration/1697247230117-InstanceSilence.js @@ -0,0 +1,16 @@ +/* + * SPDX-FileCopyrightText: syuilo and other misskey, cherrypick contributors + * SPDX-License-Identifier: AGPL-3.0-only + */ + +export class InstanceSilence1697247230117 { + name = 'InstanceSilence1697247230117' + + async up(queryRunner) { + await queryRunner.query(`ALTER TABLE "meta" ADD "silencedHosts" character varying(1024) array NOT NULL DEFAULT '{}'`); + } + + async down(queryRunner) { + await queryRunner.query(`ALTER TABLE "meta" DROP COLUMN "silencedHosts"`); + } +} diff --git a/packages/backend/migration/1697420555911-deleteCreatedAt.js b/packages/backend/migration/1697420555911-deleteCreatedAt.js new file mode 100644 index 0000000000..ea423507ad --- /dev/null +++ b/packages/backend/migration/1697420555911-deleteCreatedAt.js @@ -0,0 +1,142 @@ +/* + * SPDX-FileCopyrightText: syuilo and other misskey, cherrypick contributors + * SPDX-License-Identifier: AGPL-3.0-only + */ + +export class DeleteCreatedAt1697420555911 { + name = 'DeleteCreatedAt1697420555911' + + async up(queryRunner) { + await queryRunner.query(`DROP INDEX "public"."IDX_02878d441ceae15ce060b73daf"`); + await queryRunner.query(`DROP INDEX "public"."IDX_c8dfad3b72196dd1d6b5db168a"`); + await queryRunner.query(`DROP INDEX "public"."IDX_e11e649824a45d8ed01d597fd9"`); + await queryRunner.query(`DROP INDEX "public"."IDX_db2098070b2b5a523c58181f74"`); + await queryRunner.query(`DROP INDEX "public"."IDX_048a757923ed8b157e9895da53"`); + await queryRunner.query(`DROP INDEX "public"."IDX_1129c2ef687fc272df040bafaa"`); + await queryRunner.query(`DROP INDEX "public"."IDX_118ec703e596086fc4515acb39"`); + await queryRunner.query(`DROP INDEX "public"."IDX_b9a354f7941c1e779f3b33aea6"`); + await queryRunner.query(`DROP INDEX "public"."IDX_71cb7b435b7c0d4843317e7e16"`); + await queryRunner.query(`DROP INDEX "public"."IDX_11e71f2511589dcc8a4d3214f9"`); + await queryRunner.query(`DROP INDEX "public"."IDX_735a5544f9249d412255f47f95"`); + await queryRunner.query(`DROP INDEX "public"."IDX_582f8fab771a9040a12961f3e7"`); + await queryRunner.query(`DROP INDEX "public"."IDX_8f1a239bd077c8864a20c62c2c"`); + await queryRunner.query(`DROP INDEX "public"."IDX_f86d57fbca33c7a4e6897490cc"`); + await queryRunner.query(`DROP INDEX "public"."IDX_fbb4297c927a9b85e9cefa2eb1"`); + await queryRunner.query(`DROP INDEX "public"."IDX_0fb627e1c2f753262a74f0562d"`); + await queryRunner.query(`DROP INDEX "public"."IDX_149d2e44785707548c82999b01"`); + await queryRunner.query(`ALTER TABLE "drive_folder" DROP COLUMN "createdAt"`); + await queryRunner.query(`ALTER TABLE "drive_file" DROP COLUMN "createdAt"`); + await queryRunner.query(`ALTER TABLE "user" DROP COLUMN "createdAt"`); + await queryRunner.query(`ALTER TABLE "abuse_user_report" DROP COLUMN "createdAt"`); + await queryRunner.query(`ALTER TABLE "app" DROP COLUMN "createdAt"`); + await queryRunner.query(`ALTER TABLE "access_token" DROP COLUMN "createdAt"`); + await queryRunner.query(`ALTER TABLE "ad" DROP COLUMN "createdAt"`); + await queryRunner.query(`ALTER TABLE "announcement" DROP COLUMN "createdAt"`); + await queryRunner.query(`ALTER TABLE "announcement_read" DROP COLUMN "createdAt"`); + await queryRunner.query(`ALTER TABLE "user_list" DROP COLUMN "createdAt"`); + await queryRunner.query(`ALTER TABLE "antenna" DROP COLUMN "createdAt"`); + await queryRunner.query(`ALTER TABLE "auth_session" DROP COLUMN "createdAt"`); + await queryRunner.query(`ALTER TABLE "blocking" DROP COLUMN "createdAt"`); + await queryRunner.query(`ALTER TABLE "channel" DROP COLUMN "createdAt"`); + await queryRunner.query(`ALTER TABLE "channel_following" DROP COLUMN "createdAt"`); + await queryRunner.query(`ALTER TABLE "channel_favorite" DROP COLUMN "createdAt"`); + await queryRunner.query(`ALTER TABLE "clip" DROP COLUMN "createdAt"`); + await queryRunner.query(`ALTER TABLE "note" DROP COLUMN "createdAt"`); + await queryRunner.query(`ALTER TABLE "clip_favorite" DROP COLUMN "createdAt"`); + await queryRunner.query(`ALTER TABLE "following" DROP COLUMN "createdAt"`); + await queryRunner.query(`ALTER TABLE "follow_request" DROP COLUMN "createdAt"`); + await queryRunner.query(`ALTER TABLE "gallery_post" DROP COLUMN "createdAt"`); + await queryRunner.query(`ALTER TABLE "gallery_like" DROP COLUMN "createdAt"`); + await queryRunner.query(`ALTER TABLE "moderation_log" DROP COLUMN "createdAt"`); + await queryRunner.query(`ALTER TABLE "muting" DROP COLUMN "createdAt"`); + await queryRunner.query(`ALTER TABLE "renote_muting" DROP COLUMN "createdAt"`); + await queryRunner.query(`ALTER TABLE "note_favorite" DROP COLUMN "createdAt"`); + await queryRunner.query(`ALTER TABLE "note_reaction" DROP COLUMN "createdAt"`); + await queryRunner.query(`ALTER TABLE "note_thread_muting" DROP COLUMN "createdAt"`); + await queryRunner.query(`ALTER TABLE "page" DROP COLUMN "createdAt"`); + await queryRunner.query(`ALTER TABLE "page_like" DROP COLUMN "createdAt"`); + await queryRunner.query(`ALTER TABLE "password_reset_request" DROP COLUMN "createdAt"`); + await queryRunner.query(`ALTER TABLE "poll_vote" DROP COLUMN "createdAt"`); + await queryRunner.query(`ALTER TABLE "promo_read" DROP COLUMN "createdAt"`); + await queryRunner.query(`ALTER TABLE "registration_ticket" DROP COLUMN "createdAt"`); + await queryRunner.query(`ALTER TABLE "registry_item" DROP COLUMN "createdAt"`); + await queryRunner.query(`ALTER TABLE "signin" DROP COLUMN "createdAt"`); + await queryRunner.query(`ALTER TABLE "sw_subscription" DROP COLUMN "createdAt"`); + await queryRunner.query(`ALTER TABLE "user_list_favorite" DROP COLUMN "createdAt"`); + await queryRunner.query(`ALTER TABLE "user_list_membership" DROP COLUMN "createdAt"`); + await queryRunner.query(`ALTER TABLE "user_note_pining" DROP COLUMN "createdAt"`); + await queryRunner.query(`ALTER TABLE "user_pending" DROP COLUMN "createdAt"`); + await queryRunner.query(`ALTER TABLE "webhook" DROP COLUMN "createdAt"`); + await queryRunner.query(`ALTER TABLE "role" DROP COLUMN "createdAt"`); + await queryRunner.query(`ALTER TABLE "role_assignment" DROP COLUMN "createdAt"`); + await queryRunner.query(`ALTER TABLE "flash" DROP COLUMN "createdAt"`); + await queryRunner.query(`ALTER TABLE "flash_like" DROP COLUMN "createdAt"`); + } + + async down(queryRunner) { + await queryRunner.query(`ALTER TABLE "flash_like" ADD "createdAt" TIMESTAMP WITH TIME ZONE NOT NULL`); + await queryRunner.query(`ALTER TABLE "flash" ADD "createdAt" TIMESTAMP WITH TIME ZONE NOT NULL`); + await queryRunner.query(`ALTER TABLE "role_assignment" ADD "createdAt" TIMESTAMP WITH TIME ZONE NOT NULL`); + await queryRunner.query(`ALTER TABLE "role" ADD "createdAt" TIMESTAMP WITH TIME ZONE NOT NULL`); + await queryRunner.query(`ALTER TABLE "webhook" ADD "createdAt" TIMESTAMP WITH TIME ZONE NOT NULL`); + await queryRunner.query(`ALTER TABLE "user_pending" ADD "createdAt" TIMESTAMP WITH TIME ZONE NOT NULL`); + await queryRunner.query(`ALTER TABLE "user_note_pining" ADD "createdAt" TIMESTAMP WITH TIME ZONE NOT NULL`); + await queryRunner.query(`ALTER TABLE "user_list_membership" ADD "createdAt" TIMESTAMP WITH TIME ZONE NOT NULL`); + await queryRunner.query(`ALTER TABLE "user_list_favorite" ADD "createdAt" TIMESTAMP WITH TIME ZONE NOT NULL`); + await queryRunner.query(`ALTER TABLE "sw_subscription" ADD "createdAt" TIMESTAMP WITH TIME ZONE NOT NULL`); + await queryRunner.query(`ALTER TABLE "signin" ADD "createdAt" TIMESTAMP WITH TIME ZONE NOT NULL`); + await queryRunner.query(`ALTER TABLE "registry_item" ADD "createdAt" TIMESTAMP WITH TIME ZONE NOT NULL`); + await queryRunner.query(`ALTER TABLE "registration_ticket" ADD "createdAt" TIMESTAMP WITH TIME ZONE NOT NULL`); + await queryRunner.query(`ALTER TABLE "promo_read" ADD "createdAt" TIMESTAMP WITH TIME ZONE NOT NULL`); + await queryRunner.query(`ALTER TABLE "poll_vote" ADD "createdAt" TIMESTAMP WITH TIME ZONE NOT NULL`); + await queryRunner.query(`ALTER TABLE "password_reset_request" ADD "createdAt" TIMESTAMP WITH TIME ZONE NOT NULL`); + await queryRunner.query(`ALTER TABLE "page_like" ADD "createdAt" TIMESTAMP WITH TIME ZONE NOT NULL`); + await queryRunner.query(`ALTER TABLE "page" ADD "createdAt" TIMESTAMP WITH TIME ZONE NOT NULL`); + await queryRunner.query(`ALTER TABLE "note_thread_muting" ADD "createdAt" TIMESTAMP WITH TIME ZONE NOT NULL`); + await queryRunner.query(`ALTER TABLE "note_reaction" ADD "createdAt" TIMESTAMP WITH TIME ZONE NOT NULL`); + await queryRunner.query(`ALTER TABLE "note_favorite" ADD "createdAt" TIMESTAMP WITH TIME ZONE NOT NULL`); + await queryRunner.query(`ALTER TABLE "renote_muting" ADD "createdAt" TIMESTAMP WITH TIME ZONE NOT NULL`); + await queryRunner.query(`ALTER TABLE "muting" ADD "createdAt" TIMESTAMP WITH TIME ZONE NOT NULL`); + await queryRunner.query(`ALTER TABLE "moderation_log" ADD "createdAt" TIMESTAMP WITH TIME ZONE NOT NULL`); + await queryRunner.query(`ALTER TABLE "gallery_like" ADD "createdAt" TIMESTAMP WITH TIME ZONE NOT NULL`); + await queryRunner.query(`ALTER TABLE "gallery_post" ADD "createdAt" TIMESTAMP WITH TIME ZONE NOT NULL`); + await queryRunner.query(`ALTER TABLE "follow_request" ADD "createdAt" TIMESTAMP WITH TIME ZONE NOT NULL`); + await queryRunner.query(`ALTER TABLE "following" ADD "createdAt" TIMESTAMP WITH TIME ZONE NOT NULL`); + await queryRunner.query(`ALTER TABLE "clip_favorite" ADD "createdAt" TIMESTAMP WITH TIME ZONE NOT NULL`); + await queryRunner.query(`ALTER TABLE "note" ADD "createdAt" TIMESTAMP WITH TIME ZONE NOT NULL`); + await queryRunner.query(`ALTER TABLE "clip" ADD "createdAt" TIMESTAMP WITH TIME ZONE NOT NULL`); + await queryRunner.query(`ALTER TABLE "channel_favorite" ADD "createdAt" TIMESTAMP WITH TIME ZONE NOT NULL`); + await queryRunner.query(`ALTER TABLE "channel_following" ADD "createdAt" TIMESTAMP WITH TIME ZONE NOT NULL`); + await queryRunner.query(`ALTER TABLE "channel" ADD "createdAt" TIMESTAMP WITH TIME ZONE NOT NULL`); + await queryRunner.query(`ALTER TABLE "blocking" ADD "createdAt" TIMESTAMP WITH TIME ZONE NOT NULL`); + await queryRunner.query(`ALTER TABLE "auth_session" ADD "createdAt" TIMESTAMP WITH TIME ZONE NOT NULL`); + await queryRunner.query(`ALTER TABLE "antenna" ADD "createdAt" TIMESTAMP WITH TIME ZONE NOT NULL`); + await queryRunner.query(`ALTER TABLE "user_list" ADD "createdAt" TIMESTAMP WITH TIME ZONE NOT NULL`); + await queryRunner.query(`ALTER TABLE "announcement_read" ADD "createdAt" TIMESTAMP WITH TIME ZONE NOT NULL`); + await queryRunner.query(`ALTER TABLE "announcement" ADD "createdAt" TIMESTAMP WITH TIME ZONE NOT NULL`); + await queryRunner.query(`ALTER TABLE "ad" ADD "createdAt" TIMESTAMP WITH TIME ZONE NOT NULL`); + await queryRunner.query(`ALTER TABLE "access_token" ADD "createdAt" TIMESTAMP WITH TIME ZONE NOT NULL`); + await queryRunner.query(`ALTER TABLE "app" ADD "createdAt" TIMESTAMP WITH TIME ZONE NOT NULL`); + await queryRunner.query(`ALTER TABLE "abuse_user_report" ADD "createdAt" TIMESTAMP WITH TIME ZONE NOT NULL`); + await queryRunner.query(`ALTER TABLE "user" ADD "createdAt" TIMESTAMP WITH TIME ZONE NOT NULL`); + await queryRunner.query(`ALTER TABLE "drive_file" ADD "createdAt" TIMESTAMP WITH TIME ZONE NOT NULL`); + await queryRunner.query(`ALTER TABLE "drive_folder" ADD "createdAt" TIMESTAMP WITH TIME ZONE NOT NULL`); + await queryRunner.query(`CREATE INDEX "IDX_149d2e44785707548c82999b01" ON "flash" ("createdAt") `); + await queryRunner.query(`CREATE INDEX "IDX_0fb627e1c2f753262a74f0562d" ON "poll_vote" ("createdAt") `); + await queryRunner.query(`CREATE INDEX "IDX_fbb4297c927a9b85e9cefa2eb1" ON "page" ("createdAt") `); + await queryRunner.query(`CREATE INDEX "IDX_f86d57fbca33c7a4e6897490cc" ON "muting" ("createdAt") `); + await queryRunner.query(`CREATE INDEX "IDX_8f1a239bd077c8864a20c62c2c" ON "gallery_post" ("createdAt") `); + await queryRunner.query(`CREATE INDEX "IDX_582f8fab771a9040a12961f3e7" ON "following" ("createdAt") `); + await queryRunner.query(`CREATE INDEX "IDX_735a5544f9249d412255f47f95" ON "channel_favorite" ("createdAt") `); + await queryRunner.query(`CREATE INDEX "IDX_11e71f2511589dcc8a4d3214f9" ON "channel_following" ("createdAt") `); + await queryRunner.query(`CREATE INDEX "IDX_71cb7b435b7c0d4843317e7e16" ON "channel" ("createdAt") `); + await queryRunner.query(`CREATE INDEX "IDX_b9a354f7941c1e779f3b33aea6" ON "blocking" ("createdAt") `); + await queryRunner.query(`CREATE INDEX "IDX_118ec703e596086fc4515acb39" ON "announcement" ("createdAt") `); + await queryRunner.query(`CREATE INDEX "IDX_1129c2ef687fc272df040bafaa" ON "ad" ("createdAt") `); + await queryRunner.query(`CREATE INDEX "IDX_048a757923ed8b157e9895da53" ON "app" ("createdAt") `); + await queryRunner.query(`CREATE INDEX "IDX_db2098070b2b5a523c58181f74" ON "abuse_user_report" ("createdAt") `); + await queryRunner.query(`CREATE INDEX "IDX_e11e649824a45d8ed01d597fd9" ON "user" ("createdAt") `); + await queryRunner.query(`CREATE INDEX "IDX_c8dfad3b72196dd1d6b5db168a" ON "drive_file" ("createdAt") `); + await queryRunner.query(`CREATE INDEX "IDX_02878d441ceae15ce060b73daf" ON "drive_folder" ("createdAt") `); + } +} diff --git a/packages/backend/migration/1697436246389-antenna-localOnly.js b/packages/backend/migration/1697436246389-antenna-localOnly.js new file mode 100644 index 0000000000..15d147f210 --- /dev/null +++ b/packages/backend/migration/1697436246389-antenna-localOnly.js @@ -0,0 +1,16 @@ +/* + * SPDX-FileCopyrightText: syuilo and other misskey, cherrypick contributors + * SPDX-License-Identifier: AGPL-3.0-only + */ + +export class AntennaLocalOnly1697436246389 { + name = 'AntennaLocalOnly1697436246389' + + async up(queryRunner) { + await queryRunner.query(`ALTER TABLE "antenna" ADD "localOnly" boolean NOT NULL DEFAULT false`); + } + + async down(queryRunner) { + await queryRunner.query(`ALTER TABLE "antenna" DROP COLUMN "localOnly"`); + } +} diff --git a/packages/backend/migration/1697441463087-FollowRequestWithReplies.js b/packages/backend/migration/1697441463087-FollowRequestWithReplies.js new file mode 100644 index 0000000000..889200bc95 --- /dev/null +++ b/packages/backend/migration/1697441463087-FollowRequestWithReplies.js @@ -0,0 +1,17 @@ +/* + * SPDX-FileCopyrightText: syuilo and other misskey, cherrypick contributors + * SPDX-License-Identifier: AGPL-3.0-only + */ + + +export class FollowRequestWithReplies1697441463087 { + name = 'FollowRequestWithReplies1697441463087' + + async up(queryRunner) { + await queryRunner.query(`ALTER TABLE "follow_request" ADD "withReplies" boolean NOT NULL DEFAULT false`); + } + + async down(queryRunner) { + await queryRunner.query(`ALTER TABLE "follow_request" DROP COLUMN "withReplies"`); + } +} diff --git a/packages/backend/migration/1697673894459-note-reactionAndUserPairCache.js b/packages/backend/migration/1697673894459-note-reactionAndUserPairCache.js new file mode 100644 index 0000000000..4404e03752 --- /dev/null +++ b/packages/backend/migration/1697673894459-note-reactionAndUserPairCache.js @@ -0,0 +1,17 @@ +/* + * SPDX-FileCopyrightText: syuilo and other misskey, cherrypick contributors + * SPDX-License-Identifier: AGPL-3.0-only + */ + + +export class NoteReactionAndUserPairCache1697673894459 { + name = 'NoteReactionAndUserPairCache1697673894459' + + async up(queryRunner) { + await queryRunner.query(`ALTER TABLE "note" ADD "reactionAndUserPairCache" character varying(1024) array NOT NULL DEFAULT '{}'`); + } + + async down(queryRunner) { + await queryRunner.query(`ALTER TABLE "note" DROP COLUMN "reactionAndUserPairCache"`); + } +} diff --git a/packages/backend/migration/1697737204579-deleteCreatedAt.js b/packages/backend/migration/1697737204579-deleteCreatedAt.js new file mode 100644 index 0000000000..8f801e7913 --- /dev/null +++ b/packages/backend/migration/1697737204579-deleteCreatedAt.js @@ -0,0 +1,29 @@ + +export class DeleteCreatedAt1697737204579 { + name = 'DeleteCreatedAt1697737204579' + + async up(queryRunner) { + await queryRunner.query(`DROP INDEX "public"."IDX_e21cd3646e52ef9c94aaf17c2e"`); + await queryRunner.query(`DROP INDEX "public"."IDX_20e30aa35180e317e133d75316"`); + await queryRunner.query(`DROP INDEX "public"."IDX_fdd74ab625ed0f6a30c47b00e0"`); + await queryRunner.query(`ALTER TABLE "messaging_message" DROP COLUMN "createdAt"`); + await queryRunner.query(`ALTER TABLE "user_group" DROP COLUMN "createdAt"`); + await queryRunner.query(`ALTER TABLE "user_group_invitation" DROP COLUMN "createdAt"`); + await queryRunner.query(`ALTER TABLE "user_group_invite" DROP COLUMN "createdAt"`); + await queryRunner.query(`ALTER TABLE "user_group_joining" DROP COLUMN "createdAt"`); + await queryRunner.query(`ALTER TABLE "abuse_report_resolver" DROP COLUMN "createdAt"`); + } + + async down(queryRunner) { + await queryRunner.query(`ALTER TABLE "abuse_report_resolver" ADD "createdAt" TIMESTAMP WITH TIME ZONE NOT NULL`); + await queryRunner.query(`ALTER TABLE "user_group_joining" ADD "createdAt" TIMESTAMP WITH TIME ZONE NOT NULL`); + await queryRunner.query(`ALTER TABLE "user_group_invite" ADD "createdAt" TIMESTAMP WITH TIME ZONE NOT NULL`); + await queryRunner.query(`ALTER TABLE "user_group_invitation" ADD "createdAt" TIMESTAMP WITH TIME ZONE NOT NULL`); + await queryRunner.query(`ALTER TABLE "user_group" ADD "createdAt" TIMESTAMP WITH TIME ZONE NOT NULL`); + await queryRunner.query(`ALTER TABLE "messaging_message" ADD "createdAt" TIMESTAMP WITH TIME ZONE NOT NULL`); + await queryRunner.query(`CREATE INDEX "IDX_fdd74ab625ed0f6a30c47b00e0" ON "abuse_report_resolver" ("createdAt") `); + await queryRunner.query(`CREATE INDEX "IDX_20e30aa35180e317e133d75316" ON "user_group" ("createdAt") `); + await queryRunner.query(`CREATE INDEX "IDX_e21cd3646e52ef9c94aaf17c2e" ON "messaging_message" ("createdAt") `); + } + +} diff --git a/packages/backend/package.json b/packages/backend/package.json index e8d8a38687..16f1161a19 100644 --- a/packages/backend/package.json +++ b/packages/backend/package.json @@ -59,9 +59,9 @@ "@aws-sdk/client-s3": "3.412.0", "@aws-sdk/lib-storage": "3.412.0", "@smithy/node-http-handler": "2.1.5", - "@bull-board/api": "5.8.4", - "@bull-board/fastify": "5.8.4", - "@bull-board/ui": "5.8.4", + "@bull-board/api": "5.9.1", + "@bull-board/fastify": "5.9.1", + "@bull-board/ui": "5.9.1", "@discordapp/twemoji": "14.1.2", "@fastify/accepts": "4.2.0", "@fastify/cookie": "9.1.0", @@ -77,10 +77,10 @@ "@nestjs/core": "10.2.7", "@nestjs/testing": "10.2.7", "@peertube/http-signature": "1.7.0", - "@simplewebauthn/server": "8.2.0", - "@sinonjs/fake-timers": "11.1.0", + "@simplewebauthn/server": "8.3.2", + "@sinonjs/fake-timers": "11.2.1", "@swc/cli": "0.1.62", - "@swc/core": "1.3.92", + "@swc/core": "1.3.93", "@vitalets/google-translate-api": "9.2.0", "accepts": "1.3.8", "ajv": "8.12.0", @@ -89,7 +89,7 @@ "bcryptjs": "2.4.3", "blurhash": "2.0.5", "body-parser": "1.20.2", - "bullmq": "4.12.3", + "bullmq": "4.12.5", "cacheable-lookup": "7.0.0", "cbor": "9.0.1", "chalk": "5.3.0", @@ -102,7 +102,7 @@ "content-disposition": "0.5.4", "date-fns": "2.30.0", "deep-email-validator": "0.1.21", - "fastify": "4.23.2", + "fastify": "4.24.3", "feed": "4.2.2", "file-type": "18.5.0", "fluent-ffmpeg": "2.1.2", @@ -124,13 +124,13 @@ "microformats-parser": "1.5.2", "mime-types": "2.1.35", "ms": "3.0.0-canary.1", - "nanoid": "5.0.1", + "nanoid": "5.0.2", "nested-property": "4.0.0", "node-fetch": "3.3.2", "nodemailer": "6.9.6", "nsfwjs": "2.4.2", "oauth": "0.10.0", - "oauth2orize": "1.11.1", + "oauth2orize": "1.12.0", "oauth2orize-pkce": "0.1.2", "os-utils": "0.0.14", "otpauth": "9.1.5", @@ -159,7 +159,7 @@ "stringz": "2.1.0", "strip-ansi": "^7.1.0", "summaly": "github:misskey-dev/summaly", - "systeminformation": "5.21.11", + "systeminformation": "5.21.12", "tinycolor2": "1.6.0", "tmp": "0.2.1", "tsc-alias": "1.8.8", @@ -177,47 +177,47 @@ "@jest/globals": "29.7.0", "@simplewebauthn/typescript-types": "8.0.0", "@swc/jest": "0.2.29", - "@types/accepts": "1.3.5", - "@types/archiver": "5.3.3", - "@types/bcryptjs": "2.4.4", - "@types/body-parser": "1.19.3", + "@types/accepts": "1.3.6", + "@types/archiver": "5.3.4", + "@types/bcryptjs": "2.4.5", + "@types/body-parser": "1.19.4", "@types/cbor": "6.0.0", - "@types/color-convert": "2.0.1", - "@types/content-disposition": "0.5.6", - "@types/fluent-ffmpeg": "2.1.22", - "@types/http-link-header": "1.0.3", - "@types/jest": "29.5.5", - "@types/js-yaml": "4.0.6", - "@types/jsdom": "21.1.3", - "@types/jsonld": "1.5.10", - "@types/jsrsasign": "10.5.9", - "@types/mime-types": "2.1.2", - "@types/ms": "0.7.32", - "@types/node": "20.8.4", + "@types/color-convert": "2.0.2", + "@types/content-disposition": "0.5.7", + "@types/fluent-ffmpeg": "2.1.23", + "@types/http-link-header": "1.0.4", + "@types/jest": "29.5.6", + "@types/js-yaml": "4.0.8", + "@types/jsdom": "21.1.4", + "@types/jsonld": "1.5.11", + "@types/jsrsasign": "10.5.11", + "@types/mime-types": "2.1.3", + "@types/ms": "0.7.33", + "@types/node": "20.8.7", "@types/node-fetch": "3.0.3", - "@types/nodemailer": "6.4.11", - "@types/oauth": "0.9.2", - "@types/oauth2orize": "1.11.1", - "@types/oauth2orize-pkce": "0.1.0", - "@types/pg": "8.10.4", - "@types/pug": "2.0.7", - "@types/punycode": "2.1.0", - "@types/qrcode": "1.5.2", - "@types/random-seed": "0.3.3", - "@types/ratelimiter": "3.4.4", - "@types/rename": "1.0.5", - "@types/sanitize-html": "2.9.1", - "@types/semver": "7.5.3", + "@types/nodemailer": "6.4.13", + "@types/oauth": "0.9.3", + "@types/oauth2orize": "1.11.2", + "@types/oauth2orize-pkce": "0.1.1", + "@types/pg": "8.10.7", + "@types/pug": "2.0.8", + "@types/punycode": "2.1.1", + "@types/qrcode": "1.5.4", + "@types/random-seed": "0.3.4", + "@types/ratelimiter": "3.4.5", + "@types/rename": "1.0.6", + "@types/sanitize-html": "2.9.3", + "@types/semver": "7.5.4", "@types/sharp": "0.32.0", - "@types/simple-oauth2": "5.0.5", - "@types/sinonjs__fake-timers": "8.1.3", - "@types/tinycolor2": "1.4.4", - "@types/tmp": "0.2.4", - "@types/vary": "1.1.1", - "@types/web-push": "3.6.1", - "@types/ws": "8.5.6", - "@typescript-eslint/eslint-plugin": "6.7.5", - "@typescript-eslint/parser": "6.7.5", + "@types/simple-oauth2": "5.0.6", + "@types/sinonjs__fake-timers": "8.1.4", + "@types/tinycolor2": "1.4.5", + "@types/tmp": "0.2.5", + "@types/vary": "1.1.2", + "@types/web-push": "3.6.2", + "@types/ws": "8.5.8", + "@typescript-eslint/eslint-plugin": "6.8.0", + "@typescript-eslint/parser": "6.8.0", "aws-sdk-client-mock": "3.0.0", "cross-env": "7.0.3", "eslint": "8.51.0", diff --git a/packages/backend/src/config.ts b/packages/backend/src/config.ts index 96ff08ae30..1856600943 100644 --- a/packages/backend/src/config.ts +++ b/packages/backend/src/config.ts @@ -149,6 +149,13 @@ export type Config = { relashionshipJobPerSec: number | undefined; deliverJobMaxAttempts: number | undefined; inboxJobMaxAttempts: number | undefined; + + cloudLogging?: { + projectId: string; + saKeyPath: string; + logName?: string; + } + apFileBaseUrl: string | undefined; proxyRemoteFiles: boolean | undefined; signToActivityPubGet: boolean | undefined; diff --git a/packages/backend/src/core/AccountMoveService.ts b/packages/backend/src/core/AccountMoveService.ts index 0fc1f60e0b..d4dbdbc485 100644 --- a/packages/backend/src/core/AccountMoveService.ts +++ b/packages/backend/src/core/AccountMoveService.ts @@ -180,13 +180,13 @@ export class AccountMoveService { { muteeId: dst.id, expiresAt: IsNull() }, ).then(mutings => mutings.map(muting => muting.muterId)); - const newMutings: Map = new Map(); + const newMutings: Map = new Map(); // 重複しないようにIDを生成 const genId = (): string => { let id: string; do { - id = this.idService.genId(); + id = this.idService.gen(); } while (newMutings.has(id)); return id; }; @@ -194,7 +194,6 @@ export class AccountMoveService { if (existingMutingsMuterUserIds.includes(muting.muterId)) continue; // skip if already muted indefinitely newMutings.set(genId(), { ...muting, - createdAt: new Date(), muteeId: dst.id, }); } @@ -228,20 +227,19 @@ export class AccountMoveService { }, }).then(memberships => memberships.map(membership => membership.userListId)); - const newMemberships: Map = new Map(); + const newMemberships: Map = new Map(); // 重複しないようにIDを生成 const genId = (): string => { let id: string; do { - id = this.idService.genId(); + id = this.idService.gen(); } while (newMemberships.has(id)); return id; }; for (const membership of oldMemberships) { if (existingUserListIds.includes(membership.userListId)) continue; // skip if dst exists in this user's list newMemberships.set(genId(), { - createdAt: new Date(), userId: dst.id, userListId: membership.userListId, userListUserId: membership.userListUserId, diff --git a/packages/backend/src/core/AnnouncementService.ts b/packages/backend/src/core/AnnouncementService.ts index 3bf7319a4d..9fcb1b22bb 100644 --- a/packages/backend/src/core/AnnouncementService.ts +++ b/packages/backend/src/core/AnnouncementService.ts @@ -53,7 +53,7 @@ export class AnnouncementService { })) .andWhere(new Brackets(qb => { qb.orWhere('announcement.forExistingUsers = false'); - qb.orWhere('announcement.createdAt > :createdAt', { createdAt: user.createdAt }); + qb.orWhere('announcement.id > :userId', { userId: user.id }); })) .andWhere(`announcement.id NOT IN (${ readsQuery.getQuery() })`); @@ -65,8 +65,7 @@ export class AnnouncementService { @bindThis public async create(values: Partial, moderator?: MiUser): Promise<{ raw: MiAnnouncement; packed: Packed<'Announcement'> }> { const announcement = await this.announcementsRepository.insert({ - id: this.idService.genId(), - createdAt: new Date(), + id: this.idService.gen(), updatedAt: null, title: values.title, text: values.text, @@ -81,8 +80,8 @@ export class AnnouncementService { const packed = (await this.packMany([announcement]))[0]; if (announcement.isActive) { - if (announcement.userId) { - this.globalEventService.publishMainStream(announcement.userId, 'announcementCreated', { + if (values.userId) { + this.globalEventService.publishMainStream(values.userId, 'announcementCreated', { announcement: packed, }); @@ -181,8 +180,7 @@ export class AnnouncementService { public async read(user: MiUser, announcementId: MiAnnouncement['id']): Promise { try { await this.announcementReadsRepository.insert({ - id: this.idService.genId(), - createdAt: new Date(), + id: this.idService.gen(), announcementId: announcementId, userId: user.id, }); @@ -206,7 +204,7 @@ export class AnnouncementService { const reads = me ? (options?.reads ?? await this.getReads(me.id)) : []; return announcements.map(announcement => ({ id: announcement.id, - createdAt: announcement.createdAt.toISOString(), + createdAt: this.idService.parse(announcement.id).date.toISOString(), updatedAt: announcement.updatedAt?.toISOString() ?? null, text: announcement.text, title: announcement.title, diff --git a/packages/backend/src/core/AntennaService.ts b/packages/backend/src/core/AntennaService.ts index 72d3a4e23e..9e88c8f314 100644 --- a/packages/backend/src/core/AntennaService.ts +++ b/packages/backend/src/core/AntennaService.ts @@ -16,7 +16,7 @@ import type { AntennasRepository, UserGroupJoiningsRepository, UserListMembershi import { UtilityService } from '@/core/UtilityService.js'; import { bindThis } from '@/decorators.js'; import type { GlobalEvents } from '@/core/GlobalEventService.js'; -import { RedisTimelineService } from '@/core/RedisTimelineService.js'; +import { FunoutTimelineService } from '@/core/FunoutTimelineService.js'; import type { OnApplicationShutdown } from '@nestjs/common'; @Injectable() @@ -42,7 +42,7 @@ export class AntennaService implements OnApplicationShutdown { private utilityService: UtilityService, private globalEventService: GlobalEventService, - private redisTimelineService: RedisTimelineService, + private funoutTimelineService: FunoutTimelineService, ) { this.antennasFetched = false; this.antennas = []; @@ -60,14 +60,12 @@ export class AntennaService implements OnApplicationShutdown { case 'antennaCreated': this.antennas.push({ ...body, - createdAt: new Date(body.createdAt), lastUsedAt: new Date(body.lastUsedAt), }); break; case 'antennaUpdated': this.antennas[this.antennas.findIndex(a => a.id === body.id)] = { ...body, - createdAt: new Date(body.createdAt), lastUsedAt: new Date(body.lastUsedAt), }; break; @@ -89,7 +87,7 @@ export class AntennaService implements OnApplicationShutdown { const redisPipeline = this.redisForTimelines.pipeline(); for (const antenna of matchedAntennas) { - this.redisTimelineService.push(`antennaTimeline:${antenna.id}`, note.id, 200, redisPipeline); + this.funoutTimelineService.push(`antennaTimeline:${antenna.id}`, note.id, 200, redisPipeline); this.globalEventService.publishAntennaStream(antenna.id, 'note', note); } @@ -103,6 +101,8 @@ export class AntennaService implements OnApplicationShutdown { if (note.visibility === 'specified') return false; if (note.visibility === 'followers') return false; + if (antenna.localOnly && noteUser.host != null) return false; + if (!antenna.withReplies && note.replyId != null) return false; if (antenna.src === 'home') { diff --git a/packages/backend/src/core/ClipService.ts b/packages/backend/src/core/ClipService.ts index 4921abb01a..8fa371346b 100644 --- a/packages/backend/src/core/ClipService.ts +++ b/packages/backend/src/core/ClipService.ts @@ -46,8 +46,7 @@ export class ClipService { } const clip = await this.clipsRepository.insert({ - id: this.idService.genId(), - createdAt: new Date(), + id: this.idService.gen(), userId: me.id, name: name, isPublic: isPublic, @@ -109,7 +108,7 @@ export class ClipService { try { await this.clipNotesRepository.insert({ - id: this.idService.genId(), + id: this.idService.gen(), noteId: noteId, clipId: clip.id, }); diff --git a/packages/backend/src/core/CoreModule.ts b/packages/backend/src/core/CoreModule.ts index 0234355ae8..9b2b2b7403 100644 --- a/packages/backend/src/core/CoreModule.ts +++ b/packages/backend/src/core/CoreModule.ts @@ -62,7 +62,7 @@ import { FileInfoService } from './FileInfoService.js'; import { SearchService } from './SearchService.js'; import { ClipService } from './ClipService.js'; import { FeaturedService } from './FeaturedService.js'; -import { RedisTimelineService } from './RedisTimelineService.js'; +import { FunoutTimelineService } from './FunoutTimelineService.js'; import { ChartLoggerService } from './chart/ChartLoggerService.js'; import FederationChart from './chart/charts/federation.js'; import NotesChart from './chart/charts/notes.js'; @@ -196,7 +196,7 @@ const $FileInfoService: Provider = { provide: 'FileInfoService', useExisting: Fi const $SearchService: Provider = { provide: 'SearchService', useExisting: SearchService }; const $ClipService: Provider = { provide: 'ClipService', useExisting: ClipService }; const $FeaturedService: Provider = { provide: 'FeaturedService', useExisting: FeaturedService }; -const $RedisTimelineService: Provider = { provide: 'RedisTimelineService', useExisting: RedisTimelineService }; +const $FunoutTimelineService: Provider = { provide: 'FunoutTimelineService', useExisting: FunoutTimelineService }; const $ChartLoggerService: Provider = { provide: 'ChartLoggerService', useExisting: ChartLoggerService }; const $FederationChart: Provider = { provide: 'FederationChart', useExisting: FederationChart }; @@ -334,7 +334,7 @@ const $ApEventService: Provider = { provide: 'ApEventService', useExisting: ApEv SearchService, ClipService, FeaturedService, - RedisTimelineService, + FunoutTimelineService, ChartLoggerService, FederationChart, NotesChart, @@ -465,7 +465,7 @@ const $ApEventService: Provider = { provide: 'ApEventService', useExisting: ApEv $SearchService, $ClipService, $FeaturedService, - $RedisTimelineService, + $FunoutTimelineService, $ChartLoggerService, $FederationChart, $NotesChart, @@ -597,7 +597,7 @@ const $ApEventService: Provider = { provide: 'ApEventService', useExisting: ApEv SearchService, ClipService, FeaturedService, - RedisTimelineService, + FunoutTimelineService, FederationChart, NotesChart, UsersChart, @@ -727,7 +727,7 @@ const $ApEventService: Provider = { provide: 'ApEventService', useExisting: ApEv $SearchService, $ClipService, $FeaturedService, - $RedisTimelineService, + $FunoutTimelineService, $FederationChart, $NotesChart, $UsersChart, diff --git a/packages/backend/src/core/CreateSystemUserService.ts b/packages/backend/src/core/CreateSystemUserService.ts index f6760b89be..684b420453 100644 --- a/packages/backend/src/core/CreateSystemUserService.ts +++ b/packages/backend/src/core/CreateSystemUserService.ts @@ -52,8 +52,7 @@ export class CreateSystemUserService { if (exist) throw new Error('the user is already exists'); account = await transactionalEntityManager.insert(MiUser, { - id: this.idService.genId(), - createdAt: new Date(), + id: this.idService.gen(), username: username, usernameLower: username.toLowerCase(), host: null, diff --git a/packages/backend/src/core/CustomEmojiService.ts b/packages/backend/src/core/CustomEmojiService.ts index f347434474..1d90f0048c 100644 --- a/packages/backend/src/core/CustomEmojiService.ts +++ b/packages/backend/src/core/CustomEmojiService.ts @@ -69,7 +69,7 @@ export class CustomEmojiService implements OnApplicationShutdown { roleIdsThatCanBeUsedThisEmojiAsReaction: MiRole['id'][]; }, moderator?: MiUser): Promise { const emoji = await this.emojisRepository.insert({ - id: this.idService.genId(), + id: this.idService.gen(), updatedAt: new Date(), name: data.name, category: data.category, @@ -334,7 +334,7 @@ export class CustomEmojiService implements OnApplicationShutdown { const queryOrNull = async () => (await this.emojisRepository.findOneBy({ name, - host: host ?? IsNull(), + host, })) ?? null; const emoji = await this.cache.fetch(`${name} ${host}`, queryOrNull); diff --git a/packages/backend/src/core/DriveService.ts b/packages/backend/src/core/DriveService.ts index df6b457cca..aa7e135469 100644 --- a/packages/backend/src/core/DriveService.ts +++ b/packages/backend/src/core/DriveService.ts @@ -577,8 +577,7 @@ export class DriveService { const folder = await fetchFolder(); let file = new MiDriveFile(); - file.id = this.idService.genId(); - file.createdAt = new Date(); + file.id = this.idService.gen(); file.userId = user ? user.id : null; file.userHost = user ? user.host : null; file.folderId = folder !== null ? folder.id : null; diff --git a/packages/backend/src/core/FederatedInstanceService.ts b/packages/backend/src/core/FederatedInstanceService.ts index c916a18b12..d83194bd5c 100644 --- a/packages/backend/src/core/FederatedInstanceService.ts +++ b/packages/backend/src/core/FederatedInstanceService.ts @@ -56,7 +56,7 @@ export class FederatedInstanceService implements OnApplicationShutdown { if (index == null) { const i = await this.instancesRepository.insert({ - id: this.idService.genId(), + id: this.idService.gen(), host, firstRetrievedAt: new Date(), }).then(x => this.instancesRepository.findOneByOrFail(x.identifiers[0])); diff --git a/packages/backend/src/core/RedisTimelineService.ts b/packages/backend/src/core/FunoutTimelineService.ts similarity index 95% rename from packages/backend/src/core/RedisTimelineService.ts rename to packages/backend/src/core/FunoutTimelineService.ts index ef14be2c86..97a24aa3f3 100644 --- a/packages/backend/src/core/RedisTimelineService.ts +++ b/packages/backend/src/core/FunoutTimelineService.ts @@ -10,7 +10,7 @@ import { bindThis } from '@/decorators.js'; import { IdService } from '@/core/IdService.js'; @Injectable() -export class RedisTimelineService { +export class FunoutTimelineService { constructor( @Inject(DI.redisForTimelines) private redisForTimelines: Redis.Redis, @@ -77,4 +77,9 @@ export class RedisTimelineService { ); }); } + + @bindThis + public purge(name: string) { + return this.redisForTimelines.del('list:' + name); + } } diff --git a/packages/backend/src/core/HashtagService.ts b/packages/backend/src/core/HashtagService.ts index 653fa245ca..061339ebed 100644 --- a/packages/backend/src/core/HashtagService.ts +++ b/packages/backend/src/core/HashtagService.ts @@ -45,7 +45,7 @@ export class HashtagService { await this.updateHashtag(user, tag, true, true); } - for (const tag of (user.tags ?? []).filter(x => !tags.includes(x))) { + for (const tag of user.tags.filter(x => !tags.includes(x))) { await this.updateHashtag(user, tag, true, false); } } @@ -120,7 +120,7 @@ export class HashtagService { } else { if (isUserAttached) { this.hashtagsRepository.insert({ - id: this.idService.genId(), + id: this.idService.gen(), name: tag, mentionedUserIds: [], mentionedUsersCount: 0, @@ -137,7 +137,7 @@ export class HashtagService { } as MiHashtag); } else { this.hashtagsRepository.insert({ - id: this.idService.genId(), + id: this.idService.gen(), name: tag, mentionedUserIds: [user.id], mentionedUsersCount: 1, diff --git a/packages/backend/src/core/IdService.ts b/packages/backend/src/core/IdService.ts index 0f1bc013c6..496864c7a3 100644 --- a/packages/backend/src/core/IdService.ts +++ b/packages/backend/src/core/IdService.ts @@ -26,17 +26,21 @@ export class IdService { this.method = config.id.toLowerCase(); } + /** + * 時間を元にIDを生成します(省略時は現在日時) + * @param time 日時 + */ @bindThis - public genId(date?: Date): string { - if (!date || (date > new Date())) date = new Date(); + public gen(time?: number): string { + const t = (!time || (time > Date.now())) ? Date.now() : time; switch (this.method) { - case 'aid': return genAid(date); - case 'aidx': return genAidx(date); - case 'meid': return genMeid(date); - case 'meidg': return genMeidg(date); - case 'ulid': return ulid(date.getTime()); - case 'objectid': return genObjectId(date); + case 'aid': return genAid(t); + case 'aidx': return genAidx(t); + case 'meid': return genMeid(t); + case 'meidg': return genMeidg(t); + case 'ulid': return ulid(t); + case 'objectid': return genObjectId(t); default: throw new Error('unrecognized id generation method'); } } diff --git a/packages/backend/src/core/MessagingService.ts b/packages/backend/src/core/MessagingService.ts index e6c8976ae4..5891f2c8ea 100644 --- a/packages/backend/src/core/MessagingService.ts +++ b/packages/backend/src/core/MessagingService.ts @@ -56,11 +56,8 @@ export class MessagingService { @bindThis public async createMessage(user: { id: MiUser['id']; host: MiUser['host']; }, recipientUser: MiUser | null, recipientGroup: MiUserGroup | null, text: string | null | undefined, file: MiDriveFile | null, uri?: string) { - const data = new Date(); - const message = { - id: this.idService.genId(data), - createdAt: data, + id: this.idService.gen(Date.now()), fileId: file ? file.id : null, recipientId: recipientUser ? recipientUser.id : null, groupId: recipientGroup ? recipientGroup.id : null, @@ -135,7 +132,6 @@ export class MessagingService { const note = { id: message.id, - createdAt: message.createdAt, fileIds: message.fileId ? [message.fileId] : [], text: message.text, userId: message.userId, @@ -298,7 +294,7 @@ export class MessagingService { .where('message.groupId = :groupId', { groupId: groupId }) .andWhere('message.userId != :userId', { userId: userId }) .andWhere('NOT (:userId = ANY(message.reads))', { userId: userId }) - .andWhere('message.createdAt > :joinedAt', { joinedAt: joining.createdAt }) // 自分が加入する前の会話については、未読扱いしない + .andWhere('message.id > :joinedAt', { joinedAt: this.idService.parse(joining.id) }) // 自分が加入する前の会話については、未読扱いしない .getOne().then(x => x != null); if (!unreadExist) { diff --git a/packages/backend/src/core/ModerationLogService.ts b/packages/backend/src/core/ModerationLogService.ts index 25663d2a95..5d2e52709c 100644 --- a/packages/backend/src/core/ModerationLogService.ts +++ b/packages/backend/src/core/ModerationLogService.ts @@ -24,8 +24,7 @@ export class ModerationLogService { @bindThis public async log(moderator: { id: MiUser['id'] }, type: T, info?: ModerationLogPayloads[T]) { await this.moderationLogsRepository.insert({ - id: this.idService.genId(), - createdAt: new Date(), + id: this.idService.gen(), userId: moderator.id, type: type, info: (info as any) ?? {}, diff --git a/packages/backend/src/core/NoteCreateService.ts b/packages/backend/src/core/NoteCreateService.ts index f0e3d4b040..2149913be9 100644 --- a/packages/backend/src/core/NoteCreateService.ts +++ b/packages/backend/src/core/NoteCreateService.ts @@ -55,7 +55,8 @@ import { RoleService } from '@/core/RoleService.js'; import { MetaService } from '@/core/MetaService.js'; import { SearchService } from '@/core/SearchService.js'; import { FeaturedService } from '@/core/FeaturedService.js'; -import { RedisTimelineService } from '@/core/RedisTimelineService.js'; +import { FunoutTimelineService } from '@/core/FunoutTimelineService.js'; +import { UtilityService } from '@/core/UtilityService.js'; type NotificationType = 'reply' | 'renote' | 'quote' | 'mention'; @@ -198,7 +199,7 @@ export class NoteCreateService implements OnApplicationShutdown { private idService: IdService, private globalEventService: GlobalEventService, private queueService: QueueService, - private redisTimelineService: RedisTimelineService, + private funoutTimelineService: FunoutTimelineService, private noteReadService: NoteReadService, private notificationService: NotificationService, private relayService: RelayService, @@ -217,6 +218,7 @@ export class NoteCreateService implements OnApplicationShutdown { private perUserNotesChart: PerUserNotesChart, private activeUsersChart: ActiveUsersChart, private instanceChart: InstanceChart, + private utilityService: UtilityService, ) { } @bindThis @@ -224,8 +226,8 @@ export class NoteCreateService implements OnApplicationShutdown { id: MiUser['id']; username: MiUser['username']; host: MiUser['host']; - createdAt: MiUser['createdAt']; isBot: MiUser['isBot']; + isCat: MiUser['isCat']; }, data: Option, silent = false): Promise { // チャンネル外にリプライしたら対象のスコープに合わせる // (クライアントサイドでやっても良い処理だと思うけどとりあえずサーバーサイドで) @@ -251,8 +253,10 @@ export class NoteCreateService implements OnApplicationShutdown { if (data.channel != null) data.visibleUsers = []; if (data.channel != null) data.localOnly = true; + const meta = await this.metaService.fetch(); + if (data.visibility === 'public' && data.channel == null) { - const sensitiveWords = (await this.metaService.fetch()).sensitiveWords; + const sensitiveWords = meta.sensitiveWords; if (this.isSensitive(data, sensitiveWords)) { data.visibility = 'home'; } else if ((await this.roleService.getUserPolicies(user.id)).canPublicNote === false) { @@ -260,6 +264,12 @@ export class NoteCreateService implements OnApplicationShutdown { } } + const inSilencedInstance = this.utilityService.isSilencedHost(meta.silencedHosts, user.host); + + if (data.visibility === 'public' && inSilencedInstance && user.host !== null) { + data.visibility = 'home'; + } + if (data.renote) { switch (data.renote.visibility) { case 'public': @@ -316,7 +326,7 @@ export class NoteCreateService implements OnApplicationShutdown { // Parse MFM if needed if (!tags || !emojis || !mentionedUsers) { - const tokens = data.text ? mfm.parse(data.text)! : []; + const tokens = (data.text ? mfm.parse(data.text)! : []); const cwTokens = data.cw ? mfm.parse(data.cw)! : []; const choiceTokens = data.poll && data.poll.choices ? concat(data.poll.choices.map(choice => mfm.parse(choice)!)) @@ -331,7 +341,7 @@ export class NoteCreateService implements OnApplicationShutdown { mentionedUsers = data.apMentions ?? await this.extractMentionedUsers(user, combinedTokens); } - tags = tags.filter(tag => Array.from(tag ?? '').length <= 128).splice(0, 32); + tags = tags.filter(tag => Array.from(tag).length <= 128).splice(0, 32); if (data.reply && (user.id !== data.reply.userId) && !mentionedUsers.some(u => u.id === data.reply!.userId)) { mentionedUsers.push(await this.usersRepository.findOneByOrFail({ id: data.reply!.userId })); @@ -364,8 +374,7 @@ export class NoteCreateService implements OnApplicationShutdown { @bindThis private async insertNote(user: { id: MiUser['id']; host: MiUser['host']; }, data: Option, tags: string[], emojis: string[], mentionedUsers: MinimumUser[]) { const insert = new MiNote({ - id: this.idService.genId(data.createdAt!), - createdAt: data.createdAt!, + id: this.idService.gen(data.createdAt?.getTime()), fileIds: data.files ? data.files.map(file => file.id) : [], replyId: data.reply ? data.reply.id : null, renoteId: data.renote ? data.renote.id : null, @@ -483,7 +492,6 @@ export class NoteCreateService implements OnApplicationShutdown { id: MiUser['id']; username: MiUser['username']; host: MiUser['host']; - createdAt: MiUser['createdAt']; isBot: MiUser['isBot']; }, data: Option, silent: boolean, tags: string[], mentionedUsers: MinimumUser[]) { const meta = await this.metaService.fetch(); @@ -577,7 +585,7 @@ export class NoteCreateService implements OnApplicationShutdown { } // Pack the note - const noteObj = await this.noteEntityService.pack(note); + const noteObj = await this.noteEntityService.pack(note, null, { skipHide: true, withReactionAndUserPairCache: true }); this.globalEventService.publishNotesStream(noteObj); @@ -844,9 +852,9 @@ export class NoteCreateService implements OnApplicationShutdown { const r = this.redisForTimelines.pipeline(); if (note.channelId) { - this.redisTimelineService.push(`channelTimeline:${note.channelId}`, note.id, this.config.perChannelMaxNoteCacheCount, r); + this.funoutTimelineService.push(`channelTimeline:${note.channelId}`, note.id, this.config.perChannelMaxNoteCacheCount, r); - this.redisTimelineService.push(`userTimelineWithChannel:${user.id}`, note.id, note.userHost == null ? meta.perLocalUserUserTimelineCacheMax : meta.perRemoteUserUserTimelineCacheMax, r); + this.funoutTimelineService.push(`userTimelineWithChannel:${user.id}`, note.id, note.userHost == null ? meta.perLocalUserUserTimelineCacheMax : meta.perRemoteUserUserTimelineCacheMax, r); const channelFollowings = await this.channelFollowingsRepository.find({ where: { @@ -856,9 +864,9 @@ export class NoteCreateService implements OnApplicationShutdown { }); for (const channelFollowing of channelFollowings) { - this.redisTimelineService.push(`homeTimeline:${channelFollowing.followerId}`, note.id, meta.perUserHomeTimelineCacheMax, r); + this.funoutTimelineService.push(`homeTimeline:${channelFollowing.followerId}`, note.id, meta.perUserHomeTimelineCacheMax, r); if (note.fileIds.length > 0) { - this.redisTimelineService.push(`homeTimelineWithFiles:${channelFollowing.followerId}`, note.id, meta.perUserHomeTimelineCacheMax / 2, r); + this.funoutTimelineService.push(`homeTimelineWithFiles:${channelFollowing.followerId}`, note.id, meta.perUserHomeTimelineCacheMax / 2, r); } } } else { @@ -896,9 +904,9 @@ export class NoteCreateService implements OnApplicationShutdown { if (!following.withReplies) continue; } - this.redisTimelineService.push(`homeTimeline:${following.followerId}`, note.id, meta.perUserHomeTimelineCacheMax, r); + this.funoutTimelineService.push(`homeTimeline:${following.followerId}`, note.id, meta.perUserHomeTimelineCacheMax, r); if (note.fileIds.length > 0) { - this.redisTimelineService.push(`homeTimelineWithFiles:${following.followerId}`, note.id, meta.perUserHomeTimelineCacheMax / 2, r); + this.funoutTimelineService.push(`homeTimelineWithFiles:${following.followerId}`, note.id, meta.perUserHomeTimelineCacheMax / 2, r); } } @@ -914,36 +922,36 @@ export class NoteCreateService implements OnApplicationShutdown { if (!userListMembership.withReplies) continue; } - this.redisTimelineService.push(`userListTimeline:${userListMembership.userListId}`, note.id, meta.perUserListTimelineCacheMax, r); + this.funoutTimelineService.push(`userListTimeline:${userListMembership.userListId}`, note.id, meta.perUserListTimelineCacheMax, r); if (note.fileIds.length > 0) { - this.redisTimelineService.push(`userListTimelineWithFiles:${userListMembership.userListId}`, note.id, meta.perUserListTimelineCacheMax / 2, r); + this.funoutTimelineService.push(`userListTimelineWithFiles:${userListMembership.userListId}`, note.id, meta.perUserListTimelineCacheMax / 2, r); } } if (note.visibility !== 'specified' || !note.visibleUserIds.some(v => v === user.id)) { // 自分自身のHTL - this.redisTimelineService.push(`homeTimeline:${user.id}`, note.id, meta.perUserHomeTimelineCacheMax, r); + this.funoutTimelineService.push(`homeTimeline:${user.id}`, note.id, meta.perUserHomeTimelineCacheMax, r); if (note.fileIds.length > 0) { - this.redisTimelineService.push(`homeTimelineWithFiles:${user.id}`, note.id, meta.perUserHomeTimelineCacheMax / 2, r); + this.funoutTimelineService.push(`homeTimelineWithFiles:${user.id}`, note.id, meta.perUserHomeTimelineCacheMax / 2, r); } } // 自分自身以外への返信 if (note.replyId && note.replyUserId !== note.userId) { - this.redisTimelineService.push(`userTimelineWithReplies:${user.id}`, note.id, note.userHost == null ? meta.perLocalUserUserTimelineCacheMax : meta.perRemoteUserUserTimelineCacheMax, r); + this.funoutTimelineService.push(`userTimelineWithReplies:${user.id}`, note.id, note.userHost == null ? meta.perLocalUserUserTimelineCacheMax : meta.perRemoteUserUserTimelineCacheMax, r); if (note.visibility === 'public' && note.userHost == null) { - this.redisTimelineService.push('localTimelineWithReplies', note.id, 300, r); + this.funoutTimelineService.push('localTimelineWithReplies', note.id, 300, r); } } else { - this.redisTimelineService.push(`userTimeline:${user.id}`, note.id, note.userHost == null ? meta.perLocalUserUserTimelineCacheMax : meta.perRemoteUserUserTimelineCacheMax, r); + this.funoutTimelineService.push(`userTimeline:${user.id}`, note.id, note.userHost == null ? meta.perLocalUserUserTimelineCacheMax : meta.perRemoteUserUserTimelineCacheMax, r); if (note.fileIds.length > 0) { - this.redisTimelineService.push(`userTimelineWithFiles:${user.id}`, note.id, note.userHost == null ? meta.perLocalUserUserTimelineCacheMax / 2 : meta.perRemoteUserUserTimelineCacheMax / 2, r); + this.funoutTimelineService.push(`userTimelineWithFiles:${user.id}`, note.id, note.userHost == null ? meta.perLocalUserUserTimelineCacheMax / 2 : meta.perRemoteUserUserTimelineCacheMax / 2, r); } if (note.visibility === 'public' && note.userHost == null) { - this.redisTimelineService.push('localTimeline', note.id, 1000, r); + this.funoutTimelineService.push('localTimeline', note.id, 1000, r); if (note.fileIds.length > 0) { - this.redisTimelineService.push('localTimelineWithFiles', note.id, 500, r); + this.funoutTimelineService.push('localTimelineWithFiles', note.id, 500, r); } } } diff --git a/packages/backend/src/core/NotePiningService.ts b/packages/backend/src/core/NotePiningService.ts index 434d26ae08..2725b081f1 100644 --- a/packages/backend/src/core/NotePiningService.ts +++ b/packages/backend/src/core/NotePiningService.ts @@ -71,8 +71,7 @@ export class NotePiningService { } await this.userNotePiningsRepository.insert({ - id: this.idService.genId(), - createdAt: new Date(), + id: this.idService.gen(), userId: user.id, noteId: note.id, } as MiUserNotePining); diff --git a/packages/backend/src/core/NoteReadService.ts b/packages/backend/src/core/NoteReadService.ts index 43a9a8eca4..15f23f0090 100644 --- a/packages/backend/src/core/NoteReadService.ts +++ b/packages/backend/src/core/NoteReadService.ts @@ -57,7 +57,7 @@ export class NoteReadService implements OnApplicationShutdown { if (isThreadMuted) return; const unread = { - id: this.idService.genId(), + id: this.idService.gen(), noteId: note.id, userId: userId, isSpecified: params.isSpecified, diff --git a/packages/backend/src/core/NotificationService.ts b/packages/backend/src/core/NotificationService.ts index 3d8079f20a..4546e3c0e9 100644 --- a/packages/backend/src/core/NotificationService.ts +++ b/packages/backend/src/core/NotificationService.ts @@ -125,7 +125,7 @@ export class NotificationService implements OnApplicationShutdown { } const notification = { - id: this.idService.genId(), + id: this.idService.gen(), createdAt: new Date(), type: type, notifierId: notifierId, diff --git a/packages/backend/src/core/PollService.ts b/packages/backend/src/core/PollService.ts index 3f5f566a8b..361a8d1375 100644 --- a/packages/backend/src/core/PollService.ts +++ b/packages/backend/src/core/PollService.ts @@ -72,10 +72,8 @@ export class PollService { throw new Error('already voted'); } - // Create vote await this.pollVotesRepository.insert({ - id: this.idService.genId(), - createdAt: new Date(), + id: this.idService.gen(), noteId: note.id, userId: user.id, choice: choice, diff --git a/packages/backend/src/core/QueryService.ts b/packages/backend/src/core/QueryService.ts index 2b18098651..3b599a96da 100644 --- a/packages/backend/src/core/QueryService.ts +++ b/packages/backend/src/core/QueryService.ts @@ -52,14 +52,14 @@ export class QueryService { q.andWhere(`${q.alias}.id < :untilId`, { untilId: untilId }); q.orderBy(`${q.alias}.id`, 'DESC'); } else if (sinceDate && untilDate) { - q.andWhere(`${q.alias}.id > :sinceId`, { sinceId: this.idService.genId(new Date(sinceDate)) }); - q.andWhere(`${q.alias}.id < :untilId`, { untilId: this.idService.genId(new Date(untilDate)) }); + q.andWhere(`${q.alias}.id > :sinceId`, { sinceId: this.idService.gen(sinceDate) }); + q.andWhere(`${q.alias}.id < :untilId`, { untilId: this.idService.gen(untilDate) }); q.orderBy(`${q.alias}.id`, 'DESC'); } else if (sinceDate) { - q.andWhere(`${q.alias}.id > :sinceId`, { sinceId: this.idService.genId(new Date(sinceDate)) }); + q.andWhere(`${q.alias}.id > :sinceId`, { sinceId: this.idService.gen(sinceDate) }); q.orderBy(`${q.alias}.id`, 'ASC'); } else if (untilDate) { - q.andWhere(`${q.alias}.id < :untilId`, { untilId: this.idService.genId(new Date(untilDate)) }); + q.andWhere(`${q.alias}.id < :untilId`, { untilId: this.idService.gen(untilDate) }); q.orderBy(`${q.alias}.id`, 'DESC'); } else { q.orderBy(`${q.alias}.id`, 'DESC'); diff --git a/packages/backend/src/core/QueueService.ts b/packages/backend/src/core/QueueService.ts index 7171c5313d..0a4c2d2d5e 100644 --- a/packages/backend/src/core/QueueService.ts +++ b/packages/backend/src/core/QueueService.ts @@ -238,10 +238,11 @@ export class QueueService { } @bindThis - public createImportFollowingJob(user: ThinUser, fileId: MiDriveFile['id']) { + public createImportFollowingJob(user: ThinUser, fileId: MiDriveFile['id'], withReplies?: boolean) { return this.dbQueue.add('importFollowing', { user: { id: user.id }, fileId: fileId, + withReplies, }, { removeOnComplete: true, removeOnFail: true, @@ -249,8 +250,8 @@ export class QueueService { } @bindThis - public createImportFollowingToDbJob(user: ThinUser, targets: string[]) { - const jobs = targets.map(rel => this.generateToDbJobData('importFollowingToDb', { user, target: rel })); + public createImportFollowingToDbJob(user: ThinUser, targets: string[], withReplies?: boolean) { + const jobs = targets.map(rel => this.generateToDbJobData('importFollowingToDb', { user, target: rel, withReplies })); return this.dbQueue.addBulk(jobs); } @@ -348,7 +349,7 @@ export class QueueService { } @bindThis - public createFollowJob(followings: { from: ThinUser, to: ThinUser, requestId?: string, silent?: boolean }[]) { + public createFollowJob(followings: { from: ThinUser, to: ThinUser, requestId?: string, silent?: boolean, withReplies?: boolean }[]) { const jobs = followings.map(rel => this.generateRelationshipJobData('follow', rel)); return this.relationshipQueue.addBulk(jobs); } @@ -390,6 +391,7 @@ export class QueueService { to: { id: data.to.id }, silent: data.silent, requestId: data.requestId, + withReplies: data.withReplies, }, opts: { removeOnComplete: true, diff --git a/packages/backend/src/core/ReactionService.ts b/packages/backend/src/core/ReactionService.ts index 5d8c2a2959..11cd8f54b3 100644 --- a/packages/backend/src/core/ReactionService.ts +++ b/packages/backend/src/core/ReactionService.ts @@ -30,6 +30,7 @@ import { RoleService } from '@/core/RoleService.js'; import { FeaturedService } from '@/core/FeaturedService.js'; const FALLBACK = '❤'; +const PER_NOTE_REACTION_USER_PAIR_CACHE_MAX = 16; const legacies: Record = { 'like': '👍', @@ -148,13 +149,12 @@ export class ReactionService { reaction = FALLBACK; } } else { - reaction = this.normalize(reaction ?? null); + reaction = this.normalize(reaction); } } const record: MiNoteReaction = { - id: this.idService.genId(), - createdAt: new Date(), + id: this.idService.gen(), noteId: note.id, userId: user.id, reaction, @@ -188,6 +188,9 @@ export class ReactionService { await this.notesRepository.createQueryBuilder().update() .set({ reactions: () => sql, + ...(note.reactionAndUserPairCache.length < PER_NOTE_REACTION_USER_PAIR_CACHE_MAX ? { + reactionAndUserPairCache: () => `array_append("reactionAndUserPairCache", '${user.id}/${reaction}')`, + } : {}), }) .where('id = :id', { id: note.id }) .execute(); @@ -294,6 +297,7 @@ export class ReactionService { await this.notesRepository.createQueryBuilder().update() .set({ reactions: () => sql, + reactionAndUserPairCache: () => `array_remove("reactionAndUserPairCache", '${user.id}/${exist.reaction}')`, }) .where('id = :id', { id: note.id }) .execute(); diff --git a/packages/backend/src/core/RelayService.ts b/packages/backend/src/core/RelayService.ts index e5aeb6787b..81e4132b59 100644 --- a/packages/backend/src/core/RelayService.ts +++ b/packages/backend/src/core/RelayService.ts @@ -54,7 +54,7 @@ export class RelayService { @bindThis public async addRelay(inbox: string): Promise { const relay = await this.relaysRepository.insert({ - id: this.idService.genId(), + id: this.idService.gen(), inbox, status: 'requesting', }).then(x => this.relaysRepository.findOneByOrFail(x.identifiers[0])); diff --git a/packages/backend/src/core/RoleService.ts b/packages/backend/src/core/RoleService.ts index 59b916b095..6424a9f17b 100644 --- a/packages/backend/src/core/RoleService.ts +++ b/packages/backend/src/core/RoleService.ts @@ -20,7 +20,7 @@ import { IdService } from '@/core/IdService.js'; import { GlobalEventService } from '@/core/GlobalEventService.js'; import { ModerationLogService } from '@/core/ModerationLogService.js'; import type { Packed } from '@/misc/json-schema.js'; -import { RedisTimelineService } from '@/core/RedisTimelineService.js'; +import { FunoutTimelineService } from '@/core/FunoutTimelineService.js'; import type { OnApplicationShutdown } from '@nestjs/common'; export type RolePolicies = { @@ -107,7 +107,7 @@ export class RoleService implements OnApplicationShutdown { private globalEventService: GlobalEventService, private idService: IdService, private moderationLogService: ModerationLogService, - private redisTimelineService: RedisTimelineService, + private funoutTimelineService: FunoutTimelineService, ) { //this.onMessage = this.onMessage.bind(this); @@ -129,7 +129,6 @@ export class RoleService implements OnApplicationShutdown { if (cached) { cached.push({ ...body, - createdAt: new Date(body.createdAt), updatedAt: new Date(body.updatedAt), lastUsedAt: new Date(body.lastUsedAt), }); @@ -143,7 +142,6 @@ export class RoleService implements OnApplicationShutdown { if (i > -1) { cached[i] = { ...body, - createdAt: new Date(body.createdAt), updatedAt: new Date(body.updatedAt), lastUsedAt: new Date(body.lastUsedAt), }; @@ -163,7 +161,6 @@ export class RoleService implements OnApplicationShutdown { if (cached) { cached.push({ ...body, - createdAt: new Date(body.createdAt), expiresAt: body.expiresAt ? new Date(body.expiresAt) : null, }); } @@ -202,10 +199,10 @@ export class RoleService implements OnApplicationShutdown { return this.userEntityService.isRemoteUser(user); } case 'createdLessThan': { - return user.createdAt.getTime() > (Date.now() - (value.sec * 1000)); + return this.idService.parse(user.id).date.getTime() > (Date.now() - (value.sec * 1000)); } case 'createdMoreThan': { - return user.createdAt.getTime() < (Date.now() - (value.sec * 1000)); + return this.idService.parse(user.id).date.getTime() < (Date.now() - (value.sec * 1000)); } case 'followersLessThanOrEq': { return user.followersCount <= value.value; @@ -388,7 +385,7 @@ export class RoleService implements OnApplicationShutdown { @bindThis public async assign(userId: MiUser['id'], roleId: MiRole['id'], expiresAt: Date | null = null, moderator?: MiUser): Promise { - const now = new Date(); + const now = Date.now(); const role = await this.rolesRepository.findOneByOrFail({ id: roleId }); @@ -398,7 +395,7 @@ export class RoleService implements OnApplicationShutdown { }); if (existing) { - if (existing.expiresAt && (existing.expiresAt.getTime() < now.getTime())) { + if (existing.expiresAt && (existing.expiresAt.getTime() < now)) { await this.roleAssignmentsRepository.delete({ roleId: roleId, userId: userId, @@ -409,8 +406,7 @@ export class RoleService implements OnApplicationShutdown { } const created = await this.roleAssignmentsRepository.insert({ - id: this.idService.genId(), - createdAt: now, + id: this.idService.gen(now), expiresAt: expiresAt, roleId: roleId, userId: userId, @@ -480,7 +476,7 @@ export class RoleService implements OnApplicationShutdown { const redisPipeline = this.redisClient.pipeline(); for (const role of roles) { - this.redisTimelineService.push(`roleTimeline:${role.id}`, note.id, 1000, redisPipeline); + this.funoutTimelineService.push(`roleTimeline:${role.id}`, note.id, 1000, redisPipeline); this.globalEventService.publishRoleTimelineStream(role.id, 'note', note); } @@ -491,8 +487,7 @@ export class RoleService implements OnApplicationShutdown { public async create(values: Partial, moderator?: MiUser): Promise { const date = new Date(); const created = await this.rolesRepository.insert({ - id: this.idService.genId(), - createdAt: date, + id: this.idService.gen(date.getTime()), updatedAt: date, lastUsedAt: date, name: values.name, diff --git a/packages/backend/src/core/SearchService.ts b/packages/backend/src/core/SearchService.ts index a8a2d6dd5f..90e1326793 100644 --- a/packages/backend/src/core/SearchService.ts +++ b/packages/backend/src/core/SearchService.ts @@ -79,7 +79,7 @@ export class SearchService { ) { if (meilisearch) { this.meilisearchNoteIndex = meilisearch.index(`${config.meilisearch!.index}---notes`); - /*this.meilisearchNoteIndex.updateSettings({ + this.meilisearchNoteIndex.updateSettings({ searchableAttributes: [ 'text', 'cw', @@ -100,7 +100,7 @@ export class SearchService { pagination: { maxTotalHits: 10000, }, - });*/ + }); } if (config.meilisearch?.scope) { @@ -131,7 +131,7 @@ export class SearchService { await this.meilisearchNoteIndex?.addDocuments([{ id: note.id, - createdAt: note.createdAt.getTime(), + createdAt: this.idService.parse(note.id).date.getTime(), userId: note.userId, userHost: note.userHost, channelId: note.channelId, diff --git a/packages/backend/src/core/SignupService.ts b/packages/backend/src/core/SignupService.ts index d61d22a368..3ceeb6b8d6 100644 --- a/packages/backend/src/core/SignupService.ts +++ b/packages/backend/src/core/SignupService.ts @@ -120,8 +120,7 @@ export class SignupService { if (exist) throw new Error(' the username is already used'); account = await transactionalEntityManager.save(new MiUser({ - id: this.idService.genId(), - createdAt: new Date(), + id: this.idService.gen(), username: username, usernameLower: username.toLowerCase(), host: this.utilityService.toPunyNullable(host), diff --git a/packages/backend/src/core/UserBlockingService.ts b/packages/backend/src/core/UserBlockingService.ts index 2f050c69ba..0320ef7f29 100644 --- a/packages/backend/src/core/UserBlockingService.ts +++ b/packages/backend/src/core/UserBlockingService.ts @@ -68,8 +68,7 @@ export class UserBlockingService implements OnModuleInit { ]); const blocking = { - id: this.idService.genId(), - createdAt: new Date(), + id: this.idService.gen(), blocker, blockerId: blocker.id, blockee, diff --git a/packages/backend/src/core/UserFollowingService.ts b/packages/backend/src/core/UserFollowingService.ts index 75e721db72..cd0620528c 100644 --- a/packages/backend/src/core/UserFollowingService.ts +++ b/packages/backend/src/core/UserFollowingService.ts @@ -3,7 +3,7 @@ * SPDX-License-Identifier: AGPL-3.0-only */ -import { Inject, Injectable, OnModuleInit, forwardRef } from '@nestjs/common'; +import { Inject, Injectable, OnModuleInit } from '@nestjs/common'; import { ModuleRef } from '@nestjs/core'; import { IsNull } from 'typeorm'; import type { MiLocalUser, MiPartialLocalUser, MiPartialRemoteUser, MiRemoteUser, MiUser } from '@/models/User.js'; @@ -28,6 +28,8 @@ import { MetaService } from '@/core/MetaService.js'; import { CacheService } from '@/core/CacheService.js'; import type { Config } from '@/config.js'; import { AccountMoveService } from '@/core/AccountMoveService.js'; +import { UtilityService } from '@/core/UtilityService.js'; +import { FunoutTimelineService } from '@/core/FunoutTimelineService.js'; import Logger from '../logger.js'; const logger = new Logger('following/create'); @@ -71,6 +73,7 @@ export class UserFollowingService implements OnModuleInit { private instancesRepository: InstancesRepository, private cacheService: CacheService, + private utilityService: UtilityService, private userEntityService: UserEntityService, private idService: IdService, private queueService: QueueService, @@ -81,6 +84,7 @@ export class UserFollowingService implements OnModuleInit { private webhookService: WebhookService, private apRendererService: ApRendererService, private accountMoveService: AccountMoveService, + private funoutTimelineService: FunoutTimelineService, private perUserFollowingChart: PerUserFollowingChart, private instanceChart: InstanceChart, ) { @@ -91,7 +95,15 @@ export class UserFollowingService implements OnModuleInit { } @bindThis - public async follow(_follower: { id: MiUser['id'] }, _followee: { id: MiUser['id'] }, requestId?: string, silent = false): Promise { + public async follow( + _follower: { id: MiUser['id'] }, + _followee: { id: MiUser['id'] }, + { requestId, silent = false, withReplies }: { + requestId?: string, + silent?: boolean, + withReplies?: boolean, + } = {}, + ): Promise { const [follower, followee] = await Promise.all([ this.usersRepository.findOneByOrFail({ id: _follower.id }), this.usersRepository.findOneByOrFail({ id: _followee.id }), @@ -118,15 +130,16 @@ export class UserFollowingService implements OnModuleInit { } const followeeProfile = await this.userProfilesRepository.findOneByOrFail({ userId: followee.id }); - // フォロー対象が鍵アカウントである or // フォロワーがBotであり、フォロー対象がBotからのフォローに慎重である or - // フォロワーがローカルユーザーであり、フォロー対象がリモートユーザーである + // フォロワーがローカルユーザーであり、フォロー対象がリモートユーザーである or + // フォロワーがローカルユーザーであり、フォロー対象がサイレンスされているサーバーである // 上記のいずれかに当てはまる場合はすぐフォローせずにフォローリクエストを発行しておく if ( followee.isLocked || (followeeProfile.carefulBot && follower.isBot) || - (this.userEntityService.isLocalUser(follower) && this.userEntityService.isRemoteUser(followee) && process.env.FORCE_FOLLOW_REMOTE_USER_FOR_TESTING !== 'true') + (this.userEntityService.isLocalUser(follower) && this.userEntityService.isRemoteUser(followee) && process.env.FORCE_FOLLOW_REMOTE_USER_FOR_TESTING !== 'true') || + (this.userEntityService.isLocalUser(followee) && this.userEntityService.isRemoteUser(follower) && this.utilityService.isSilencedHost((await this.metaService.fetch()).silencedHosts, follower.host)) ) { let autoAccept = false; @@ -168,12 +181,12 @@ export class UserFollowingService implements OnModuleInit { } if (!autoAccept) { - await this.createFollowRequest(follower, followee, requestId); + await this.createFollowRequest(follower, followee, requestId, withReplies); return; } } - await this.insertFollowingDoc(followee, follower, silent); + await this.insertFollowingDoc(followee, follower, silent, withReplies); if (this.userEntityService.isRemoteUser(follower) && this.userEntityService.isLocalUser(followee)) { const content = this.apRendererService.addContext(this.apRendererService.renderAccept(this.apRendererService.renderFollow(follower, followee, requestId), followee)); @@ -190,16 +203,17 @@ export class UserFollowingService implements OnModuleInit { id: MiUser['id']; host: MiUser['host']; uri: MiUser['host']; inbox: MiUser['inbox']; sharedInbox: MiUser['sharedInbox'] }, silent = false, + withReplies?: boolean, ): Promise { if (follower.id === followee.id) return; let alreadyFollowed = false as boolean; await this.followingsRepository.insert({ - id: this.idService.genId(), - createdAt: new Date(), + id: this.idService.gen(), followerId: follower.id, followeeId: followee.id, + withReplies: withReplies, // 非正規化 followerHost: follower.host, @@ -276,8 +290,8 @@ export class UserFollowingService implements OnModuleInit { this.perUserFollowingChart.update(follower, followee, true); } - // Publish follow event if (this.userEntityService.isLocalUser(follower) && !silent) { + // Publish follow event this.userEntityService.pack(followee.id, follower, { detail: true, }).then(async packed => { @@ -290,6 +304,8 @@ export class UserFollowingService implements OnModuleInit { }); } }); + + this.funoutTimelineService.purge(`homeTimeline:${follower.id}`); } // Publish followed event @@ -343,8 +359,8 @@ export class UserFollowingService implements OnModuleInit { this.decrementFollowing(following.follower, following.followee); - // Publish unfollow event if (!silent && this.userEntityService.isLocalUser(follower)) { + // Publish unfollow event this.userEntityService.pack(followee.id, follower, { detail: true, }).then(async packed => { @@ -357,6 +373,8 @@ export class UserFollowingService implements OnModuleInit { }); } }); + + this.funoutTimelineService.purge(`homeTimeline:${follower.id}`); } if (this.userEntityService.isLocalUser(follower) && this.userEntityService.isRemoteUser(followee)) { @@ -452,6 +470,7 @@ export class UserFollowingService implements OnModuleInit { id: MiUser['id']; host: MiUser['host']; uri: MiUser['host']; inbox: MiUser['inbox']; sharedInbox: MiUser['sharedInbox']; }, requestId?: string, + withReplies?: boolean, ): Promise { if (follower.id === followee.id) return; @@ -465,11 +484,11 @@ export class UserFollowingService implements OnModuleInit { if (blocked) throw new Error('blocked'); const followRequest = await this.followRequestsRepository.insert({ - id: this.idService.genId(), - createdAt: new Date(), + id: this.idService.gen(), followerId: follower.id, followeeId: followee.id, requestId, + withReplies, // 非正規化 followerHost: follower.host, @@ -554,7 +573,7 @@ export class UserFollowingService implements OnModuleInit { throw new IdentifiableError('8884c2dd-5795-4ac9-b27e-6a01d38190f9', 'No follow request.'); } - await this.insertFollowingDoc(followee, follower); + await this.insertFollowingDoc(followee, follower, false, request.withReplies); if (this.userEntityService.isRemoteUser(follower) && this.userEntityService.isLocalUser(followee)) { const content = this.apRendererService.addContext(this.apRendererService.renderAccept(this.apRendererService.renderFollow(follower, followee as MiPartialLocalUser, request.requestId!), followee)); @@ -694,4 +713,12 @@ export class UserFollowingService implements OnModuleInit { }); } } + + @bindThis + public getFollowees(userId: MiUser['id']) { + return this.followingsRepository.createQueryBuilder('following') + .select('following.followeeId') + .where('following.followerId = :followerId', { followerId: userId }) + .getMany(); + } } diff --git a/packages/backend/src/core/UserListService.ts b/packages/backend/src/core/UserListService.ts index 465e365c50..d522551aff 100644 --- a/packages/backend/src/core/UserListService.ts +++ b/packages/backend/src/core/UserListService.ts @@ -93,8 +93,7 @@ export class UserListService implements OnApplicationShutdown { } await this.userListMembershipsRepository.insert({ - id: this.idService.genId(), - createdAt: new Date(), + id: this.idService.gen(), userId: target.id, userListId: list.id, userListUserId: list.userId, diff --git a/packages/backend/src/core/UserMutingService.ts b/packages/backend/src/core/UserMutingService.ts index 862896384e..df40a210b9 100644 --- a/packages/backend/src/core/UserMutingService.ts +++ b/packages/backend/src/core/UserMutingService.ts @@ -26,8 +26,7 @@ export class UserMutingService { @bindThis public async mute(user: MiUser, target: MiUser, expiresAt: Date | null = null): Promise { await this.mutingsRepository.insert({ - id: this.idService.genId(), - createdAt: new Date(), + id: this.idService.gen(), expiresAt: expiresAt ?? null, muterId: user.id, muteeId: target.id, diff --git a/packages/backend/src/core/UtilityService.ts b/packages/backend/src/core/UtilityService.ts index 3f1ef1a17d..83d9a29eae 100644 --- a/packages/backend/src/core/UtilityService.ts +++ b/packages/backend/src/core/UtilityService.ts @@ -35,6 +35,12 @@ export class UtilityService { return blockedHosts.some(x => `.${host.toLowerCase()}`.endsWith(`.${x}`)); } + @bindThis + public isSilencedHost(silencedHosts: string[] | undefined, host: string | null): boolean { + if (!silencedHosts || host == null) return false; + return silencedHosts.some(x => `.${host.toLowerCase()}`.endsWith(`.${x}`)); + } + @bindThis public extractDbHost(uri: string): string { const url = new URL(uri); diff --git a/packages/backend/src/core/WebhookService.ts b/packages/backend/src/core/WebhookService.ts index 8ef3624e9d..7d0de2a5a9 100644 --- a/packages/backend/src/core/WebhookService.ts +++ b/packages/backend/src/core/WebhookService.ts @@ -51,7 +51,6 @@ export class WebhookService implements OnApplicationShutdown { if (body.active) { this.webhooks.push({ ...body, - createdAt: new Date(body.createdAt), latestSentAt: body.latestSentAt ? new Date(body.latestSentAt) : null, }); } @@ -62,13 +61,11 @@ export class WebhookService implements OnApplicationShutdown { if (i > -1) { this.webhooks[i] = { ...body, - createdAt: new Date(body.createdAt), latestSentAt: body.latestSentAt ? new Date(body.latestSentAt) : null, }; } else { this.webhooks.push({ ...body, - createdAt: new Date(body.createdAt), latestSentAt: body.latestSentAt ? new Date(body.latestSentAt) : null, }); } diff --git a/packages/backend/src/core/activitypub/ApInboxService.ts b/packages/backend/src/core/activitypub/ApInboxService.ts index cc82e9000f..598c3b6f57 100644 --- a/packages/backend/src/core/activitypub/ApInboxService.ts +++ b/packages/backend/src/core/activitypub/ApInboxService.ts @@ -173,7 +173,7 @@ export class ApInboxService { } // don't queue because the sender may attempt again when timeout - await this.userFollowingService.follow(actor, followee, activity.id); + await this.userFollowingService.follow(actor, followee, { requestId: activity.id }); return 'ok'; } @@ -564,8 +564,7 @@ export class ApInboxService { if (users.length < 1) return 'skip'; const report = await this.abuseUserReportsRepository.insert({ - id: this.idService.genId(), - createdAt: new Date(), + id: this.idService.gen(), targetUserId: users[0].id, targetUserHost: users[0].host, reporterId: actor.id, diff --git a/packages/backend/src/core/activitypub/ApRendererService.ts b/packages/backend/src/core/activitypub/ApRendererService.ts index b0504bdef0..b149605070 100644 --- a/packages/backend/src/core/activitypub/ApRendererService.ts +++ b/packages/backend/src/core/activitypub/ApRendererService.ts @@ -28,6 +28,7 @@ import type { UsersRepository, UserProfilesRepository, NotesRepository, DriveFil import { bindThis } from '@/decorators.js'; import { CustomEmojiService } from '@/core/CustomEmojiService.js'; import { isNotNull } from '@/misc/is-not-null.js'; +import { IdService } from '@/core/IdService.js'; import { LdSignatureService } from './LdSignatureService.js'; import { ApMfmService } from './ApMfmService.js'; import type { IAccept, IActivity, IAdd, IAnnounce, IApDocument, IApEmoji, IApHashtag, IApImage, IApMention, IBlock, ICreate, IDelete, IFlag, IFollow, IKey, ILike, IMove, IObject, IPost, IQuestion, IRead, IReject, IRemove, ITombstone, IUndo, IUpdate } from './type.js'; @@ -63,6 +64,7 @@ export class ApRendererService { private userKeypairService: UserKeypairService, private apMfmService: ApMfmService, private mfmService: MfmService, + private idService: IdService, ) { } @@ -109,7 +111,7 @@ export class ApRendererService { id: `${this.config.url}/notes/${note.id}/activity`, actor: this.userEntityService.genLocalUserUri(note.userId), type: 'Announce', - published: note.createdAt.toISOString(), + published: this.idService.parse(note.id).date.toISOString(), to, cc, object, @@ -141,7 +143,7 @@ export class ApRendererService { id: `${this.config.url}/notes/${note.id}/activity`, actor: this.userEntityService.genLocalUserUri(note.userId), type: 'Create', - published: note.createdAt.toISOString(), + published: this.idService.parse(note.id).date.toISOString(), object, }; @@ -457,7 +459,7 @@ export class ApRendererService { }, _misskey_quote: quote, quoteUrl: quote, - published: note.createdAt.toISOString(), + published: this.idService.parse(note.id).date.toISOString(), to, cc, inReplyTo, diff --git a/packages/backend/src/core/activitypub/models/ApNoteService.ts b/packages/backend/src/core/activitypub/models/ApNoteService.ts index e4480a30ba..01308dfb0c 100644 --- a/packages/backend/src/core/activitypub/models/ApNoteService.ts +++ b/packages/backend/src/core/activitypub/models/ApNoteService.ts @@ -416,7 +416,7 @@ export class ApNoteService { this.logger.info(`register emoji host=${host}, name=${name}`); return await this.emojisRepository.insert({ - id: this.idService.genId(), + id: this.idService.gen(), host, name, uri: tag.id, diff --git a/packages/backend/src/core/activitypub/models/ApPersonService.ts b/packages/backend/src/core/activitypub/models/ApPersonService.ts index 0cb05ad719..07a66ed19d 100644 --- a/packages/backend/src/core/activitypub/models/ApPersonService.ts +++ b/packages/backend/src/core/activitypub/models/ApPersonService.ts @@ -355,10 +355,9 @@ export class ApPersonService implements OnModuleInit { // Start transaction await this.db.transaction(async transactionalEntityManager => { user = await transactionalEntityManager.save(new MiUser({ - id: this.idService.genId(), + id: this.idService.gen(), avatarId: null, bannerId: null, - createdAt: new Date(), lastFetchedAt: new Date(), name: truncate(person.name, nameLength), isLocked: person.manuallyApprovesFollowers, @@ -760,8 +759,7 @@ export class ApPersonService implements OnModuleInit { for (const note of featuredNotes.filter((note): note is MiNote => note != null)) { td -= 1000; transactionalEntityManager.insert(MiUserNotePining, { - id: this.idService.genId(new Date(Date.now() + td)), - createdAt: new Date(), + id: this.idService.gen(Date.now() + td), userId: user.id, noteId: note.id, }); diff --git a/packages/backend/src/core/chart/charts/active-users.ts b/packages/backend/src/core/chart/charts/active-users.ts index cb35d1670e..a0fe2230d0 100644 --- a/packages/backend/src/core/chart/charts/active-users.ts +++ b/packages/backend/src/core/chart/charts/active-users.ts @@ -9,6 +9,7 @@ import { AppLockService } from '@/core/AppLockService.js'; import type { MiUser } from '@/models/User.js'; import { DI } from '@/di-symbols.js'; import { bindThis } from '@/decorators.js'; +import { IdService } from '@/core/IdService.js'; import Chart from '../core.js'; import { ChartLoggerService } from '../ChartLoggerService.js'; import { name, schema } from './entities/active-users.js'; @@ -29,6 +30,7 @@ export default class ActiveUsersChart extends Chart { // eslint-d private appLockService: AppLockService, private chartLoggerService: ChartLoggerService, + private idService: IdService, ) { super(db, (k) => appLockService.getChartInsertLock(k), chartLoggerService.logger, name, schema); } @@ -42,20 +44,21 @@ export default class ActiveUsersChart extends Chart { // eslint-d } @bindThis - public async read(user: { id: MiUser['id'], host: null, createdAt: MiUser['createdAt'] }): Promise { + public async read(user: { id: MiUser['id'], host: null }): Promise { + const createdAt = this.idService.parse(user.id).date; await this.commit({ 'read': [user.id], - 'registeredWithinWeek': (Date.now() - user.createdAt.getTime() < week) ? [user.id] : [], - 'registeredWithinMonth': (Date.now() - user.createdAt.getTime() < month) ? [user.id] : [], - 'registeredWithinYear': (Date.now() - user.createdAt.getTime() < year) ? [user.id] : [], - 'registeredOutsideWeek': (Date.now() - user.createdAt.getTime() > week) ? [user.id] : [], - 'registeredOutsideMonth': (Date.now() - user.createdAt.getTime() > month) ? [user.id] : [], - 'registeredOutsideYear': (Date.now() - user.createdAt.getTime() > year) ? [user.id] : [], + 'registeredWithinWeek': (Date.now() - createdAt.getTime() < week) ? [user.id] : [], + 'registeredWithinMonth': (Date.now() - createdAt.getTime() < month) ? [user.id] : [], + 'registeredWithinYear': (Date.now() - createdAt.getTime() < year) ? [user.id] : [], + 'registeredOutsideWeek': (Date.now() - createdAt.getTime() > week) ? [user.id] : [], + 'registeredOutsideMonth': (Date.now() - createdAt.getTime() > month) ? [user.id] : [], + 'registeredOutsideYear': (Date.now() - createdAt.getTime() > year) ? [user.id] : [], }); } @bindThis - public async write(user: { id: MiUser['id'], host: null, createdAt: MiUser['createdAt'] }): Promise { + public async write(user: { id: MiUser['id'], host: null }): Promise { await this.commit({ 'write': [user.id], }); diff --git a/packages/backend/src/core/entities/AbuseUserReportEntityService.ts b/packages/backend/src/core/entities/AbuseUserReportEntityService.ts index 7fda046276..ee24b73097 100644 --- a/packages/backend/src/core/entities/AbuseUserReportEntityService.ts +++ b/packages/backend/src/core/entities/AbuseUserReportEntityService.ts @@ -9,6 +9,7 @@ import type { AbuseUserReportsRepository } from '@/models/_.js'; import { awaitAll } from '@/misc/prelude/await-all.js'; import type { MiAbuseUserReport } from '@/models/AbuseUserReport.js'; import { bindThis } from '@/decorators.js'; +import { IdService } from '@/core/IdService.js'; import { UserEntityService } from './UserEntityService.js'; @Injectable() @@ -18,6 +19,7 @@ export class AbuseUserReportEntityService { private abuseUserReportsRepository: AbuseUserReportsRepository, private userEntityService: UserEntityService, + private idService: IdService, ) { } @@ -29,7 +31,7 @@ export class AbuseUserReportEntityService { return await awaitAll({ id: report.id, - createdAt: report.createdAt.toISOString(), + createdAt: this.idService.parse(report.id).date.toISOString(), comment: report.comment, resolved: report.resolved, reporterId: report.reporterId, diff --git a/packages/backend/src/core/entities/AntennaEntityService.ts b/packages/backend/src/core/entities/AntennaEntityService.ts index 22fd836b21..f6b1847b8e 100644 --- a/packages/backend/src/core/entities/AntennaEntityService.ts +++ b/packages/backend/src/core/entities/AntennaEntityService.ts @@ -9,6 +9,7 @@ import type { AntennasRepository, UserGroupJoiningsRepository } from '@/models/_ import type { Packed } from '@/misc/json-schema.js'; import type { MiAntenna } from '@/models/Antenna.js'; import { bindThis } from '@/decorators.js'; +import { IdService } from '@/core/IdService.js'; @Injectable() export class AntennaEntityService { @@ -18,6 +19,8 @@ export class AntennaEntityService { @Inject(DI.userGroupJoiningsRepository) private userGroupJoiningsRepository: UserGroupJoiningsRepository, + + private idService: IdService, ) { } @@ -31,7 +34,7 @@ export class AntennaEntityService { return { id: antenna.id, - createdAt: antenna.createdAt.toISOString(), + createdAt: this.idService.parse(antenna.id).date.toISOString(), name: antenna.name, keywords: antenna.keywords, excludeKeywords: antenna.excludeKeywords, @@ -40,6 +43,7 @@ export class AntennaEntityService { userGroupId: userGroupJoining ? userGroupJoining.userGroupId : null, users: antenna.users, caseSensitive: antenna.caseSensitive, + localOnly: antenna.localOnly, notify: antenna.notify, withReplies: antenna.withReplies, withFile: antenna.withFile, diff --git a/packages/backend/src/core/entities/BlockingEntityService.ts b/packages/backend/src/core/entities/BlockingEntityService.ts index e5a589f823..09a74298db 100644 --- a/packages/backend/src/core/entities/BlockingEntityService.ts +++ b/packages/backend/src/core/entities/BlockingEntityService.ts @@ -11,6 +11,7 @@ import type { Packed } from '@/misc/json-schema.js'; import type { MiBlocking } from '@/models/Blocking.js'; import type { MiUser } from '@/models/User.js'; import { bindThis } from '@/decorators.js'; +import { IdService } from '@/core/IdService.js'; import { UserEntityService } from './UserEntityService.js'; @Injectable() @@ -20,6 +21,7 @@ export class BlockingEntityService { private blockingsRepository: BlockingsRepository, private userEntityService: UserEntityService, + private idService: IdService, ) { } @@ -32,7 +34,7 @@ export class BlockingEntityService { return await awaitAll({ id: blocking.id, - createdAt: blocking.createdAt.toISOString(), + createdAt: this.idService.parse(blocking.id).date.toISOString(), blockeeId: blocking.blockeeId, blockee: this.userEntityService.pack(blocking.blockeeId, me, { detail: true, diff --git a/packages/backend/src/core/entities/ChannelEntityService.ts b/packages/backend/src/core/entities/ChannelEntityService.ts index 1b18faa9f6..9a89f78fa9 100644 --- a/packages/backend/src/core/entities/ChannelEntityService.ts +++ b/packages/backend/src/core/entities/ChannelEntityService.ts @@ -11,6 +11,7 @@ import type { } from '@/models/Blocking.js'; import type { MiUser } from '@/models/User.js'; import type { MiChannel } from '@/models/Channel.js'; import { bindThis } from '@/decorators.js'; +import { IdService } from '@/core/IdService.js'; import { DriveFileEntityService } from './DriveFileEntityService.js'; import { NoteEntityService } from './NoteEntityService.js'; import { In } from 'typeorm'; @@ -38,6 +39,7 @@ export class ChannelEntityService { private noteEntityService: NoteEntityService, private driveFileEntityService: DriveFileEntityService, + private idService: IdService, ) { } @@ -81,7 +83,7 @@ export class ChannelEntityService { return { id: channel.id, - createdAt: channel.createdAt.toISOString(), + createdAt: this.idService.parse(channel.id).date.toISOString(), lastNotedAt: channel.lastNotedAt ? channel.lastNotedAt.toISOString() : null, name: channel.name, description: channel.description, diff --git a/packages/backend/src/core/entities/ClipEntityService.ts b/packages/backend/src/core/entities/ClipEntityService.ts index 9c8740c6f9..a38a2ece14 100644 --- a/packages/backend/src/core/entities/ClipEntityService.ts +++ b/packages/backend/src/core/entities/ClipEntityService.ts @@ -11,6 +11,7 @@ import type { Packed } from '@/misc/json-schema.js'; import type { } from '@/models/Blocking.js'; import type { MiClip } from '@/models/Clip.js'; import { bindThis } from '@/decorators.js'; +import { IdService } from '@/core/IdService.js'; import { UserEntityService } from './UserEntityService.js'; @Injectable() @@ -23,6 +24,7 @@ export class ClipEntityService { private clipFavoritesRepository: ClipFavoritesRepository, private userEntityService: UserEntityService, + private idService: IdService, ) { } @@ -36,7 +38,7 @@ export class ClipEntityService { return await awaitAll({ id: clip.id, - createdAt: clip.createdAt.toISOString(), + createdAt: this.idService.parse(clip.id).date.toISOString(), lastClippedAt: clip.lastClippedAt ? clip.lastClippedAt.toISOString() : null, userId: clip.userId, user: this.userEntityService.pack(clip.user ?? clip.userId), diff --git a/packages/backend/src/core/entities/DriveFileEntityService.ts b/packages/backend/src/core/entities/DriveFileEntityService.ts index b88b7fd74f..8fe7e6c419 100644 --- a/packages/backend/src/core/entities/DriveFileEntityService.ts +++ b/packages/backend/src/core/entities/DriveFileEntityService.ts @@ -17,6 +17,7 @@ import { deepClone } from '@/misc/clone.js'; import { bindThis } from '@/decorators.js'; import { isMimeImage } from '@/misc/is-mime-image.js'; import { isNotNull } from '@/misc/is-not-null.js'; +import { IdService } from '@/core/IdService.js'; import { UtilityService } from '../UtilityService.js'; import { VideoProcessingService } from '../VideoProcessingService.js'; import { UserEntityService } from './UserEntityService.js'; @@ -44,6 +45,7 @@ export class DriveFileEntityService { private utilityService: UtilityService, private driveFolderEntityService: DriveFolderEntityService, private videoProcessingService: VideoProcessingService, + private idService: IdService, ) { } @@ -88,7 +90,7 @@ export class DriveFileEntityService { if (file.type.startsWith('video')) { if (file.thumbnailUrl) return file.thumbnailUrl; - return this.videoProcessingService.getExternalVideoThumbnailUrl(file.webpublicUrl ?? file.url ?? file.uri); + return this.videoProcessingService.getExternalVideoThumbnailUrl(file.webpublicUrl ?? file.url); } else if (file.uri != null && file.userHost != null && this.config.externalMediaProxyEnabled) { // 動画ではなくリモートかつメディアプロキシ return this.getProxiedUrl(file.uri, 'static'); @@ -153,7 +155,7 @@ export class DriveFileEntityService { .select('SUM(file.size)', 'sum') .getRawOne(); - return parseInt(sum, 10) ?? 0; + return parseInt(sum, 10) || 0; } @bindThis @@ -165,7 +167,7 @@ export class DriveFileEntityService { .select('SUM(file.size)', 'sum') .getRawOne(); - return parseInt(sum, 10) ?? 0; + return parseInt(sum, 10) || 0; } @bindThis @@ -177,7 +179,7 @@ export class DriveFileEntityService { .select('SUM(file.size)', 'sum') .getRawOne(); - return parseInt(sum, 10) ?? 0; + return parseInt(sum, 10) || 0; } @bindThis @@ -189,7 +191,7 @@ export class DriveFileEntityService { .select('SUM(file.size)', 'sum') .getRawOne(); - return parseInt(sum, 10) ?? 0; + return parseInt(sum, 10) || 0; } @bindThis @@ -206,7 +208,7 @@ export class DriveFileEntityService { return await awaitAll>({ id: file.id, - createdAt: file.createdAt.toISOString(), + createdAt: this.idService.parse(file.id).date.toISOString(), name: file.name, type: file.type, md5: file.md5, @@ -241,7 +243,7 @@ export class DriveFileEntityService { return await awaitAll>({ id: file.id, - createdAt: file.createdAt.toISOString(), + createdAt: this.idService.parse(file.id).date.toISOString(), name: file.name, type: file.type, md5: file.md5, diff --git a/packages/backend/src/core/entities/DriveFolderEntityService.ts b/packages/backend/src/core/entities/DriveFolderEntityService.ts index a388617818..05f66d989d 100644 --- a/packages/backend/src/core/entities/DriveFolderEntityService.ts +++ b/packages/backend/src/core/entities/DriveFolderEntityService.ts @@ -11,6 +11,7 @@ import type { Packed } from '@/misc/json-schema.js'; import type { } from '@/models/Blocking.js'; import type { MiDriveFolder } from '@/models/DriveFolder.js'; import { bindThis } from '@/decorators.js'; +import { IdService } from '@/core/IdService.js'; @Injectable() export class DriveFolderEntityService { @@ -20,6 +21,8 @@ export class DriveFolderEntityService { @Inject(DI.driveFilesRepository) private driveFilesRepository: DriveFilesRepository, + + private idService: IdService, ) { } @@ -38,7 +41,7 @@ export class DriveFolderEntityService { return await awaitAll({ id: folder.id, - createdAt: folder.createdAt.toISOString(), + createdAt: this.idService.parse(folder.id).date.toISOString(), name: folder.name, parentId: folder.parentId, diff --git a/packages/backend/src/core/entities/FlashEntityService.ts b/packages/backend/src/core/entities/FlashEntityService.ts index 99eedcda7d..80ab25ccdd 100644 --- a/packages/backend/src/core/entities/FlashEntityService.ts +++ b/packages/backend/src/core/entities/FlashEntityService.ts @@ -12,6 +12,7 @@ import type { } from '@/models/Blocking.js'; import type { MiUser } from '@/models/User.js'; import type { MiFlash } from '@/models/Flash.js'; import { bindThis } from '@/decorators.js'; +import { IdService } from '@/core/IdService.js'; import { UserEntityService } from './UserEntityService.js'; @Injectable() @@ -24,6 +25,7 @@ export class FlashEntityService { private flashLikesRepository: FlashLikesRepository, private userEntityService: UserEntityService, + private idService: IdService, ) { } @@ -37,7 +39,7 @@ export class FlashEntityService { return await awaitAll({ id: flash.id, - createdAt: flash.createdAt.toISOString(), + createdAt: this.idService.parse(flash.id).date.toISOString(), updatedAt: flash.updatedAt.toISOString(), userId: flash.userId, user: this.userEntityService.pack(flash.user ?? flash.userId, me), // { detail: true } すると無限ループするので注意 diff --git a/packages/backend/src/core/entities/FollowingEntityService.ts b/packages/backend/src/core/entities/FollowingEntityService.ts index fbe8ab133a..81121b72c9 100644 --- a/packages/backend/src/core/entities/FollowingEntityService.ts +++ b/packages/backend/src/core/entities/FollowingEntityService.ts @@ -12,6 +12,7 @@ import type { } from '@/models/Blocking.js'; import type { MiUser } from '@/models/User.js'; import type { MiFollowing } from '@/models/Following.js'; import { bindThis } from '@/decorators.js'; +import { IdService } from '@/core/IdService.js'; import { UserEntityService } from './UserEntityService.js'; type LocalFollowerFollowing = MiFollowing & { @@ -45,6 +46,7 @@ export class FollowingEntityService { private followingsRepository: FollowingsRepository, private userEntityService: UserEntityService, + private idService: IdService, ) { } @@ -83,7 +85,7 @@ export class FollowingEntityService { return await awaitAll({ id: following.id, - createdAt: following.createdAt.toISOString(), + createdAt: this.idService.parse(following.id).date.toISOString(), followeeId: following.followeeId, followerId: following.followerId, followee: opts.populateFollowee ? this.userEntityService.pack(following.followee ?? following.followeeId, me, { diff --git a/packages/backend/src/core/entities/GalleryPostEntityService.ts b/packages/backend/src/core/entities/GalleryPostEntityService.ts index 9b94aa6eee..c1ea5ca43f 100644 --- a/packages/backend/src/core/entities/GalleryPostEntityService.ts +++ b/packages/backend/src/core/entities/GalleryPostEntityService.ts @@ -12,6 +12,7 @@ import type { } from '@/models/Blocking.js'; import type { MiUser } from '@/models/User.js'; import type { MiGalleryPost } from '@/models/GalleryPost.js'; import { bindThis } from '@/decorators.js'; +import { IdService } from '@/core/IdService.js'; import { UserEntityService } from './UserEntityService.js'; import { DriveFileEntityService } from './DriveFileEntityService.js'; @@ -26,6 +27,7 @@ export class GalleryPostEntityService { private userEntityService: UserEntityService, private driveFileEntityService: DriveFileEntityService, + private idService: IdService, ) { } @@ -39,7 +41,7 @@ export class GalleryPostEntityService { return await awaitAll({ id: post.id, - createdAt: post.createdAt.toISOString(), + createdAt: this.idService.parse(post.id).date.toISOString(), updatedAt: post.updatedAt.toISOString(), userId: post.userId, user: this.userEntityService.pack(post.user ?? post.userId, me), diff --git a/packages/backend/src/core/entities/InstanceEntityService.ts b/packages/backend/src/core/entities/InstanceEntityService.ts index 7ab2b6575d..bc2cb086d9 100644 --- a/packages/backend/src/core/entities/InstanceEntityService.ts +++ b/packages/backend/src/core/entities/InstanceEntityService.ts @@ -5,7 +5,6 @@ import { Injectable } from '@nestjs/common'; import type { Packed } from '@/misc/json-schema.js'; -import type { } from '@/models/Blocking.js'; import type { MiInstance } from '@/models/Instance.js'; import { MetaService } from '@/core/MetaService.js'; import { bindThis } from '@/decorators.js'; @@ -43,6 +42,7 @@ export class InstanceEntityService { description: instance.description, maintainerName: instance.maintainerName, maintainerEmail: instance.maintainerEmail, + isSilenced: this.utilityService.isSilencedHost(meta.silencedHosts, instance.host), iconUrl: instance.iconUrl, faviconUrl: instance.faviconUrl, themeColor: instance.themeColor, diff --git a/packages/backend/src/core/entities/InviteCodeEntityService.ts b/packages/backend/src/core/entities/InviteCodeEntityService.ts index 03f6501147..2d0b8be09a 100644 --- a/packages/backend/src/core/entities/InviteCodeEntityService.ts +++ b/packages/backend/src/core/entities/InviteCodeEntityService.ts @@ -11,6 +11,7 @@ import type { Packed } from '@/misc/json-schema.js'; import type { MiUser } from '@/models/User.js'; import type { MiRegistrationTicket } from '@/models/RegistrationTicket.js'; import { bindThis } from '@/decorators.js'; +import { IdService } from '@/core/IdService.js'; import { UserEntityService } from './UserEntityService.js'; @Injectable() @@ -20,6 +21,7 @@ export class InviteCodeEntityService { private registrationTicketsRepository: RegistrationTicketsRepository, private userEntityService: UserEntityService, + private idService: IdService, ) { } @@ -39,7 +41,7 @@ export class InviteCodeEntityService { id: target.id, code: target.code, expiresAt: target.expiresAt ? target.expiresAt.toISOString() : null, - createdAt: target.createdAt.toISOString(), + createdAt: this.idService.parse(target.id).date.toISOString(), createdBy: target.createdBy ? await this.userEntityService.pack(target.createdBy, me) : null, usedBy: target.usedBy ? await this.userEntityService.pack(target.usedBy, me) : null, usedAt: target.usedAt ? target.usedAt.toISOString() : null, diff --git a/packages/backend/src/core/entities/MessagingMessageEntityService.ts b/packages/backend/src/core/entities/MessagingMessageEntityService.ts index 5011bb16aa..5974e984f8 100644 --- a/packages/backend/src/core/entities/MessagingMessageEntityService.ts +++ b/packages/backend/src/core/entities/MessagingMessageEntityService.ts @@ -10,6 +10,7 @@ import type { Packed } from '@/misc/json-schema.js'; import type { MiUser } from '@/models/User.js'; import type { MiMessagingMessage } from '@/models/MessagingMessage.js'; import { bindThis } from '@/decorators.js'; +import { IdService } from '@/core/IdService.js'; import { UserEntityService } from './UserEntityService.js'; import { DriveFileEntityService } from './DriveFileEntityService.js'; import { UserGroupEntityService } from './UserGroupEntityService.js'; @@ -20,6 +21,7 @@ export class MessagingMessageEntityService { @Inject(DI.messagingMessagesRepository) private messagingMessagesRepository: MessagingMessagesRepository, + private idService: IdService, private userEntityService: UserEntityService, private userGroupEntityService: UserGroupEntityService, private driveFileEntityService: DriveFileEntityService, @@ -44,7 +46,7 @@ export class MessagingMessageEntityService { return { id: message.id, - createdAt: message.createdAt.toISOString(), + createdAt: this.idService.parse(message.id).date.toISOString(), text: message.text, userId: message.userId, user: await this.userEntityService.pack(message.user ?? message.userId, me), diff --git a/packages/backend/src/core/entities/ModerationLogEntityService.ts b/packages/backend/src/core/entities/ModerationLogEntityService.ts index d1107effcb..6973e64c19 100644 --- a/packages/backend/src/core/entities/ModerationLogEntityService.ts +++ b/packages/backend/src/core/entities/ModerationLogEntityService.ts @@ -10,6 +10,7 @@ import { awaitAll } from '@/misc/prelude/await-all.js'; import type { } from '@/models/Blocking.js'; import type { MiModerationLog } from '@/models/ModerationLog.js'; import { bindThis } from '@/decorators.js'; +import { IdService } from '@/core/IdService.js'; import { UserEntityService } from './UserEntityService.js'; @Injectable() @@ -19,6 +20,7 @@ export class ModerationLogEntityService { private moderationLogsRepository: ModerationLogsRepository, private userEntityService: UserEntityService, + private idService: IdService, ) { } @@ -30,7 +32,7 @@ export class ModerationLogEntityService { return await awaitAll({ id: log.id, - createdAt: log.createdAt.toISOString(), + createdAt: this.idService.parse(log.id).date.toISOString(), type: log.type, info: log.info, userId: log.userId, diff --git a/packages/backend/src/core/entities/MutingEntityService.ts b/packages/backend/src/core/entities/MutingEntityService.ts index e8592b1f1f..ef035a7091 100644 --- a/packages/backend/src/core/entities/MutingEntityService.ts +++ b/packages/backend/src/core/entities/MutingEntityService.ts @@ -12,6 +12,7 @@ import type { } from '@/models/Blocking.js'; import type { MiUser } from '@/models/User.js'; import type { MiMuting } from '@/models/Muting.js'; import { bindThis } from '@/decorators.js'; +import { IdService } from '@/core/IdService.js'; import { UserEntityService } from './UserEntityService.js'; @Injectable() @@ -21,6 +22,7 @@ export class MutingEntityService { private mutingsRepository: MutingsRepository, private userEntityService: UserEntityService, + private idService: IdService, ) { } @@ -33,7 +35,7 @@ export class MutingEntityService { return await awaitAll({ id: muting.id, - createdAt: muting.createdAt.toISOString(), + createdAt: this.idService.parse(muting.id).date.toISOString(), expiresAt: muting.expiresAt ? muting.expiresAt.toISOString() : null, muteeId: muting.muteeId, mutee: this.userEntityService.pack(muting.muteeId, me, { diff --git a/packages/backend/src/core/entities/NoteEntityService.ts b/packages/backend/src/core/entities/NoteEntityService.ts index 697fbd6893..52c5988cb7 100644 --- a/packages/backend/src/core/entities/NoteEntityService.ts +++ b/packages/backend/src/core/entities/NoteEntityService.ts @@ -5,11 +5,9 @@ import { Inject, Injectable } from '@nestjs/common'; import { In } from 'typeorm'; -import * as mfm from 'cherrypick-mfm-js'; import { ModuleRef } from '@nestjs/core'; import { DI } from '@/di-symbols.js'; import type { Packed } from '@/misc/json-schema.js'; -import { nyaize } from '@/misc/nyaize.js'; import { awaitAll } from '@/misc/prelude/await-all.js'; import type { MiUser } from '@/models/User.js'; import type { MiNote } from '@/models/Note.js'; @@ -18,6 +16,7 @@ import type { UsersRepository, NotesRepository, FollowingsRepository, PollsRepos import { bindThis } from '@/decorators.js'; import { isNotNull } from '@/misc/is-not-null.js'; import { DebounceLoader } from '@/misc/loader.js'; +import { IdService } from '@/core/IdService.js'; import type { OnModuleInit } from '@nestjs/common'; import type { CustomEmojiService } from '../CustomEmojiService.js'; import type { ReactionService } from '../ReactionService.js'; @@ -30,6 +29,7 @@ export class NoteEntityService implements OnModuleInit { private driveFileEntityService: DriveFileEntityService; private customEmojiService: CustomEmojiService; private reactionService: ReactionService; + private idService: IdService; private noteLoader = new DebounceLoader(this.findNoteOrFail); constructor( @@ -71,11 +71,12 @@ export class NoteEntityService implements OnModuleInit { this.driveFileEntityService = this.moduleRef.get('DriveFileEntityService'); this.customEmojiService = this.moduleRef.get('CustomEmojiService'); this.reactionService = this.moduleRef.get('ReactionService'); + this.idService = this.moduleRef.get('IdService'); } @bindThis private async hideNote(packedNote: Packed<'Note'>, meId: MiUser['id'] | null) { - // TODO: isVisibleForMe を使うようにしても良さそう(型違うけど) + // TODO: isVisibleForMe を使うようにしても良さそう(型違うけど) let hide = false; // visibility が specified かつ自分が指定されていなかったら非表示 @@ -85,7 +86,7 @@ export class NoteEntityService implements OnModuleInit { } else if (meId === packedNote.userId) { hide = false; } else { - // 指定されているかどうか + // 指定されているかどうか const specified = packedNote.visibleUserIds!.some((id: any) => meId === id); if (specified) { @@ -183,21 +184,31 @@ export class NoteEntityService implements OnModuleInit { } @bindThis - private async populateMyReaction(note: MiNote, meId: MiUser['id'], _hint_?: { - myReactions: Map; + public async populateMyReaction(note: { id: MiNote['id']; reactions: MiNote['reactions']; reactionAndUserPairCache?: MiNote['reactionAndUserPairCache']; }, meId: MiUser['id'], _hint_?: { + myReactions: Map; }) { if (_hint_?.myReactions) { const reaction = _hint_.myReactions.get(note.id); if (reaction) { - return this.reactionService.convertLegacyReaction(reaction.reaction); - } else if (reaction === null) { + return this.reactionService.convertLegacyReaction(reaction); + } else { + return undefined; + } + } + + const reactionsCount = Object.values(note.reactions).reduce((a, b) => a + b, 0); + if (reactionsCount === 0) return undefined; + if (note.reactionAndUserPairCache && reactionsCount <= note.reactionAndUserPairCache.length) { + const pair = note.reactionAndUserPairCache.find(p => p.startsWith(meId)); + if (pair) { + return this.reactionService.convertLegacyReaction(pair.split('/')[1]); + } else { return undefined; } - // 実装上抜けがあるだけかもしれないので、「ヒントに含まれてなかったら(=undefinedなら)return」のようにはしない } - // パフォーマンスのためノートが作成されてから1秒以上経っていない場合はリアクションを取得しない - if (note.createdAt.getTime() + 1000 > Date.now()) { + // パフォーマンスのためノートが作成されてから2秒以上経っていない場合はリアクションを取得しない + if (this.idService.parse(note.id).date.getTime() + 2000 > Date.now()) { return undefined; } @@ -289,8 +300,9 @@ export class NoteEntityService implements OnModuleInit { options?: { detail?: boolean; skipHide?: boolean; + withReactionAndUserPairCache?: boolean; _hint_?: { - myReactions: Map; + myReactions: Map; packedFiles: Map | null>; }; }, @@ -298,6 +310,7 @@ export class NoteEntityService implements OnModuleInit { const opts = Object.assign({ detail: true, skipHide: false, + withReactionAndUserPairCache: false, }, options); const meId = me ? me.id : null; @@ -324,8 +337,9 @@ export class NoteEntityService implements OnModuleInit { const packed: Packed<'Note'> = await awaitAll({ id: note.id, - createdAt: note.createdAt.toISOString(), + createdAt: this.idService.parse(note.id).date.toISOString(), updatedAt: note.updatedAt ? note.updatedAt.toISOString() : undefined, + updatedAtHistory: note.updatedAtHistory ? note.updatedAtHistory.map(x => x.toISOString()) : undefined, noteEditHistory: note.noteEditHistory.length ? note.noteEditHistory : undefined, userId: note.userId, user: this.userEntityService.pack(note.user ?? note.userId, me, { @@ -334,7 +348,7 @@ export class NoteEntityService implements OnModuleInit { text: text, cw: note.cw, visibility: note.visibility, - localOnly: note.localOnly ?? undefined, + localOnly: note.localOnly, reactionAcceptance: note.reactionAcceptance, visibleUserIds: note.visibility === 'specified' ? note.visibleUserIds : undefined, disableRightClick: note.disableRightClick || undefined, @@ -342,6 +356,7 @@ export class NoteEntityService implements OnModuleInit { repliesCount: note.repliesCount, reactions: this.reactionService.convertLegacyReactions(note.reactions), reactionEmojis: this.customEmojiService.populateEmojis(reactionEmojiNames, host), + reactionAndUserPairCache: opts.withReactionAndUserPairCache ? note.reactionAndUserPairCache : undefined, emojis: host != null ? this.customEmojiService.populateEmojis(note.emojis, host) : undefined, tags: note.tags.length > 0 ? note.tags : undefined, fileIds: note.fileIds, @@ -364,42 +379,27 @@ export class NoteEntityService implements OnModuleInit { reply: note.replyId ? this.pack(note.reply ?? note.replyId, me, { detail: false, + skipHide: opts.skipHide, + withReactionAndUserPairCache: opts.withReactionAndUserPairCache, _hint_: options?._hint_, }) : undefined, renote: note.renoteId ? this.pack(note.renote ?? note.renoteId, me, { detail: true, + skipHide: opts.skipHide, + withReactionAndUserPairCache: opts.withReactionAndUserPairCache, _hint_: options?._hint_, }) : undefined, poll: note.hasPoll ? this.populatePoll(note, meId) : undefined, event: note.hasEvent ? this.populateEvent(note) : undefined, - ...(meId ? { + ...(meId && Object.keys(note.reactions).length > 0 ? { myReaction: this.populateMyReaction(note, meId, options?._hint_), } : {}), } : {}), }); - if (packed.user.isCat && packed.text) { - const tokens = packed.text ? mfm.parse(packed.text) : []; - function nyaizeNode(node: mfm.MfmNode) { - if (node.type === 'quote') return; - if (node.type === 'text') { - node.props.text = nyaize(node.props.text); - } - if (node.children) { - for (const child of node.children) { - nyaizeNode(child); - } - } - } - for (const node of tokens) { - nyaizeNode(node); - } - packed.text = mfm.toString(tokens); - } - if (!opts.skipHide) { await this.hideNote(packed, meId); } @@ -419,18 +419,48 @@ export class NoteEntityService implements OnModuleInit { if (notes.length === 0) return []; const meId = me ? me.id : null; - const myReactionsMap = new Map(); + const myReactionsMap = new Map(); if (meId) { - const renoteIds = notes.filter(n => n.renoteId != null).map(n => n.renoteId!); - // パフォーマンスのためノートが作成されてから1秒以上経っていない場合はリアクションを取得しない - const targets = [...notes.filter(n => n.createdAt.getTime() + 1000 < Date.now()).map(n => n.id), ...renoteIds]; - const myReactions = await this.noteReactionsRepository.findBy({ + const idsNeedFetchMyReaction = new Set(); + + // パフォーマンスのためノートが作成されてから2秒以上経っていない場合はリアクションを取得しない + const oldId = this.idService.gen(Date.now() - 2000); + + for (const note of notes) { + if (note.renote && (note.text == null && note.fileIds.length === 0)) { // pure renote + const reactionsCount = Object.values(note.renote.reactions).reduce((a, b) => a + b, 0); + if (reactionsCount === 0) { + myReactionsMap.set(note.renote.id, null); + } else if (reactionsCount <= note.renote.reactionAndUserPairCache.length) { + const pair = note.renote.reactionAndUserPairCache.find(p => p.startsWith(meId)); + myReactionsMap.set(note.renote.id, pair ? pair.split('/')[1] : null); + } else { + idsNeedFetchMyReaction.add(note.renote.id); + } + } else { + if (note.id < oldId) { + const reactionsCount = Object.values(note.reactions).reduce((a, b) => a + b, 0); + if (reactionsCount === 0) { + myReactionsMap.set(note.id, null); + } else if (reactionsCount <= note.reactionAndUserPairCache.length) { + const pair = note.reactionAndUserPairCache.find(p => p.startsWith(meId)); + myReactionsMap.set(note.id, pair ? pair.split('/')[1] : null); + } else { + idsNeedFetchMyReaction.add(note.id); + } + } else { + myReactionsMap.set(note.id, null); + } + } + } + + const myReactions = idsNeedFetchMyReaction.size > 0 ? await this.noteReactionsRepository.findBy({ userId: meId, - noteId: In(targets), - }); + noteId: In(Array.from(idsNeedFetchMyReaction)), + }) : []; - for (const target of targets) { - myReactionsMap.set(target, myReactions.find(reaction => reaction.noteId === target) ?? null); + for (const id of idsNeedFetchMyReaction) { + myReactionsMap.set(id, myReactions.find(reaction => reaction.noteId === id)?.reaction ?? null); } } diff --git a/packages/backend/src/core/entities/NoteFavoriteEntityService.ts b/packages/backend/src/core/entities/NoteFavoriteEntityService.ts index 549150eda8..b8a5aaf8ae 100644 --- a/packages/backend/src/core/entities/NoteFavoriteEntityService.ts +++ b/packages/backend/src/core/entities/NoteFavoriteEntityService.ts @@ -10,6 +10,7 @@ import type { } from '@/models/Blocking.js'; import type { MiUser } from '@/models/User.js'; import type { MiNoteFavorite } from '@/models/NoteFavorite.js'; import { bindThis } from '@/decorators.js'; +import { IdService } from '@/core/IdService.js'; import { NoteEntityService } from './NoteEntityService.js'; @Injectable() @@ -19,6 +20,7 @@ export class NoteFavoriteEntityService { private noteFavoritesRepository: NoteFavoritesRepository, private noteEntityService: NoteEntityService, + private idService: IdService, ) { } @@ -31,7 +33,7 @@ export class NoteFavoriteEntityService { return { id: favorite.id, - createdAt: favorite.createdAt.toISOString(), + createdAt: this.idService.parse(favorite.id).date.toISOString(), noteId: favorite.noteId, note: await this.noteEntityService.pack(favorite.note ?? favorite.noteId, me), }; diff --git a/packages/backend/src/core/entities/NoteReactionEntityService.ts b/packages/backend/src/core/entities/NoteReactionEntityService.ts index 32c6a73866..46c0897822 100644 --- a/packages/backend/src/core/entities/NoteReactionEntityService.ts +++ b/packages/backend/src/core/entities/NoteReactionEntityService.ts @@ -8,6 +8,7 @@ import { DI } from '@/di-symbols.js'; import type { NoteReactionsRepository } from '@/models/_.js'; import type { Packed } from '@/misc/json-schema.js'; import { bindThis } from '@/decorators.js'; +import { IdService } from '@/core/IdService.js'; import type { OnModuleInit } from '@nestjs/common'; import type { } from '@/models/Blocking.js'; import type { MiUser } from '@/models/User.js'; @@ -22,6 +23,7 @@ export class NoteReactionEntityService implements OnModuleInit { private userEntityService: UserEntityService; private noteEntityService: NoteEntityService; private reactionService: ReactionService; + private idService: IdService; constructor( private moduleRef: ModuleRef, @@ -32,6 +34,7 @@ export class NoteReactionEntityService implements OnModuleInit { //private userEntityService: UserEntityService, //private noteEntityService: NoteEntityService, //private reactionService: ReactionService, + //private idService: IdService, ) { } @@ -39,6 +42,7 @@ export class NoteReactionEntityService implements OnModuleInit { this.userEntityService = this.moduleRef.get('UserEntityService'); this.noteEntityService = this.moduleRef.get('NoteEntityService'); this.reactionService = this.moduleRef.get('ReactionService'); + this.idService = this.moduleRef.get('IdService'); } @bindThis @@ -57,7 +61,7 @@ export class NoteReactionEntityService implements OnModuleInit { return { id: reaction.id, - createdAt: reaction.createdAt.toISOString(), + createdAt: this.idService.parse(reaction.id).date.toISOString(), user: await this.userEntityService.pack(reaction.user ?? reaction.userId, me), type: this.reactionService.convertLegacyReaction(reaction.reaction), ...(opts.withNote ? { diff --git a/packages/backend/src/core/entities/PageEntityService.ts b/packages/backend/src/core/entities/PageEntityService.ts index 3781daf5fa..17d4c0b575 100644 --- a/packages/backend/src/core/entities/PageEntityService.ts +++ b/packages/backend/src/core/entities/PageEntityService.ts @@ -13,6 +13,7 @@ import type { MiUser } from '@/models/User.js'; import type { MiPage } from '@/models/Page.js'; import type { MiDriveFile } from '@/models/DriveFile.js'; import { bindThis } from '@/decorators.js'; +import { IdService } from '@/core/IdService.js'; import { UserEntityService } from './UserEntityService.js'; import { DriveFileEntityService } from './DriveFileEntityService.js'; @@ -30,6 +31,7 @@ export class PageEntityService { private userEntityService: UserEntityService, private driveFileEntityService: DriveFileEntityService, + private idService: IdService, ) { } @@ -85,7 +87,7 @@ export class PageEntityService { return await awaitAll({ id: page.id, - createdAt: page.createdAt.toISOString(), + createdAt: this.idService.parse(page.id).date.toISOString(), updatedAt: page.updatedAt.toISOString(), userId: page.userId, user: this.userEntityService.pack(page.user ?? page.userId, me), // { detail: true } すると無限ループするので注意 diff --git a/packages/backend/src/core/entities/RenoteMutingEntityService.ts b/packages/backend/src/core/entities/RenoteMutingEntityService.ts index 0be0acf050..6ecb8f7671 100644 --- a/packages/backend/src/core/entities/RenoteMutingEntityService.ts +++ b/packages/backend/src/core/entities/RenoteMutingEntityService.ts @@ -12,6 +12,7 @@ import type { } from '@/models/Blocking.js'; import type { MiUser } from '@/models/User.js'; import type { MiRenoteMuting } from '@/models/RenoteMuting.js'; import { bindThis } from '@/decorators.js'; +import { IdService } from '@/core/IdService.js'; import { UserEntityService } from './UserEntityService.js'; @Injectable() @@ -21,6 +22,7 @@ export class RenoteMutingEntityService { private renoteMutingsRepository: RenoteMutingsRepository, private userEntityService: UserEntityService, + private idService: IdService, ) { } @@ -33,7 +35,7 @@ export class RenoteMutingEntityService { return await awaitAll({ id: muting.id, - createdAt: muting.createdAt.toISOString(), + createdAt: this.idService.parse(muting.id).date.toISOString(), muteeId: muting.muteeId, mutee: this.userEntityService.pack(muting.muteeId, me, { detail: true, diff --git a/packages/backend/src/core/entities/RoleEntityService.ts b/packages/backend/src/core/entities/RoleEntityService.ts index cf0db25b12..c5d9c0dccd 100644 --- a/packages/backend/src/core/entities/RoleEntityService.ts +++ b/packages/backend/src/core/entities/RoleEntityService.ts @@ -12,6 +12,7 @@ import type { MiUser } from '@/models/User.js'; import type { MiRole } from '@/models/Role.js'; import { bindThis } from '@/decorators.js'; import { DEFAULT_POLICIES } from '@/core/RoleService.js'; +import { IdService } from '@/core/IdService.js'; @Injectable() export class RoleEntityService { @@ -21,6 +22,8 @@ export class RoleEntityService { @Inject(DI.roleAssignmentsRepository) private roleAssignmentsRepository: RoleAssignmentsRepository, + + private idService: IdService, ) { } @@ -51,7 +54,7 @@ export class RoleEntityService { return await awaitAll({ id: role.id, - createdAt: role.createdAt.toISOString(), + createdAt: this.idService.parse(role.id).date.toISOString(), updatedAt: role.updatedAt.toISOString(), name: role.name, description: role.description, diff --git a/packages/backend/src/core/entities/UserEntityService.ts b/packages/backend/src/core/entities/UserEntityService.ts index 5ac0376879..5e34a3abd8 100644 --- a/packages/backend/src/core/entities/UserEntityService.ts +++ b/packages/backend/src/core/entities/UserEntityService.ts @@ -21,6 +21,7 @@ import { bindThis } from '@/decorators.js'; import { RoleService } from '@/core/RoleService.js'; import { ApPersonService } from '@/core/activitypub/models/ApPersonService.js'; import { FederatedInstanceService } from '@/core/FederatedInstanceService.js'; +import { IdService } from '@/core/IdService.js'; import type { OnModuleInit } from '@nestjs/common'; import type { AnnouncementService } from '../AnnouncementService.js'; import type { CustomEmojiService } from '../CustomEmojiService.js'; @@ -61,6 +62,7 @@ export class UserEntityService implements OnModuleInit { private announcementService: AnnouncementService; private roleService: RoleService; private federatedInstanceService: FederatedInstanceService; + private idService: IdService; constructor( private moduleRef: ModuleRef, @@ -118,13 +120,6 @@ export class UserEntityService implements OnModuleInit { @Inject(DI.userMemosRepository) private userMemosRepository: UserMemoRepository, - - //private noteEntityService: NoteEntityService, - //private driveFileEntityService: DriveFileEntityService, - //private pageEntityService: PageEntityService, - //private customEmojiService: CustomEmojiService, - //private antennaService: AntennaService, - //private roleService: RoleService, ) { } @@ -137,6 +132,7 @@ export class UserEntityService implements OnModuleInit { this.announcementService = this.moduleRef.get('AnnouncementService'); this.roleService = this.moduleRef.get('RoleService'); this.federatedInstanceService = this.moduleRef.get('FederatedInstanceService'); + this.idService = this.moduleRef.get('IdService'); } //#region Validators @@ -237,7 +233,7 @@ export class UserEntityService implements OnModuleInit { .where('message.groupId = :groupId', { groupId: j.userGroupId }) .andWhere('message.userId != :userId', { userId: userId }) .andWhere('NOT (:userId = ANY(message.reads))', { userId: userId }) - .andWhere('message.createdAt > :joinedAt', { joinedAt: j.createdAt }) // 自分が加入する前の会話については、未読扱いしない + .andWhere('message.id > :joinedAt', { joinedAt: this.idService.parse(j.id) }) // 自分が加入する前の会話については、未読扱いしない .getOne().then(x => x != null))); const [withUser, withGroups] = await Promise.all([ @@ -380,7 +376,11 @@ export class UserEntityService implements OnModuleInit { const isModerator = isMe && opts.detail ? this.roleService.isModerator(user) : null; const isAdmin = isMe && opts.detail ? this.roleService.isAdministrator(user) : null; - const unreadAnnouncements = isMe && opts.detail ? await this.announcementService.getUnreadAnnouncements(user) : null; + const unreadAnnouncements = isMe && opts.detail ? + (await this.announcementService.getUnreadAnnouncements(user)).map((announcement) => ({ + createdAt: this.idService.parse(announcement.id).date.toISOString(), + ...announcement, + })) : null; const notificationsInfo = isMe && opts.detail ? await this.getNotificationsInfo(user.id) : null; @@ -393,8 +393,8 @@ export class UserEntityService implements OnModuleInit { host: user.host, avatarUrl: user.avatarUrl ?? this.getIdenticonUrl(user), avatarBlurhash: user.avatarBlurhash, - isBot: user.isBot ?? falsy, - isCat: user.isCat ?? falsy, + isBot: user.isBot, + isCat: user.isCat, instance: user.host ? this.federatedInstanceService.federatedInstanceCache.fetch(user.host).then(instance => instance ? { name: instance.name, softwareName: instance.softwareName, @@ -420,14 +420,14 @@ export class UserEntityService implements OnModuleInit { ? Promise.all(user.alsoKnownAs.map(uri => this.apPersonService.fetchPerson(uri).then(user => user?.id).catch(() => null))) .then(xs => xs.length === 0 ? null : xs.filter(x => x != null) as string[]) : null, - createdAt: user.createdAt.toISOString(), + createdAt: this.idService.parse(user.id).date.toISOString(), updatedAt: user.updatedAt ? user.updatedAt.toISOString() : null, lastFetchedAt: user.lastFetchedAt ? user.lastFetchedAt.toISOString() : null, bannerUrl: user.bannerUrl, bannerBlurhash: user.bannerBlurhash, isLocked: user.isLocked, isSilenced: this.roleService.getUserPolicies(user.id).then(r => !r.canPublicNote), - isSuspended: user.isSuspended ?? falsy, + isSuspended: user.isSuspended, description: profile!.description, location: profile!.location, birthday: profile!.birthday, diff --git a/packages/backend/src/core/entities/UserGroupEntityService.ts b/packages/backend/src/core/entities/UserGroupEntityService.ts index e9faf50276..72de937062 100644 --- a/packages/backend/src/core/entities/UserGroupEntityService.ts +++ b/packages/backend/src/core/entities/UserGroupEntityService.ts @@ -9,6 +9,7 @@ import type { UserGroupJoiningsRepository, UserGroupsRepository } from '@/models import type { Packed } from '@/misc/json-schema.js'; import type { MiUserGroup } from '@/models/UserGroup.js'; import { bindThis } from '@/decorators.js'; +import { IdService } from '@/core/IdService.js'; @Injectable() export class UserGroupEntityService { @@ -18,6 +19,8 @@ export class UserGroupEntityService { @Inject(DI.userGroupJoiningsRepository) private userGroupJoiningsRepository: UserGroupJoiningsRepository, + + private idService: IdService, ) { } @@ -33,7 +36,7 @@ export class UserGroupEntityService { return { id: userGroup.id, - createdAt: userGroup.createdAt.toISOString(), + createdAt: this.idService.parse(userGroup.id).date.toISOString(), name: userGroup.name, ownerId: userGroup.userId, userIds: users.map((x: { userId: any; }) => x.userId), diff --git a/packages/backend/src/core/entities/UserListEntityService.ts b/packages/backend/src/core/entities/UserListEntityService.ts index cab0732b13..3026684689 100644 --- a/packages/backend/src/core/entities/UserListEntityService.ts +++ b/packages/backend/src/core/entities/UserListEntityService.ts @@ -10,6 +10,7 @@ import type { Packed } from '@/misc/json-schema.js'; import type { } from '@/models/Blocking.js'; import type { MiUserList } from '@/models/UserList.js'; import { bindThis } from '@/decorators.js'; +import { IdService } from '@/core/IdService.js'; import { UserEntityService } from './UserEntityService.js'; @Injectable() @@ -22,6 +23,7 @@ export class UserListEntityService { private userListMembershipsRepository: UserListMembershipsRepository, private userEntityService: UserEntityService, + private idService: IdService, ) { } @@ -37,7 +39,7 @@ export class UserListEntityService { return { id: userList.id, - createdAt: userList.createdAt.toISOString(), + createdAt: this.idService.parse(userList.id).date.toISOString(), name: userList.name, userIds: users.map(x => x.userId), isPublic: userList.isPublic, @@ -50,7 +52,7 @@ export class UserListEntityService { ) { return Promise.all(memberships.map(async x => ({ id: x.id, - createdAt: x.createdAt.toISOString(), + createdAt: this.idService.parse(x.id).date.toISOString(), userId: x.userId, user: await this.userEntityService.pack(x.userId), withReplies: x.withReplies, diff --git a/packages/backend/src/daemons/ServerStatsService.ts b/packages/backend/src/daemons/ServerStatsService.ts index 7ee3711c0e..a8b337c479 100644 --- a/packages/backend/src/daemons/ServerStatsService.ts +++ b/packages/backend/src/daemons/ServerStatsService.ts @@ -108,6 +108,5 @@ async function net() { // FS STAT async function fs() { - const data = await si.disksIO().catch(() => ({ rIO_sec: 0, wIO_sec: 0 })); - return data ?? { rIO_sec: 0, wIO_sec: 0 }; + return await si.disksIO().catch(() => ({ rIO_sec: 0, wIO_sec: 0 })); } diff --git a/packages/backend/src/misc/id/aid.ts b/packages/backend/src/misc/id/aid.ts index ebb5ca0187..d1f93d6326 100644 --- a/packages/backend/src/misc/id/aid.ts +++ b/packages/backend/src/misc/id/aid.ts @@ -24,8 +24,7 @@ function getNoise(): string { return counter.toString(36).padStart(2, '0').slice(-2); } -export function genAid(date: Date): string { - const t = date.getTime(); +export function genAid(t: number): string { if (isNaN(t)) throw new Error('Failed to create AID: Invalid Date'); counter++; return getTime(t) + getNoise(); diff --git a/packages/backend/src/misc/id/aidx.ts b/packages/backend/src/misc/id/aidx.ts index e6d9c6b459..53e7aec66d 100644 --- a/packages/backend/src/misc/id/aidx.ts +++ b/packages/backend/src/misc/id/aidx.ts @@ -31,8 +31,7 @@ function getNoise(): string { return counter.toString(36).padStart(NOISE_LENGTH, '0').slice(-NOISE_LENGTH); } -export function genAidx(date: Date): string { - const t = date.getTime(); +export function genAidx(t: number): string { if (isNaN(t)) throw new Error('Failed to create AIDX: Invalid Date'); counter++; return getTime(t) + nodeId + getNoise(); diff --git a/packages/backend/src/misc/id/meid.ts b/packages/backend/src/misc/id/meid.ts index 4beaca4c65..00e5419e50 100644 --- a/packages/backend/src/misc/id/meid.ts +++ b/packages/backend/src/misc/id/meid.ts @@ -29,8 +29,8 @@ function getRandom() { return str; } -export function genMeid(date: Date): string { - return getTime(date.getTime()) + getRandom(); +export function genMeid(t: number): string { + return getTime(t) + getRandom(); } export function parseMeid(id: string): { date: Date; } { diff --git a/packages/backend/src/misc/id/meidg.ts b/packages/backend/src/misc/id/meidg.ts index e3590aff08..46ae180d18 100644 --- a/packages/backend/src/misc/id/meidg.ts +++ b/packages/backend/src/misc/id/meidg.ts @@ -29,8 +29,8 @@ function getRandom() { return str; } -export function genMeidg(date: Date): string { - return 'g' + getTime(date.getTime()) + getRandom(); +export function genMeidg(t: number): string { + return 'g' + getTime(t) + getRandom(); } export function parseMeidg(id: string): { date: Date; } { diff --git a/packages/backend/src/misc/id/object-id.ts b/packages/backend/src/misc/id/object-id.ts index e973cc67ca..9c7ff4d8d8 100644 --- a/packages/backend/src/misc/id/object-id.ts +++ b/packages/backend/src/misc/id/object-id.ts @@ -29,8 +29,8 @@ function getRandom() { return str; } -export function genObjectId(date: Date): string { - return getTime(date.getTime()) + getRandom(); +export function genObjectId(t: number): string { + return getTime(t) + getRandom(); } export function parseObjectId(id: string): { date: Date; } { diff --git a/packages/backend/src/models/AbuseReportResolver.ts b/packages/backend/src/models/AbuseReportResolver.ts index f0a82fd1d8..bdcaeeb729 100644 --- a/packages/backend/src/models/AbuseReportResolver.ts +++ b/packages/backend/src/models/AbuseReportResolver.ts @@ -11,12 +11,6 @@ export class MiAbuseReportResolver { @PrimaryColumn(id()) public id: string; - @Index() - @Column('timestamp with time zone', { - comment: 'The created date of AbuseReportResolver', - }) - public createdAt: Date; - @Index() @Column('timestamp with time zone', { comment: 'The updated date of AbuseReportResolver', diff --git a/packages/backend/src/models/AbuseUserReport.ts b/packages/backend/src/models/AbuseUserReport.ts index 896dd9d17a..955d0a5e56 100644 --- a/packages/backend/src/models/AbuseUserReport.ts +++ b/packages/backend/src/models/AbuseUserReport.ts @@ -12,12 +12,6 @@ export class MiAbuseUserReport { @PrimaryColumn(id()) public id: string; - @Index() - @Column('timestamp with time zone', { - comment: 'The created date of the AbuseUserReport.', - }) - public createdAt: Date; - @Index() @Column(id()) public targetUserId: MiUser['id']; diff --git a/packages/backend/src/models/AccessToken.ts b/packages/backend/src/models/AccessToken.ts index cf8896c1d9..dd9efc8ffd 100644 --- a/packages/backend/src/models/AccessToken.ts +++ b/packages/backend/src/models/AccessToken.ts @@ -13,11 +13,6 @@ export class MiAccessToken { @PrimaryColumn(id()) public id: string; - @Column('timestamp with time zone', { - comment: 'The created date of the AccessToken.', - }) - public createdAt: Date; - @Column('timestamp with time zone', { nullable: true, }) diff --git a/packages/backend/src/models/Ad.ts b/packages/backend/src/models/Ad.ts index 6ff176be7c..0de12befc8 100644 --- a/packages/backend/src/models/Ad.ts +++ b/packages/backend/src/models/Ad.ts @@ -11,12 +11,6 @@ export class MiAd { @PrimaryColumn(id()) public id: string; - @Index() - @Column('timestamp with time zone', { - comment: 'The created date of the Ad.', - }) - public createdAt: Date; - @Index() @Column('timestamp with time zone', { comment: 'The expired date of the Ad.', diff --git a/packages/backend/src/models/Announcement.ts b/packages/backend/src/models/Announcement.ts index 436b9b6c46..9158f10b9d 100644 --- a/packages/backend/src/models/Announcement.ts +++ b/packages/backend/src/models/Announcement.ts @@ -12,12 +12,6 @@ export class MiAnnouncement { @PrimaryColumn(id()) public id: string; - @Index() - @Column('timestamp with time zone', { - comment: 'The created date of the Announcement.', - }) - public createdAt: Date; - @Column('timestamp with time zone', { comment: 'The updated date of the Announcement.', nullable: true, diff --git a/packages/backend/src/models/AnnouncementRead.ts b/packages/backend/src/models/AnnouncementRead.ts index 375e5d0ab7..1fb1b965bd 100644 --- a/packages/backend/src/models/AnnouncementRead.ts +++ b/packages/backend/src/models/AnnouncementRead.ts @@ -14,11 +14,6 @@ export class MiAnnouncementRead { @PrimaryColumn(id()) public id: string; - @Column('timestamp with time zone', { - comment: 'The created date of the AnnouncementRead.', - }) - public createdAt: Date; - @Index() @Column(id()) public userId: MiUser['id']; diff --git a/packages/backend/src/models/Antenna.ts b/packages/backend/src/models/Antenna.ts index 3cc088a494..a2c54322a1 100644 --- a/packages/backend/src/models/Antenna.ts +++ b/packages/backend/src/models/Antenna.ts @@ -14,11 +14,6 @@ export class MiAntenna { @PrimaryColumn(id()) public id: string; - @Column('timestamp with time zone', { - comment: 'The created date of the Antenna.', - }) - public createdAt: Date; - @Index() @Column('timestamp with time zone') public lastUsedAt: Date; @@ -111,4 +106,9 @@ export class MiAntenna { default: true, }) public isActive: boolean; + + @Column('boolean', { + default: false, + }) + public localOnly: boolean; } diff --git a/packages/backend/src/models/App.ts b/packages/backend/src/models/App.ts index 7bf3da2731..521f5f50e2 100644 --- a/packages/backend/src/models/App.ts +++ b/packages/backend/src/models/App.ts @@ -12,12 +12,6 @@ export class MiApp { @PrimaryColumn(id()) public id: string; - @Index() - @Column('timestamp with time zone', { - comment: 'The created date of the App.', - }) - public createdAt: Date; - @Index() @Column({ ...id(), diff --git a/packages/backend/src/models/AuthSession.ts b/packages/backend/src/models/AuthSession.ts index fb90553059..f1cb0b52ed 100644 --- a/packages/backend/src/models/AuthSession.ts +++ b/packages/backend/src/models/AuthSession.ts @@ -13,11 +13,6 @@ export class MiAuthSession { @PrimaryColumn(id()) public id: string; - @Column('timestamp with time zone', { - comment: 'The created date of the AuthSession.', - }) - public createdAt: Date; - @Index() @Column('varchar', { length: 128, diff --git a/packages/backend/src/models/Blocking.ts b/packages/backend/src/models/Blocking.ts index b545e70e29..571b7d8b99 100644 --- a/packages/backend/src/models/Blocking.ts +++ b/packages/backend/src/models/Blocking.ts @@ -13,12 +13,6 @@ export class MiBlocking { @PrimaryColumn(id()) public id: string; - @Index() - @Column('timestamp with time zone', { - comment: 'The created date of the Blocking.', - }) - public createdAt: Date; - @Index() @Column({ ...id(), diff --git a/packages/backend/src/models/Channel.ts b/packages/backend/src/models/Channel.ts index 0ce0a5f07f..7c36a937bf 100644 --- a/packages/backend/src/models/Channel.ts +++ b/packages/backend/src/models/Channel.ts @@ -13,12 +13,6 @@ export class MiChannel { @PrimaryColumn(id()) public id: string; - @Index() - @Column('timestamp with time zone', { - comment: 'The created date of the Channel.', - }) - public createdAt: Date; - @Index() @Column('timestamp with time zone', { nullable: true, diff --git a/packages/backend/src/models/ChannelFavorite.ts b/packages/backend/src/models/ChannelFavorite.ts index d4d8a30a53..272411cac3 100644 --- a/packages/backend/src/models/ChannelFavorite.ts +++ b/packages/backend/src/models/ChannelFavorite.ts @@ -14,12 +14,6 @@ export class MiChannelFavorite { @PrimaryColumn(id()) public id: string; - @Index() - @Column('timestamp with time zone', { - comment: 'The created date of the ChannelFavorite.', - }) - public createdAt: Date; - @Index() @Column({ ...id(), diff --git a/packages/backend/src/models/ChannelFollowing.ts b/packages/backend/src/models/ChannelFollowing.ts index 1d1f417cfc..ad245f14b5 100644 --- a/packages/backend/src/models/ChannelFollowing.ts +++ b/packages/backend/src/models/ChannelFollowing.ts @@ -14,12 +14,6 @@ export class MiChannelFollowing { @PrimaryColumn(id()) public id: string; - @Index() - @Column('timestamp with time zone', { - comment: 'The created date of the ChannelFollowing.', - }) - public createdAt: Date; - @Index() @Column({ ...id(), diff --git a/packages/backend/src/models/Clip.ts b/packages/backend/src/models/Clip.ts index 0f0c7ab7b3..54f3c97c63 100644 --- a/packages/backend/src/models/Clip.ts +++ b/packages/backend/src/models/Clip.ts @@ -12,11 +12,6 @@ export class MiClip { @PrimaryColumn(id()) public id: string; - @Column('timestamp with time zone', { - comment: 'The created date of the Clip.', - }) - public createdAt: Date; - @Index() @Column('timestamp with time zone', { nullable: true, diff --git a/packages/backend/src/models/ClipFavorite.ts b/packages/backend/src/models/ClipFavorite.ts index e3c03ae394..4a00d60e97 100644 --- a/packages/backend/src/models/ClipFavorite.ts +++ b/packages/backend/src/models/ClipFavorite.ts @@ -14,9 +14,6 @@ export class MiClipFavorite { @PrimaryColumn(id()) public id: string; - @Column('timestamp with time zone') - public createdAt: Date; - @Index() @Column(id()) public userId: MiUser['id']; diff --git a/packages/backend/src/models/DriveFile.ts b/packages/backend/src/models/DriveFile.ts index 7d026ec97f..ba4226a592 100644 --- a/packages/backend/src/models/DriveFile.ts +++ b/packages/backend/src/models/DriveFile.ts @@ -14,12 +14,6 @@ export class MiDriveFile { @PrimaryColumn(id()) public id: string; - @Index() - @Column('timestamp with time zone', { - comment: 'The created date of the DriveFile.', - }) - public createdAt: Date; - @Index() @Column({ ...id(), diff --git a/packages/backend/src/models/DriveFolder.ts b/packages/backend/src/models/DriveFolder.ts index 4d8564ae6a..7a71ac001e 100644 --- a/packages/backend/src/models/DriveFolder.ts +++ b/packages/backend/src/models/DriveFolder.ts @@ -12,12 +12,6 @@ export class MiDriveFolder { @PrimaryColumn(id()) public id: string; - @Index() - @Column('timestamp with time zone', { - comment: 'The created date of the DriveFolder.', - }) - public createdAt: Date; - @Column('varchar', { length: 128, comment: 'The name of the DriveFolder.', diff --git a/packages/backend/src/models/Flash.ts b/packages/backend/src/models/Flash.ts index ffac96d017..8df28a62c1 100644 --- a/packages/backend/src/models/Flash.ts +++ b/packages/backend/src/models/Flash.ts @@ -12,12 +12,6 @@ export class MiFlash { @PrimaryColumn(id()) public id: string; - @Index() - @Column('timestamp with time zone', { - comment: 'The created date of the Flash.', - }) - public createdAt: Date; - @Index() @Column('timestamp with time zone', { comment: 'The updated date of the Flash.', diff --git a/packages/backend/src/models/FlashLike.ts b/packages/backend/src/models/FlashLike.ts index 29c7ca4d1e..5362a7fe63 100644 --- a/packages/backend/src/models/FlashLike.ts +++ b/packages/backend/src/models/FlashLike.ts @@ -14,9 +14,6 @@ export class MiFlashLike { @PrimaryColumn(id()) public id: string; - @Column('timestamp with time zone') - public createdAt: Date; - @Index() @Column(id()) public userId: MiUser['id']; diff --git a/packages/backend/src/models/FollowRequest.ts b/packages/backend/src/models/FollowRequest.ts index 4129f5f55e..e90e03464c 100644 --- a/packages/backend/src/models/FollowRequest.ts +++ b/packages/backend/src/models/FollowRequest.ts @@ -13,11 +13,6 @@ export class MiFollowRequest { @PrimaryColumn(id()) public id: string; - @Column('timestamp with time zone', { - comment: 'The created date of the FollowRequest.', - }) - public createdAt: Date; - @Index() @Column({ ...id(), @@ -50,6 +45,11 @@ export class MiFollowRequest { }) public requestId: string | null; + @Column('boolean', { + default: false, + }) + public withReplies: boolean; + //#region Denormalized fields @Column('varchar', { length: 128, nullable: true, diff --git a/packages/backend/src/models/Following.ts b/packages/backend/src/models/Following.ts index 9465540eac..a9658ee13c 100644 --- a/packages/backend/src/models/Following.ts +++ b/packages/backend/src/models/Following.ts @@ -14,12 +14,6 @@ export class MiFollowing { @PrimaryColumn(id()) public id: string; - @Index() - @Column('timestamp with time zone', { - comment: 'The created date of the Following.', - }) - public createdAt: Date; - @Index() @Column({ ...id(), diff --git a/packages/backend/src/models/GalleryLike.ts b/packages/backend/src/models/GalleryLike.ts index 84dce67680..a6288b87f6 100644 --- a/packages/backend/src/models/GalleryLike.ts +++ b/packages/backend/src/models/GalleryLike.ts @@ -14,9 +14,6 @@ export class MiGalleryLike { @PrimaryColumn(id()) public id: string; - @Column('timestamp with time zone') - public createdAt: Date; - @Index() @Column(id()) public userId: MiUser['id']; diff --git a/packages/backend/src/models/GalleryPost.ts b/packages/backend/src/models/GalleryPost.ts index 45f0a8bd9e..3b54a221d8 100644 --- a/packages/backend/src/models/GalleryPost.ts +++ b/packages/backend/src/models/GalleryPost.ts @@ -13,12 +13,6 @@ export class MiGalleryPost { @PrimaryColumn(id()) public id: string; - @Index() - @Column('timestamp with time zone', { - comment: 'The created date of the GalleryPost.', - }) - public createdAt: Date; - @Index() @Column('timestamp with time zone', { comment: 'The updated date of the GalleryPost.', diff --git a/packages/backend/src/models/MessagingMessage.ts b/packages/backend/src/models/MessagingMessage.ts index f5a70e20e6..80b3c2c4c2 100644 --- a/packages/backend/src/models/MessagingMessage.ts +++ b/packages/backend/src/models/MessagingMessage.ts @@ -14,12 +14,6 @@ export class MiMessagingMessage { @PrimaryColumn(id()) public id: string; - @Index() - @Column('timestamp with time zone', { - comment: 'The created date of the MessagingMessage.', - }) - public createdAt: Date; - @Index() @Column({ ...id(), diff --git a/packages/backend/src/models/Meta.ts b/packages/backend/src/models/Meta.ts index 3df8906c32..bd910837ad 100644 --- a/packages/backend/src/models/Meta.ts +++ b/packages/backend/src/models/Meta.ts @@ -81,6 +81,11 @@ export class MiMeta { }) public sensitiveWords: string[]; + @Column('varchar', { + length: 1024, array: true, default: '{}', + }) + public silencedHosts: string[]; + @Column('varchar', { length: 1024, nullable: true, diff --git a/packages/backend/src/models/ModerationLog.ts b/packages/backend/src/models/ModerationLog.ts index 93108338ed..dc43a192fa 100644 --- a/packages/backend/src/models/ModerationLog.ts +++ b/packages/backend/src/models/ModerationLog.ts @@ -12,11 +12,6 @@ export class MiModerationLog { @PrimaryColumn(id()) public id: string; - @Column('timestamp with time zone', { - comment: 'The created date of the ModerationLog.', - }) - public createdAt: Date; - @Index() @Column(id()) public userId: MiUser['id']; diff --git a/packages/backend/src/models/Muting.ts b/packages/backend/src/models/Muting.ts index 4fd80b626b..d4ce4e0788 100644 --- a/packages/backend/src/models/Muting.ts +++ b/packages/backend/src/models/Muting.ts @@ -13,12 +13,6 @@ export class MiMuting { @PrimaryColumn(id()) public id: string; - @Index() - @Column('timestamp with time zone', { - comment: 'The created date of the Muting.', - }) - public createdAt: Date; - @Index() @Column('timestamp with time zone', { nullable: true, diff --git a/packages/backend/src/models/Note.ts b/packages/backend/src/models/Note.ts index 17d93de122..2573334dec 100644 --- a/packages/backend/src/models/Note.ts +++ b/packages/backend/src/models/Note.ts @@ -19,14 +19,15 @@ export class MiNote { public id: string; @Column('timestamp with time zone', { - comment: 'The created date of the Note.', + default: null, }) - public createdAt: Date; + public updatedAt: Date | null; @Column('timestamp with time zone', { + array: true, default: null, }) - public updatedAt: Date | null; + public updatedAtHistory: Date[] | null; @Column('varchar', { length: 3000, @@ -191,6 +192,11 @@ export class MiNote { }) public mentionedRemoteUsers: string; + @Column('varchar', { + length: 1024, array: true, default: '{}', + }) + public reactionAndUserPairCache: string[]; + @Column('varchar', { length: 128, array: true, default: '{}', }) diff --git a/packages/backend/src/models/NoteFavorite.ts b/packages/backend/src/models/NoteFavorite.ts index c58ccfb758..30a055047e 100644 --- a/packages/backend/src/models/NoteFavorite.ts +++ b/packages/backend/src/models/NoteFavorite.ts @@ -14,11 +14,6 @@ export class MiNoteFavorite { @PrimaryColumn(id()) public id: string; - @Column('timestamp with time zone', { - comment: 'The created date of the NoteFavorite.', - }) - public createdAt: Date; - @Index() @Column(id()) public userId: MiUser['id']; diff --git a/packages/backend/src/models/NoteReaction.ts b/packages/backend/src/models/NoteReaction.ts index a17e80b890..3b378a1285 100644 --- a/packages/backend/src/models/NoteReaction.ts +++ b/packages/backend/src/models/NoteReaction.ts @@ -14,11 +14,6 @@ export class MiNoteReaction { @PrimaryColumn(id()) public id: string; - @Column('timestamp with time zone', { - comment: 'The created date of the NoteReaction.', - }) - public createdAt: Date; - @Index() @Column(id()) public userId: MiUser['id']; diff --git a/packages/backend/src/models/NoteThreadMuting.ts b/packages/backend/src/models/NoteThreadMuting.ts index 42eace5638..43058762e8 100644 --- a/packages/backend/src/models/NoteThreadMuting.ts +++ b/packages/backend/src/models/NoteThreadMuting.ts @@ -13,10 +13,6 @@ export class MiNoteThreadMuting { @PrimaryColumn(id()) public id: string; - @Column('timestamp with time zone', { - }) - public createdAt: Date; - @Index() @Column({ ...id(), diff --git a/packages/backend/src/models/Page.ts b/packages/backend/src/models/Page.ts index 332c246a9d..05b6ccd714 100644 --- a/packages/backend/src/models/Page.ts +++ b/packages/backend/src/models/Page.ts @@ -14,12 +14,6 @@ export class MiPage { @PrimaryColumn(id()) public id: string; - @Index() - @Column('timestamp with time zone', { - comment: 'The created date of the Page.', - }) - public createdAt: Date; - @Index() @Column('timestamp with time zone', { comment: 'The updated date of the Page.', diff --git a/packages/backend/src/models/PageLike.ts b/packages/backend/src/models/PageLike.ts index ad00bacdf0..46b57f8304 100644 --- a/packages/backend/src/models/PageLike.ts +++ b/packages/backend/src/models/PageLike.ts @@ -14,9 +14,6 @@ export class MiPageLike { @PrimaryColumn(id()) public id: string; - @Column('timestamp with time zone') - public createdAt: Date; - @Index() @Column(id()) public userId: MiUser['id']; diff --git a/packages/backend/src/models/PasswordResetRequest.ts b/packages/backend/src/models/PasswordResetRequest.ts index 4b36529a82..a7420f35b9 100644 --- a/packages/backend/src/models/PasswordResetRequest.ts +++ b/packages/backend/src/models/PasswordResetRequest.ts @@ -12,9 +12,6 @@ export class MiPasswordResetRequest { @PrimaryColumn(id()) public id: string; - @Column('timestamp with time zone') - public createdAt: Date; - @Index({ unique: true }) @Column('varchar', { length: 256, diff --git a/packages/backend/src/models/PollVote.ts b/packages/backend/src/models/PollVote.ts index 598252cc2a..89b6ed6e9e 100644 --- a/packages/backend/src/models/PollVote.ts +++ b/packages/backend/src/models/PollVote.ts @@ -14,12 +14,6 @@ export class MiPollVote { @PrimaryColumn(id()) public id: string; - @Index() - @Column('timestamp with time zone', { - comment: 'The created date of the PollVote.', - }) - public createdAt: Date; - @Index() @Column(id()) public userId: MiUser['id']; diff --git a/packages/backend/src/models/PromoRead.ts b/packages/backend/src/models/PromoRead.ts index 5880228945..f2b43eb885 100644 --- a/packages/backend/src/models/PromoRead.ts +++ b/packages/backend/src/models/PromoRead.ts @@ -14,11 +14,6 @@ export class MiPromoRead { @PrimaryColumn(id()) public id: string; - @Column('timestamp with time zone', { - comment: 'The created date of the PromoRead.', - }) - public createdAt: Date; - @Index() @Column(id()) public userId: MiUser['id']; diff --git a/packages/backend/src/models/RegistrationTicket.ts b/packages/backend/src/models/RegistrationTicket.ts index 1fb98b7e9b..f8986c9ed3 100644 --- a/packages/backend/src/models/RegistrationTicket.ts +++ b/packages/backend/src/models/RegistrationTicket.ts @@ -23,9 +23,6 @@ export class MiRegistrationTicket { }) public expiresAt: Date | null; - @Column('timestamp with time zone') - public createdAt: Date; - @ManyToOne(type => MiUser, { onDelete: 'CASCADE', }) diff --git a/packages/backend/src/models/RegistryItem.ts b/packages/backend/src/models/RegistryItem.ts index 7a5ffd324b..70a9e12dde 100644 --- a/packages/backend/src/models/RegistryItem.ts +++ b/packages/backend/src/models/RegistryItem.ts @@ -13,11 +13,6 @@ export class MiRegistryItem { @PrimaryColumn(id()) public id: string; - @Column('timestamp with time zone', { - comment: 'The created date of the RegistryItem.', - }) - public createdAt: Date; - @Column('timestamp with time zone', { comment: 'The updated date of the RegistryItem.', }) diff --git a/packages/backend/src/models/RenoteMuting.ts b/packages/backend/src/models/RenoteMuting.ts index 6a4c739812..ad1459b3a7 100644 --- a/packages/backend/src/models/RenoteMuting.ts +++ b/packages/backend/src/models/RenoteMuting.ts @@ -13,12 +13,6 @@ export class MiRenoteMuting { @PrimaryColumn(id()) public id: string; - @Index() - @Column('timestamp with time zone', { - comment: 'The created date of the Muting.', - }) - public createdAt: Date; - @Index() @Column({ ...id(), diff --git a/packages/backend/src/models/Role.ts b/packages/backend/src/models/Role.ts index 0708ce458c..07b70a6f94 100644 --- a/packages/backend/src/models/Role.ts +++ b/packages/backend/src/models/Role.ts @@ -89,11 +89,6 @@ export class MiRole { @PrimaryColumn(id()) public id: string; - @Column('timestamp with time zone', { - comment: 'The created date of the Role.', - }) - public createdAt: Date; - @Column('timestamp with time zone', { comment: 'The updated date of the Role.', }) diff --git a/packages/backend/src/models/RoleAssignment.ts b/packages/backend/src/models/RoleAssignment.ts index 91167d06b3..f5ef8dcf69 100644 --- a/packages/backend/src/models/RoleAssignment.ts +++ b/packages/backend/src/models/RoleAssignment.ts @@ -14,11 +14,6 @@ export class MiRoleAssignment { @PrimaryColumn(id()) public id: string; - @Column('timestamp with time zone', { - comment: 'The created date of the RoleAssignment.', - }) - public createdAt: Date; - @Index() @Column({ ...id(), diff --git a/packages/backend/src/models/Signin.ts b/packages/backend/src/models/Signin.ts index 359e811da3..7a46f03b2a 100644 --- a/packages/backend/src/models/Signin.ts +++ b/packages/backend/src/models/Signin.ts @@ -12,11 +12,6 @@ export class MiSignin { @PrimaryColumn(id()) public id: string; - @Column('timestamp with time zone', { - comment: 'The created date of the Signin.', - }) - public createdAt: Date; - @Index() @Column(id()) public userId: MiUser['id']; diff --git a/packages/backend/src/models/SwSubscription.ts b/packages/backend/src/models/SwSubscription.ts index 4fe357541d..092060e09b 100644 --- a/packages/backend/src/models/SwSubscription.ts +++ b/packages/backend/src/models/SwSubscription.ts @@ -12,9 +12,6 @@ export class MiSwSubscription { @PrimaryColumn(id()) public id: string; - @Column('timestamp with time zone') - public createdAt: Date; - @Index() @Column(id()) public userId: MiUser['id']; diff --git a/packages/backend/src/models/User.ts b/packages/backend/src/models/User.ts index 31159d476b..3bc6baa641 100644 --- a/packages/backend/src/models/User.ts +++ b/packages/backend/src/models/User.ts @@ -13,12 +13,6 @@ export class MiUser { @PrimaryColumn(id()) public id: string; - @Index() - @Column('timestamp with time zone', { - comment: 'The created date of the User.', - }) - public createdAt: Date; - @Index() @Column('timestamp with time zone', { nullable: true, diff --git a/packages/backend/src/models/UserGroup.ts b/packages/backend/src/models/UserGroup.ts index 853170202b..96005898dd 100644 --- a/packages/backend/src/models/UserGroup.ts +++ b/packages/backend/src/models/UserGroup.ts @@ -12,12 +12,6 @@ export class MiUserGroup { @PrimaryColumn(id()) public id: string; - @Index() - @Column('timestamp with time zone', { - comment: 'The created date of the UserGroup.', - }) - public createdAt: Date; - @Column('varchar', { length: 256, }) diff --git a/packages/backend/src/models/UserGroupInvitation.ts b/packages/backend/src/models/UserGroupInvitation.ts index 9d809460ca..59b1aee163 100644 --- a/packages/backend/src/models/UserGroupInvitation.ts +++ b/packages/backend/src/models/UserGroupInvitation.ts @@ -14,11 +14,6 @@ export class MiUserGroupInvitation { @PrimaryColumn(id()) public id: string; - @Column('timestamp with time zone', { - comment: 'The created date of the UserGroupInvitation.', - }) - public createdAt: Date; - @Index() @Column({ ...id(), diff --git a/packages/backend/src/models/UserGroupJoining.ts b/packages/backend/src/models/UserGroupJoining.ts index d978a7277c..7cfb6dacb1 100644 --- a/packages/backend/src/models/UserGroupJoining.ts +++ b/packages/backend/src/models/UserGroupJoining.ts @@ -14,11 +14,6 @@ export class MiUserGroupJoining { @PrimaryColumn(id()) public id: string; - @Column('timestamp with time zone', { - comment: 'The created date of the UserGroupJoining.', - }) - public createdAt: Date; - @Index() @Column({ ...id(), diff --git a/packages/backend/src/models/UserList.ts b/packages/backend/src/models/UserList.ts index 43848bf286..ed2beb7f4b 100644 --- a/packages/backend/src/models/UserList.ts +++ b/packages/backend/src/models/UserList.ts @@ -12,11 +12,6 @@ export class MiUserList { @PrimaryColumn(id()) public id: string; - @Column('timestamp with time zone', { - comment: 'The created date of the UserList.', - }) - public createdAt: Date; - @Index() @Column({ ...id(), diff --git a/packages/backend/src/models/UserListFavorite.ts b/packages/backend/src/models/UserListFavorite.ts index d442bd3e5b..b2c37b8eb4 100644 --- a/packages/backend/src/models/UserListFavorite.ts +++ b/packages/backend/src/models/UserListFavorite.ts @@ -14,9 +14,6 @@ export class MiUserListFavorite { @PrimaryColumn(id()) public id: string; - @Column('timestamp with time zone') - public createdAt: Date; - @Index() @Column(id()) public userId: MiUser['id']; diff --git a/packages/backend/src/models/UserListMembership.ts b/packages/backend/src/models/UserListMembership.ts index 4255f3fa2b..1aede8b268 100644 --- a/packages/backend/src/models/UserListMembership.ts +++ b/packages/backend/src/models/UserListMembership.ts @@ -14,11 +14,6 @@ export class MiUserListMembership { @PrimaryColumn(id()) public id: string; - @Column('timestamp with time zone', { - comment: 'The created date of the UserListMembership.', - }) - public createdAt: Date; - @Index() @Column({ ...id(), diff --git a/packages/backend/src/models/UserNotePining.ts b/packages/backend/src/models/UserNotePining.ts index 1a588a205c..15379c6144 100644 --- a/packages/backend/src/models/UserNotePining.ts +++ b/packages/backend/src/models/UserNotePining.ts @@ -14,11 +14,6 @@ export class MiUserNotePining { @PrimaryColumn(id()) public id: string; - @Column('timestamp with time zone', { - comment: 'The created date of the UserNotePinings.', - }) - public createdAt: Date; - @Index() @Column(id()) public userId: MiUser['id']; diff --git a/packages/backend/src/models/UserPending.ts b/packages/backend/src/models/UserPending.ts index 0645a1102c..b488a7f15a 100644 --- a/packages/backend/src/models/UserPending.ts +++ b/packages/backend/src/models/UserPending.ts @@ -11,9 +11,6 @@ export class MiUserPending { @PrimaryColumn(id()) public id: string; - @Column('timestamp with time zone') - public createdAt: Date; - @Index({ unique: true }) @Column('varchar', { length: 128, diff --git a/packages/backend/src/models/Webhook.ts b/packages/backend/src/models/Webhook.ts index 505c44eb4e..d659c9100a 100644 --- a/packages/backend/src/models/Webhook.ts +++ b/packages/backend/src/models/Webhook.ts @@ -14,11 +14,6 @@ export class MiWebhook { @PrimaryColumn(id()) public id: string; - @Column('timestamp with time zone', { - comment: 'The created date of the Antenna.', - }) - public createdAt: Date; - @Index() @Column({ ...id(), diff --git a/packages/backend/src/models/json-schema/antenna.ts b/packages/backend/src/models/json-schema/antenna.ts index 7b96369ace..f3b4face1c 100644 --- a/packages/backend/src/models/json-schema/antenna.ts +++ b/packages/backend/src/models/json-schema/antenna.ts @@ -72,6 +72,11 @@ export const packedAntennaSchema = { optional: false, nullable: false, default: false, }, + localOnly: { + type: 'boolean', + optional: false, nullable: false, + default: false, + }, notify: { type: 'boolean', optional: false, nullable: false, diff --git a/packages/backend/src/models/json-schema/federation-instance.ts b/packages/backend/src/models/json-schema/federation-instance.ts index d70d904973..11a9c697f8 100644 --- a/packages/backend/src/models/json-schema/federation-instance.ts +++ b/packages/backend/src/models/json-schema/federation-instance.ts @@ -93,6 +93,11 @@ export const packedFederationInstanceSchema = { type: 'string', optional: false, nullable: true, }, + isSilenced: { + type: 'boolean', + optional: false, + nullable: false, + }, infoUpdatedAt: { type: 'string', optional: false, nullable: true, diff --git a/packages/backend/src/models/json-schema/note.ts b/packages/backend/src/models/json-schema/note.ts index 9b214295c0..4357de6f15 100644 --- a/packages/backend/src/models/json-schema/note.ts +++ b/packages/backend/src/models/json-schema/note.ts @@ -22,6 +22,15 @@ export const packedNoteSchema = { optional: true, nullable: true, format: 'date-time', }, + updatedAtHistory: { + type: 'array', + optional: true, nullable: true, + items: { + type: 'string', + optional: false, nullable: false, + format: 'date-time', + }, + }, noteEditHistory: { type: 'array', optional: true, nullable: false, @@ -187,6 +196,14 @@ export const packedNoteSchema = { type: 'string', optional: true, nullable: false, }, + reactionAndUserPairCache: { + type: 'array', + optional: true, nullable: false, + items: { + type: 'string', + optional: false, nullable: false, + }, + }, myReaction: { type: 'object', diff --git a/packages/backend/src/queue/processors/AggregateRetentionProcessorService.ts b/packages/backend/src/queue/processors/AggregateRetentionProcessorService.ts index 240479bff6..ca0ddcef95 100644 --- a/packages/backend/src/queue/processors/AggregateRetentionProcessorService.ts +++ b/packages/backend/src/queue/processors/AggregateRetentionProcessorService.ts @@ -47,13 +47,13 @@ export class AggregateRetentionProcessorService { // 今日登録したユーザーを全て取得 const targetUsers = await this.usersRepository.findBy({ host: IsNull(), - createdAt: MoreThan(new Date(Date.now() - (1000 * 60 * 60 * 24))), + id: MoreThan(this.idService.gen(Date.now() - (1000 * 60 * 60 * 24))), }); const targetUserIds = targetUsers.map(u => u.id); try { await this.retentionAggregationsRepository.insert({ - id: this.idService.genId(), + id: this.idService.gen(), createdAt: now, updatedAt: now, dateKey, diff --git a/packages/backend/src/queue/processors/ExportAntennasProcessorService.ts b/packages/backend/src/queue/processors/ExportAntennasProcessorService.ts index 2e1139a09f..d4645078bc 100644 --- a/packages/backend/src/queue/processors/ExportAntennasProcessorService.ts +++ b/packages/backend/src/queue/processors/ExportAntennasProcessorService.ts @@ -80,6 +80,7 @@ export class ExportAntennasProcessorService { return this.utilityService.getFullApAccount(u.username, u.host); // acct }) : null, caseSensitive: antenna.caseSensitive, + localOnly: antenna.localOnly, withReplies: antenna.withReplies, withFile: antenna.withFile, notify: antenna.notify, diff --git a/packages/backend/src/queue/processors/ExportFavoritesProcessorService.ts b/packages/backend/src/queue/processors/ExportFavoritesProcessorService.ts index 717b82bea3..c255d9f1ec 100644 --- a/packages/backend/src/queue/processors/ExportFavoritesProcessorService.ts +++ b/packages/backend/src/queue/processors/ExportFavoritesProcessorService.ts @@ -15,6 +15,7 @@ import { createTemp } from '@/misc/create-temp.js'; import type { MiPoll } from '@/models/Poll.js'; import type { MiNote } from '@/models/Note.js'; import { bindThis } from '@/decorators.js'; +import { IdService } from '@/core/IdService.js'; import { QueueLoggerService } from '../QueueLoggerService.js'; import type * as Bull from 'bullmq'; import type { DbJobDataWithUser } from '../types.js'; @@ -35,6 +36,7 @@ export class ExportFavoritesProcessorService { private driveService: DriveService, private queueLoggerService: QueueLoggerService, + private idService: IdService, ) { this.logger = this.queueLoggerService.logger.createSubLogger('export-favorites'); } @@ -99,7 +101,7 @@ export class ExportFavoritesProcessorService { if (favorite.note.hasPoll) { poll = await this.pollsRepository.findOneByOrFail({ noteId: favorite.note.id }); } - const content = JSON.stringify(serialize(favorite, poll)); + const content = JSON.stringify(this.serialize(favorite, poll)); const isFirst = exportedFavoritesCount === 0; await write(isFirst ? content : ',\n' + content); exportedFavoritesCount++; @@ -125,34 +127,34 @@ export class ExportFavoritesProcessorService { cleanup(); } } -} -function serialize(favorite: MiNoteFavorite & { note: MiNote & { user: MiUser } }, poll: MiPoll | null = null): Record { - return { - id: favorite.id, - createdAt: favorite.createdAt, - note: { - id: favorite.note.id, - text: favorite.note.text, - createdAt: favorite.note.createdAt, - fileIds: favorite.note.fileIds, - replyId: favorite.note.replyId, - renoteId: favorite.note.renoteId, - poll: poll, - cw: favorite.note.cw, - visibility: favorite.note.visibility, - visibleUserIds: favorite.note.visibleUserIds, - localOnly: favorite.note.localOnly, - reactionAcceptance: favorite.note.reactionAcceptance, - uri: favorite.note.uri, - url: favorite.note.url, - user: { - id: favorite.note.user.id, - name: favorite.note.user.name, - username: favorite.note.user.username, - host: favorite.note.user.host, - uri: favorite.note.user.uri, + private serialize(favorite: MiNoteFavorite & { note: MiNote & { user: MiUser } }, poll: MiPoll | null = null): Record { + return { + id: favorite.id, + createdAt: this.idService.parse(favorite.id).date.toISOString(), + note: { + id: favorite.note.id, + text: favorite.note.text, + createdAt: this.idService.parse(favorite.note.id).date.toISOString(), + fileIds: favorite.note.fileIds, + replyId: favorite.note.replyId, + renoteId: favorite.note.renoteId, + poll: poll, + cw: favorite.note.cw, + visibility: favorite.note.visibility, + visibleUserIds: favorite.note.visibleUserIds, + localOnly: favorite.note.localOnly, + reactionAcceptance: favorite.note.reactionAcceptance, + uri: favorite.note.uri, + url: favorite.note.url, + user: { + id: favorite.note.user.id, + name: favorite.note.user.name, + username: favorite.note.user.username, + host: favorite.note.user.host, + uri: favorite.note.user.uri, + }, }, - }, - }; + }; + } } diff --git a/packages/backend/src/queue/processors/ExportNotesProcessorService.ts b/packages/backend/src/queue/processors/ExportNotesProcessorService.ts index b6d5d99f89..d49cdfd904 100644 --- a/packages/backend/src/queue/processors/ExportNotesProcessorService.ts +++ b/packages/backend/src/queue/processors/ExportNotesProcessorService.ts @@ -17,6 +17,7 @@ import type { MiNote } from '@/models/Note.js'; import { bindThis } from '@/decorators.js'; import { DriveFileEntityService } from '@/core/entities/DriveFileEntityService.js'; import { Packed } from '@/misc/json-schema.js'; +import { IdService } from '@/core/IdService.js'; import { QueueLoggerService } from '../QueueLoggerService.js'; import type * as Bull from 'bullmq'; import type { DbJobDataWithUser } from '../types.js'; @@ -37,8 +38,8 @@ export class ExportNotesProcessorService { private driveService: DriveService, private queueLoggerService: QueueLoggerService, - private driveFileEntityService: DriveFileEntityService, + private idService: IdService, ) { this.logger = this.queueLoggerService.logger.createSubLogger('export-notes'); } @@ -103,7 +104,7 @@ export class ExportNotesProcessorService { poll = await this.pollsRepository.findOneByOrFail({ noteId: note.id }); } const files = await this.driveFileEntityService.packManyByIds(note.fileIds); - const content = JSON.stringify(serialize(note, poll, files)); + const content = JSON.stringify(this.serialize(note, poll, files)); const isFirst = exportedNotesCount === 0; await write(isFirst ? content : ',\n' + content); exportedNotesCount++; @@ -129,22 +130,22 @@ export class ExportNotesProcessorService { cleanup(); } } -} -function serialize(note: MiNote, poll: MiPoll | null = null, files: Packed<'DriveFile'>[]): Record { - return { - id: note.id, - text: note.text, - createdAt: note.createdAt, - fileIds: note.fileIds, - files: files, - replyId: note.replyId, - renoteId: note.renoteId, - poll: poll, - cw: note.cw, - visibility: note.visibility, - visibleUserIds: note.visibleUserIds, - localOnly: note.localOnly, - reactionAcceptance: note.reactionAcceptance, - }; + private serialize(note: MiNote, poll: MiPoll | null = null, files: Packed<'DriveFile'>[]): Record { + return { + id: note.id, + text: note.text, + createdAt: this.idService.parse(note.id).date.toISOString(), + fileIds: note.fileIds, + files: files, + replyId: note.replyId, + renoteId: note.renoteId, + poll: poll, + cw: note.cw, + visibility: note.visibility, + visibleUserIds: note.visibleUserIds, + localOnly: note.localOnly, + reactionAcceptance: note.reactionAcceptance, + }; + } } diff --git a/packages/backend/src/queue/processors/ImportAntennasProcessorService.ts b/packages/backend/src/queue/processors/ImportAntennasProcessorService.ts index 4d88711bfb..e2ee6a4712 100644 --- a/packages/backend/src/queue/processors/ImportAntennasProcessorService.ts +++ b/packages/backend/src/queue/processors/ImportAntennasProcessorService.ts @@ -43,6 +43,7 @@ const validate = new Ajv().compile({ type: 'string', } }, caseSensitive: { type: 'boolean' }, + localOnly: { type: 'boolean' }, withReplies: { type: 'boolean' }, withFile: { type: 'boolean' }, notify: { type: 'boolean' }, @@ -76,8 +77,7 @@ export class ImportAntennasProcessorService { continue; } const result = await this.antennasRepository.insert({ - id: this.idService.genId(), - createdAt: now, + id: this.idService.gen(now.getTime()), lastUsedAt: now, userId: job.data.user.id, name: antenna.name, @@ -87,6 +87,7 @@ export class ImportAntennasProcessorService { excludeKeywords: antenna.excludeKeywords, users: (antenna.src === 'list' && antenna.userListAccts !== null ? antenna.userListAccts : antenna.users).filter(Boolean), caseSensitive: antenna.caseSensitive, + localOnly: antenna.localOnly, withReplies: antenna.withReplies, withFile: antenna.withFile, notify: antenna.notify, diff --git a/packages/backend/src/queue/processors/ImportFollowingProcessorService.ts b/packages/backend/src/queue/processors/ImportFollowingProcessorService.ts index 88f806355e..9e341988f6 100644 --- a/packages/backend/src/queue/processors/ImportFollowingProcessorService.ts +++ b/packages/backend/src/queue/processors/ImportFollowingProcessorService.ts @@ -56,7 +56,7 @@ export class ImportFollowingProcessorService { const csv = await this.downloadService.downloadTextFile(file.url); const targets = csv.trim().split('\n'); - this.queueService.createImportFollowingToDbJob({ id: user.id }, targets); + this.queueService.createImportFollowingToDbJob({ id: user.id }, targets, job.data.withReplies); this.logger.succ('Import jobs created'); } @@ -93,9 +93,9 @@ export class ImportFollowingProcessorService { // skip myself if (target.id === job.data.user.id) return; - this.logger.info(`Follow ${target.id} ...`); + this.logger.info(`Follow ${target.id} ${job.data.withReplies ? 'with replies' : 'without replies'} ...`); - this.queueService.createFollowJob([{ from: user, to: { id: target.id }, silent: true }]); + this.queueService.createFollowJob([{ from: user, to: { id: target.id }, silent: true, withReplies: job.data.withReplies }]); } catch (e) { this.logger.warn(`Error: ${e}`); } diff --git a/packages/backend/src/queue/processors/ImportUserListsProcessorService.ts b/packages/backend/src/queue/processors/ImportUserListsProcessorService.ts index 8ec3b88b6b..9f103c106f 100644 --- a/packages/backend/src/queue/processors/ImportUserListsProcessorService.ts +++ b/packages/backend/src/queue/processors/ImportUserListsProcessorService.ts @@ -80,8 +80,7 @@ export class ImportUserListsProcessorService { if (list == null) { list = await this.userListsRepository.insert({ - id: this.idService.genId(), - createdAt: new Date(), + id: this.idService.gen(), userId: user.id, name: listName, }).then(x => this.userListsRepository.findOneByOrFail(x.identifiers[0])); diff --git a/packages/backend/src/queue/processors/InboxProcessorService.ts b/packages/backend/src/queue/processors/InboxProcessorService.ts index 9b5b317c3d..4e28475d15 100644 --- a/packages/backend/src/queue/processors/InboxProcessorService.ts +++ b/packages/backend/src/queue/processors/InboxProcessorService.ts @@ -88,7 +88,7 @@ export class InboxProcessorService { if (err.isClientError) { throw new Bull.UnrecoverableError(`skip: Ignored deleted actors on both ends ${activity.actor} - ${err.statusCode}`); } - throw new Error(`Error in actor ${activity.actor} - ${err.statusCode ?? err}`); + throw new Error(`Error in actor ${activity.actor} - ${err.statusCode}`); } } } diff --git a/packages/backend/src/queue/processors/RelationshipProcessorService.ts b/packages/backend/src/queue/processors/RelationshipProcessorService.ts index dfc266e669..c29b1ab914 100644 --- a/packages/backend/src/queue/processors/RelationshipProcessorService.ts +++ b/packages/backend/src/queue/processors/RelationshipProcessorService.ts @@ -34,8 +34,12 @@ export class RelationshipProcessorService { @bindThis public async processFollow(job: Bull.Job): Promise { - this.logger.info(`${job.data.from.id} is trying to follow ${job.data.to.id}`); - await this.userFollowingService.follow(job.data.from, job.data.to, job.data.requestId, job.data.silent); + this.logger.info(`${job.data.from.id} is trying to follow ${job.data.to.id} ${job.data.withReplies ? 'with replies' : 'without replies'}`); + await this.userFollowingService.follow(job.data.from, job.data.to, { + requestId: job.data.requestId, + silent: job.data.silent, + withReplies: job.data.withReplies, + }); return 'ok'; } diff --git a/packages/backend/src/queue/types.ts b/packages/backend/src/queue/types.ts index 15aa558578..e844e65704 100644 --- a/packages/backend/src/queue/types.ts +++ b/packages/backend/src/queue/types.ts @@ -33,6 +33,7 @@ export type RelationshipJobData = { to: ThinUser; silent?: boolean; requestId?: string; + withReplies?: boolean; } export type DbJobData = DbJobMap[T]; @@ -80,6 +81,7 @@ export type DbUserDeleteJobData = { export type DbUserImportJobData = { user: ThinUser; fileId: MiDriveFile['id']; + withReplies?: boolean; }; export type DBAntennaImportJobData = { @@ -90,6 +92,7 @@ export type DBAntennaImportJobData = { export type DbUserImportToDbJobData = { user: ThinUser; target: string; + withReplies?: boolean; }; export type DbAbuseReportJobData = MiAbuseUserReport; diff --git a/packages/backend/src/server/ServerService.ts b/packages/backend/src/server/ServerService.ts index 30466ec83f..4b4b91b402 100644 --- a/packages/backend/src/server/ServerService.ts +++ b/packages/backend/src/server/ServerService.ts @@ -73,7 +73,7 @@ export class ServerService implements OnApplicationShutdown { public async launch(): Promise { const fastify = Fastify({ trustProxy: true, - logger: !['production', 'test'].includes(process.env.NODE_ENV ?? ''), + logger: false, }); this.#fastify = fastify; diff --git a/packages/backend/src/server/api/ApiCallService.ts b/packages/backend/src/server/api/ApiCallService.ts index 3aa434adcb..9c0aee7d12 100644 --- a/packages/backend/src/server/api/ApiCallService.ts +++ b/packages/backend/src/server/api/ApiCallService.ts @@ -320,8 +320,9 @@ export class ApiCallService implements OnApplicationShutdown { } if (ep.meta.requireRolePolicy != null && !user!.isRoot) { + const myRoles = await this.roleService.getUserRoles(user!.id); const policies = await this.roleService.getUserPolicies(user!.id); - if (!policies[ep.meta.requireRolePolicy]) { + if (!policies[ep.meta.requireRolePolicy] && !myRoles.some(r => r.isAdministrator)) { throw new ApiError({ message: 'You are not assigned to a required role.', code: 'ROLE_PERMISSION_DENIED', diff --git a/packages/backend/src/server/api/EndpointsModule.ts b/packages/backend/src/server/api/EndpointsModule.ts index 618b05afb9..742b12a42c 100644 --- a/packages/backend/src/server/api/EndpointsModule.ts +++ b/packages/backend/src/server/api/EndpointsModule.ts @@ -381,6 +381,7 @@ import * as ep___users_achievements from './endpoints/users/achievements.js'; import * as ep___users_updateMemo from './endpoints/users/update-memo.js'; import * as ep___users_translate from './endpoints/users/translate.js'; import * as ep___fetchRss from './endpoints/fetch-rss.js'; +import * as ep___fetchExternalResources from './endpoints/fetch-external-resources.js'; import * as ep___retention from './endpoints/retention.js'; import { GetterService } from './GetterService.js'; import { ApiLoggerService } from './ApiLoggerService.js'; @@ -760,6 +761,7 @@ const $users_achievements: Provider = { provide: 'ep:users/achievements', useCla const $users_updateMemo: Provider = { provide: 'ep:users/update-memo', useClass: ep___users_updateMemo.default }; const $users_translate: Provider = { provide: 'ep:users/translate', useClass: ep___users_translate.default }; const $fetchRss: Provider = { provide: 'ep:fetch-rss', useClass: ep___fetchRss.default }; +const $fetchExternalResources: Provider = { provide: 'ep:fetch-external-resources', useClass: ep___fetchExternalResources.default }; const $retention: Provider = { provide: 'ep:retention', useClass: ep___retention.default }; @Module({ @@ -1144,6 +1146,7 @@ const $retention: Provider = { provide: 'ep:retention', useClass: ep___retention $users_updateMemo, $users_translate, $fetchRss, + $fetchExternalResources, $retention, ], exports: [ @@ -1517,6 +1520,7 @@ const $retention: Provider = { provide: 'ep:retention', useClass: ep___retention $users_updateMemo, $users_translate, $fetchRss, + $fetchExternalResources, $retention, ], }) diff --git a/packages/backend/src/server/api/SigninApiService.ts b/packages/backend/src/server/api/SigninApiService.ts index 9b721a2a0b..fcdec234c2 100644 --- a/packages/backend/src/server/api/SigninApiService.ts +++ b/packages/backend/src/server/api/SigninApiService.ts @@ -128,8 +128,7 @@ export class SigninApiService { const fail = async (status?: number, failure?: { id: string }) => { // Append signin history await this.signinsRepository.insert({ - id: this.idService.genId(), - createdAt: new Date(), + id: this.idService.gen(), userId: user.id, ip: request.ip, headers: request.headers as any, diff --git a/packages/backend/src/server/api/SigninService.ts b/packages/backend/src/server/api/SigninService.ts index f6062b6802..4ab0f2d1cc 100644 --- a/packages/backend/src/server/api/SigninService.ts +++ b/packages/backend/src/server/api/SigninService.ts @@ -30,8 +30,7 @@ export class SigninService { setImmediate(async () => { // Append signin history const record = await this.signinsRepository.insert({ - id: this.idService.genId(), - createdAt: new Date(), + id: this.idService.gen(), userId: user.id, ip: request.ip, headers: request.headers as any, diff --git a/packages/backend/src/server/api/SignupApiService.ts b/packages/backend/src/server/api/SignupApiService.ts index 5d4e857e0f..f9a86427a0 100644 --- a/packages/backend/src/server/api/SignupApiService.ts +++ b/packages/backend/src/server/api/SignupApiService.ts @@ -164,8 +164,7 @@ export class SignupApiService { const hash = await bcrypt.hash(password, salt); const pendingUser = await this.userPendingsRepository.insert({ - id: this.idService.genId(), - createdAt: new Date(), + id: this.idService.gen(), code, email: emailAddress!, username: username, diff --git a/packages/backend/src/server/api/endpoints.ts b/packages/backend/src/server/api/endpoints.ts index f18d79d52d..1eb2670b68 100644 --- a/packages/backend/src/server/api/endpoints.ts +++ b/packages/backend/src/server/api/endpoints.ts @@ -380,6 +380,7 @@ import * as ep___users_achievements from './endpoints/users/achievements.js'; import * as ep___users_updateMemo from './endpoints/users/update-memo.js'; import * as ep___users_translate from './endpoints/users/translate.js'; import * as ep___fetchRss from './endpoints/fetch-rss.js'; +import * as ep___fetchExternalResources from './endpoints/fetch-external-resources.js'; import * as ep___retention from './endpoints/retention.js'; const eps = [ @@ -757,6 +758,7 @@ const eps = [ ['users/update-memo', ep___users_updateMemo], ['users/translate', ep___users_translate], ['fetch-rss', ep___fetchRss], + ['fetch-external-resources', ep___fetchExternalResources], ['retention', ep___retention], ]; diff --git a/packages/backend/src/server/api/endpoints/admin/abuse-report-resolver/create.ts b/packages/backend/src/server/api/endpoints/admin/abuse-report-resolver/create.ts index d72e3efe7a..a61337a15d 100644 --- a/packages/backend/src/server/api/endpoints/admin/abuse-report-resolver/create.ts +++ b/packages/backend/src/server/api/endpoints/admin/abuse-report-resolver/create.ts @@ -124,8 +124,7 @@ export default class extends Endpoint { ps.expiresAt === '1year' ? function () { expirationDate!.setUTCFullYear(expirationDate!.getUTCFullYear() + 1); } : function () { expirationDate = null; })(); return await this.abuseReportResolverRepository.insert({ - id: this.idService.genId(), - createdAt: now, + id: this.idService.gen(), updatedAt: now, name: ps.name, targetUserPattern: ps.targetUserPattern, diff --git a/packages/backend/src/server/api/endpoints/admin/ad/create.ts b/packages/backend/src/server/api/endpoints/admin/ad/create.ts index f106ef1476..06eece1c81 100644 --- a/packages/backend/src/server/api/endpoints/admin/ad/create.ts +++ b/packages/backend/src/server/api/endpoints/admin/ad/create.ts @@ -44,8 +44,7 @@ export default class extends Endpoint { // eslint- ) { super(meta, paramDef, async (ps, me) => { const ad = await this.adsRepository.insert({ - id: this.idService.genId(), - createdAt: new Date(), + id: this.idService.gen(), expiresAt: new Date(ps.expiresAt), startsAt: new Date(ps.startsAt), dayOfWeek: ps.dayOfWeek, diff --git a/packages/backend/src/server/api/endpoints/admin/announcements/create.ts b/packages/backend/src/server/api/endpoints/admin/announcements/create.ts index 82a543259f..7ee6cde998 100644 --- a/packages/backend/src/server/api/endpoints/admin/announcements/create.ts +++ b/packages/backend/src/server/api/endpoints/admin/announcements/create.ts @@ -71,7 +71,6 @@ export default class extends Endpoint { // eslint- ) { super(meta, paramDef, async (ps, me) => { const { raw, packed } = await this.announcementService.create({ - createdAt: new Date(), updatedAt: null, title: ps.title, text: ps.text, diff --git a/packages/backend/src/server/api/endpoints/admin/announcements/list.ts b/packages/backend/src/server/api/endpoints/admin/announcements/list.ts index 90ee1a78ce..328ea5e722 100644 --- a/packages/backend/src/server/api/endpoints/admin/announcements/list.ts +++ b/packages/backend/src/server/api/endpoints/admin/announcements/list.ts @@ -9,6 +9,7 @@ import type { MiAnnouncement } from '@/models/Announcement.js'; import { Endpoint } from '@/server/api/endpoint-base.js'; import { QueryService } from '@/core/QueryService.js'; import { DI } from '@/di-symbols.js'; +import { IdService } from '@/core/IdService.js'; export const meta = { tags: ['admin'], @@ -81,6 +82,7 @@ export default class extends Endpoint { // eslint- private announcementReadsRepository: AnnouncementReadsRepository, private queryService: QueryService, + private idService: IdService, ) { super(meta, paramDef, async (ps, me) => { const query = this.queryService.makePaginationQuery(this.announcementsRepository.createQueryBuilder('announcement'), ps.sinceId, ps.untilId); @@ -102,7 +104,7 @@ export default class extends Endpoint { // eslint- return announcements.map(announcement => ({ id: announcement.id, - createdAt: announcement.createdAt.toISOString(), + createdAt: this.idService.parse(announcement.id).date.toISOString(), updatedAt: announcement.updatedAt?.toISOString() ?? null, title: announcement.title, text: announcement.text, diff --git a/packages/backend/src/server/api/endpoints/admin/drive/show-file.ts b/packages/backend/src/server/api/endpoints/admin/drive/show-file.ts index 2420ade0ba..efe556a951 100644 --- a/packages/backend/src/server/api/endpoints/admin/drive/show-file.ts +++ b/packages/backend/src/server/api/endpoints/admin/drive/show-file.ts @@ -8,6 +8,7 @@ import type { DriveFilesRepository, UsersRepository } from '@/models/_.js'; import { Endpoint } from '@/server/api/endpoint-base.js'; import { DI } from '@/di-symbols.js'; import { RoleService } from '@/core/RoleService.js'; +import { IdService } from '@/core/IdService.js'; import { ApiError } from '../../../error.js'; export const meta = { @@ -163,6 +164,7 @@ export default class extends Endpoint { // eslint- private usersRepository: UsersRepository, private roleService: RoleService, + private idService: IdService, ) { super(meta, paramDef, async (ps, me) => { const file = ps.fileId ? await this.driveFilesRepository.findOneBy({ id: ps.fileId }) : await this.driveFilesRepository.findOne({ @@ -212,7 +214,7 @@ export default class extends Endpoint { // eslint- type: file.type, name: file.name, md5: file.md5, - createdAt: file.createdAt.toISOString(), + createdAt: this.idService.parse(file.id).date.toISOString(), requestIp: iAmModerator ? file.requestIp : null, requestHeaders: iAmModerator && !ownerIsModerator ? file.requestHeaders : null, }; diff --git a/packages/backend/src/server/api/endpoints/admin/emoji/adds.ts b/packages/backend/src/server/api/endpoints/admin/emoji/adds.ts index ef2fd3db0d..4140f63e54 100644 --- a/packages/backend/src/server/api/endpoints/admin/emoji/adds.ts +++ b/packages/backend/src/server/api/endpoints/admin/emoji/adds.ts @@ -8,7 +8,6 @@ import { Endpoint } from '@/server/api/endpoint-base.js'; import type { DriveFilesRepository } from '@/models/_.js'; import { DI } from '@/di-symbols.js'; import { CustomEmojiService } from '@/core/CustomEmojiService.js'; -import { ModerationLogService } from '@/core/ModerationLogService.js'; import { EmojiEntityService } from '@/core/entities/EmojiEntityService.js'; import { secureRndstr } from '@/misc/secure-rndstr.js'; import { ApiError } from '../../../error.js'; @@ -25,6 +24,11 @@ export const meta = { code: 'NO_SUCH_FILE', id: 'fc46b5a4-6b92-4c33-ac66-b806659bb5cf', }, + duplicateName: { + message: 'Duplicate name.', + code: 'DUPLICATE_NAME', + id: 'f7a3462c-4e6e-4069-8421-b9bd4f4c3975', + }, }, } as const; @@ -62,7 +66,6 @@ export default class extends Endpoint { // eslint- private customEmojiService: CustomEmojiService, private emojiEntityService: EmojiEntityService, - private moderationLogService: ModerationLogService, ) { super(meta, paramDef, async (ps, me) => { const driveFile = await this.driveFilesRepository.findOneBy({ id: ps.fileId }); @@ -70,6 +73,9 @@ export default class extends Endpoint { // eslint- const name = driveFile.name.split('.')[0].match(/^[a-z0-9_]+$/) ? driveFile.name.split('.')[0] : `_${secureRndstr(8)}_`; + const isDuplicate = await this.customEmojiService.checkDuplicate(name); + if (isDuplicate) throw new ApiError(meta.errors.duplicateName); + const emoji = await this.customEmojiService.add({ driveFile, name, @@ -80,11 +86,7 @@ export default class extends Endpoint { // eslint- isSensitive: ps.isSensitive ?? false, localOnly: ps.localOnly ?? false, roleIdsThatCanBeUsedThisEmojiAsReaction: ps.roleIdsThatCanBeUsedThisEmojiAsReaction ?? [], - }); - - this.moderationLogService.insertModerationLog(me, 'addEmoji', { - emojiId: emoji.id, - }); + }, me); return this.emojiEntityService.packDetailed(emoji); }); diff --git a/packages/backend/src/server/api/endpoints/admin/emoji/copy.ts b/packages/backend/src/server/api/endpoints/admin/emoji/copy.ts index 6237f45211..1a9ad24115 100644 --- a/packages/backend/src/server/api/endpoints/admin/emoji/copy.ts +++ b/packages/backend/src/server/api/endpoints/admin/emoji/copy.ts @@ -79,7 +79,7 @@ export default class extends Endpoint { // eslint- } const copied = await this.emojisRepository.insert({ - id: this.idService.genId(), + id: this.idService.gen(), updatedAt: new Date(), name: emoji.name, host: null, diff --git a/packages/backend/src/server/api/endpoints/admin/get-user-ips.ts b/packages/backend/src/server/api/endpoints/admin/get-user-ips.ts index c0d395deb8..e73a2c4468 100644 --- a/packages/backend/src/server/api/endpoints/admin/get-user-ips.ts +++ b/packages/backend/src/server/api/endpoints/admin/get-user-ips.ts @@ -7,6 +7,7 @@ import { Inject, Injectable } from '@nestjs/common'; import type { UserIpsRepository } from '@/models/_.js'; import { Endpoint } from '@/server/api/endpoint-base.js'; import { DI } from '@/di-symbols.js'; +import { IdService } from '@/core/IdService.js'; export const meta = { tags: ['admin'], @@ -28,11 +29,13 @@ export default class extends Endpoint { // eslint- constructor( @Inject(DI.userIpsRepository) private userIpsRepository: UserIpsRepository, + + private idService: IdService, ) { super(meta, paramDef, async (ps, me) => { const ips = await this.userIpsRepository.find({ where: { userId: ps.userId }, - order: { createdAt: 'DESC' }, + order: { id: 'DESC' }, take: 30, }); diff --git a/packages/backend/src/server/api/endpoints/admin/invite/create.ts b/packages/backend/src/server/api/endpoints/admin/invite/create.ts index bc2338ad31..10b172750d 100644 --- a/packages/backend/src/server/api/endpoints/admin/invite/create.ts +++ b/packages/backend/src/server/api/endpoints/admin/invite/create.ts @@ -72,8 +72,7 @@ export default class extends Endpoint { // eslint- for (let i = 0; i < ps.count; i++) { ticketsPromises.push(this.registrationTicketsRepository.insert({ - id: this.idService.genId(), - createdAt: new Date(), + id: this.idService.gen(), expiresAt: ps.expiresAt ? new Date(ps.expiresAt) : null, code: generateInviteCode(), }).then(x => this.registrationTicketsRepository.findOneByOrFail(x.identifiers[0]))); diff --git a/packages/backend/src/server/api/endpoints/admin/invite/list.ts b/packages/backend/src/server/api/endpoints/admin/invite/list.ts index 820808e4d6..cb37e24f34 100644 --- a/packages/backend/src/server/api/endpoints/admin/invite/list.ts +++ b/packages/backend/src/server/api/endpoints/admin/invite/list.ts @@ -56,8 +56,8 @@ export default class extends Endpoint { // eslint- } switch (ps.sort) { - case '+createdAt': query.orderBy('ticket.createdAt', 'DESC'); break; - case '-createdAt': query.orderBy('ticket.createdAt', 'ASC'); break; + case '+createdAt': query.orderBy('ticket.id', 'DESC'); break; + case '-createdAt': query.orderBy('ticket.id', 'ASC'); break; case '+usedAt': query.orderBy('ticket.usedAt', 'DESC', 'NULLS LAST'); break; case '-usedAt': query.orderBy('ticket.usedAt', 'ASC', 'NULLS FIRST'); break; default: query.orderBy('ticket.id', 'DESC'); break; diff --git a/packages/backend/src/server/api/endpoints/admin/meta.ts b/packages/backend/src/server/api/endpoints/admin/meta.ts index c544212742..a4cc35cc82 100644 --- a/packages/backend/src/server/api/endpoints/admin/meta.ts +++ b/packages/backend/src/server/api/endpoints/admin/meta.ts @@ -109,6 +109,16 @@ export const meta = { type: 'string', optional: false, nullable: true, }, + silencedHosts: { + type: 'array', + optional: true, + nullable: false, + items: { + type: 'string', + optional: false, + nullable: false, + }, + }, pinnedUsers: { type: 'array', optional: false, nullable: false, @@ -444,6 +454,7 @@ export default class extends Endpoint { // eslint- pinnedUsers: instance.pinnedUsers, hiddenTags: instance.hiddenTags, blockedHosts: instance.blockedHosts, + silencedHosts: instance.silencedHosts, sensitiveWords: instance.sensitiveWords, preservedUsernames: instance.preservedUsernames, hcaptchaSecretKey: instance.hcaptchaSecretKey, diff --git a/packages/backend/src/server/api/endpoints/admin/roles/users.ts b/packages/backend/src/server/api/endpoints/admin/roles/users.ts index df34984f63..8e6ffbcc39 100644 --- a/packages/backend/src/server/api/endpoints/admin/roles/users.ts +++ b/packages/backend/src/server/api/endpoints/admin/roles/users.ts @@ -10,6 +10,7 @@ import { Endpoint } from '@/server/api/endpoint-base.js'; import { QueryService } from '@/core/QueryService.js'; import { DI } from '@/di-symbols.js'; import { UserEntityService } from '@/core/entities/UserEntityService.js'; +import { IdService } from '@/core/IdService.js'; import { ApiError } from '../../../error.js'; export const meta = { @@ -49,6 +50,7 @@ export default class extends Endpoint { // eslint- private queryService: QueryService, private userEntityService: UserEntityService, + private idService: IdService, ) { super(meta, paramDef, async (ps, me) => { const role = await this.rolesRepository.findOneBy({ @@ -74,7 +76,7 @@ export default class extends Endpoint { // eslint- return await Promise.all(assigns.map(async assign => ({ id: assign.id, - createdAt: assign.createdAt, + createdAt: this.idService.parse(assign.id).date.toISOString(), user: await this.userEntityService.pack(assign.user!, me, { detail: true }), expiresAt: assign.expiresAt, }))); diff --git a/packages/backend/src/server/api/endpoints/admin/show-user.ts b/packages/backend/src/server/api/endpoints/admin/show-user.ts index 4091ec5b4d..042ede39b8 100644 --- a/packages/backend/src/server/api/endpoints/admin/show-user.ts +++ b/packages/backend/src/server/api/endpoints/admin/show-user.ts @@ -9,6 +9,7 @@ import { Endpoint } from '@/server/api/endpoint-base.js'; import { DI } from '@/di-symbols.js'; import { RoleService } from '@/core/RoleService.js'; import { RoleEntityService } from '@/core/entities/RoleEntityService.js'; +import { IdService } from '@/core/IdService.js'; export const meta = { tags: ['admin'], @@ -44,6 +45,7 @@ export default class extends Endpoint { // eslint- private roleService: RoleService, private roleEntityService: RoleEntityService, + private idService: IdService, ) { super(meta, paramDef, async (ps, me) => { const [user, profile] = await Promise.all([ @@ -92,7 +94,7 @@ export default class extends Endpoint { // eslint- policies: await this.roleService.getUserPolicies(user.id), roles: await this.roleEntityService.packMany(roles, me), roleAssigns: roleAssigns.map(a => ({ - createdAt: a.createdAt.toISOString(), + createdAt: this.idService.parse(a.id).date.toISOString(), expiresAt: a.expiresAt ? a.expiresAt.toISOString() : null, roleId: a.roleId, })), diff --git a/packages/backend/src/server/api/endpoints/admin/show-users.ts b/packages/backend/src/server/api/endpoints/admin/show-users.ts index d051ac5034..00354821f0 100644 --- a/packages/backend/src/server/api/endpoints/admin/show-users.ts +++ b/packages/backend/src/server/api/endpoints/admin/show-users.ts @@ -99,8 +99,8 @@ export default class extends Endpoint { // eslint- switch (ps.sort) { case '+follower': query.orderBy('user.followersCount', 'DESC'); break; case '-follower': query.orderBy('user.followersCount', 'ASC'); break; - case '+createdAt': query.orderBy('user.createdAt', 'DESC'); break; - case '-createdAt': query.orderBy('user.createdAt', 'ASC'); break; + case '+createdAt': query.orderBy('user.id', 'DESC'); break; + case '-createdAt': query.orderBy('user.id', 'ASC'); break; case '+updatedAt': query.orderBy('user.updatedAt', 'DESC', 'NULLS LAST'); break; case '-updatedAt': query.orderBy('user.updatedAt', 'ASC', 'NULLS FIRST'); break; case '+lastActiveDate': query.orderBy('user.lastActiveDate', 'DESC', 'NULLS LAST'); break; diff --git a/packages/backend/src/server/api/endpoints/admin/update-meta.ts b/packages/backend/src/server/api/endpoints/admin/update-meta.ts index 7d40ee9f7c..6c94ad8ba3 100644 --- a/packages/backend/src/server/api/endpoints/admin/update-meta.ts +++ b/packages/backend/src/server/api/endpoints/admin/update-meta.ts @@ -22,18 +22,26 @@ export const paramDef = { type: 'object', properties: { disableRegistration: { type: 'boolean', nullable: true }, - pinnedUsers: { type: 'array', nullable: true, items: { - type: 'string', - } }, - hiddenTags: { type: 'array', nullable: true, items: { - type: 'string', - } }, - blockedHosts: { type: 'array', nullable: true, items: { - type: 'string', - } }, - sensitiveWords: { type: 'array', nullable: true, items: { - type: 'string', - } }, + pinnedUsers: { + type: 'array', nullable: true, items: { + type: 'string', + }, + }, + hiddenTags: { + type: 'array', nullable: true, items: { + type: 'string', + }, + }, + blockedHosts: { + type: 'array', nullable: true, items: { + type: 'string', + }, + }, + sensitiveWords: { + type: 'array', nullable: true, items: { + type: 'string', + }, + }, themeColor: { type: 'string', nullable: true, pattern: '^#[0-9a-fA-F]{6}$' }, mascotImageUrl: { type: 'string', nullable: true }, bannerUrl: { type: 'string', nullable: true }, @@ -69,9 +77,11 @@ export const paramDef = { proxyAccountId: { type: 'string', format: 'misskey:id', nullable: true }, maintainerName: { type: 'string', nullable: true }, maintainerEmail: { type: 'string', nullable: true }, - langs: { type: 'array', items: { - type: 'string', - } }, + langs: { + type: 'array', items: { + type: 'string', + }, + }, summalyProxy: { type: 'string', nullable: true }, translatorType: { type: 'string', nullable: true }, deeplAuthKey: { type: 'string', nullable: true }, @@ -94,8 +104,8 @@ export const paramDef = { tosUrl: { type: 'string', nullable: true }, repositoryUrl: { type: 'string' }, feedbackUrl: { type: 'string' }, - impressumUrl: { type: 'string' }, - privacyPolicyUrl: { type: 'string' }, + impressumUrl: { type: 'string', nullable: true }, + privacyPolicyUrl: { type: 'string', nullable: true }, useObjectStorage: { type: 'boolean' }, objectStorageBaseUrl: { type: 'string', nullable: true }, objectStorageBucket: { type: 'string', nullable: true }, @@ -138,6 +148,13 @@ export const paramDef = { perUserHomeTimelineCacheMax: { type: 'integer' }, perUserListTimelineCacheMax: { type: 'integer' }, notesPerOneAd: { type: 'integer' }, + silencedHosts: { + type: 'array', + nullable: true, + items: { + type: 'string', + }, + }, enableReceivePrerelease: { type: 'boolean' }, skipVersion: { type: 'boolean' }, skipCherryPickVersion: { type: 'string', nullable: true }, @@ -174,7 +191,14 @@ export default class extends Endpoint { // eslint- if (Array.isArray(ps.sensitiveWords)) { set.sensitiveWords = ps.sensitiveWords.filter(Boolean); } - + if (Array.isArray(ps.silencedHosts)) { + let lastValue = ''; + set.silencedHosts = ps.silencedHosts.sort().filter((h) => { + const lv = lastValue; + lastValue = h; + return h !== '' && h !== lv && !set.blockedHosts?.includes(h); + }); + } if (ps.themeColor !== undefined) { set.themeColor = ps.themeColor; } diff --git a/packages/backend/src/server/api/endpoints/antennas/create.ts b/packages/backend/src/server/api/endpoints/antennas/create.ts index 91e43c1bb8..cab9b8b47a 100644 --- a/packages/backend/src/server/api/endpoints/antennas/create.ts +++ b/packages/backend/src/server/api/endpoints/antennas/create.ts @@ -70,6 +70,7 @@ export const paramDef = { type: 'string', } }, caseSensitive: { type: 'boolean' }, + localOnly: { type: 'boolean' }, withReplies: { type: 'boolean' }, withFile: { type: 'boolean' }, notify: { type: 'boolean' }, @@ -132,8 +133,7 @@ export default class extends Endpoint { // eslint- const now = new Date(); const antenna = await this.antennasRepository.insert({ - id: this.idService.genId(), - createdAt: now, + id: this.idService.gen(now.getTime()), lastUsedAt: now, userId: me.id, name: ps.name, @@ -144,6 +144,7 @@ export default class extends Endpoint { // eslint- excludeKeywords: ps.excludeKeywords, users: ps.users, caseSensitive: ps.caseSensitive, + localOnly: ps.localOnly, withReplies: ps.withReplies, withFile: ps.withFile, notify: ps.notify, diff --git a/packages/backend/src/server/api/endpoints/antennas/notes.ts b/packages/backend/src/server/api/endpoints/antennas/notes.ts index e1fda37d36..5f02ccf595 100644 --- a/packages/backend/src/server/api/endpoints/antennas/notes.ts +++ b/packages/backend/src/server/api/endpoints/antennas/notes.ts @@ -12,7 +12,7 @@ import { NoteReadService } from '@/core/NoteReadService.js'; import { DI } from '@/di-symbols.js'; import { NoteEntityService } from '@/core/entities/NoteEntityService.js'; import { IdService } from '@/core/IdService.js'; -import { RedisTimelineService } from '@/core/RedisTimelineService.js'; +import { FunoutTimelineService } from '@/core/FunoutTimelineService.js'; import { ApiError } from '../../error.js'; export const meta = { @@ -70,11 +70,11 @@ export default class extends Endpoint { // eslint- private noteEntityService: NoteEntityService, private queryService: QueryService, private noteReadService: NoteReadService, - private redisTimelineService: RedisTimelineService, + private funoutTimelineService: FunoutTimelineService, ) { super(meta, paramDef, async (ps, me) => { - const untilId = ps.untilId ?? (ps.untilDate ? this.idService.genId(new Date(ps.untilDate!)) : null); - const sinceId = ps.sinceId ?? (ps.sinceDate ? this.idService.genId(new Date(ps.sinceDate!)) : null); + const untilId = ps.untilId ?? (ps.untilDate ? this.idService.gen(ps.untilDate!) : null); + const sinceId = ps.sinceId ?? (ps.sinceDate ? this.idService.gen(ps.sinceDate!) : null); const antenna = await this.antennasRepository.findOneBy({ id: ps.antennaId, @@ -90,7 +90,7 @@ export default class extends Endpoint { // eslint- lastUsedAt: new Date(), }); - let noteIds = await this.redisTimelineService.get(`antennaTimeline:${antenna.id}`, untilId, sinceId); + let noteIds = await this.funoutTimelineService.get(`antennaTimeline:${antenna.id}`, untilId, sinceId); noteIds = noteIds.slice(0, ps.limit); if (noteIds.length === 0) { return []; diff --git a/packages/backend/src/server/api/endpoints/antennas/update.ts b/packages/backend/src/server/api/endpoints/antennas/update.ts index 871584c196..718f934494 100644 --- a/packages/backend/src/server/api/endpoints/antennas/update.ts +++ b/packages/backend/src/server/api/endpoints/antennas/update.ts @@ -69,6 +69,7 @@ export const paramDef = { type: 'string', } }, caseSensitive: { type: 'boolean' }, + localOnly: { type: 'boolean' }, withReplies: { type: 'boolean' }, withFile: { type: 'boolean' }, notify: { type: 'boolean' }, @@ -137,6 +138,7 @@ export default class extends Endpoint { // eslint- excludeKeywords: ps.excludeKeywords, users: ps.users, caseSensitive: ps.caseSensitive, + localOnly: ps.localOnly, withReplies: ps.withReplies, withFile: ps.withFile, notify: ps.notify, diff --git a/packages/backend/src/server/api/endpoints/app/create.ts b/packages/backend/src/server/api/endpoints/app/create.ts index 3096ab96c8..42174c8400 100644 --- a/packages/backend/src/server/api/endpoints/app/create.ts +++ b/packages/backend/src/server/api/endpoints/app/create.ts @@ -55,8 +55,7 @@ export default class extends Endpoint { // eslint- // Create account const app = await this.appsRepository.insert({ - id: this.idService.genId(), - createdAt: new Date(), + id: this.idService.gen(), userId: me ? me.id : null, name: ps.name, description: ps.description, diff --git a/packages/backend/src/server/api/endpoints/auth/accept.ts b/packages/backend/src/server/api/endpoints/auth/accept.ts index f1dd4f27cf..6b466109fc 100644 --- a/packages/backend/src/server/api/endpoints/auth/accept.ts +++ b/packages/backend/src/server/api/endpoints/auth/accept.ts @@ -80,8 +80,7 @@ export default class extends Endpoint { // eslint- const now = new Date(); await this.accessTokensRepository.insert({ - id: this.idService.genId(), - createdAt: now, + id: this.idService.gen(now.getTime()), lastUsedAt: now, appId: session.appId, userId: me.id, diff --git a/packages/backend/src/server/api/endpoints/auth/session/generate.ts b/packages/backend/src/server/api/endpoints/auth/session/generate.ts index 2f4f835f34..b14e75c4a7 100644 --- a/packages/backend/src/server/api/endpoints/auth/session/generate.ts +++ b/packages/backend/src/server/api/endpoints/auth/session/generate.ts @@ -79,8 +79,7 @@ export default class extends Endpoint { // eslint- // Create session token document const doc = await this.authSessionsRepository.insert({ - id: this.idService.genId(), - createdAt: new Date(), + id: this.idService.gen(), appId: app.id, token: token, }).then(x => this.authSessionsRepository.findOneByOrFail(x.identifiers[0])); diff --git a/packages/backend/src/server/api/endpoints/channels/create.ts b/packages/backend/src/server/api/endpoints/channels/create.ts index b9a1ca8cb4..939e1e4532 100644 --- a/packages/backend/src/server/api/endpoints/channels/create.ts +++ b/packages/backend/src/server/api/endpoints/channels/create.ts @@ -80,8 +80,7 @@ export default class extends Endpoint { // eslint- } const channel = await this.channelsRepository.insert({ - id: this.idService.genId(), - createdAt: new Date(), + id: this.idService.gen(), userId: me.id, name: ps.name, description: ps.description ?? null, diff --git a/packages/backend/src/server/api/endpoints/channels/favorite.ts b/packages/backend/src/server/api/endpoints/channels/favorite.ts index 8067e35eb4..e7564d7708 100644 --- a/packages/backend/src/server/api/endpoints/channels/favorite.ts +++ b/packages/backend/src/server/api/endpoints/channels/favorite.ts @@ -57,8 +57,7 @@ export default class extends Endpoint { // eslint- } await this.channelFavoritesRepository.insert({ - id: this.idService.genId(), - createdAt: new Date(), + id: this.idService.gen(), userId: me.id, channelId: channel.id, }); diff --git a/packages/backend/src/server/api/endpoints/channels/follow.ts b/packages/backend/src/server/api/endpoints/channels/follow.ts index 532b6e128b..2d7727d811 100644 --- a/packages/backend/src/server/api/endpoints/channels/follow.ts +++ b/packages/backend/src/server/api/endpoints/channels/follow.ts @@ -57,8 +57,7 @@ export default class extends Endpoint { // eslint- } await this.channelFollowingsRepository.insert({ - id: this.idService.genId(), - createdAt: new Date(), + id: this.idService.gen(), followerId: me.id, followeeId: channel.id, }); diff --git a/packages/backend/src/server/api/endpoints/channels/timeline.ts b/packages/backend/src/server/api/endpoints/channels/timeline.ts index 454984d8f9..1d65091939 100644 --- a/packages/backend/src/server/api/endpoints/channels/timeline.ts +++ b/packages/backend/src/server/api/endpoints/channels/timeline.ts @@ -12,7 +12,7 @@ import { NoteEntityService } from '@/core/entities/NoteEntityService.js'; import ActiveUsersChart from '@/core/chart/charts/active-users.js'; import { DI } from '@/di-symbols.js'; import { IdService } from '@/core/IdService.js'; -import { RedisTimelineService } from '@/core/RedisTimelineService.js'; +import { FunoutTimelineService } from '@/core/FunoutTimelineService.js'; import { isUserRelated } from '@/misc/is-user-related.js'; import { CacheService } from '@/core/CacheService.js'; import { ApiError } from '../../error.js'; @@ -69,13 +69,13 @@ export default class extends Endpoint { // eslint- private idService: IdService, private noteEntityService: NoteEntityService, private queryService: QueryService, - private redisTimelineService: RedisTimelineService, + private funoutTimelineService: FunoutTimelineService, private cacheService: CacheService, private activeUsersChart: ActiveUsersChart, ) { super(meta, paramDef, async (ps, me) => { - const untilId = ps.untilId ?? (ps.untilDate ? this.idService.genId(new Date(ps.untilDate!)) : null); - const sinceId = ps.sinceId ?? (ps.sinceDate ? this.idService.genId(new Date(ps.sinceDate!)) : null); + const untilId = ps.untilId ?? (ps.untilDate ? this.idService.gen(ps.untilDate!) : null); + const sinceId = ps.sinceId ?? (ps.sinceDate ? this.idService.gen(ps.sinceDate!) : null); const isRangeSpecified = untilId != null && sinceId != null; const channel = await this.channelsRepository.findOneBy({ @@ -95,7 +95,7 @@ export default class extends Endpoint { // eslint- this.cacheService.userMutingsCache.fetch(me.id), ]) : [new Set()]; - let noteIds = await this.redisTimelineService.get(`channelTimeline:${channel.id}`, untilId, sinceId); + let noteIds = await this.funoutTimelineService.get(`channelTimeline:${channel.id}`, untilId, sinceId); noteIds = noteIds.slice(0, ps.limit); if (noteIds.length > 0) { diff --git a/packages/backend/src/server/api/endpoints/clips/favorite.ts b/packages/backend/src/server/api/endpoints/clips/favorite.ts index 2356dbb7f4..51f013e634 100644 --- a/packages/backend/src/server/api/endpoints/clips/favorite.ts +++ b/packages/backend/src/server/api/endpoints/clips/favorite.ts @@ -74,8 +74,7 @@ export default class extends Endpoint { // eslint- } await this.clipFavoritesRepository.insert({ - id: this.idService.genId(), - createdAt: new Date(), + id: this.idService.gen(), clipId: clip.id, userId: me.id, }); diff --git a/packages/backend/src/server/api/endpoints/drive/files.ts b/packages/backend/src/server/api/endpoints/drive/files.ts index bc497478e0..8cbae234d7 100644 --- a/packages/backend/src/server/api/endpoints/drive/files.ts +++ b/packages/backend/src/server/api/endpoints/drive/files.ts @@ -69,8 +69,8 @@ export default class extends Endpoint { // eslint- } switch (ps.sort) { - case '+createdAt': query.orderBy('file.createdAt', 'DESC'); break; - case '-createdAt': query.orderBy('file.createdAt', 'ASC'); break; + case '+createdAt': query.orderBy('file.id', 'DESC'); break; + case '-createdAt': query.orderBy('file.id', 'ASC'); break; case '+name': query.orderBy('file.name', 'DESC'); break; case '-name': query.orderBy('file.name', 'ASC'); break; case '+size': query.orderBy('file.size', 'DESC'); break; diff --git a/packages/backend/src/server/api/endpoints/drive/folders/create.ts b/packages/backend/src/server/api/endpoints/drive/folders/create.ts index 597b51d80e..293e96fe88 100644 --- a/packages/backend/src/server/api/endpoints/drive/folders/create.ts +++ b/packages/backend/src/server/api/endpoints/drive/folders/create.ts @@ -76,8 +76,7 @@ export default class extends Endpoint { // eslint- // Create folder const folder = await this.driveFoldersRepository.insert({ - id: this.idService.genId(), - createdAt: new Date(), + id: this.idService.gen(), name: ps.name, parentId: parent !== null ? parent.id : null, userId: me.id, diff --git a/packages/backend/src/server/api/endpoints/federation/instances.ts b/packages/backend/src/server/api/endpoints/federation/instances.ts index d238e7e5e7..c9630235fe 100644 --- a/packages/backend/src/server/api/endpoints/federation/instances.ts +++ b/packages/backend/src/server/api/endpoints/federation/instances.ts @@ -36,6 +36,7 @@ export const paramDef = { blocked: { type: 'boolean', nullable: true }, notResponding: { type: 'boolean', nullable: true }, suspended: { type: 'boolean', nullable: true }, + silenced: { type: 'boolean', nullable: true }, federating: { type: 'boolean', nullable: true }, subscribing: { type: 'boolean', nullable: true }, publishing: { type: 'boolean', nullable: true }, @@ -102,6 +103,23 @@ export default class extends Endpoint { // eslint- } } + if (typeof ps.silenced === 'boolean') { + const meta = await this.metaService.fetch(true); + + if (ps.silenced) { + if (meta.silencedHosts.length === 0) { + return []; + } + query.andWhere('instance.host IN (:...silences)', { + silences: meta.silencedHosts, + }); + } else if (meta.silencedHosts.length > 0) { + query.andWhere('instance.host NOT IN (:...silences)', { + silences: meta.silencedHosts, + }); + } + } + if (typeof ps.federating === 'boolean') { if (ps.federating) { query.andWhere('((instance.followingCount > 0) OR (instance.followersCount > 0))'); diff --git a/packages/backend/src/server/api/endpoints/fetch-external-resources.ts b/packages/backend/src/server/api/endpoints/fetch-external-resources.ts new file mode 100644 index 0000000000..f113e5b87a --- /dev/null +++ b/packages/backend/src/server/api/endpoints/fetch-external-resources.ts @@ -0,0 +1,72 @@ +/* + * SPDX-FileCopyrightText: syuilo and other misskey, cherrypick contributors + * SPDX-License-Identifier: AGPL-3.0-only + */ + +import { createHash } from 'crypto'; +import ms from 'ms'; +import { Injectable } from '@nestjs/common'; +import { Endpoint } from '@/server/api/endpoint-base.js'; +import { HttpRequestService } from '@/core/HttpRequestService.js'; +import { ApiError } from '../error.js'; + +export const meta = { + tags: ['meta'], + + requireCredential: true, + + limit: { + duration: ms('1hour'), + max: 50, + }, + + errors: { + invalidSchema: { + message: 'External resource returned invalid schema.', + code: 'EXT_RESOURCE_RETURNED_INVALID_SCHEMA', + id: 'bb774091-7a15-4a70-9dc5-6ac8cf125856', + }, + hashUnmached: { + message: 'Hash did not match.', + code: 'EXT_RESOURCE_HASH_DIDNT_MATCH', + id: '693ba8ba-b486-40df-a174-72f8279b56a4', + }, + }, +} as const; + +export const paramDef = { + type: 'object', + properties: { + url: { type: 'string' }, + hash: { type: 'string' }, + }, + required: ['url', 'hash'], +} as const; + +@Injectable() +export default class extends Endpoint { // eslint-disable-line import/no-default-export + constructor( + private httpRequestService: HttpRequestService, + ) { + super(meta, paramDef, async (ps) => { + const res = await this.httpRequestService.getJson<{ + type: string; + data: string; + }>(ps.url); + + if (!res.data || !res.type) { + throw new ApiError(meta.errors.invalidSchema); + } + + const resHash = createHash('sha512').update(res.data.replace(/\r\n/g, '\n')).digest('hex'); + if (resHash !== ps.hash) { + throw new ApiError(meta.errors.hashUnmached); + } + + return { + type: res.type, + data: res.data, + }; + }); + } +} diff --git a/packages/backend/src/server/api/endpoints/flash/create.ts b/packages/backend/src/server/api/endpoints/flash/create.ts index 1bdb809b33..12b70f06c3 100644 --- a/packages/backend/src/server/api/endpoints/flash/create.ts +++ b/packages/backend/src/server/api/endpoints/flash/create.ts @@ -53,9 +53,8 @@ export default class extends Endpoint { // eslint- ) { super(meta, paramDef, async (ps, me) => { const flash = await this.flashsRepository.insert({ - id: this.idService.genId(), + id: this.idService.gen(), userId: me.id, - createdAt: new Date(), updatedAt: new Date(), title: ps.title, summary: ps.summary, diff --git a/packages/backend/src/server/api/endpoints/flash/like.ts b/packages/backend/src/server/api/endpoints/flash/like.ts index f67ad15707..66fa22639f 100644 --- a/packages/backend/src/server/api/endpoints/flash/like.ts +++ b/packages/backend/src/server/api/endpoints/flash/like.ts @@ -83,8 +83,7 @@ export default class extends Endpoint { // eslint- // Create like await this.flashLikesRepository.insert({ - id: this.idService.genId(), - createdAt: new Date(), + id: this.idService.gen(), flashId: flash.id, userId: me.id, }); diff --git a/packages/backend/src/server/api/endpoints/following/create.ts b/packages/backend/src/server/api/endpoints/following/create.ts index b05a09e0c1..194d13cfe1 100644 --- a/packages/backend/src/server/api/endpoints/following/create.ts +++ b/packages/backend/src/server/api/endpoints/following/create.ts @@ -71,6 +71,7 @@ export const paramDef = { type: 'object', properties: { userId: { type: 'string', format: 'misskey:id' }, + withReplies: { type: 'boolean' }, }, required: ['userId'], } as const; @@ -112,7 +113,7 @@ export default class extends Endpoint { // eslint- } try { - await this.userFollowingService.follow(follower, followee); + await this.userFollowingService.follow(follower, followee, { withReplies: ps.withReplies }); } catch (e) { if (e instanceof IdentifiableError) { if (e.id === '710e8fb0-b8c3-4922-be49-d5d93d8e6a6e') throw new ApiError(meta.errors.blocking); diff --git a/packages/backend/src/server/api/endpoints/gallery/posts/create.ts b/packages/backend/src/server/api/endpoints/gallery/posts/create.ts index c36bffac69..50e08ee42d 100644 --- a/packages/backend/src/server/api/endpoints/gallery/posts/create.ts +++ b/packages/backend/src/server/api/endpoints/gallery/posts/create.ts @@ -76,8 +76,7 @@ export default class extends Endpoint { // eslint- } const post = await this.galleryPostsRepository.insert(new MiGalleryPost({ - id: this.idService.genId(), - createdAt: new Date(), + id: this.idService.gen(), updatedAt: new Date(), title: ps.title, description: ps.description, diff --git a/packages/backend/src/server/api/endpoints/gallery/posts/like.ts b/packages/backend/src/server/api/endpoints/gallery/posts/like.ts index 63d9bdc344..e3ae6e4239 100644 --- a/packages/backend/src/server/api/endpoints/gallery/posts/like.ts +++ b/packages/backend/src/server/api/endpoints/gallery/posts/like.ts @@ -83,8 +83,7 @@ export default class extends Endpoint { // eslint- // Create like await this.galleryLikesRepository.insert({ - id: this.idService.genId(), - createdAt: new Date(), + id: this.idService.gen(), postId: post.id, userId: me.id, }); diff --git a/packages/backend/src/server/api/endpoints/hashtags/users.ts b/packages/backend/src/server/api/endpoints/hashtags/users.ts index 5a3eef6581..6f7507fb12 100644 --- a/packages/backend/src/server/api/endpoints/hashtags/users.ts +++ b/packages/backend/src/server/api/endpoints/hashtags/users.ts @@ -66,8 +66,8 @@ export default class extends Endpoint { // eslint- switch (ps.sort) { case '+follower': query.orderBy('user.followersCount', 'DESC'); break; case '-follower': query.orderBy('user.followersCount', 'ASC'); break; - case '+createdAt': query.orderBy('user.createdAt', 'DESC'); break; - case '-createdAt': query.orderBy('user.createdAt', 'ASC'); break; + case '+createdAt': query.orderBy('user.id', 'DESC'); break; + case '-createdAt': query.orderBy('user.id', 'ASC'); break; case '+updatedAt': query.orderBy('user.updatedAt', 'DESC'); break; case '-updatedAt': query.orderBy('user.updatedAt', 'ASC'); break; } diff --git a/packages/backend/src/server/api/endpoints/i/apps.ts b/packages/backend/src/server/api/endpoints/i/apps.ts index 14d507d4b3..7d5020dfe5 100644 --- a/packages/backend/src/server/api/endpoints/i/apps.ts +++ b/packages/backend/src/server/api/endpoints/i/apps.ts @@ -7,6 +7,7 @@ import { Inject, Injectable } from '@nestjs/common'; import { Endpoint } from '@/server/api/endpoint-base.js'; import type { AccessTokensRepository } from '@/models/_.js'; import { DI } from '@/di-symbols.js'; +import { IdService } from '@/core/IdService.js'; export const meta = { requireCredential: true, @@ -27,6 +28,8 @@ export default class extends Endpoint { // eslint- constructor( @Inject(DI.accessTokensRepository) private accessTokensRepository: AccessTokensRepository, + + private idService: IdService, ) { super(meta, paramDef, async (ps, me) => { const query = this.accessTokensRepository.createQueryBuilder('token') @@ -34,8 +37,8 @@ export default class extends Endpoint { // eslint- .leftJoinAndSelect('token.app', 'app'); switch (ps.sort) { - case '+createdAt': query.orderBy('token.createdAt', 'DESC'); break; - case '-createdAt': query.orderBy('token.createdAt', 'ASC'); break; + case '+createdAt': query.orderBy('token.id', 'DESC'); break; + case '-createdAt': query.orderBy('token.id', 'ASC'); break; case '+lastUsedAt': query.orderBy('token.lastUsedAt', 'DESC'); break; case '-lastUsedAt': query.orderBy('token.lastUsedAt', 'ASC'); break; default: query.orderBy('token.id', 'ASC'); break; @@ -46,7 +49,7 @@ export default class extends Endpoint { // eslint- return await Promise.all(tokens.map(token => ({ id: token.id, name: token.name ?? token.app?.name, - createdAt: token.createdAt, + createdAt: this.idService.parse(token.id).date.toISOString(), lastUsedAt: token.lastUsedAt, permission: token.permission, }))); diff --git a/packages/backend/src/server/api/endpoints/i/import-following.ts b/packages/backend/src/server/api/endpoints/i/import-following.ts index 63559fb6d0..1df4aecd0d 100644 --- a/packages/backend/src/server/api/endpoints/i/import-following.ts +++ b/packages/backend/src/server/api/endpoints/i/import-following.ts @@ -52,6 +52,7 @@ export const paramDef = { type: 'object', properties: { fileId: { type: 'string', format: 'misskey:id' }, + withReplies: { type: 'boolean' }, }, required: ['fileId'], } as const; @@ -79,7 +80,7 @@ export default class extends Endpoint { // eslint- ); if (checkMoving ? file.size > 32 * 1024 * 1024 : file.size > 64 * 1024) throw new ApiError(meta.errors.tooBigFile); - this.queueService.createImportFollowingJob(me, file.id); + this.queueService.createImportFollowingJob(me, file.id, ps.withReplies); }); } } diff --git a/packages/backend/src/server/api/endpoints/i/registry/set.ts b/packages/backend/src/server/api/endpoints/i/registry/set.ts index 55f0e66a82..683dbf811e 100644 --- a/packages/backend/src/server/api/endpoints/i/registry/set.ts +++ b/packages/backend/src/server/api/endpoints/i/registry/set.ts @@ -53,8 +53,7 @@ export default class extends Endpoint { // eslint- }); } else { await this.registryItemsRepository.insert({ - id: this.idService.genId(), - createdAt: new Date(), + id: this.idService.gen(), updatedAt: new Date(), userId: me.id, domain: null, diff --git a/packages/backend/src/server/api/endpoints/i/webhooks/create.ts b/packages/backend/src/server/api/endpoints/i/webhooks/create.ts index 28f1fbff00..5f7d81cabc 100644 --- a/packages/backend/src/server/api/endpoints/i/webhooks/create.ts +++ b/packages/backend/src/server/api/endpoints/i/webhooks/create.ts @@ -63,8 +63,7 @@ export default class extends Endpoint { // eslint- } const webhook = await this.webhooksRepository.insert({ - id: this.idService.genId(), - createdAt: new Date(), + id: this.idService.gen(), userId: me.id, name: ps.name, url: ps.url, diff --git a/packages/backend/src/server/api/endpoints/invite/create.ts b/packages/backend/src/server/api/endpoints/invite/create.ts index 6e0aadfe05..3f4b0b7f87 100644 --- a/packages/backend/src/server/api/endpoints/invite/create.ts +++ b/packages/backend/src/server/api/endpoints/invite/create.ts @@ -62,7 +62,7 @@ export default class extends Endpoint { // eslint- if (policies.inviteLimit) { const count = await this.registrationTicketsRepository.countBy({ - createdAt: MoreThan(new Date(Date.now() - (policies.inviteLimitCycle * 1000 * 60))), + id: MoreThan(this.idService.gen(Date.now() - (policies.inviteLimitCycle * 1000 * 60))), createdById: me.id, }); @@ -72,8 +72,7 @@ export default class extends Endpoint { // eslint- } const ticket = await this.registrationTicketsRepository.insert({ - id: this.idService.genId(), - createdAt: new Date(), + id: this.idService.gen(), createdBy: me, createdById: me.id, expiresAt: policies.inviteExpirationTime ? new Date(Date.now() + (policies.inviteExpirationTime * 1000 * 60)) : null, diff --git a/packages/backend/src/server/api/endpoints/invite/limit.ts b/packages/backend/src/server/api/endpoints/invite/limit.ts index 585ded194a..6107ad2852 100644 --- a/packages/backend/src/server/api/endpoints/invite/limit.ts +++ b/packages/backend/src/server/api/endpoints/invite/limit.ts @@ -9,6 +9,7 @@ import { Endpoint } from '@/server/api/endpoint-base.js'; import type { RegistrationTicketsRepository } from '@/models/_.js'; import { RoleService } from '@/core/RoleService.js'; import { DI } from '@/di-symbols.js'; +import { IdService } from '@/core/IdService.js'; export const meta = { tags: ['meta'], @@ -41,12 +42,13 @@ export default class extends Endpoint { // eslint- private registrationTicketsRepository: RegistrationTicketsRepository, private roleService: RoleService, + private idService: IdService, ) { super(meta, paramDef, async (ps, me) => { const policies = await this.roleService.getUserPolicies(me.id); const count = policies.inviteLimit ? await this.registrationTicketsRepository.countBy({ - createdAt: MoreThan(new Date(Date.now() - (policies.inviteExpirationTime * 60 * 1000))), + id: MoreThan(this.idService.gen(Date.now() - (policies.inviteExpirationTime * 60 * 1000))), createdById: me.id, }) : null; diff --git a/packages/backend/src/server/api/endpoints/messaging/history.ts b/packages/backend/src/server/api/endpoints/messaging/history.ts index 83e9e0f783..c314ba46c7 100644 --- a/packages/backend/src/server/api/endpoints/messaging/history.ts +++ b/packages/backend/src/server/api/endpoints/messaging/history.ts @@ -73,7 +73,7 @@ export default class extends Endpoint { // eslint- : history.map(m => (m.userId === me.id) ? m.recipientId! : m.userId!); const query = this.messagingMessagesRepository.createQueryBuilder('message') - .orderBy('message.createdAt', 'DESC'); + .orderBy('message.id', 'DESC'); if (ps.group) { query.where('message.groupId IN (:...groups)', { groups: groups }); diff --git a/packages/backend/src/server/api/endpoints/miauth/gen-token.ts b/packages/backend/src/server/api/endpoints/miauth/gen-token.ts index 62419823b7..1b7d533d01 100644 --- a/packages/backend/src/server/api/endpoints/miauth/gen-token.ts +++ b/packages/backend/src/server/api/endpoints/miauth/gen-token.ts @@ -59,8 +59,7 @@ export default class extends Endpoint { // eslint- // Insert access token doc await this.accessTokensRepository.insert({ - id: this.idService.genId(), - createdAt: now, + id: this.idService.gen(now.getTime()), lastUsedAt: now, session: ps.session, userId: me.id, diff --git a/packages/backend/src/server/api/endpoints/notes/events/search.ts b/packages/backend/src/server/api/endpoints/notes/events/search.ts index 412c198b0f..de6352e7a4 100644 --- a/packages/backend/src/server/api/endpoints/notes/events/search.ts +++ b/packages/backend/src/server/api/endpoints/notes/events/search.ts @@ -144,7 +144,7 @@ export default class extends Endpoint { // eslint- if (ps.sinceDate && ps.untilDate && ps.sinceDate > ps.untilDate) throw new ApiError(meta.errors.invalidParam); - if (ps.sinceDate || ps.sortBy !== 'createdAt') { + if (ps.sinceDate ?? ps.sortBy !== 'createdAt') { const sinceDate = ps.sinceDate ? new Date(ps.sinceDate) : new Date(); query.andWhere('event.start > :sinceDate', { sinceDate: sinceDate }) .andWhere('(event.end IS NULL OR event.end > :sinceDate)', { sinceDate: sinceDate }); @@ -155,7 +155,7 @@ export default class extends Endpoint { // eslint- } if (ps.sortBy === 'createdAt') { - query.orderBy('note.createdAt', 'DESC'); + query.orderBy('note.id', 'DESC'); } else { query.orderBy('event.start', 'ASC'); } diff --git a/packages/backend/src/server/api/endpoints/notes/favorites/create.ts b/packages/backend/src/server/api/endpoints/notes/favorites/create.ts index 0ea36fe24c..5918614a1d 100644 --- a/packages/backend/src/server/api/endpoints/notes/favorites/create.ts +++ b/packages/backend/src/server/api/endpoints/notes/favorites/create.ts @@ -80,8 +80,7 @@ export default class extends Endpoint { // eslint- // Create favorite await this.noteFavoritesRepository.insert({ - id: this.idService.genId(), - createdAt: new Date(), + id: this.idService.gen(), noteId: note.id, userId: me.id, }); diff --git a/packages/backend/src/server/api/endpoints/notes/hybrid-timeline.ts b/packages/backend/src/server/api/endpoints/notes/hybrid-timeline.ts index 6a68c8a310..3121600ed5 100644 --- a/packages/backend/src/server/api/endpoints/notes/hybrid-timeline.ts +++ b/packages/backend/src/server/api/endpoints/notes/hybrid-timeline.ts @@ -5,7 +5,6 @@ import { Brackets } from 'typeorm'; import { Inject, Injectable } from '@nestjs/common'; -import * as Redis from 'ioredis'; import type { NotesRepository, FollowingsRepository, MiNote } from '@/models/_.js'; import { Endpoint } from '@/server/api/endpoint-base.js'; import ActiveUsersChart from '@/core/chart/charts/active-users.js'; @@ -15,7 +14,9 @@ import { RoleService } from '@/core/RoleService.js'; import { IdService } from '@/core/IdService.js'; import { isUserRelated } from '@/misc/is-user-related.js'; import { CacheService } from '@/core/CacheService.js'; -import { RedisTimelineService } from '@/core/RedisTimelineService.js'; +import { FunoutTimelineService } from '@/core/FunoutTimelineService.js'; +import { QueryService } from '@/core/QueryService.js'; +import { UserFollowingService } from '@/core/UserFollowingService.js'; import { ApiError } from '../../error.js'; export const meta = { @@ -64,9 +65,6 @@ export const paramDef = { @Injectable() export default class extends Endpoint { // eslint-disable-line import/no-default-export constructor( - @Inject(DI.redisForTimelines) - private redisForTimelines: Redis.Redis, - @Inject(DI.notesRepository) private notesRepository: NotesRepository, @@ -75,11 +73,13 @@ export default class extends Endpoint { // eslint- private activeUsersChart: ActiveUsersChart, private idService: IdService, private cacheService: CacheService, - private redisTimelineService: RedisTimelineService, + private funoutTimelineService: FunoutTimelineService, + private queryService: QueryService, + private userFollowingService: UserFollowingService, ) { super(meta, paramDef, async (ps, me) => { - const untilId = ps.untilId ?? (ps.untilDate ? this.idService.genId(new Date(ps.untilDate!)) : null); - const sinceId = ps.sinceId ?? (ps.sinceDate ? this.idService.genId(new Date(ps.sinceDate!)) : null); + const untilId = ps.untilId ?? (ps.untilDate ? this.idService.gen(ps.untilDate!) : null); + const sinceId = ps.sinceId ?? (ps.sinceDate ? this.idService.gen(ps.sinceDate!) : null); const policies = await this.roleService.getUserPolicies(me.id); if (!policies.ltlAvailable) { @@ -97,75 +97,156 @@ export default class extends Endpoint { // eslint- ]); let noteIds: string[]; + let shouldFallbackToDb = false; if (ps.withFiles) { - const [htlNoteIds, ltlNoteIds] = await this.redisTimelineService.getMulti([ + const [htlNoteIds, ltlNoteIds] = await this.funoutTimelineService.getMulti([ `homeTimelineWithFiles:${me.id}`, 'localTimelineWithFiles', ], untilId, sinceId); noteIds = Array.from(new Set([...htlNoteIds, ...ltlNoteIds])); } else if (ps.withReplies) { - const [htlNoteIds, ltlNoteIds, ltlReplyNoteIds] = await this.redisTimelineService.getMulti([ + const [htlNoteIds, ltlNoteIds, ltlReplyNoteIds] = await this.funoutTimelineService.getMulti([ `homeTimeline:${me.id}`, 'localTimeline', 'localTimelineWithReplies', ], untilId, sinceId); noteIds = Array.from(new Set([...htlNoteIds, ...ltlNoteIds, ...ltlReplyNoteIds])); } else { - const [htlNoteIds, ltlNoteIds] = await this.redisTimelineService.getMulti([ + const [htlNoteIds, ltlNoteIds] = await this.funoutTimelineService.getMulti([ `homeTimeline:${me.id}`, 'localTimeline', ], untilId, sinceId); noteIds = Array.from(new Set([...htlNoteIds, ...ltlNoteIds])); + shouldFallbackToDb = htlNoteIds.length === 0; } noteIds.sort((a, b) => a > b ? -1 : 1); noteIds = noteIds.slice(0, ps.limit); - if (noteIds.length === 0) { - return []; - } + shouldFallbackToDb = shouldFallbackToDb || (noteIds.length === 0); - const query = this.notesRepository.createQueryBuilder('note') - .where('note.id IN (:...noteIds)', { noteIds: noteIds }) - .innerJoinAndSelect('note.user', 'user') - .leftJoinAndSelect('note.reply', 'reply') - .leftJoinAndSelect('note.renote', 'renote') - .leftJoinAndSelect('reply.user', 'replyUser') - .leftJoinAndSelect('renote.user', 'renoteUser') - .leftJoinAndSelect('note.channel', 'channel'); - - if (ps.withCats) { - query.andWhere('(select "isCat" from "user" where id = note."userId")'); - } + if (!shouldFallbackToDb) { + const query = this.notesRepository.createQueryBuilder('note') + .where('note.id IN (:...noteIds)', { noteIds: noteIds }) + .innerJoinAndSelect('note.user', 'user') + .leftJoinAndSelect('note.reply', 'reply') + .leftJoinAndSelect('note.renote', 'renote') + .leftJoinAndSelect('reply.user', 'replyUser') + .leftJoinAndSelect('renote.user', 'renoteUser') + .leftJoinAndSelect('note.channel', 'channel'); + + if (ps.withCats) { + query.andWhere('(select "isCat" from "user" where id = note."userId")'); + } + + let timeline = await query.getMany(); - let timeline = await query.getMany(); + timeline = timeline.filter(note => { + if (note.userId === me.id) { + return true; + } + if (isUserRelated(note, userIdsWhoBlockingMe)) return false; + if (isUserRelated(note, userIdsWhoMeMuting)) return false; + if (note.renoteId) { + if (note.text == null && note.fileIds.length === 0 && !note.hasPoll) { + if (isUserRelated(note, userIdsWhoMeMutingRenotes)) return false; + if (ps.withRenotes === false) return false; + } + } - timeline = timeline.filter(note => { - if (note.userId === me.id) { return true; + }); + + // TODO: フィルタした結果件数が足りなかった場合の対応 + + timeline.sort((a, b) => a.id > b.id ? -1 : 1); + + process.nextTick(() => { + this.activeUsersChart.read(me); + }); + + return await this.noteEntityService.packMany(timeline, me); + } else { // fallback to db + const followees = await this.userFollowingService.getFollowees(me.id); + + const query = this.queryService.makePaginationQuery(this.notesRepository.createQueryBuilder('note'), ps.sinceId, ps.untilId, ps.sinceDate, ps.untilDate) + .andWhere(new Brackets(qb => { + if (followees.length > 0) { + const meOrFolloweeIds = [me.id, ...followees.map(f => f.followeeId)]; + qb.where('note.userId IN (:...meOrFolloweeIds)', { meOrFolloweeIds: meOrFolloweeIds }); + qb.orWhere('(note.visibility = \'public\') AND (note.userHost IS NULL)'); + } else { + qb.where('note.userId = :meId', { meId: me.id }); + qb.orWhere('(note.visibility = \'public\') AND (note.userHost IS NULL)'); + } + })) + .innerJoinAndSelect('note.user', 'user') + .leftJoinAndSelect('note.reply', 'reply') + .leftJoinAndSelect('note.renote', 'renote') + .leftJoinAndSelect('reply.user', 'replyUser') + .leftJoinAndSelect('renote.user', 'renoteUser'); + + if (!ps.withReplies) { + query.andWhere(new Brackets(qb => { + qb + .where('note.replyId IS NULL') // 返信ではない + .orWhere(new Brackets(qb => { + qb // 返信だけど投稿者自身への返信 + .where('note.replyId IS NOT NULL') + .andWhere('note.replyUserId = note.userId'); + })); + })); } - if (isUserRelated(note, userIdsWhoBlockingMe)) return false; - if (isUserRelated(note, userIdsWhoMeMuting)) return false; - if (note.renoteId) { - if (note.text == null && note.fileIds.length === 0 && !note.hasPoll) { - if (isUserRelated(note, userIdsWhoMeMutingRenotes)) return false; - if (ps.withRenotes === false) return false; - } + + this.queryService.generateVisibilityQuery(query, me); + this.queryService.generateMutedUserQuery(query, me); + this.queryService.generateBlockedUserQuery(query, me); + this.queryService.generateMutedUserRenotesQueryForNotes(query, me); + + if (ps.includeMyRenotes === false) { + query.andWhere(new Brackets(qb => { + qb.orWhere('note.userId != :meId', { meId: me.id }); + qb.orWhere('note.renoteId IS NULL'); + qb.orWhere('note.text IS NOT NULL'); + qb.orWhere('note.fileIds != \'{}\''); + qb.orWhere('0 < (SELECT COUNT(*) FROM poll WHERE poll."noteId" = note.id)'); + })); } - return true; - }); + if (ps.includeRenotedMyNotes === false) { + query.andWhere(new Brackets(qb => { + qb.orWhere('note.renoteUserId != :meId', { meId: me.id }); + qb.orWhere('note.renoteId IS NULL'); + qb.orWhere('note.text IS NOT NULL'); + qb.orWhere('note.fileIds != \'{}\''); + qb.orWhere('0 < (SELECT COUNT(*) FROM poll WHERE poll."noteId" = note.id)'); + })); + } - // TODO: フィルタした結果件数が足りなかった場合の対応 + if (ps.includeLocalRenotes === false) { + query.andWhere(new Brackets(qb => { + qb.orWhere('note.renoteUserHost IS NOT NULL'); + qb.orWhere('note.renoteId IS NULL'); + qb.orWhere('note.text IS NOT NULL'); + qb.orWhere('note.fileIds != \'{}\''); + qb.orWhere('0 < (SELECT COUNT(*) FROM poll WHERE poll."noteId" = note.id)'); + })); + } - timeline.sort((a, b) => a.id > b.id ? -1 : 1); + if (ps.withFiles) { + query.andWhere('note.fileIds != \'{}\''); + } + //#endregion + + const timeline = await query.limit(ps.limit).getMany(); - process.nextTick(() => { - this.activeUsersChart.read(me); - }); + process.nextTick(() => { + this.activeUsersChart.read(me); + }); - return await this.noteEntityService.packMany(timeline, me); + return await this.noteEntityService.packMany(timeline, me); + } }); } } diff --git a/packages/backend/src/server/api/endpoints/notes/local-timeline.ts b/packages/backend/src/server/api/endpoints/notes/local-timeline.ts index f56dcf7a87..dd336aa4f1 100644 --- a/packages/backend/src/server/api/endpoints/notes/local-timeline.ts +++ b/packages/backend/src/server/api/endpoints/notes/local-timeline.ts @@ -5,7 +5,6 @@ import { Brackets } from 'typeorm'; import { Inject, Injectable } from '@nestjs/common'; -import * as Redis from 'ioredis'; import type { MiNote, NotesRepository } from '@/models/_.js'; import { Endpoint } from '@/server/api/endpoint-base.js'; import { NoteEntityService } from '@/core/entities/NoteEntityService.js'; @@ -15,7 +14,8 @@ import { RoleService } from '@/core/RoleService.js'; import { IdService } from '@/core/IdService.js'; import { CacheService } from '@/core/CacheService.js'; import { isUserRelated } from '@/misc/is-user-related.js'; -import { RedisTimelineService } from '@/core/RedisTimelineService.js'; +import { FunoutTimelineService } from '@/core/FunoutTimelineService.js'; +import { QueryService } from '@/core/QueryService.js'; import { ApiError } from '../../error.js'; export const meta = { @@ -60,9 +60,6 @@ export const paramDef = { @Injectable() export default class extends Endpoint { // eslint-disable-line import/no-default-export constructor( - @Inject(DI.redisForTimelines) - private redisForTimelines: Redis.Redis, - @Inject(DI.notesRepository) private notesRepository: NotesRepository, @@ -71,11 +68,12 @@ export default class extends Endpoint { // eslint- private activeUsersChart: ActiveUsersChart, private idService: IdService, private cacheService: CacheService, - private redisTimelineService: RedisTimelineService, + private funoutTimelineService: FunoutTimelineService, + private queryService: QueryService, ) { super(meta, paramDef, async (ps, me) => { - const untilId = ps.untilId ?? (ps.untilDate ? this.idService.genId(new Date(ps.untilDate!)) : null); - const sinceId = ps.sinceId ?? (ps.sinceDate ? this.idService.genId(new Date(ps.sinceDate!)) : null); + const untilId = ps.untilId ?? (ps.untilDate ? this.idService.gen(ps.untilDate!) : null); + const sinceId = ps.sinceId ?? (ps.sinceDate ? this.idService.gen(ps.sinceDate!) : null); const policies = await this.roleService.getUserPolicies(me ? me.id : null); if (!policies.ltlAvailable) { @@ -95,9 +93,9 @@ export default class extends Endpoint { // eslint- let noteIds: string[]; if (ps.withFiles) { - noteIds = await this.redisTimelineService.get('localTimelineWithFiles', untilId, sinceId); + noteIds = await this.funoutTimelineService.get('localTimelineWithFiles', untilId, sinceId); } else { - const [nonReplyNoteIds, replyNoteIds] = await this.redisTimelineService.getMulti([ + const [nonReplyNoteIds, replyNoteIds] = await this.funoutTimelineService.getMulti([ 'localTimeline', 'localTimelineWithReplies', ], untilId, sinceId); @@ -107,53 +105,91 @@ export default class extends Endpoint { // eslint- noteIds = noteIds.slice(0, ps.limit); - if (noteIds.length === 0) { - return []; - } + if (noteIds.length > 0) { + const query = this.notesRepository.createQueryBuilder('note') + .where('note.id IN (:...noteIds)', { noteIds: noteIds }) + .innerJoinAndSelect('note.user', 'user') + .leftJoinAndSelect('note.reply', 'reply') + .leftJoinAndSelect('note.renote', 'renote') + .leftJoinAndSelect('reply.user', 'replyUser') + .leftJoinAndSelect('renote.user', 'renoteUser') + .leftJoinAndSelect('note.channel', 'channel'); + + if (ps.withCats) { + query.andWhere('(select "isCat" from "user" where id = note."userId")'); + } - const query = this.notesRepository.createQueryBuilder('note') - .where('note.id IN (:...noteIds)', { noteIds: noteIds }) - .innerJoinAndSelect('note.user', 'user') - .leftJoinAndSelect('note.reply', 'reply') - .leftJoinAndSelect('note.renote', 'renote') - .leftJoinAndSelect('reply.user', 'replyUser') - .leftJoinAndSelect('renote.user', 'renoteUser') - .leftJoinAndSelect('note.channel', 'channel'); - - if (ps.withCats) { - query.andWhere('(select "isCat" from "user" where id = note."userId")'); - } + let timeline = await query.getMany(); - let timeline = await query.getMany(); + timeline = timeline.filter(note => { + if (me && (note.userId === me.id)) { + return true; + } + if (!ps.withReplies && note.replyId && (me == null || note.replyUserId !== me.id)) return false; + if (me && isUserRelated(note, userIdsWhoBlockingMe)) return false; + if (me && isUserRelated(note, userIdsWhoMeMuting)) return false; + if (note.renoteId) { + if (note.text == null && note.fileIds.length === 0 && !note.hasPoll) { + if (me && isUserRelated(note, userIdsWhoMeMutingRenotes)) return false; + if (ps.withRenotes === false) return false; + } + } - timeline = timeline.filter(note => { - if (me && (note.userId === me.id)) { return true; - } - if (!ps.withReplies && note.replyId && (me == null || note.replyUserId !== me.id)) return false; - if (me && isUserRelated(note, userIdsWhoBlockingMe)) return false; - if (me && isUserRelated(note, userIdsWhoMeMuting)) return false; - if (note.renoteId) { - if (note.text == null && note.fileIds.length === 0 && !note.hasPoll) { - if (me && isUserRelated(note, userIdsWhoMeMutingRenotes)) return false; - if (ps.withRenotes === false) return false; - } - } + }); - return true; - }); + // TODO: フィルタした結果件数が足りなかった場合の対応 - // TODO: フィルタした結果件数が足りなかった場合の対応 + timeline.sort((a, b) => a.id > b.id ? -1 : 1); - timeline.sort((a, b) => a.id > b.id ? -1 : 1); + process.nextTick(() => { + if (me) { + this.activeUsersChart.read(me); + } + }); + + return await this.noteEntityService.packMany(timeline, me); + } else { // fallback to db + const query = this.queryService.makePaginationQuery(this.notesRepository.createQueryBuilder('note'), + ps.sinceId, ps.untilId, ps.sinceDate, ps.untilDate) + .andWhere('(note.visibility = \'public\') AND (note.userHost IS NULL)') + .innerJoinAndSelect('note.user', 'user') + .leftJoinAndSelect('note.reply', 'reply') + .leftJoinAndSelect('note.renote', 'renote') + .leftJoinAndSelect('reply.user', 'replyUser') + .leftJoinAndSelect('renote.user', 'renoteUser'); + + this.queryService.generateVisibilityQuery(query, me); + if (me) this.queryService.generateMutedUserQuery(query, me); + if (me) this.queryService.generateBlockedUserQuery(query, me); + if (me) this.queryService.generateMutedUserRenotesQueryForNotes(query, me); + + if (ps.withFiles) { + query.andWhere('note.fileIds != \'{}\''); + } - process.nextTick(() => { - if (me) { - this.activeUsersChart.read(me); + if (!ps.withReplies) { + query.andWhere(new Brackets(qb => { + qb + .where('note.replyId IS NULL') // 返信ではない + .orWhere(new Brackets(qb => { + qb // 返信だけど投稿者自身への返信 + .where('note.replyId IS NOT NULL') + .andWhere('note.replyUserId = note.userId'); + })); + })); } - }); - return await this.noteEntityService.packMany(timeline, me); + const timeline = await query.limit(ps.limit).getMany(); + + process.nextTick(() => { + if (me) { + this.activeUsersChart.read(me); + } + }); + + return await this.noteEntityService.packMany(timeline, me); + } }); } } diff --git a/packages/backend/src/server/api/endpoints/notes/polls/recommendation.ts b/packages/backend/src/server/api/endpoints/notes/polls/recommendation.ts index 66ab9ecacc..b88c6c8254 100644 --- a/packages/backend/src/server/api/endpoints/notes/polls/recommendation.ts +++ b/packages/backend/src/server/api/endpoints/notes/polls/recommendation.ts @@ -98,7 +98,7 @@ export default class extends Endpoint { // eslint- id: In(polls.map(poll => poll.noteId)), }, order: { - createdAt: 'DESC', + id: 'DESC', }, }); diff --git a/packages/backend/src/server/api/endpoints/notes/polls/vote.ts b/packages/backend/src/server/api/endpoints/notes/polls/vote.ts index 265687a144..1509705b16 100644 --- a/packages/backend/src/server/api/endpoints/notes/polls/vote.ts +++ b/packages/backend/src/server/api/endpoints/notes/polls/vote.ts @@ -145,8 +145,7 @@ export default class extends Endpoint { // eslint- // Create vote const vote = await this.pollVotesRepository.insert({ - id: this.idService.genId(), - createdAt, + id: this.idService.gen(createdAt.getTime()), noteId: note.id, userId: me.id, choice: ps.choice, diff --git a/packages/backend/src/server/api/endpoints/notes/thread-muting/create.ts b/packages/backend/src/server/api/endpoints/notes/thread-muting/create.ts index 8311bbdeff..374ef6438d 100644 --- a/packages/backend/src/server/api/endpoints/notes/thread-muting/create.ts +++ b/packages/backend/src/server/api/endpoints/notes/thread-muting/create.ts @@ -72,8 +72,7 @@ export default class extends Endpoint { // eslint- await this.noteReadService.read(me.id, mutedNotes); await this.noteThreadMutingsRepository.insert({ - id: this.idService.genId(), - createdAt: new Date(), + id: this.idService.gen(), threadId: note.threadId ?? note.id, userId: me.id, }); diff --git a/packages/backend/src/server/api/endpoints/notes/timeline.ts b/packages/backend/src/server/api/endpoints/notes/timeline.ts index d9f11b60c0..97bb113ea4 100644 --- a/packages/backend/src/server/api/endpoints/notes/timeline.ts +++ b/packages/backend/src/server/api/endpoints/notes/timeline.ts @@ -5,8 +5,7 @@ import { Brackets } from 'typeorm'; import { Inject, Injectable } from '@nestjs/common'; -import * as Redis from 'ioredis'; -import type { NotesRepository, FollowingsRepository, MiNote } from '@/models/_.js'; +import type { NotesRepository } from '@/models/_.js'; import { Endpoint } from '@/server/api/endpoint-base.js'; import { QueryService } from '@/core/QueryService.js'; import ActiveUsersChart from '@/core/chart/charts/active-users.js'; @@ -15,7 +14,8 @@ import { DI } from '@/di-symbols.js'; import { IdService } from '@/core/IdService.js'; import { CacheService } from '@/core/CacheService.js'; import { isUserRelated } from '@/misc/is-user-related.js'; -import { RedisTimelineService } from '@/core/RedisTimelineService.js'; +import { FunoutTimelineService } from '@/core/FunoutTimelineService.js'; +import { UserFollowingService } from '@/core/UserFollowingService.js'; export const meta = { tags: ['notes'], @@ -54,9 +54,6 @@ export const paramDef = { @Injectable() export default class extends Endpoint { // eslint-disable-line import/no-default-export constructor( - @Inject(DI.redisForTimelines) - private redisForTimelines: Redis.Redis, - @Inject(DI.notesRepository) private notesRepository: NotesRepository, @@ -64,11 +61,13 @@ export default class extends Endpoint { // eslint- private activeUsersChart: ActiveUsersChart, private idService: IdService, private cacheService: CacheService, - private redisTimelineService: RedisTimelineService, + private funoutTimelineService: FunoutTimelineService, + private userFollowingService: UserFollowingService, + private queryService: QueryService, ) { super(meta, paramDef, async (ps, me) => { - const untilId = ps.untilId ?? (ps.untilDate ? this.idService.genId(new Date(ps.untilDate!)) : null); - const sinceId = ps.sinceId ?? (ps.sinceDate ? this.idService.genId(new Date(ps.sinceDate!)) : null); + const untilId = ps.untilId ?? (ps.untilDate ? this.idService.gen(ps.untilDate!) : null); + const sinceId = ps.sinceId ?? (ps.sinceDate ? this.idService.gen(ps.sinceDate!) : null); const [ followings, @@ -82,56 +81,131 @@ export default class extends Endpoint { // eslint- this.cacheService.userBlockedCache.fetch(me.id), ]); - let noteIds = await this.redisTimelineService.get(ps.withFiles ? `homeTimelineWithFiles:${me.id}` : `homeTimeline:${me.id}`, untilId, sinceId); + let noteIds = await this.funoutTimelineService.get(ps.withFiles ? `homeTimelineWithFiles:${me.id}` : `homeTimeline:${me.id}`, untilId, sinceId); noteIds = noteIds.slice(0, ps.limit); - if (noteIds.length === 0) { - return []; - } + if (noteIds.length > 0) { + const query = this.notesRepository.createQueryBuilder('note') + .where('note.id IN (:...noteIds)', { noteIds: noteIds }) + .innerJoinAndSelect('note.user', 'user') + .leftJoinAndSelect('note.reply', 'reply') + .leftJoinAndSelect('note.renote', 'renote') + .leftJoinAndSelect('reply.user', 'replyUser') + .leftJoinAndSelect('renote.user', 'renoteUser') + .leftJoinAndSelect('note.channel', 'channel'); + + if (ps.withCats) { + query.andWhere('(select "isCat" from "user" where id = note."userId")'); + } - const query = this.notesRepository.createQueryBuilder('note') - .where('note.id IN (:...noteIds)', { noteIds: noteIds }) - .innerJoinAndSelect('note.user', 'user') - .leftJoinAndSelect('note.reply', 'reply') - .leftJoinAndSelect('note.renote', 'renote') - .leftJoinAndSelect('reply.user', 'replyUser') - .leftJoinAndSelect('renote.user', 'renoteUser') - .leftJoinAndSelect('note.channel', 'channel'); - - if (ps.withCats) { - query.andWhere('(select "isCat" from "user" where id = note."userId")'); - } + let timeline = await query.getMany(); - let timeline = await query.getMany(); + timeline = timeline.filter(note => { + if (note.userId === me.id) { + return true; + } + if (isUserRelated(note, userIdsWhoBlockingMe)) return false; + if (isUserRelated(note, userIdsWhoMeMuting)) return false; + if (note.renoteId) { + if (note.text == null && note.fileIds.length === 0 && !note.hasPoll) { + if (isUserRelated(note, userIdsWhoMeMutingRenotes)) return false; + if (ps.withRenotes === false) return false; + } + } + if (note.reply && note.reply.visibility === 'followers') { + if (!Object.hasOwn(followings, note.reply.userId)) return false; + } - timeline = timeline.filter(note => { - if (note.userId === me.id) { return true; + }); + + // TODO: フィルタした結果件数が足りなかった場合の対応 + + timeline.sort((a, b) => a.id > b.id ? -1 : 1); + + process.nextTick(() => { + this.activeUsersChart.read(me); + }); + + return await this.noteEntityService.packMany(timeline, me); + } else { // fallback to db + const followees = await this.userFollowingService.getFollowees(me.id); + + //#region Construct query + const query = this.queryService.makePaginationQuery(this.notesRepository.createQueryBuilder('note'), ps.sinceId, ps.untilId, ps.sinceDate, ps.untilDate) + .andWhere('note.channelId IS NULL') + .innerJoinAndSelect('note.user', 'user') + .leftJoinAndSelect('note.reply', 'reply') + .leftJoinAndSelect('note.renote', 'renote') + .leftJoinAndSelect('reply.user', 'replyUser') + .leftJoinAndSelect('renote.user', 'renoteUser'); + + if (followees.length > 0) { + const meOrFolloweeIds = [me.id, ...followees.map(f => f.followeeId)]; + + query.andWhere('note.userId IN (:...meOrFolloweeIds)', { meOrFolloweeIds: meOrFolloweeIds }); + } else { + query.andWhere('note.userId = :meId', { meId: me.id }); } - if (isUserRelated(note, userIdsWhoBlockingMe)) return false; - if (isUserRelated(note, userIdsWhoMeMuting)) return false; - if (note.renoteId) { - if (note.text == null && note.fileIds.length === 0 && !note.hasPoll) { - if (isUserRelated(note, userIdsWhoMeMutingRenotes)) return false; - if (ps.withRenotes === false) return false; - } + + query.andWhere(new Brackets(qb => { + qb + .where('note.replyId IS NULL') // 返信ではない + .orWhere(new Brackets(qb => { + qb // 返信だけど投稿者自身への返信 + .where('note.replyId IS NOT NULL') + .andWhere('note.replyUserId = note.userId'); + })); + })); + + this.queryService.generateVisibilityQuery(query, me); + this.queryService.generateMutedUserQuery(query, me); + this.queryService.generateBlockedUserQuery(query, me); + this.queryService.generateMutedUserRenotesQueryForNotes(query, me); + + if (ps.includeMyRenotes === false) { + query.andWhere(new Brackets(qb => { + qb.orWhere('note.userId != :meId', { meId: me.id }); + qb.orWhere('note.renoteId IS NULL'); + qb.orWhere('note.text IS NOT NULL'); + qb.orWhere('note.fileIds != \'{}\''); + qb.orWhere('0 < (SELECT COUNT(*) FROM poll WHERE poll."noteId" = note.id)'); + })); } - if (note.reply && note.reply.visibility === 'followers') { - if (!Object.hasOwn(followings, note.reply.userId)) return false; + + if (ps.includeRenotedMyNotes === false) { + query.andWhere(new Brackets(qb => { + qb.orWhere('note.renoteUserId != :meId', { meId: me.id }); + qb.orWhere('note.renoteId IS NULL'); + qb.orWhere('note.text IS NOT NULL'); + qb.orWhere('note.fileIds != \'{}\''); + qb.orWhere('0 < (SELECT COUNT(*) FROM poll WHERE poll."noteId" = note.id)'); + })); } - return true; - }); + if (ps.includeLocalRenotes === false) { + query.andWhere(new Brackets(qb => { + qb.orWhere('note.renoteUserHost IS NOT NULL'); + qb.orWhere('note.renoteId IS NULL'); + qb.orWhere('note.text IS NOT NULL'); + qb.orWhere('note.fileIds != \'{}\''); + qb.orWhere('0 < (SELECT COUNT(*) FROM poll WHERE poll."noteId" = note.id)'); + })); + } - // TODO: フィルタした結果件数が足りなかった場合の対応 + if (ps.withFiles) { + query.andWhere('note.fileIds != \'{}\''); + } + //#endregion - timeline.sort((a, b) => a.id > b.id ? -1 : 1); + const timeline = await query.limit(ps.limit).getMany(); - process.nextTick(() => { - this.activeUsersChart.read(me); - }); + process.nextTick(() => { + this.activeUsersChart.read(me); + }); - return await this.noteEntityService.packMany(timeline, me); + return await this.noteEntityService.packMany(timeline, me); + } }); } } diff --git a/packages/backend/src/server/api/endpoints/notes/update.ts b/packages/backend/src/server/api/endpoints/notes/update.ts index 311a0aafd2..a4fdebe383 100644 --- a/packages/backend/src/server/api/endpoints/notes/update.ts +++ b/packages/backend/src/server/api/endpoints/notes/update.ts @@ -74,11 +74,13 @@ export default class extends Endpoint { // eslint- throw new ApiError(meta.errors.noSuchNote); } + const updatedAtHistory = note.updatedAtHistory ? note.updatedAtHistory : []; await this.notesRepository.update({ id: note.id }, { updatedAt: new Date(), cw: ps.cw, text: ps.text, - noteEditHistory: [...note.noteEditHistory, note.text!], + updatedAtHistory: [...updatedAtHistory, new Date()], + noteEditHistory: [...note.noteEditHistory, (note.cw ? note.cw + '\n' : '') + note.text!], }); this.globalEventService.publishNoteStream(note.id, 'updated', { diff --git a/packages/backend/src/server/api/endpoints/notes/user-list-timeline.ts b/packages/backend/src/server/api/endpoints/notes/user-list-timeline.ts index e72dad9779..082871929e 100644 --- a/packages/backend/src/server/api/endpoints/notes/user-list-timeline.ts +++ b/packages/backend/src/server/api/endpoints/notes/user-list-timeline.ts @@ -3,19 +3,16 @@ * SPDX-License-Identifier: AGPL-3.0-only */ -import { Brackets } from 'typeorm'; import { Inject, Injectable } from '@nestjs/common'; -import * as Redis from 'ioredis'; -import type { NotesRepository, UserListsRepository, UserListMembershipsRepository, MiNote } from '@/models/_.js'; +import type { NotesRepository, UserListsRepository } from '@/models/_.js'; import { Endpoint } from '@/server/api/endpoint-base.js'; -import { QueryService } from '@/core/QueryService.js'; import { NoteEntityService } from '@/core/entities/NoteEntityService.js'; import ActiveUsersChart from '@/core/chart/charts/active-users.js'; import { DI } from '@/di-symbols.js'; import { CacheService } from '@/core/CacheService.js'; import { IdService } from '@/core/IdService.js'; import { isUserRelated } from '@/misc/is-user-related.js'; -import { RedisTimelineService } from '@/core/RedisTimelineService.js'; +import { FunoutTimelineService } from '@/core/FunoutTimelineService.js'; import { ApiError } from '../../error.js'; export const meta = { @@ -68,9 +65,6 @@ export const paramDef = { @Injectable() export default class extends Endpoint { // eslint-disable-line import/no-default-export constructor( - @Inject(DI.redisForTimelines) - private redisForTimelines: Redis.Redis, - @Inject(DI.notesRepository) private notesRepository: NotesRepository, @@ -81,11 +75,11 @@ export default class extends Endpoint { // eslint- private activeUsersChart: ActiveUsersChart, private cacheService: CacheService, private idService: IdService, - private redisTimelineService: RedisTimelineService, + private funoutTimelineService: FunoutTimelineService, ) { super(meta, paramDef, async (ps, me) => { - const untilId = ps.untilId ?? (ps.untilDate ? this.idService.genId(new Date(ps.untilDate!)) : null); - const sinceId = ps.sinceId ?? (ps.sinceDate ? this.idService.genId(new Date(ps.sinceDate!)) : null); + const untilId = ps.untilId ?? (ps.untilDate ? this.idService.gen(ps.untilDate!) : null); + const sinceId = ps.sinceId ?? (ps.sinceDate ? this.idService.gen(ps.sinceDate!) : null); const list = await this.userListsRepository.findOneBy({ id: ps.listId, @@ -106,7 +100,7 @@ export default class extends Endpoint { // eslint- this.cacheService.userBlockedCache.fetch(me.id), ]); - let noteIds = await this.redisTimelineService.get(ps.withFiles ? `userListTimelineWithFiles:${list.id}` : `userListTimeline:${list.id}`, untilId, sinceId); + let noteIds = await this.funoutTimelineService.get(ps.withFiles ? `userListTimelineWithFiles:${list.id}` : `userListTimeline:${list.id}`, untilId, sinceId); noteIds = noteIds.slice(0, ps.limit); if (noteIds.length === 0) { diff --git a/packages/backend/src/server/api/endpoints/pages/create.ts b/packages/backend/src/server/api/endpoints/pages/create.ts index 00a60c7634..8538019484 100644 --- a/packages/backend/src/server/api/endpoints/pages/create.ts +++ b/packages/backend/src/server/api/endpoints/pages/create.ts @@ -103,8 +103,7 @@ export default class extends Endpoint { // eslint- }); const page = await this.pagesRepository.insert(new MiPage({ - id: this.idService.genId(), - createdAt: new Date(), + id: this.idService.gen(), updatedAt: new Date(), title: ps.title, name: ps.name, diff --git a/packages/backend/src/server/api/endpoints/pages/like.ts b/packages/backend/src/server/api/endpoints/pages/like.ts index 088a8feb83..433a19439c 100644 --- a/packages/backend/src/server/api/endpoints/pages/like.ts +++ b/packages/backend/src/server/api/endpoints/pages/like.ts @@ -83,8 +83,7 @@ export default class extends Endpoint { // eslint- // Create like await this.pageLikesRepository.insert({ - id: this.idService.genId(), - createdAt: new Date(), + id: this.idService.gen(), pageId: page.id, userId: me.id, }); diff --git a/packages/backend/src/server/api/endpoints/promo/read.ts b/packages/backend/src/server/api/endpoints/promo/read.ts index eb4dd90033..b1af29b58e 100644 --- a/packages/backend/src/server/api/endpoints/promo/read.ts +++ b/packages/backend/src/server/api/endpoints/promo/read.ts @@ -60,8 +60,7 @@ export default class extends Endpoint { // eslint- } await this.promoReadsRepository.insert({ - id: this.idService.genId(), - createdAt: new Date(), + id: this.idService.gen(), noteId: note.id, userId: me.id, }); diff --git a/packages/backend/src/server/api/endpoints/renote-mute/create.ts b/packages/backend/src/server/api/endpoints/renote-mute/create.ts index 7ffe65aaf9..cf7a9126d0 100644 --- a/packages/backend/src/server/api/endpoints/renote-mute/create.ts +++ b/packages/backend/src/server/api/endpoints/renote-mute/create.ts @@ -90,8 +90,7 @@ export default class extends Endpoint { // eslint- // Create mute await this.renoteMutingsRepository.insert({ - id: this.idService.genId(), - createdAt: new Date(), + id: this.idService.gen(), muterId: muter.id, muteeId: mutee.id, } as MiRenoteMuting); diff --git a/packages/backend/src/server/api/endpoints/request-reset-password.ts b/packages/backend/src/server/api/endpoints/request-reset-password.ts index ec0baad711..a0560745ec 100644 --- a/packages/backend/src/server/api/endpoints/request-reset-password.ts +++ b/packages/backend/src/server/api/endpoints/request-reset-password.ts @@ -84,8 +84,7 @@ export default class extends Endpoint { // eslint- const token = secureRndstr(64, { chars: L_CHARS }); await this.passwordResetRequestsRepository.insert({ - id: this.idService.genId(), - createdAt: new Date(), + id: this.idService.gen(), userId: profile.userId, token, }); diff --git a/packages/backend/src/server/api/endpoints/reset-password.ts b/packages/backend/src/server/api/endpoints/reset-password.ts index e48998ed8b..7a10c758be 100644 --- a/packages/backend/src/server/api/endpoints/reset-password.ts +++ b/packages/backend/src/server/api/endpoints/reset-password.ts @@ -8,6 +8,7 @@ import { Inject, Injectable } from '@nestjs/common'; import type { UserProfilesRepository, PasswordResetRequestsRepository } from '@/models/_.js'; import { Endpoint } from '@/server/api/endpoint-base.js'; import { DI } from '@/di-symbols.js'; +import { IdService } from '@/core/IdService.js'; export const meta = { tags: ['reset password'], @@ -38,6 +39,8 @@ export default class extends Endpoint { // eslint- @Inject(DI.userProfilesRepository) private userProfilesRepository: UserProfilesRepository, + + private idService: IdService, ) { super(meta, paramDef, async (ps, me) => { const req = await this.passwordResetRequestsRepository.findOneByOrFail({ @@ -45,7 +48,7 @@ export default class extends Endpoint { // eslint- }); // 発行してから30分以上経過していたら無効 - if (Date.now() - req.createdAt.getTime() > 1000 * 60 * 30) { + if (Date.now() - this.idService.parse(req.id).date.getTime() > 1000 * 60 * 30) { throw new Error(); // TODO } diff --git a/packages/backend/src/server/api/endpoints/roles/notes.ts b/packages/backend/src/server/api/endpoints/roles/notes.ts index b8cd93e660..75454fb7a1 100644 --- a/packages/backend/src/server/api/endpoints/roles/notes.ts +++ b/packages/backend/src/server/api/endpoints/roles/notes.ts @@ -11,7 +11,7 @@ import { QueryService } from '@/core/QueryService.js'; import { DI } from '@/di-symbols.js'; import { NoteEntityService } from '@/core/entities/NoteEntityService.js'; import { IdService } from '@/core/IdService.js'; -import { RedisTimelineService } from '@/core/RedisTimelineService.js'; +import { FunoutTimelineService } from '@/core/FunoutTimelineService.js'; import { ApiError } from '../../error.js'; export const meta = { @@ -66,11 +66,11 @@ export default class extends Endpoint { // eslint- private idService: IdService, private noteEntityService: NoteEntityService, private queryService: QueryService, - private redisTimelineService: RedisTimelineService, + private funoutTimelineService: FunoutTimelineService, ) { super(meta, paramDef, async (ps, me) => { - const untilId = ps.untilId ?? (ps.untilDate ? this.idService.genId(new Date(ps.untilDate!)) : null); - const sinceId = ps.sinceId ?? (ps.sinceDate ? this.idService.genId(new Date(ps.sinceDate!)) : null); + const untilId = ps.untilId ?? (ps.untilDate ? this.idService.gen(ps.untilDate!) : null); + const sinceId = ps.sinceId ?? (ps.sinceDate ? this.idService.gen(ps.sinceDate!) : null); const role = await this.rolesRepository.findOneBy({ id: ps.roleId, @@ -84,7 +84,7 @@ export default class extends Endpoint { // eslint- return []; } - let noteIds = await this.redisTimelineService.get(`roleTimeline:${role.id}`, untilId, sinceId); + let noteIds = await this.funoutTimelineService.get(`roleTimeline:${role.id}`, untilId, sinceId); noteIds = noteIds.slice(0, ps.limit); if (noteIds.length === 0) { diff --git a/packages/backend/src/server/api/endpoints/sw/register.ts b/packages/backend/src/server/api/endpoints/sw/register.ts index 233044a40b..d75d7eea50 100644 --- a/packages/backend/src/server/api/endpoints/sw/register.ts +++ b/packages/backend/src/server/api/endpoints/sw/register.ts @@ -88,8 +88,7 @@ export default class extends Endpoint { // eslint- } await this.swSubscriptionsRepository.insert({ - id: this.idService.genId(), - createdAt: new Date(), + id: this.idService.gen(), userId: me.id, endpoint: ps.endpoint, auth: ps.auth, diff --git a/packages/backend/src/server/api/endpoints/users.ts b/packages/backend/src/server/api/endpoints/users.ts index d3ee6a4c10..ff710c6350 100644 --- a/packages/backend/src/server/api/endpoints/users.ts +++ b/packages/backend/src/server/api/endpoints/users.ts @@ -74,8 +74,8 @@ export default class extends Endpoint { // eslint- switch (ps.sort) { case '+follower': query.orderBy('user.followersCount', 'DESC'); break; case '-follower': query.orderBy('user.followersCount', 'ASC'); break; - case '+createdAt': query.orderBy('user.createdAt', 'DESC'); break; - case '-createdAt': query.orderBy('user.createdAt', 'ASC'); break; + case '+createdAt': query.orderBy('user.id', 'DESC'); break; + case '-createdAt': query.orderBy('user.id', 'ASC'); break; case '+updatedAt': query.andWhere('user.updatedAt IS NOT NULL').orderBy('user.updatedAt', 'DESC'); break; case '-updatedAt': query.andWhere('user.updatedAt IS NOT NULL').orderBy('user.updatedAt', 'ASC'); break; default: query.orderBy('user.id', 'ASC'); break; diff --git a/packages/backend/src/server/api/endpoints/users/groups/create.ts b/packages/backend/src/server/api/endpoints/users/groups/create.ts index 0c46eb9279..0bcc4bf7be 100644 --- a/packages/backend/src/server/api/endpoints/users/groups/create.ts +++ b/packages/backend/src/server/api/endpoints/users/groups/create.ts @@ -56,16 +56,14 @@ export default class extends Endpoint { // eslint- ) { super(meta, paramDef, async (ps, me) => { const userGroup = await this.userGroupsRepository.insert({ - id: this.idService.genId(), - createdAt: new Date(), + id: this.idService.gen(), userId: me.id, name: ps.name, } as MiUserGroup).then(x => this.userGroupsRepository.findOneByOrFail(x.identifiers[0])); // Push the owner await this.userGroupJoiningsRepository.insert({ - id: this.idService.genId(), - createdAt: new Date(), + id: this.idService.gen(), userId: me.id, userGroupId: userGroup.id, } as MiUserGroupJoining); diff --git a/packages/backend/src/server/api/endpoints/users/groups/invitations/accept.ts b/packages/backend/src/server/api/endpoints/users/groups/invitations/accept.ts index 0af8e87725..e790d000bc 100644 --- a/packages/backend/src/server/api/endpoints/users/groups/invitations/accept.ts +++ b/packages/backend/src/server/api/endpoints/users/groups/invitations/accept.ts @@ -62,8 +62,7 @@ export default class extends Endpoint { // eslint- // Push the user await this.userGroupJoiningsRepository.insert({ - id: this.idService.genId(), - createdAt: new Date(), + id: this.idService.gen(), userId: me.id, userGroupId: invitation.userGroupId, } as MiUserGroupJoining); diff --git a/packages/backend/src/server/api/endpoints/users/groups/invite.ts b/packages/backend/src/server/api/endpoints/users/groups/invite.ts index 263227e91d..aa5488e271 100644 --- a/packages/backend/src/server/api/endpoints/users/groups/invite.ts +++ b/packages/backend/src/server/api/endpoints/users/groups/invite.ts @@ -110,17 +110,15 @@ export default class extends Endpoint { // eslint- } const invitation = await this.userGroupInvitationsRepository.insert({ - id: this.idService.genId(), - createdAt: new Date(), + id: this.idService.gen(), userId: user.id, userGroupId: userGroup.id, } as MiUserGroupInvitation).then(x => this.userGroupInvitationsRepository.findOneByOrFail(x.identifiers[0])); // 通知を作成 this.notificationService.createNotification(user.id, 'groupInvited', { - notifierId: me.id, userGroupInvitationId: invitation.id, - }); + }, me.id); }); } } diff --git a/packages/backend/src/server/api/endpoints/users/lists/create-from-public.ts b/packages/backend/src/server/api/endpoints/users/lists/create-from-public.ts index 533d0efa43..5e2df3c512 100644 --- a/packages/backend/src/server/api/endpoints/users/lists/create-from-public.ts +++ b/packages/backend/src/server/api/endpoints/users/lists/create-from-public.ts @@ -104,8 +104,7 @@ export default class extends Endpoint { // eslint- } const userList = await this.userListsRepository.insert({ - id: this.idService.genId(), - createdAt: new Date(), + id: this.idService.gen(), userId: me.id, name: ps.name, } as MiUserList).then(x => this.userListsRepository.findOneByOrFail(x.identifiers[0])); diff --git a/packages/backend/src/server/api/endpoints/users/lists/create.ts b/packages/backend/src/server/api/endpoints/users/lists/create.ts index 707f1f3f87..cb035e76f7 100644 --- a/packages/backend/src/server/api/endpoints/users/lists/create.ts +++ b/packages/backend/src/server/api/endpoints/users/lists/create.ts @@ -66,8 +66,7 @@ export default class extends Endpoint { // eslint- } const userList = await this.userListsRepository.insert({ - id: this.idService.genId(), - createdAt: new Date(), + id: this.idService.gen(), userId: me.id, name: ps.name, } as MiUserList).then(x => this.userListsRepository.findOneByOrFail(x.identifiers[0])); diff --git a/packages/backend/src/server/api/endpoints/users/lists/favorite.ts b/packages/backend/src/server/api/endpoints/users/lists/favorite.ts index 08d9d18e7b..da0dfd6190 100644 --- a/packages/backend/src/server/api/endpoints/users/lists/favorite.ts +++ b/packages/backend/src/server/api/endpoints/users/lists/favorite.ts @@ -69,8 +69,7 @@ export default class extends Endpoint { } await this.userListFavoritesRepository.insert({ - id: this.idService.genId(), - createdAt: new Date(), + id: this.idService.gen(), userId: me.id, userListId: ps.listId, }); diff --git a/packages/backend/src/server/api/endpoints/users/notes.ts b/packages/backend/src/server/api/endpoints/users/notes.ts index 1c12931046..5d88d0eb95 100644 --- a/packages/backend/src/server/api/endpoints/users/notes.ts +++ b/packages/backend/src/server/api/endpoints/users/notes.ts @@ -14,7 +14,7 @@ import { CacheService } from '@/core/CacheService.js'; import { IdService } from '@/core/IdService.js'; import { isUserRelated } from '@/misc/is-user-related.js'; import { QueryService } from '@/core/QueryService.js'; -import { RedisTimelineService } from '@/core/RedisTimelineService.js'; +import { FunoutTimelineService } from '@/core/FunoutTimelineService.js'; import { ApiError } from '../../error.js'; export const meta = { @@ -72,11 +72,11 @@ export default class extends Endpoint { // eslint- private queryService: QueryService, private cacheService: CacheService, private idService: IdService, - private redisTimelineService: RedisTimelineService, + private funoutTimelineService: FunoutTimelineService, ) { super(meta, paramDef, async (ps, me) => { - const untilId = ps.untilId ?? (ps.untilDate ? this.idService.genId(new Date(ps.untilDate!)) : null); - const sinceId = ps.sinceId ?? (ps.sinceDate ? this.idService.genId(new Date(ps.sinceDate!)) : null); + const untilId = ps.untilId ?? (ps.untilDate ? this.idService.gen(ps.untilDate!) : null); + const sinceId = ps.sinceId ?? (ps.sinceDate ? this.idService.gen(ps.sinceDate!) : null); const isRangeSpecified = untilId != null && sinceId != null; const isSelf = me && (me.id === ps.userId); @@ -88,9 +88,9 @@ export default class extends Endpoint { // eslint- ]) : [new Set()]; const [noteIdsRes, repliesNoteIdsRes, channelNoteIdsRes] = await Promise.all([ - this.redisTimelineService.get(ps.withFiles ? `userTimelineWithFiles:${ps.userId}` : `userTimeline:${ps.userId}`, untilId, sinceId), - ps.withReplies ? this.redisTimelineService.get(`userTimelineWithReplies:${ps.userId}`, untilId, sinceId) : Promise.resolve([]), - ps.withChannelNotes ? this.redisTimelineService.get(`userTimelineWithChannel:${ps.userId}`, untilId, sinceId) : Promise.resolve([]), + this.funoutTimelineService.get(ps.withFiles ? `userTimelineWithFiles:${ps.userId}` : `userTimeline:${ps.userId}`, untilId, sinceId), + ps.withReplies ? this.funoutTimelineService.get(`userTimelineWithReplies:${ps.userId}`, untilId, sinceId) : Promise.resolve([]), + ps.withChannelNotes ? this.funoutTimelineService.get(`userTimelineWithChannel:${ps.userId}`, untilId, sinceId) : Promise.resolve([]), ]); let noteIds = Array.from(new Set([ @@ -156,7 +156,10 @@ export default class extends Endpoint { // eslint- .leftJoinAndSelect('renote.user', 'renoteUser'); if (ps.withChannelNotes) { - if (!isSelf) query.andWhere('channel.isSensitive = false'); + if (!isSelf) query.andWhere(new Brackets(qb => { + qb.orWhere('note.channelId IS NULL'); + qb.orWhere('channel.isSensitive = false'); + })); } else { query.andWhere('note.channelId IS NULL'); } diff --git a/packages/backend/src/server/api/endpoints/users/report-abuse.ts b/packages/backend/src/server/api/endpoints/users/report-abuse.ts index e9c019d3fb..07e76bfd53 100644 --- a/packages/backend/src/server/api/endpoints/users/report-abuse.ts +++ b/packages/backend/src/server/api/endpoints/users/report-abuse.ts @@ -77,8 +77,7 @@ export default class extends Endpoint { // eslint- } const report = await this.abuseUserReportsRepository.insert({ - id: this.idService.genId(), - createdAt: new Date(), + id: this.idService.gen(), targetUserId: user.id, targetUserHost: user.host, reporterId: me.id, diff --git a/packages/backend/src/server/api/endpoints/users/update-memo.ts b/packages/backend/src/server/api/endpoints/users/update-memo.ts index 1e5e984f17..9e3a564b84 100644 --- a/packages/backend/src/server/api/endpoints/users/update-memo.ts +++ b/packages/backend/src/server/api/endpoints/users/update-memo.ts @@ -72,7 +72,7 @@ export default class extends Endpoint { // eslint- if (!previousMemo) { await this.userMemosRepository.insert({ - id: this.idService.genId(), + id: this.idService.gen(), userId: me.id, targetUserId: target.id, memo: ps.memo, diff --git a/packages/backend/src/server/api/stream/channels/channel.ts b/packages/backend/src/server/api/stream/channels/channel.ts index 714b8da43b..086e7b8262 100644 --- a/packages/backend/src/server/api/stream/channels/channel.ts +++ b/packages/backend/src/server/api/stream/channels/channel.ts @@ -47,19 +47,6 @@ class ChannelChannel extends Channel { private async onNote(note: Packed<'Note'>) { if (note.channelId !== this.channelId) return; - // リプライなら再pack - if (note.replyId != null) { - note.reply = await this.noteEntityService.pack(note.replyId, this.user, { - detail: true, - }); - } - // Renoteなら再pack - if (note.renoteId != null) { - note.renote = await this.noteEntityService.pack(note.renoteId, this.user, { - detail: true, - }); - } - // 流れてきたNoteがミュートしているユーザーが関わるものだったら無視する if (isUserRelated(note, this.userIdsWhoMeMuting)) return; // 流れてきたNoteがブロックされているユーザーが関わるものだったら無視する @@ -67,6 +54,13 @@ class ChannelChannel extends Channel { if (note.renote && !note.text && isUserRelated(note, this.userIdsWhoMeMutingRenotes)) return; + if (this.user && note.renoteId && !note.text) { + if (note.renote && Object.keys(note.renote.reactions).length > 0) { + const myRenoteReaction = await this.noteEntityService.populateMyReaction(note.renote, this.user.id); + note.renote.myReaction = myRenoteReaction; + } + } + this.connection.cacheNote(note); this.send('note', note); diff --git a/packages/backend/src/server/api/stream/channels/global-timeline.ts b/packages/backend/src/server/api/stream/channels/global-timeline.ts index fb3da323f5..fc74ced541 100644 --- a/packages/backend/src/server/api/stream/channels/global-timeline.ts +++ b/packages/backend/src/server/api/stream/channels/global-timeline.ts @@ -52,19 +52,6 @@ class GlobalTimelineChannel extends Channel { if (note.visibility !== 'public') return; if (note.channelId != null) return; - // リプライなら再pack - if (note.replyId != null) { - note.reply = await this.noteEntityService.pack(note.replyId, this.user, { - detail: true, - }); - } - // Renoteなら再pack - if (note.renoteId != null) { - note.renote = await this.noteEntityService.pack(note.renoteId, this.user, { - detail: true, - }); - } - // 関係ない返信は除外 if (note.reply && !this.following[note.userId]?.withReplies) { const reply = note.reply; @@ -84,6 +71,13 @@ class GlobalTimelineChannel extends Channel { if (note.renote && !note.text && isUserRelated(note, this.userIdsWhoMeMutingRenotes)) return; + if (this.user && note.renoteId && !note.text) { + if (note.renote && Object.keys(note.renote.reactions).length > 0) { + const myRenoteReaction = await this.noteEntityService.populateMyReaction(note.renote, this.user.id); + note.renote.myReaction = myRenoteReaction; + } + } + this.connection.cacheNote(note); this.send('note', note); diff --git a/packages/backend/src/server/api/stream/channels/hashtag.ts b/packages/backend/src/server/api/stream/channels/hashtag.ts index 8087e983ba..c46d0eb706 100644 --- a/packages/backend/src/server/api/stream/channels/hashtag.ts +++ b/packages/backend/src/server/api/stream/channels/hashtag.ts @@ -43,13 +43,6 @@ class HashtagChannel extends Channel { const matched = this.q.some(tags => tags.every(tag => noteTags.includes(normalizeForSearch(tag)))); if (!matched) return; - // Renoteなら再pack - if (note.renoteId != null) { - note.renote = await this.noteEntityService.pack(note.renoteId, this.user, { - detail: true, - }); - } - // 流れてきたNoteがミュートしているユーザーが関わるものだったら無視する if (isUserRelated(note, this.userIdsWhoMeMuting)) return; // 流れてきたNoteがブロックされているユーザーが関わるものだったら無視する @@ -57,6 +50,13 @@ class HashtagChannel extends Channel { if (note.renote && !note.text && isUserRelated(note, this.userIdsWhoMeMutingRenotes)) return; + if (this.user && note.renoteId && !note.text) { + if (note.renote && Object.keys(note.renote.reactions).length > 0) { + const myRenoteReaction = await this.noteEntityService.populateMyReaction(note.renote, this.user.id); + note.renote.myReaction = myRenoteReaction; + } + } + this.connection.cacheNote(note); this.send('note', note); diff --git a/packages/backend/src/server/api/stream/channels/home-timeline.ts b/packages/backend/src/server/api/stream/channels/home-timeline.ts index d7c66608f4..f49f35b3aa 100644 --- a/packages/backend/src/server/api/stream/channels/home-timeline.ts +++ b/packages/backend/src/server/api/stream/channels/home-timeline.ts @@ -39,46 +39,31 @@ class HomeTimelineChannel extends Channel { @bindThis private async onNote(note: Packed<'Note'>) { + const isMe = this.user!.id === note.userId; + if (this.withFiles && (note.fileIds == null || note.fileIds.length === 0)) return; if (note.channelId) { if (!this.followingChannels.has(note.channelId)) return; } else { // その投稿のユーザーをフォローしていなかったら弾く - if ((this.user!.id !== note.userId) && !Object.hasOwn(this.following, note.userId)) return; + if (!isMe && !Object.hasOwn(this.following, note.userId)) return; } // Ignore notes from instances the user has muted - if (isInstanceMuted(note, new Set(this.userProfile!.mutedInstances ?? []))) return; - - if (['followers', 'specified'].includes(note.visibility)) { - note = await this.noteEntityService.pack(note.id, this.user!, { - detail: true, - }); + if (isInstanceMuted(note, new Set(this.userProfile!.mutedInstances))) return; - if (note.isHidden) { - return; - } - } else { - // リプライなら再pack - if (note.replyId != null) { - note.reply = await this.noteEntityService.pack(note.replyId, this.user!, { - detail: true, - }); - } - // Renoteなら再pack - if (note.renoteId != null) { - note.renote = await this.noteEntityService.pack(note.renoteId, this.user!, { - detail: true, - }); - } + if (note.visibility === 'followers') { + if (!isMe && !Object.hasOwn(this.following, note.userId)) return; + } else if (note.visibility === 'specified') { + if (!note.visibleUserIds!.includes(this.user!.id)) return; } // 関係ない返信は除外 if (note.reply && !this.following[note.userId]?.withReplies) { const reply = note.reply; // 「チャンネル接続主への返信」でもなければ、「チャンネル接続主が行った返信」でもなければ、「投稿者の投稿者自身への返信」でもない場合 - if (reply.userId !== this.user!.id && note.userId !== this.user!.id && reply.userId !== note.userId) return; + if (reply.userId !== this.user!.id && !isMe && reply.userId !== note.userId) return; } if (note.renote && note.text == null && (note.fileIds == null || note.fileIds.length === 0) && !this.withRenotes) return; @@ -90,6 +75,13 @@ class HomeTimelineChannel extends Channel { if (note.renote && !note.text && isUserRelated(note, this.userIdsWhoMeMutingRenotes)) return; + if (this.user && note.renoteId && !note.text) { + if (note.renote && Object.keys(note.renote.reactions).length > 0) { + const myRenoteReaction = await this.noteEntityService.populateMyReaction(note.renote, this.user.id); + note.renote.myReaction = myRenoteReaction; + } + } + this.connection.cacheNote(note); this.send('note', note); diff --git a/packages/backend/src/server/api/stream/channels/hybrid-timeline.ts b/packages/backend/src/server/api/stream/channels/hybrid-timeline.ts index b733b591f2..b02720f6d6 100644 --- a/packages/backend/src/server/api/stream/channels/hybrid-timeline.ts +++ b/packages/backend/src/server/api/stream/channels/hybrid-timeline.ts @@ -49,6 +49,8 @@ class HybridTimelineChannel extends Channel { @bindThis private async onNote(note: Packed<'Note'>) { + const isMe = this.user!.id === note.userId; + if (this.withFiles && (note.fileIds == null || note.fileIds.length === 0)) return; // チャンネルの投稿ではなく、自分自身の投稿 または @@ -56,43 +58,26 @@ class HybridTimelineChannel extends Channel { // チャンネルの投稿ではなく、全体公開のローカルの投稿 または // フォローしているチャンネルの投稿 の場合だけ if (!( - (note.channelId == null && this.user!.id === note.userId) || + (note.channelId == null && isMe) || (note.channelId == null && Object.hasOwn(this.following, note.userId)) || (note.channelId == null && (note.user.host == null && note.visibility === 'public')) || (note.channelId != null && this.followingChannels.has(note.channelId)) )) return; - if (['followers', 'specified'].includes(note.visibility)) { - note = await this.noteEntityService.pack(note.id, this.user!, { - detail: true, - }); - - if (note.isHidden) { - return; - } - } else { - // リプライなら再pack - if (note.replyId != null) { - note.reply = await this.noteEntityService.pack(note.replyId, this.user!, { - detail: true, - }); - } - // Renoteなら再pack - if (note.renoteId != null) { - note.renote = await this.noteEntityService.pack(note.renoteId, this.user!, { - detail: true, - }); - } + if (note.visibility === 'followers') { + if (!isMe && !Object.hasOwn(this.following, note.userId)) return; + } else if (note.visibility === 'specified') { + if (!note.visibleUserIds!.includes(this.user!.id)) return; } // Ignore notes from instances the user has muted - if (isInstanceMuted(note, new Set(this.userProfile!.mutedInstances ?? []))) return; + if (isInstanceMuted(note, new Set(this.userProfile!.mutedInstances))) return; // 関係ない返信は除外 if (note.reply && !this.following[note.userId]?.withReplies && !this.withReplies) { const reply = note.reply; // 「チャンネル接続主への返信」でもなければ、「チャンネル接続主が行った返信」でもなければ、「投稿者の投稿者自身への返信」でもない場合 - if (reply.userId !== this.user!.id && note.userId !== this.user!.id && reply.userId !== note.userId) return; + if (reply.userId !== this.user!.id && !isMe && reply.userId !== note.userId) return; } if (note.renote && note.text == null && (note.fileIds == null || note.fileIds.length === 0) && !this.withRenotes) return; @@ -104,6 +89,14 @@ class HybridTimelineChannel extends Channel { if (note.renote && !note.text && isUserRelated(note, this.userIdsWhoMeMutingRenotes)) return; + if (this.user && note.renoteId && !note.text) { + if (note.renote && Object.keys(note.renote.reactions).length > 0) { + console.log(note.renote.reactionAndUserPairCache); + const myRenoteReaction = await this.noteEntityService.populateMyReaction(note.renote, this.user.id); + note.renote.myReaction = myRenoteReaction; + } + } + this.connection.cacheNote(note); this.send('note', note); diff --git a/packages/backend/src/server/api/stream/channels/local-timeline.ts b/packages/backend/src/server/api/stream/channels/local-timeline.ts index 3d2893006c..43994ad676 100644 --- a/packages/backend/src/server/api/stream/channels/local-timeline.ts +++ b/packages/backend/src/server/api/stream/channels/local-timeline.ts @@ -54,19 +54,6 @@ class LocalTimelineChannel extends Channel { if (note.visibility !== 'public') return; if (note.channelId != null && !this.followingChannels.has(note.channelId)) return; - // リプライなら再pack - if (note.replyId != null) { - note.reply = await this.noteEntityService.pack(note.replyId, this.user, { - detail: true, - }); - } - // Renoteなら再pack - if (note.renoteId != null) { - note.renote = await this.noteEntityService.pack(note.renoteId, this.user, { - detail: true, - }); - } - // 関係ない返信は除外 if (note.reply && this.user && !this.following[note.userId]?.withReplies && !this.withReplies) { const reply = note.reply; @@ -83,6 +70,13 @@ class LocalTimelineChannel extends Channel { if (note.renote && !note.text && isUserRelated(note, this.userIdsWhoMeMutingRenotes)) return; + if (this.user && note.renoteId && !note.text) { + if (note.renote && Object.keys(note.renote.reactions).length > 0) { + const myRenoteReaction = await this.noteEntityService.populateMyReaction(note.renote, this.user.id); + note.renote.myReaction = myRenoteReaction; + } + } + this.connection.cacheNote(note); this.send('note', note); diff --git a/packages/backend/src/server/api/stream/channels/user-list.ts b/packages/backend/src/server/api/stream/channels/user-list.ts index 0eb25e637f..5869d7d9b8 100644 --- a/packages/backend/src/server/api/stream/channels/user-list.ts +++ b/packages/backend/src/server/api/stream/channels/user-list.ts @@ -78,38 +78,23 @@ class UserListChannel extends Channel { @bindThis private async onNote(note: Packed<'Note'>) { + const isMe = this.user!.id === note.userId; + if (this.withFiles && (note.fileIds == null || note.fileIds.length === 0)) return; if (!Object.hasOwn(this.membershipsMap, note.userId)) return; - if (['followers', 'specified'].includes(note.visibility)) { - note = await this.noteEntityService.pack(note.id, this.user, { - detail: true, - }); - - if (note.isHidden) { - return; - } - } else { - // リプライなら再pack - if (note.replyId != null) { - note.reply = await this.noteEntityService.pack(note.replyId, this.user, { - detail: true, - }); - } - // Renoteなら再pack - if (note.renoteId != null) { - note.renote = await this.noteEntityService.pack(note.renoteId, this.user, { - detail: true, - }); - } + if (note.visibility === 'followers') { + if (!isMe && !Object.hasOwn(this.following, note.userId)) return; + } else if (note.visibility === 'specified') { + if (!note.visibleUserIds!.includes(this.user!.id)) return; } // 関係ない返信は除外 if (note.reply && !this.membershipsMap[note.userId]?.withReplies) { const reply = note.reply; // 「チャンネル接続主への返信」でもなければ、「チャンネル接続主が行った返信」でもなければ、「投稿者の投稿者自身への返信」でもない場合 - if (reply.userId !== this.user!.id && note.userId !== this.user!.id && reply.userId !== note.userId) return; + if (reply.userId !== this.user!.id && !isMe && reply.userId !== note.userId) return; } // 流れてきたNoteがミュートしているユーザーが関わるものだったら無視する @@ -119,6 +104,15 @@ class UserListChannel extends Channel { if (note.renote && !note.text && isUserRelated(note, this.userIdsWhoMeMutingRenotes)) return; + if (this.user && note.renoteId && !note.text) { + if (note.renote && Object.keys(note.renote.reactions).length > 0) { + const myRenoteReaction = await this.noteEntityService.populateMyReaction(note.renote, this.user.id); + note.renote.myReaction = myRenoteReaction; + } + } + + this.connection.cacheNote(note); + this.send('note', note); } diff --git a/packages/backend/src/server/oauth/OAuth2ProviderService.ts b/packages/backend/src/server/oauth/OAuth2ProviderService.ts index b5c4eb16fb..46e2b93328 100644 --- a/packages/backend/src/server/oauth/OAuth2ProviderService.ts +++ b/packages/backend/src/server/oauth/OAuth2ProviderService.ts @@ -325,8 +325,7 @@ export class OAuth2ProviderService { // NOTE: we don't have a setup for automatic token expiration await accessTokensRepository.insert({ - id: idService.genId(), - createdAt: now, + id: idService.gen(now.getTime()), lastUsedAt: now, userId: granted.userId, token: accessToken, diff --git a/packages/backend/src/server/web/FeedService.ts b/packages/backend/src/server/web/FeedService.ts index cbfeccca4f..0c9a5370cc 100644 --- a/packages/backend/src/server/web/FeedService.ts +++ b/packages/backend/src/server/web/FeedService.ts @@ -13,6 +13,7 @@ import type { MiUser } from '@/models/User.js'; import { UserEntityService } from '@/core/entities/UserEntityService.js'; import { DriveFileEntityService } from '@/core/entities/DriveFileEntityService.js'; import { bindThis } from '@/decorators.js'; +import { IdService } from '@/core/IdService.js'; @Injectable() export class FeedService { @@ -31,6 +32,7 @@ export class FeedService { private userEntityService: UserEntityService, private driveFileEntityService: DriveFileEntityService, + private idService: IdService, ) { } @@ -49,14 +51,14 @@ export class FeedService { renoteId: IsNull(), visibility: In(['public', 'home']), }, - order: { createdAt: -1 }, + order: { id: -1 }, take: 20, }); const feed = new Feed({ id: author.link, title: `${author.name} (@${user.username}@${this.config.host})`, - updated: notes[0].createdAt, + updated: this.idService.parse(notes[0].id).date, generator: 'CherryPick', description: `${user.notesCount} Notes, ${profile.ffVisibility === 'public' ? user.followingCount : '?'} Following, ${profile.ffVisibility === 'public' ? user.followersCount : '?'} Followers${profile.description ? ` · ${profile.description}` : ''}`, link: author.link, @@ -78,10 +80,10 @@ export class FeedService { feed.addItem({ title: `New note by ${author.name}`, link: `${this.config.url}/notes/${note.id}`, - date: note.createdAt, + date: this.idService.parse(note.id).date, description: note.cw ?? undefined, content: note.text ?? undefined, - image: file ? this.driveFileEntityService.getPublicUrl(file) ?? undefined : undefined, + image: file ? this.driveFileEntityService.getPublicUrl(file) : undefined, }); } diff --git a/packages/backend/test/e2e/antennas.ts b/packages/backend/test/e2e/antennas.ts index b4d57dc186..c94dad7a2c 100644 --- a/packages/backend/test/e2e/antennas.ts +++ b/packages/backend/test/e2e/antennas.ts @@ -176,6 +176,7 @@ describe('アンテナ', () => { users: [''], withFile: false, withReplies: false, + localOnly: false, } as Antenna; assert.deepStrictEqual(response, expected); }); diff --git a/packages/backend/test/e2e/move.ts b/packages/backend/test/e2e/move.ts index 604a3a3640..ca3f825f56 100644 --- a/packages/backend/test/e2e/move.ts +++ b/packages/backend/test/e2e/move.ts @@ -188,6 +188,7 @@ describe('Account Move', () => { excludeKeywords: [], users: [], caseSensitive: false, + localOnly: false, withReplies: false, withFile: false, notify: false, @@ -431,6 +432,7 @@ describe('Account Move', () => { excludeKeywords: [], users: [eve.id], caseSensitive: false, + localOnly: false, withReplies: false, withFile: false, notify: false, diff --git a/packages/backend/test/e2e/streaming.ts b/packages/backend/test/e2e/streaming.ts index 278cad4066..06f5de1270 100644 --- a/packages/backend/test/e2e/streaming.ts +++ b/packages/backend/test/e2e/streaming.ts @@ -18,7 +18,6 @@ describe('Streaming', () => { const follow = async (follower: any, followee: any) => { await Followings.save({ id: 'a', - createdAt: new Date(), followerId: follower.id, followeeId: followee.id, followerHost: follower.host, @@ -116,6 +115,16 @@ describe('Streaming', () => { assert.strictEqual(fired, true); }); + test('自分の visibility: followers な投稿が流れる', async () => { + const fired = await waitFire( + ayano, 'homeTimeline', // ayano:Home + () => api('notes/create', { text: 'foo', visibility: 'followers' }, ayano), // ayano posts + msg => msg.type === 'note' && msg.body.text === 'foo', + ); + + assert.strictEqual(fired, true); + }); + test('フォローしているユーザーの投稿が流れる', async () => { const fired = await waitFire( ayano, 'homeTimeline', // ayano:home @@ -126,6 +135,30 @@ describe('Streaming', () => { assert.strictEqual(fired, true); }); + test('フォローしているユーザーの visibility: followers な投稿が流れる', async () => { + const fired = await waitFire( + ayano, 'homeTimeline', // ayano:home + () => api('notes/create', { text: 'foo', visibility: 'followers' }, kyoko), // kyoko posts + msg => msg.type === 'note' && msg.body.userId === kyoko.id, // wait kyoko + ); + + assert.strictEqual(fired, true); + }); + + /* なんか失敗する + test('フォローしているユーザーの visibility: followers な投稿への返信が流れる', async () => { + const note = await api('notes/create', { text: 'foo', visibility: 'followers' }, kyoko); + + const fired = await waitFire( + ayano, 'homeTimeline', // ayano:home + () => api('notes/create', { text: 'bar', visibility: 'followers', replyId: note.body.id }, kyoko), // kyoko posts + msg => msg.type === 'note' && msg.body.userId === kyoko.id && msg.body.reply.text === 'foo', + ); + + assert.strictEqual(fired, true); + }); + */ + test('フォローしていないユーザーの投稿は流れない', async () => { const fired = await waitFire( kyoko, 'homeTimeline', // kyoko:home @@ -242,6 +275,16 @@ describe('Streaming', () => { assert.strictEqual(fired, true); }); + test('自分の visibility: followers な投稿が流れる', async () => { + const fired = await waitFire( + ayano, 'hybridTimeline', + () => api('notes/create', { text: 'foo', visibility: 'followers' }, ayano), // ayano posts + msg => msg.type === 'note' && msg.body.text === 'foo', + ); + + assert.strictEqual(fired, true); + }); + test('フォローしていないローカルユーザーの投稿が流れる', async () => { const fired = await waitFire( ayano, 'hybridTimeline', // ayano:Hybrid @@ -294,6 +337,16 @@ describe('Streaming', () => { assert.strictEqual(fired, true); }); + test('フォローしているユーザーの visibility: followers な投稿が流れる', async () => { + const fired = await waitFire( + ayano, 'hybridTimeline', // ayano:Hybrid + () => api('notes/create', { text: 'foo', visibility: 'followers' }, kyoko), + msg => msg.type === 'note' && msg.body.userId === kyoko.id, // wait kyoko + ); + + assert.strictEqual(fired, true); + }); + test('フォローしていないローカルユーザーのホーム投稿は流れない', async () => { const fired = await waitFire( ayano, 'hybridTimeline', // ayano:Hybrid diff --git a/packages/backend/test/e2e/timelines.ts b/packages/backend/test/e2e/timelines.ts index 3391acf0ba..fd1f38c06c 100644 --- a/packages/backend/test/e2e/timelines.ts +++ b/packages/backend/test/e2e/timelines.ts @@ -727,7 +727,7 @@ describe('Timelines', () => { await waitForPushToTl(); - const res = await api('/notes/hybrid-timeline', { }, alice); + const res = await api('/notes/hybrid-timeline', { limit: 100 }, alice); assert.strictEqual(res.body.some((note: any) => note.id === bobNote.id), false); assert.strictEqual(res.body.some((note: any) => note.id === carolNote.id), true); diff --git a/packages/backend/test/unit/AnnouncementService.ts b/packages/backend/test/unit/AnnouncementService.ts index f09d1c9111..99f9510907 100644 --- a/packages/backend/test/unit/AnnouncementService.ts +++ b/packages/backend/test/unit/AnnouncementService.ts @@ -35,8 +35,7 @@ describe('AnnouncementService', () => { function createUser(data: Partial = {}) { const un = secureRndstr(16); return usersRepository.insert({ - id: genAidx(new Date()), - createdAt: new Date(), + id: genAidx(Date.now()), username: un, usernameLower: un, ...data, @@ -44,10 +43,9 @@ describe('AnnouncementService', () => { .then(x => usersRepository.findOneByOrFail(x.identifiers[0])); } - function createAnnouncement(data: Partial = {}) { + function createAnnouncement(data: Partial = {}) { return announcementsRepository.insert({ - id: genAidx(new Date()), - createdAt: new Date(), + id: genAidx(data.createdAt ?? new Date()), updatedAt: null, title: 'Title', text: 'Text', diff --git a/packages/backend/test/unit/RoleService.ts b/packages/backend/test/unit/RoleService.ts index 866e2e3530..7feae17051 100644 --- a/packages/backend/test/unit/RoleService.ts +++ b/packages/backend/test/unit/RoleService.ts @@ -37,8 +37,7 @@ describe('RoleService', () => { function createUser(data: Partial = {}) { const un = secureRndstr(16); return usersRepository.insert({ - id: genAidx(new Date()), - createdAt: new Date(), + id: genAidx(Date.now()), username: un, usernameLower: un, ...data, @@ -48,8 +47,7 @@ describe('RoleService', () => { function createRole(data: Partial = {}) { return rolesRepository.insert({ - id: genAidx(new Date()), - createdAt: new Date(), + id: genAidx(Date.now()), updatedAt: new Date(), lastUsedAt: new Date(), description: '', @@ -198,10 +196,10 @@ describe('RoleService', () => { test('conditional role', async () => { const user1 = await createUser({ - createdAt: new Date(Date.now() - (1000 * 60 * 60 * 24 * 365)), + id: genAidx(Date.now() - (1000 * 60 * 60 * 24 * 365)), }); const user2 = await createUser({ - createdAt: new Date(Date.now() - (1000 * 60 * 60 * 24 * 365)), + id: genAidx(Date.now() - (1000 * 60 * 60 * 24 * 365)), followersCount: 10, }); await createRole({ diff --git a/packages/backend/test/unit/activitypub.ts b/packages/backend/test/unit/activitypub.ts index 707735c62c..e57a2df3ce 100644 --- a/packages/backend/test/unit/activitypub.ts +++ b/packages/backend/test/unit/activitypub.ts @@ -23,6 +23,7 @@ import { secureRndstr } from '@/misc/secure-rndstr.js'; import { DownloadService } from '@/core/DownloadService.js'; import { MetaService } from '@/core/MetaService.js'; import type { MiRemoteUser } from '@/models/User.js'; +import { genAidx } from '@/misc/id/aidx.js'; import { MockResolver } from '../misc/mock-resolver.js'; const host = 'https://host1.test'; @@ -200,7 +201,7 @@ describe('ActivityPub', () => { describe('Renderer', () => { test('Render an announce with visibility: followers', () => { rendererService.renderAnnounce(null, { - createdAt: new Date(0), + id: genAidx(Date.now()), visibility: 'followers', } as MiNote); }); diff --git a/packages/backend/test/unit/misc/id.ts b/packages/backend/test/unit/misc/id.ts index d4295c5079..090429ac3c 100644 --- a/packages/backend/test/unit/misc/id.ts +++ b/packages/backend/test/unit/misc/id.ts @@ -14,44 +14,44 @@ import { ulidRegExp, parseUlid } from '@/misc/id/ulid.js'; describe('misc:id', () => { test('aid', () => { - const date = new Date(); + const date = Date.now(); const gotAid = genAid(date); expect(gotAid).toMatch(aidRegExp); - expect(parseAid(gotAid).date.getTime()).toBe(date.getTime()); + expect(parseAid(gotAid).date.getTime()).toBe(date); }); test('aidx', () => { - const date = new Date(); + const date = Date.now(); const gotAidx = genAidx(date); expect(gotAidx).toMatch(aidxRegExp); - expect(parseAidx(gotAidx).date.getTime()).toBe(date.getTime()); + expect(parseAidx(gotAidx).date.getTime()).toBe(date); }); test('meid', () => { - const date = new Date(); + const date = Date.now(); const gotMeid = genMeid(date); expect(gotMeid).toMatch(meidRegExp); - expect(parseMeid(gotMeid).date.getTime()).toBe(date.getTime()); + expect(parseMeid(gotMeid).date.getTime()).toBe(date); }); test('meidg', () => { - const date = new Date(); + const date = Date.now(); const gotMeidg = genMeidg(date); expect(gotMeidg).toMatch(meidgRegExp); - expect(parseMeidg(gotMeidg).date.getTime()).toBe(date.getTime()); + expect(parseMeidg(gotMeidg).date.getTime()).toBe(date); }); test('objectid', () => { - const date = new Date(); + const date = Date.now(); const gotObjectId = genObjectId(date); expect(gotObjectId).toMatch(objectIdRegExp); - expect(Math.floor(parseObjectId(gotObjectId).date.getTime() / 1000)).toBe(Math.floor(date.getTime() / 1000)); + expect(Math.floor(parseObjectId(gotObjectId).date.getTime() / 1000)).toBe(Math.floor(date / 1000)); }); test('ulid', () => { - const date = new Date(); - const gotUlid = ulid(date.getTime()); + const date = Date.now(); + const gotUlid = ulid(date); expect(gotUlid).toMatch(ulidRegExp); - expect(parseUlid(gotUlid).date.getTime()).toBe(date.getTime()); + expect(parseUlid(gotUlid).date.getTime()).toBe(date); }); }); diff --git a/packages/cherrypick-js/etc/cherrypick-js.api.md b/packages/cherrypick-js/etc/cherrypick-js.api.md index 4316bf5da1..981489e2d9 100644 --- a/packages/cherrypick-js/etc/cherrypick-js.api.md +++ b/packages/cherrypick-js/etc/cherrypick-js.api.md @@ -29,6 +29,7 @@ type Ad = TODO_2; // @public (undocumented) type AdminInstanceMetadata = DetailedInstanceMetadata & { blockedHosts: string[]; + silencedHosts: string[]; app192IconUrl: string | null; app512IconUrl: string | null; manifestJsonOverride: string; @@ -61,6 +62,7 @@ type Antenna = { userGroupId: ID | null; users: string[]; caseSensitive: boolean; + localOnly: boolean; notify: boolean; withReplies: boolean; withFile: boolean; @@ -1211,6 +1213,7 @@ export type Endpoints = { 'following/create': { req: { userId: User['id']; + withReplies?: boolean; }; res: User; }; @@ -1784,6 +1787,14 @@ export type Endpoints = { }; res: null; }; + 'notes/update': { + req: { + noteId: Note['id']; + text?: null | string; + cw?: null | string; + }; + res: null; + }; 'notes/favorites/create': { req: { noteId: Note['id']; @@ -2282,6 +2293,22 @@ export type Endpoints = { }; }; }; + 'fetch-rss': { + req: { + url: string; + }; + res: TODO; + }; + 'fetch-external-resources': { + req: { + url: string; + hash: string; + }; + res: { + type: string; + data: string; + }; + }; }; declare namespace entities { @@ -2414,6 +2441,7 @@ type Instance = { lastCommunicatedAt: DateString; isNotResponding: boolean; isSuspended: boolean; + isSilenced: boolean; isBlocked: boolean; softwareName: string | null; softwareVersion: string | null; @@ -2701,6 +2729,7 @@ type Note = { id: ID; createdAt: DateString; updatedAt?: DateString | null; + updatedAtHistory: DateString[] | null; noteEditHistory: string[]; text: string | null; cw: string | null; @@ -3023,7 +3052,7 @@ type UserLite = { id: ID; username: string; host: string | null; - name: string; + name: string | null; onlineStatus: 'online' | 'active' | 'offline' | 'unknown'; avatarUrl: string; avatarBlurhash: string; @@ -3039,6 +3068,8 @@ type UserLite = { faviconUrl: Instance['faviconUrl']; themeColor: Instance['themeColor']; }; + isCat?: boolean; + isBot?: boolean; }; // @public (undocumented) @@ -3048,9 +3079,9 @@ type UserSorting = '+follower' | '-follower' | '+createdAt' | '-createdAt' | '+u // // src/api.types.ts:16:32 - (ae-forgotten-export) The symbol "TODO" needs to be exported by the entry point index.d.ts // src/api.types.ts:18:25 - (ae-forgotten-export) The symbol "NoParams" needs to be exported by the entry point index.d.ts -// src/api.types.ts:658:18 - (ae-forgotten-export) The symbol "ShowUserReq" needs to be exported by the entry point index.d.ts -// src/entities.ts:108:2 - (ae-forgotten-export) The symbol "notificationTypes_2" needs to be exported by the entry point index.d.ts -// src/entities.ts:610:2 - (ae-forgotten-export) The symbol "ModerationLogPayloads" needs to be exported by the entry point index.d.ts +// src/api.types.ts:662:18 - (ae-forgotten-export) The symbol "ShowUserReq" needs to be exported by the entry point index.d.ts +// src/entities.ts:110:2 - (ae-forgotten-export) The symbol "notificationTypes_2" needs to be exported by the entry point index.d.ts +// src/entities.ts:616:2 - (ae-forgotten-export) The symbol "ModerationLogPayloads" needs to be exported by the entry point index.d.ts // src/streaming.types.ts:33:4 - (ae-forgotten-export) The symbol "FIXME" needs to be exported by the entry point index.d.ts // (No @packageDocumentation comment for this package) diff --git a/packages/cherrypick-js/package.json b/packages/cherrypick-js/package.json index c663be961f..c2148ecea5 100644 --- a/packages/cherrypick-js/package.json +++ b/packages/cherrypick-js/package.json @@ -22,10 +22,10 @@ "devDependencies": { "@microsoft/api-extractor": "7.38.0", "@swc/jest": "0.2.29", - "@types/jest": "29.5.5", - "@types/node": "20.8.4", - "@typescript-eslint/eslint-plugin": "6.7.5", - "@typescript-eslint/parser": "6.7.5", + "@types/jest": "29.5.6", + "@types/node": "20.8.7", + "@typescript-eslint/eslint-plugin": "6.8.0", + "@typescript-eslint/parser": "6.8.0", "eslint": "8.51.0", "jest": "29.7.0", "jest-fetch-mock": "3.0.3", @@ -39,7 +39,7 @@ ], "dependencies": { "@swc/cli": "0.1.62", - "@swc/core": "1.3.92", + "@swc/core": "1.3.93", "eventemitter3": "5.0.1", "reconnecting-websocket": "4.4.0" } diff --git a/packages/cherrypick-js/src/api.types.ts b/packages/cherrypick-js/src/api.types.ts index 1400ff2ebb..d652e69283 100644 --- a/packages/cherrypick-js/src/api.types.ts +++ b/packages/cherrypick-js/src/api.types.ts @@ -328,7 +328,10 @@ export type Endpoints = { 'federation/users': { req: { host: string; limit?: number; sinceId?: User['id']; untilId?: User['id']; }; res: UserDetailed[]; }; // following - 'following/create': { req: { userId: User['id'] }; res: User; }; + 'following/create': { req: { + userId: User['id'], + withReplies?: boolean, + }; res: User; }; 'following/delete': { req: { userId: User['id'] }; res: User; }; 'following/requests/accept': { req: { userId: User['id'] }; res: null; }; 'following/requests/cancel': { req: { userId: User['id'] }; res: User; }; @@ -523,6 +526,7 @@ export type Endpoints = { } }; res: { createdNote: Note }; }; 'notes/delete': { req: { noteId: Note['id']; }; res: null; }; + 'notes/update': { req: { noteId: Note['id']; text?: null | string; cw?: null | string; }; res: null; }; 'notes/favorites/create': { req: { noteId: Note['id']; }; res: null; }; 'notes/favorites/delete': { req: { noteId: Note['id']; }; res: null; }; 'notes/featured': { req: TODO; res: Note[]; }; @@ -664,4 +668,11 @@ export type Endpoints = { $default: UserDetailed; }; }; }; + + // fetching external data + 'fetch-rss': { req: { url: string; }; res: TODO; }; + 'fetch-external-resources': { + req: { url: string; hash: string; }; + res: { type: string; data: string; }; + }; }; diff --git a/packages/cherrypick-js/src/entities.ts b/packages/cherrypick-js/src/entities.ts index dc2fbbbbd6..ed3040309a 100644 --- a/packages/cherrypick-js/src/entities.ts +++ b/packages/cherrypick-js/src/entities.ts @@ -12,7 +12,7 @@ export type UserLite = { id: ID; username: string; host: string | null; - name: string; + name: string | null; onlineStatus: 'online' | 'active' | 'offline' | 'unknown'; avatarUrl: string; avatarBlurhash: string; @@ -28,6 +28,8 @@ export type UserLite = { faviconUrl: Instance['faviconUrl']; themeColor: Instance['themeColor']; }; + isCat?: boolean; + isBot?: boolean; }; export type UserDetailed = UserLite & { @@ -179,6 +181,7 @@ export type Note = { id: ID; createdAt: DateString; updatedAt?: DateString | null; + updatedAtHistory: DateString[] | null; noteEditHistory: string[]; text: string | null; cw: string | null; @@ -395,6 +398,7 @@ export type InstanceMetadata = LiteInstanceMetadata | DetailedInstanceMetadata; export type AdminInstanceMetadata = DetailedInstanceMetadata & { // TODO: There are more fields. blockedHosts: string[]; + silencedHosts: string[]; app192IconUrl: string | null; app512IconUrl: string | null; manifestJsonOverride: string; @@ -480,6 +484,7 @@ export type Antenna = { userGroupId: ID | null; // TODO users: string[]; // TODO caseSensitive: boolean; + localOnly: boolean; notify: boolean; withReplies: boolean; withFile: boolean; @@ -554,6 +559,7 @@ export type Instance = { lastCommunicatedAt: DateString; isNotResponding: boolean; isSuspended: boolean; + isSilenced: boolean; isBlocked: boolean; softwareName: string | null; softwareVersion: string | null; diff --git a/packages/frontend/package.json b/packages/frontend/package.json index 0989bbad76..155023a5e0 100644 --- a/packages/frontend/package.json +++ b/packages/frontend/package.json @@ -21,16 +21,16 @@ "@github/webauthn-json": "2.1.1", "@rollup/plugin-alias": "5.0.1", "@rollup/plugin-json": "6.0.1", - "@rollup/plugin-replace": "5.0.3", + "@rollup/plugin-replace": "5.0.4", "@rollup/pluginutils": "5.0.5", "@syuilo/aiscript": "0.16.0", "@tabler/icons-webfont": "2.37.0", "@vitejs/plugin-vue": "4.4.0", "@vue-macros/reactivity-transform": "0.3.23", - "@vue/compiler-sfc": "3.3.4", + "@vue/compiler-sfc": "3.3.5", "astring": "1.8.6", "autosize": "6.0.1", - "broadcast-channel": "5.3.0", + "broadcast-channel": "5.5.0", "browser-image-resizer": "github:misskey-dev/browser-image-resizer#v2.2.1-misskey.3", "buraha": "0.0.1", "canvas-confetti": "1.6.1", @@ -41,7 +41,7 @@ "chartjs-plugin-zoom": "2.0.1", "cherrypick-js": "workspace:*", "cherrypick-mfm-js": "github:kokonect-link/mfm.js", - "chromatic": "7.2.3", + "chromatic": "7.4.0", "compare-versions": "6.1.0", "cropperjs": "2.0.0-beta.4", "date-fns": "2.30.0", @@ -60,9 +60,9 @@ "prismjs": "1.29.0", "punycode": "2.3.0", "querystring": "0.2.1", - "rollup": "4.0.2", + "rollup": "4.1.4", "sanitize-html": "2.11.0", - "sass": "1.69.1", + "sass": "1.69.4", "strict-event-emitter-types": "2.0.0", "temml": "0.10.13", "textarea-caret": "3.1.0", @@ -76,52 +76,52 @@ "uuid": "9.0.1", "v-code-diff": "1.7.1", "vanilla-tilt": "1.8.1", - "vite": "4.4.11", - "vue": "3.3.4", + "vite": "4.5.0", + "vue": "3.3.5", "vue-prism-editor": "2.0.0-alpha.2", "vuedraggable": "next" }, "devDependencies": { - "@storybook/addon-actions": "7.4.6", - "@storybook/addon-essentials": "7.4.6", - "@storybook/addon-interactions": "7.4.6", - "@storybook/addon-links": "7.4.6", - "@storybook/addon-storysource": "7.4.6", - "@storybook/addons": "7.4.6", - "@storybook/blocks": "7.4.6", - "@storybook/core-events": "7.4.6", + "@storybook/addon-actions": "7.5.1", + "@storybook/addon-essentials": "7.5.1", + "@storybook/addon-interactions": "7.5.1", + "@storybook/addon-links": "7.5.1", + "@storybook/addon-storysource": "7.5.1", + "@storybook/addons": "7.5.1", + "@storybook/blocks": "7.5.1", + "@storybook/core-events": "7.5.1", "@storybook/jest": "0.2.3", - "@storybook/manager-api": "7.4.6", - "@storybook/preview-api": "7.4.6", - "@storybook/react": "7.4.6", - "@storybook/react-vite": "7.4.6", + "@storybook/manager-api": "7.5.1", + "@storybook/preview-api": "7.5.1", + "@storybook/react": "7.5.1", + "@storybook/react-vite": "7.5.1", "@storybook/testing-library": "0.2.2", - "@storybook/theming": "7.4.6", - "@storybook/types": "7.4.6", - "@storybook/vue3": "7.4.6", - "@storybook/vue3-vite": "7.4.6", + "@storybook/theming": "7.5.1", + "@storybook/types": "7.5.1", + "@storybook/vue3": "7.5.1", + "@storybook/vue3-vite": "7.5.1", "@testing-library/vue": "7.0.0", "@types/autosize": "^4.0.1", - "@types/escape-regexp": "0.0.1", - "@types/estree": "1.0.2", - "@types/matter-js": "0.19.1", - "@types/micromatch": "4.0.3", - "@types/node": "20.8.4", + "@types/escape-regexp": "0.0.2", + "@types/estree": "1.0.3", + "@types/matter-js": "0.19.2", + "@types/micromatch": "4.0.4", + "@types/node": "20.8.7", "@types/prismjs": "^1.26.0", - "@types/punycode": "2.1.0", - "@types/sanitize-html": "2.9.1", - "@types/throttle-debounce": "5.0.0", - "@types/tinycolor2": "1.4.4", - "@types/uuid": "9.0.5", - "@types/websocket": "1.0.7", - "@types/ws": "8.5.6", - "@typescript-eslint/eslint-plugin": "6.7.5", - "@typescript-eslint/parser": "6.7.5", + "@types/punycode": "2.1.1", + "@types/sanitize-html": "2.9.3", + "@types/throttle-debounce": "5.0.1", + "@types/tinycolor2": "1.4.5", + "@types/uuid": "9.0.6", + "@types/websocket": "1.0.8", + "@types/ws": "8.5.8", + "@typescript-eslint/eslint-plugin": "6.8.0", + "@typescript-eslint/parser": "6.8.0", "@vitest/coverage-v8": "0.34.6", - "@vue/runtime-core": "3.3.4", + "@vue/runtime-core": "3.3.5", "acorn": "8.10.0", "cross-env": "7.0.3", - "cypress": "13.3.0", + "cypress": "13.3.2", "eslint": "8.51.0", "eslint-plugin-import": "2.28.1", "eslint-plugin-storybook": "^0.6.13", @@ -130,19 +130,19 @@ "happy-dom": "10.0.3", "micromatch": "4.0.5", "msw": "1.3.2", - "msw-storybook-addon": "1.8.0", + "msw-storybook-addon": "1.9.0", "nodemon": "3.0.1", "prettier": "3.0.3", "react": "18.2.0", "react-dom": "18.2.0", "start-server-and-test": "2.0.1", - "storybook": "7.4.6", + "storybook": "7.5.1", "storybook-addon-misskey-theme": "github:misskey-dev/storybook-addon-misskey-theme", "summaly": "github:misskey-dev/summaly", "vite-plugin-turbosnap": "1.0.3", "vitest": "0.34.6", "vitest-fetch-mock": "0.2.2", "vue-eslint-parser": "9.3.2", - "vue-tsc": "1.8.18" + "vue-tsc": "1.8.19" } } diff --git a/packages/frontend/src/components/MkAutocomplete.vue b/packages/frontend/src/components/MkAutocomplete.vue index d5df85b056..e349a7ada4 100644 --- a/packages/frontend/src/components/MkAutocomplete.vue +++ b/packages/frontend/src/components/MkAutocomplete.vue @@ -127,7 +127,6 @@ export default { diff --git a/packages/frontend/src/components/global/MkUrl.vue b/packages/frontend/src/components/global/MkUrl.vue index a53698ce51..a84b9e383b 100644 --- a/packages/frontend/src/components/global/MkUrl.vue +++ b/packages/frontend/src/components/global/MkUrl.vue @@ -31,23 +31,28 @@ import * as os from '@/os.js'; import { useTooltip } from '@/scripts/use-tooltip.js'; import { safeURIDecode } from '@/scripts/safe-uri-decode.js'; -const props = defineProps<{ +const props = withDefaults(defineProps<{ url: string; rel?: string; -}>(); + showUrlPreview?: boolean; +}>(), { + showUrlPreview: true, +}); const self = props.url.startsWith(local); const url = new URL(props.url); if (!['http:', 'https:'].includes(url.protocol)) throw new Error('invalid url'); const el = ref(); -useTooltip(el, (showing) => { - os.popup(defineAsyncComponent(() => import('@/components/MkUrlPreviewPopup.vue')), { - showing, - url: props.url, - source: el.value, - }, {}, 'closed'); -}); +if (props.showUrlPreview) { + useTooltip(el, (showing) => { + os.popup(defineAsyncComponent(() => import('@/components/MkUrlPreviewPopup.vue')), { + showing, + url: props.url, + source: el.value, + }, {}, 'closed'); + }); +} const schema = url.protocol; const hostname = decodePunycode(url.hostname); diff --git a/packages/frontend/src/pages/about-misskey.vue b/packages/frontend/src/pages/about-misskey.vue index 942769896a..624d62f60e 100644 --- a/packages/frontend/src/pages/about-misskey.vue +++ b/packages/frontend/src/pages/about-misskey.vue @@ -279,6 +279,9 @@ const patronsWithIconWithMisskey = [{ }, { name: '百日紅', icon: 'https://misskey-hub.net/patrons/302dce2898dd457ba03c3f7dc037900b.jpg', +}, { + name: 'taichan', + icon: 'https://misskey-hub.net/patrons/f981ab0159fb4e2c998e05f7263e1cd9.png', }]; const patronsWithCherryPick = [ diff --git a/packages/frontend/src/pages/about.federation.vue b/packages/frontend/src/pages/about.federation.vue index 43887ec425..8c11ddd1dc 100644 --- a/packages/frontend/src/pages/about.federation.vue +++ b/packages/frontend/src/pages/about.federation.vue @@ -18,6 +18,7 @@ SPDX-License-Identifier: AGPL-3.0-only + @@ -75,6 +76,7 @@ const pagination = { state === 'publishing' ? { publishing: true } : state === 'suspended' ? { suspended: true } : state === 'blocked' ? { blocked: true } : + state === 'silenced' ? { silenced: true } : state === 'notResponding' ? { notResponding: true } : {}), })), @@ -83,6 +85,7 @@ const pagination = { function getStatus(instance) { if (instance.isSuspended) return 'Suspended'; if (instance.isBlocked) return 'Blocked'; + if (instance.isSilenced) return 'Silenced'; if (instance.isNotResponding) return 'Error'; return 'Alive'; } diff --git a/packages/frontend/src/pages/admin/instance-block.vue b/packages/frontend/src/pages/admin/instance-block.vue index 2e7024d5a1..7d1a47d7f3 100644 --- a/packages/frontend/src/pages/admin/instance-block.vue +++ b/packages/frontend/src/pages/admin/instance-block.vue @@ -5,14 +5,17 @@ SPDX-License-Identifier: AGPL-3.0-only + + diff --git a/packages/frontend/src/pages/instance-info.vue b/packages/frontend/src/pages/instance-info.vue index 606b203918..38b0042fdb 100644 --- a/packages/frontend/src/pages/instance-info.vue +++ b/packages/frontend/src/pages/instance-info.vue @@ -36,6 +36,7 @@ SPDX-License-Identifier: AGPL-3.0-only
{{ i18n.ts.stopActivityDelivery }} {{ i18n.ts.blockThisInstance }} + {{ i18n.ts.silenceThisInstance }} Refresh metadata
@@ -147,6 +148,7 @@ let meta = $ref(null); let instance = $ref(null); let suspended = $ref(false); let isBlocked = $ref(false); +let isSilenced = $ref(false); let faviconUrl = $ref(null); const usersPagination = { @@ -169,6 +171,7 @@ async function fetch(): Promise { }); suspended = instance.isSuspended; isBlocked = instance.isBlocked; + isSilenced = instance.isSilenced; faviconUrl = getProxiedImageUrlNullable(instance.faviconUrl, 'preview') ?? getProxiedImageUrlNullable(instance.iconUrl, 'preview'); } @@ -180,7 +183,14 @@ async function toggleBlock(): Promise { blockedHosts: isBlocked ? meta.blockedHosts.concat([host]) : meta.blockedHosts.filter(x => x !== host), }); } - +async function toggleSilenced(): Promise { + if (!meta) throw new Error('No meta?'); + if (!instance) throw new Error('No instance?'); + const { host } = instance; + await os.api('admin/update-meta', { + silencedHosts: isSilenced ? meta.silencedHosts.concat([host]) : meta.silencedHosts.filter(x => x !== host), + }); +} async function toggleSuspend(): Promise { if (!instance) throw new Error('No instance?'); await os.api('admin/federation/update-instance', { diff --git a/packages/frontend/src/pages/my-antennas/create.vue b/packages/frontend/src/pages/my-antennas/create.vue index b32d52100f..d96f9fc80a 100644 --- a/packages/frontend/src/pages/my-antennas/create.vue +++ b/packages/frontend/src/pages/my-antennas/create.vue @@ -14,7 +14,7 @@ import XAntenna from './editor.vue'; import { i18n } from '@/i18n.js'; import { definePageMetadata } from '@/scripts/page-metadata.js'; import { useRouter } from '@/router.js'; -import { antennasCache } from '@/cache'; +import { antennasCache } from '@/cache.js'; const router = useRouter(); @@ -28,6 +28,7 @@ let draft = $ref({ excludeKeywords: [], withReplies: false, caseSensitive: false, + localOnly: false, withFile: false, notify: false, }); diff --git a/packages/frontend/src/pages/my-antennas/editor.vue b/packages/frontend/src/pages/my-antennas/editor.vue index 048a984efb..dd981d082e 100644 --- a/packages/frontend/src/pages/my-antennas/editor.vue +++ b/packages/frontend/src/pages/my-antennas/editor.vue @@ -42,6 +42,7 @@ SPDX-License-Identifier: AGPL-3.0-only + {{ i18n.ts.localOnly }} {{ i18n.ts.caseSensitive }} {{ i18n.ts.withFileAntenna }} {{ i18n.ts.notifyAntenna }} @@ -84,6 +85,7 @@ let users: string = $ref(props.antenna.users.join('\n')); let keywords: string = $ref(props.antenna.keywords.map(x => x.join(' ')).join('\n')); let excludeKeywords: string = $ref(props.antenna.excludeKeywords.map(x => x.join(' ')).join('\n')); let caseSensitive: boolean = $ref(props.antenna.caseSensitive); +let localOnly: boolean = $ref(props.antenna.localOnly); let withReplies: boolean = $ref(props.antenna.withReplies); let withFile: boolean = $ref(props.antenna.withFile); let notify: boolean = $ref(props.antenna.notify); @@ -117,6 +119,7 @@ async function saveAntenna() { withFile, notify, caseSensitive, + localOnly, users: users.trim().split('\n').map(x => x.trim()), keywords: keywords.trim().split('\n').map(x => x.trim().split(' ')), excludeKeywords: excludeKeywords.trim().split('\n').map(x => x.trim().split(' ')), diff --git a/packages/frontend/src/pages/settings/general.vue b/packages/frontend/src/pages/settings/general.vue index 403d49dcef..bf5c321d02 100644 --- a/packages/frontend/src/pages/settings/general.vue +++ b/packages/frontend/src/pages/settings/general.vue @@ -29,6 +29,7 @@ SPDX-License-Identifier: AGPL-3.0-only
{{ i18n.ts.showFixedPostForm }} {{ i18n.ts.showFixedPostFormInChannel }} + {{ i18n.ts.withRepliesByDefaultForNewlyFollowed }} @@ -356,6 +357,7 @@ const mediaListWithOneImageAppearance = computed(defaultStore.makeGetterSetter(' const notificationPosition = computed(defaultStore.makeGetterSetter('notificationPosition')); const notificationStackAxis = computed(defaultStore.makeGetterSetter('notificationStackAxis')); const keepScreenOn = computed(defaultStore.makeGetterSetter('keepScreenOn')); +const defaultWithReplies = computed(defaultStore.makeGetterSetter('defaultWithReplies')); const showUnreadNotificationCount = computed(defaultStore.makeGetterSetter('showUnreadNotificationCount')); const newNoteReceivedNotificationBehavior = computed(defaultStore.makeGetterSetter('newNoteReceivedNotificationBehavior')); const fontSize = computed(defaultStore.makeGetterSetter('fontSize')); diff --git a/packages/frontend/src/pages/settings/import-export.vue b/packages/frontend/src/pages/settings/import-export.vue index 6f422ccaf2..d7bc044bf6 100644 --- a/packages/frontend/src/pages/settings/import-export.vue +++ b/packages/frontend/src/pages/settings/import-export.vue @@ -40,6 +40,9 @@ SPDX-License-Identifier: AGPL-3.0-only + + {{ i18n.ts._exportOrImport.withReplies }} + {{ i18n.ts.import }}
@@ -118,9 +121,11 @@ import { selectFile } from '@/scripts/select-file.js'; import { i18n } from '@/i18n.js'; import { definePageMetadata } from '@/scripts/page-metadata.js'; import { $i } from '@/account.js'; +import { defaultStore } from '@/store.js'; const excludeMutingUsers = ref(false); const excludeInactiveUsers = ref(false); +const withReplies = ref(defaultStore.state.defaultWithReplies); const onExportSuccess = () => { os.alert({ @@ -177,7 +182,10 @@ const exportAntennas = () => { const importFollowing = async (ev) => { const file = await selectFile(ev.currentTarget ?? ev.target); - os.api('i/import-following', { fileId: file.id }).then(onImportSuccess).catch(onError); + os.api('i/import-following', { + fileId: file.id, + withReplies: withReplies.value, + }).then(onImportSuccess).catch(onError); }; const importUserLists = async (ev) => { diff --git a/packages/frontend/src/pages/settings/plugin.install.vue b/packages/frontend/src/pages/settings/plugin.install.vue index 652a82ed85..8d55823a8b 100644 --- a/packages/frontend/src/pages/settings/plugin.install.vue +++ b/packages/frontend/src/pages/settings/plugin.install.vue @@ -18,130 +18,35 @@ SPDX-License-Identifier: AGPL-3.0-only