diff options
| author | Christophe Besson <cbesson@gmail.com> | 2026-08-09 05:17:28 +0200 |
|---|---|---|
| committer | Christophe Besson <cbesson@gmail.com> | 2026-08-09 05:17:28 +0200 |
| commit | 42556800d103ede20b4e97f2d91d20bbc0000c1e (patch) | |
| tree | 1a392221995f4e8092bd20fb3acdd95a28c1d1f1 /packages/meshbay-hub/src/meshbay_hub/db/models.py | |
| parent | 1734c668406c66e2be63e0c6999b4b2af2f60808 (diff) | |
| download | meshbay-42556800d103ede20b4e97f2d91d20bbc0000c1e.tar.gz | |
feat(hub): add moderation — content blocklist + reports — 5.9
DB: ContentReport + ContentBlocklist tables.
POST /v1/reports: public endpoint, auto-blocks after 2 reports.
GET /v1/blocklist/check: node sync check before serving public content.
GET /v1/blocklist: full list for node startup sync.
GET|POST|DELETE /v1/admin/blocklist: admin management.
6/6 tests. Full suite: 59/59.
Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
Diffstat (limited to 'packages/meshbay-hub/src/meshbay_hub/db/models.py')
| -rw-r--r-- | packages/meshbay-hub/src/meshbay_hub/db/models.py | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/packages/meshbay-hub/src/meshbay_hub/db/models.py b/packages/meshbay-hub/src/meshbay_hub/db/models.py index 3814f2e..63cc8c3 100644 --- a/packages/meshbay-hub/src/meshbay_hub/db/models.py +++ b/packages/meshbay-hub/src/meshbay_hub/db/models.py @@ -142,6 +142,41 @@ class RefreshToken(Base): # ── IP logs (legal compliance) ──────────────────────────────────────────────── +class ContentReport(Base): + """ + Report of a public content hash for moderation. + Two reports → automatic suspension. Third → admin review needed. + """ + __tablename__ = "content_reports" + + id: Mapped[int] = mapped_column(Integer, primary_key=True, autoincrement=True) + reporter_id: Mapped[str | None] = mapped_column(ForeignKey("users.id")) + content_hash: Mapped[str] = mapped_column(String(64), nullable=False) # blake3 hex + group_id: Mapped[str | None] = mapped_column(ForeignKey("groups.id")) + reason: Mapped[str] = mapped_column(String(32), default="illegal") + detail: Mapped[str | None] = mapped_column(String(256)) + ip_address: Mapped[str] = mapped_column(String(45), nullable=False) + reported_at: Mapped[datetime] = mapped_column(DateTime(timezone=True), default=_now) + + __table_args__ = ( + Index("ix_content_reports_hash", "content_hash"), + Index("ix_content_reports_group", "group_id"), + ) + + +class ContentBlocklist(Base): + """ + Hash-based blocklist for public content. + Populated automatically after threshold reports, or manually by admins. + """ + __tablename__ = "content_blocklist" + + content_hash: Mapped[str] = mapped_column(String(64), primary_key=True) + reason: Mapped[str] = mapped_column(String(64), nullable=False) + added_at: Mapped[datetime] = mapped_column(DateTime(timezone=True), default=_now) + added_by: Mapped[str | None] = mapped_column(String(64)) # "auto" or admin username + + class IPLog(Base): """ Connection log for legal compliance. |