Changeset 0.29.0 (#195)

This commit is contained in:
2026-03-17 16:28:47 +00:00
parent 128cbb8174
commit 5d637d3a90
129 changed files with 9418 additions and 3016 deletions

View File

@@ -6,7 +6,6 @@ import (
"github.com/gin-gonic/gin"
"git.gobha.me/xcaliber/chat-switchboard/database"
"git.gobha.me/xcaliber/chat-switchboard/models"
"git.gobha.me/xcaliber/chat-switchboard/store"
)
@@ -260,17 +259,10 @@ func (h *ParticipantHandler) Remove(c *gin.Context) {
}
// v0.23.2: DM guard — cannot drop below 2 human participants
var channelType string
_ = database.DB.QueryRowContext(c.Request.Context(), database.Q(`
SELECT COALESCE(type, 'direct') FROM channels WHERE id = $1
`), channelID).Scan(&channelType)
channelType, _, _ := h.stores.Channels.GetTypeAndTeamID(c.Request.Context(), channelID)
if channelType == "dm" && p.ParticipantType == "user" {
var userCount int
_ = database.DB.QueryRowContext(c.Request.Context(), database.Q(`
SELECT COUNT(*) FROM channel_participants
WHERE channel_id = $1 AND participant_type = 'user'
`), channelID).Scan(&userCount)
userCount, _ := h.stores.Channels.CountParticipantsByType(c.Request.Context(), channelID, "user")
if userCount <= 2 {
c.JSON(http.StatusConflict, gin.H{"error": "DMs require at least 2 participants"})
return
@@ -279,11 +271,7 @@ func (h *ParticipantHandler) Remove(c *gin.Context) {
// v0.23.2: Group guard — cannot remove the last persona
if channelType == "group" && p.ParticipantType == "persona" {
var personaCount int
_ = database.DB.QueryRowContext(c.Request.Context(), database.Q(`
SELECT COUNT(*) FROM channel_participants
WHERE channel_id = $1 AND participant_type = 'persona'
`), channelID).Scan(&personaCount)
personaCount, _ := h.stores.Channels.CountParticipantsByType(c.Request.Context(), channelID, "persona")
if personaCount <= 1 {
c.JSON(http.StatusConflict, gin.H{"error": "group chats require at least 1 persona"})
return