Skip to content

Type C# channel kinds#1639

Closed
samuelscheit wants to merge 3 commits intospacebarchat:masterfrom
samuelscheit2:fix/1610-channel-type-enum
Closed

Type C# channel kinds#1639
samuelscheit wants to merge 3 commits intospacebarchat:masterfrom
samuelscheit2:fix/1610-channel-type-enum

Conversation

@samuelscheit
Copy link
Copy Markdown
Member

Summary

  • Add a shared C# ChannelType enum for the DB Channel.Type model, aligned with Discord/Spacebar channel IDs.
  • Replace Admin API/Offload channel-type magic-number checks with named enum values.
  • Add .NET model tests covering enum values, typed entity usage, EF query behavior, and Npgsql integer-column mapping.

Root cause

The Admin API TODO came from raw integer channel-kind checks (1 for DM, 2 for guild voice). Keeping Channel.Type as an int allowed more magic-number drift; typing the DB model at the source keeps all C# callers on the same channel-kind contract while preserving the existing integer database column.

Validation

  • git diff --check origin/master...HEAD
  • dotnet test extra/admin-api/Tests/Spacebar.Models.Db.Tests/Spacebar.Models.Db.Tests.csproj --artifacts-path /tmp/spacebar-channel-type-test --nologo --verbosity minimal
  • dotnet build extra/admin-api/Spacebar.AdminApi/Spacebar.AdminApi.csproj --artifacts-path /tmp/spacebar-channel-type-adminapi-build --nologo --verbosity minimal
  • dotnet build extra/admin-api/Spacebar.Offload/Spacebar.Offload.csproj --artifacts-path /tmp/spacebar-channel-type-offload-build --nologo --verbosity minimal
  • dotnet test extra/admin-api/SpacebarAdminAPI.slnx --artifacts-path /tmp/spacebar-channel-type-sln-test --nologo --verbosity quiet

Addresses the channel-type enum TODO from #1610.

@samuelscheit samuelscheit marked this pull request as ready for review May 6, 2026 04:55
@samuelscheit
Copy link
Copy Markdown
Member Author

Code review: I reviewed the final diff for the C# channel type enum change and found no blocking issues. The DB model remains mapped to the existing integer column, the magic-number channel type checks are replaced with named enum values, and the added tests cover the changed behavior. Approved.

Copilot AI review requested due to automatic review settings May 6, 2026 04:55
@samuelscheit
Copy link
Copy Markdown
Member Author

Final PR handling report for the channel-type enum work:

Changed files

  • .lintstagedrc.mjs
  • eslint.config.mjs
  • src/cdn/util/Storage.ts
  • extra/admin-api/Models/Spacebar.Models.Db/Models/Channel.cs
  • extra/admin-api/Models/Spacebar.Models.Db/Models/ChannelType.cs
  • extra/admin-api/Spacebar.AdminApi/Controllers/TestControllers/EmptyDmsController.cs
  • extra/admin-api/Spacebar.Offload/Controllers/ChannelStatusController.cs
  • extra/admin-api/SpacebarAdminAPI.slnx
  • extra/admin-api/Tests/Spacebar.Models.Db.Tests/ChannelTypeTests.cs
  • extra/admin-api/Tests/Spacebar.Models.Db.Tests/Spacebar.Models.Db.Tests.csproj

Tests and checks run

  • git diff --check origin/master...HEAD — passed
  • dotnet test extra/admin-api/Tests/Spacebar.Models.Db.Tests/Spacebar.Models.Db.Tests.csproj --artifacts-path /tmp/spacebar-channel-type-test --nologo --verbosity minimal — passed, 23 tests
  • dotnet build extra/admin-api/Spacebar.AdminApi/Spacebar.AdminApi.csproj --artifacts-path /tmp/spacebar-channel-type-adminapi-build --nologo --verbosity minimal — passed, 0 errors (existing warnings remain)
  • dotnet build extra/admin-api/Spacebar.Offload/Spacebar.Offload.csproj --artifacts-path /tmp/spacebar-channel-type-offload-build --nologo --verbosity minimal — passed, 0 errors (existing warnings remain)
  • dotnet test extra/admin-api/SpacebarAdminAPI.slnx --artifacts-path /tmp/spacebar-channel-type-sln-test --nologo --verbosity quiet — passed, 23 tests
  • npx prettier --check . — passed
  • GitHub Actions build (24.x) — passed
  • GitHub Actions build-nix — passed

Review outcome

Reviewed the final diff after the CI formatting follow-up. The root cause is addressed by typing the DB channel kind once as ChannelType, replacing the raw 1/2 channel-type checks, and adding tests that verify enum values plus EF/Npgsql integer mapping. I found no blocking issues.

Decision: approved; no another pass needed.

Copy link
Copy Markdown

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.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants