Skip to content

✨ Add user block/mute domain foundation and REST API - #17

Merged
turtton merged 2 commits into
mainfrom
feature/block-mute-core
Jul 25, 2026
Merged

✨ Add user block/mute domain foundation and REST API#17
turtton merged 2 commits into
mainfrom
feature/block-mute-core

Conversation

@turtton

@turtton turtton commented Jul 22, 2026

Copy link
Copy Markdown
Member

Summary

Close #16

ユーザーブロック/ミュート機能のドメイン基盤と REST API を実装。既存 Follow の純粋 CRUD Repository パターンに倣い、エンティティ・Repository・ユースケース・エンドポイントを新設。ブロック成立時の双方向フォロー解除までをローカルで完結させる。ActivityPub 連合(Block アクティビティの配送/受信)は後続 issue (block-mute-federation) で扱う。

Changes

  • Migration 20260722000001_add_blocks_and_mutes.sql: blocks / mutes テーブル(local/remote 排他 CHECK、FK ON DELETE CASCADE、4 方向の部分ユニークインデックス)
  • kernel: Block / Mute エンティティ(Remote→Remote はドメインルールで拒否)、BlockRepository / MuteRepository trait、テストビルダー
  • driver: Postgres 実装。重複作成は 23505 → KernelError::Rejected、存在しない削除は NotFound
  • application: block/unblock/get_blocks・mute/unmute/get_mutes の 6 ユースケース
    • ターゲット解決: ローカル nanoid → リモート actor URL / acct(remote_actor ヘルパーを pub(crate) に widening して再利用)
    • ブロック成立時に remove_follows_between で双方向のフォロー関係を解除
    • 権限チェックは follow と同じ account_sign パーミッション
  • server: 認証付き REST エンドポイント 6 本(/api/v1/accounts/{account_id}/ 配下)
Method Path Description
POST /accounts/{account_id}/block ブロック作成(フォロー双方向解除込み)
POST /accounts/{account_id}/unblock ブロック解除
GET /accounts/{account_id}/blocks ブロック一覧
POST /accounts/{account_id}/mute ミュート作成
POST /accounts/{account_id}/unmute ミュート解除
GET /accounts/{account_id}/mutes ミュート一覧

Test plan

  • cargo test --workspace 全パス(実 DB: 257 passed / 0 failed)
  • 新規テスト 7 件: driver の block/mute repository CRUD 各 3 件 + ブロック→双方向フォロー解除のビヘイビアテスト 1 件
  • OpenAPI 駆動 route smoke test で 6 ルートの到達性・401 認証要件を確認
  • cargo fmt --check / git diff --check パス

🤖 Generated with OhMyOpenCode

turtton added 2 commits July 22, 2026 08:38
Add Block and Mute relationship support following the existing pure-CRUD
Follow pattern across all layers:

- Migration: blocks/mutes tables with local/remote exclusive CHECK
  constraints, FK CASCADE, and partial unique indexes per direction
- kernel: Block/Mute entities (rejecting remote-to-remote) and
  BlockRepository/MuteRepository traits
- driver: Postgres implementations with duplicate detection (23505)
- application: block/unblock/get_blocks and mute/unmute/get_mutes use
  cases with local-nanoid/remote-actor target resolution; blocking an
  account removes follow relationships in both directions
- server: authenticated REST endpoints under
  /api/v1/accounts/{account_id}/{block,unblock,blocks,mute,unmute,mutes}
  with OpenAPI registration

ActivityPub federation of Block activities is out of scope and will be
handled in a follow-up issue (block-mute-federation).
@turtton turtton added intent-target intent-cli workflow label intent-pr-reviewing intent-cli workflow label labels Jul 22, 2026
@turtton
turtton merged commit 17a7f2b into main Jul 25, 2026
11 checks passed
@turtton
turtton deleted the feature/block-mute-core branch July 25, 2026 03:47
turtton added a commit that referenced this pull request Jul 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

intent-pr-reviewing intent-cli workflow label intent-target intent-cli workflow label

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ユーザーブロック/ミュート: エンティティと REST API の実装

1 participant