Changeset 0.8.1 (#44)

This commit is contained in:
2026-02-22 01:22:23 +00:00
parent 1adef94617
commit c0d95fd7f5
13 changed files with 473 additions and 55 deletions

View File

@@ -269,7 +269,7 @@ func (h *TeamHandler) DeleteTeam(c *gin.Context) {
// ── Members: List ───────────────────────────
func (h *TeamHandler) ListMembers(c *gin.Context) {
teamID := c.Param("id")
teamID := getTeamID(c)
rows, err := database.DB.Query(`
SELECT tm.id, tm.user_id, tm.role, tm.joined_at,
@@ -312,7 +312,7 @@ func (h *TeamHandler) ListMembers(c *gin.Context) {
// ── Members: Add ────────────────────────────
func (h *TeamHandler) AddMember(c *gin.Context) {
teamID := c.Param("id")
teamID := getTeamID(c)
var req addMemberRequest
if err := c.ShouldBindJSON(&req); err != nil {
@@ -445,6 +445,14 @@ func (h *TeamHandler) MyTeams(c *gin.Context) {
// ── Helpers ─────────────────────────────────
// getTeamID extracts team ID from either :id (admin routes) or :teamId (team-scoped routes).
func getTeamID(c *gin.Context) string {
if id := c.Param("teamId"); id != "" {
return id
}
return c.Param("id")
}
// isUniqueViolation checks if a PG error is a unique constraint violation.
func isUniqueViolation(err error) bool {
if err == nil {