fix: invite handler used creator_id but DB column is created_by
This commit is contained in:
@@ -40,7 +40,7 @@ type inviteResponse struct {
|
|||||||
Code string `json:"code"`
|
Code string `json:"code"`
|
||||||
ServerID string `json:"server_id"`
|
ServerID string `json:"server_id"`
|
||||||
ServerName string `json:"server_name"`
|
ServerName string `json:"server_name"`
|
||||||
CreatorID string `json:"creator_id"`
|
CreatorID string `json:"created_by"`
|
||||||
MaxUses *int `json:"max_uses"`
|
MaxUses *int `json:"max_uses"`
|
||||||
UseCount int `json:"use_count"`
|
UseCount int `json:"use_count"`
|
||||||
ExpiresAt *string `json:"expires_at"`
|
ExpiresAt *string `json:"expires_at"`
|
||||||
@@ -145,9 +145,9 @@ func (h *Handler) Create(w http.ResponseWriter, r *http.Request) {
|
|||||||
var createdAtStr sql.NullString
|
var createdAtStr sql.NullString
|
||||||
|
|
||||||
err = h.db.QueryRowContext(r.Context(), `
|
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)
|
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(
|
`, code, serverID, userID, maxUses, expiresAt).Scan(
|
||||||
&invite.ID, &invite.Code, &invite.ServerID, &invite.CreatorID,
|
&invite.ID, &invite.Code, &invite.ServerID, &invite.CreatorID,
|
||||||
&invite.MaxUses, &invite.UseCount, &expiresAtStr, &createdAtStr,
|
&invite.MaxUses, &invite.UseCount, &expiresAtStr, &createdAtStr,
|
||||||
@@ -191,7 +191,7 @@ func (h *Handler) Get(w http.ResponseWriter, r *http.Request) {
|
|||||||
var createdAtStr sql.NullString
|
var createdAtStr sql.NullString
|
||||||
|
|
||||||
err := h.db.QueryRowContext(r.Context(), `
|
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
|
i.max_uses, i.use_count, i.expires_at::text, i.created_at::text
|
||||||
FROM invites i
|
FROM invites i
|
||||||
LEFT JOIN servers s ON s.id = i.server_id
|
LEFT JOIN servers s ON s.id = i.server_id
|
||||||
|
|||||||
Reference in New Issue
Block a user