Skip to content

Conversation

@u1-liquid
Copy link
Member

@u1-liquid u1-liquid commented Jan 4, 2026

Motivation

  • Allow admin/federation/update-instance to act as a host-only cache-invalidation endpoint without doing a DB lookup.
  • Compute the suspensionState value more clearly and concisely in a single expression.
  • Keep moderation operations explicit while making cache invalidation host-only when appropriate.
  • Remove the previously added focused unit test per request.

Description

  • Added invalidate(host: string) to FederatedInstanceService which normalizes the host with UtilityService and deletes the cached entry via federatedInstanceCache.delete.
  • Updated the endpoint in server/api/endpoints/admin/federation/update-instance.ts to normalize the host up-front and early-return to call federatedInstanceService.invalidate(normalizedHost) when both isSuspended and moderationNote are null.
  • Refactored suspension state computation into the single expression const suspensionState = (ps.isSuspended != null && isSuspendedBefore !== ps.isSuspended) ? (ps.isSuspended ? 'manuallySuspended' : 'none') : undefined;.
  • Removed the unit test file packages/backend/test/unit/server/api/admin/federation/update-instance.ts as requested.

Testing

  • The removed unit test file packages/backend/test/unit/server/api/admin/federation/update-instance.ts was deleted and therefore not executed here.
  • No automated test suites were run in this environment.
  • Changes were limited and focused to preserve existing behavior for non-host-only requests and cache semantics.
  • Lint and style conventions were preserved in the diff.

Codex Task

Summary by CodeRabbit

リリースノート

  • 新機能

    • インスタンス無効化機能が追加されました。
  • 改善

    • インスタンス管理APIのホスト処理が統一化され、処理効率が向上しました。

✏️ Tip: You can customize this high-level summary in your review settings.

Copilot AI review requested due to automatic review settings January 4, 2026 13:32
@snyk-io
Copy link

snyk-io bot commented Jan 4, 2026

Snyk checks have passed. No issues have been found so far.

Status Scanner Critical High Medium Low Total (0)
Open Source Security 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

@coderabbitai
Copy link

coderabbitai bot commented Jan 4, 2026

Walkthrough

フェデレーテッドインスタンスサービスに新しい invalidate メソッドを追加し、ホストを正規化してキャッシュから削除します。これを使用して、インスタンス更新エンドポイント内で早期無効化パスを実装します。

Changes

Cohort / File(s) 変更概要
キャッシュ無効化メソッド追加
packages/backend/src/core/FederatedInstanceService.ts
invalidate(host: string): Promise<void> メソッドを追加。ホストを正規化し、フェデレーテッドインスタンスキャッシュから対応するキーを削除します。
インスタンス更新エンドポイントの変更
packages/backend/src/server/api/endpoints/admin/federation/update-instance.ts
ホストを早期に正規化し、サスペンション状態と調整ノートの両方が無効な場合は無効化メソッドを呼び出して返却する早期リターンを導入。中止状態の計算ロジックを簡潔化。

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐰 キャッシュをさっと削除して、
インスタンスの古い情報は去りぬ、
正規化されたホストの道を進み、
新しい無効化の魔法が輝く。
簡潔なコードで駆ける、ウサギのように!

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description check ✅ Passed PR説明は、Motivation、Description、Testingセクションを含み、リポジトリテンプレートの主要な要素をカバーしています。変更内容、意図、テスト対象が明確に記述されています。
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Title check ✅ Passed The title accurately summarizes the main changes: adding cache invalidation behavior adjustments and removing a unit test, which aligns with the core modifications to FederatedInstanceService and update-instance endpoint.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch 2026-01-04-fix-update-instance-for-cache-invalidation

Comment @coderabbitai help to get the list of available commands and usage tips.

@sonarqubecloud
Copy link

sonarqubecloud bot commented Jan 4, 2026

@u1-liquid u1-liquid changed the title Adjust update-instance cache invalidation behavior and remove unit test spec(federation): Admin APIのupdate-instanceでInstance cacheをクリアできるように Jan 4, 2026
@codecov
Copy link

codecov bot commented Jan 4, 2026

Codecov Report

❌ Patch coverage is 11.76471% with 15 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
.../api/endpoints/admin/federation/update-instance.ts 0.00% 11 Missing ⚠️
...kages/backend/src/core/FederatedInstanceService.ts 33.33% 4 Missing ⚠️

📢 Thoughts on this report? Let us know!

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR enhances the admin/federation/update-instance endpoint to support cache-only invalidation without requiring a database lookup, refactors the suspension state computation for better clarity, and removes a unit test as requested.

  • Adds a new invalidate method to FederatedInstanceService for host-based cache invalidation
  • Enables the endpoint to skip database operations when only cache invalidation is needed
  • Refactors suspension state logic into a single, more concise expression

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
packages/backend/src/core/FederatedInstanceService.ts Adds invalidate method to support cache invalidation by host
packages/backend/src/server/api/endpoints/admin/federation/update-instance.ts Implements early-return for cache-only invalidation and refactors suspension state calculation

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@u1-liquid u1-liquid removed the codex label Jan 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants