fix: invite handler used creator_id but DB column is created_by

This commit is contained in:
2026-06-29 15:32:24 -04:00
parent 7261ebaafa
commit 6a737c3db3
+4 -4
View File
@@ -40,7 +40,7 @@ type inviteResponse struct {
Code string `json:"code"`
ServerID string `json:"server_id"`
ServerName string `json:"server_name"`
CreatorID string `json:"creator_id"`
CreatorID string `json:"created_by"`
MaxUses *int `json:"max_uses"`
UseCount int `json:"use_count"`
ExpiresAt *string `json:"expires_at"`
@@ -145,9 +145,9 @@ func (h *Handler) Create(w http.ResponseWriter, r *http.Request) {
var createdAtStr sql.NullString
err = h.db.QueryRowContext(r.Context(), `
INSERT INTO invites (code, server_id, creator_id, max_uses, expires_at)
INSERT INTO invites (code, server_id, created_by, max_uses, expires_at)
VALUES ($1, $2, $3, $4, $5)
RETURNING id, code, server_id, creator_id, max_uses, use_count, expires_at::text, created_at::text
RETURNING id, code, server_id, created_by, max_uses, use_count, expires_at::text, created_at::text
`, code, serverID, userID, maxUses, expiresAt).Scan(
&invite.ID, &invite.Code, &invite.ServerID, &invite.CreatorID,
&invite.MaxUses, &invite.UseCount, &expiresAtStr, &createdAtStr,
@@ -191,7 +191,7 @@ func (h *Handler) Get(w http.ResponseWriter, r *http.Request) {
var createdAtStr sql.NullString
err := h.db.QueryRowContext(r.Context(), `
SELECT i.id, i.code, i.server_id, COALESCE(s.name, ''), i.creator_id,
SELECT i.id, i.code, i.server_id, COALESCE(s.name, ''), i.created_by,
i.max_uses, i.use_count, i.expires_at::text, i.created_at::text
FROM invites i
LEFT JOIN servers s ON s.id = i.server_id