mirror of
https://github.com/memohai/Memoh.git
synced 2026-04-27 07:16:19 +09:00
85251a2905
- Remove user-level model settings (chat_model_id, memory_model_id, embedding_model_id, max_context_load_time, language) from users table - Merge migration 0002 into 0001, remove compatibility migrations - Delete dead conversation/resolver.go (1177 lines, only flow/resolver.go used) - Remove type aliases (Chat=Conversation, types_alias.go) - Fix SQL: remove AND false stub, fix UpdateChatTitle model_id, reset model IDs in DeleteSettings, add preauth expiry filter, add ListMessages limit, remove 10 dead queries - Extract shared handler helpers (RequireChannelIdentityID, AuthorizeBotAccess) - Rename internal/router to internal/channel/inbound - Fix identity confusion: remove UserID->ChannelIdentityID fallbacks - Fix all _ = var patterns with proper error logging - Fix error propagation: storeMessages, rescheduleJob, botContainerID - Fix naming: ModelId->ModelID, active->is_active, Duration semantic fix - Remove dead code: mcpService, ReplyTarget, callMCPServer, sshShellQuote, buildSessionMetadata, ChatRequest.Language, TriggerPayload.ChatID - Fix code quality: errors.Is(), remove goto, CreateHuman deprecated - Remove Enable model endpoint and user-level settings CLI commands - Regenerate sqlc, swagger, SDK
92 lines
2.1 KiB
Go
92 lines
2.1 KiB
Go
// Code generated by sqlc. DO NOT EDIT.
|
|
// versions:
|
|
// sqlc v1.30.0
|
|
// source: preauth.sql
|
|
|
|
package sqlc
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/jackc/pgx/v5/pgtype"
|
|
)
|
|
|
|
const createBotPreauthKey = `-- name: CreateBotPreauthKey :one
|
|
INSERT INTO bot_preauth_keys (bot_id, token, issued_by_user_id, expires_at)
|
|
VALUES ($1, $2, $3, $4)
|
|
RETURNING id, bot_id, token, issued_by_user_id, expires_at, used_at, created_at
|
|
`
|
|
|
|
type CreateBotPreauthKeyParams struct {
|
|
BotID pgtype.UUID `json:"bot_id"`
|
|
Token string `json:"token"`
|
|
IssuedByUserID pgtype.UUID `json:"issued_by_user_id"`
|
|
ExpiresAt pgtype.Timestamptz `json:"expires_at"`
|
|
}
|
|
|
|
func (q *Queries) CreateBotPreauthKey(ctx context.Context, arg CreateBotPreauthKeyParams) (BotPreauthKey, error) {
|
|
row := q.db.QueryRow(ctx, createBotPreauthKey,
|
|
arg.BotID,
|
|
arg.Token,
|
|
arg.IssuedByUserID,
|
|
arg.ExpiresAt,
|
|
)
|
|
var i BotPreauthKey
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.BotID,
|
|
&i.Token,
|
|
&i.IssuedByUserID,
|
|
&i.ExpiresAt,
|
|
&i.UsedAt,
|
|
&i.CreatedAt,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const getBotPreauthKey = `-- name: GetBotPreauthKey :one
|
|
SELECT id, bot_id, token, issued_by_user_id, expires_at, used_at, created_at
|
|
FROM bot_preauth_keys
|
|
WHERE token = $1
|
|
AND used_at IS NULL
|
|
AND (expires_at IS NULL OR expires_at > now())
|
|
LIMIT 1
|
|
`
|
|
|
|
func (q *Queries) GetBotPreauthKey(ctx context.Context, token string) (BotPreauthKey, error) {
|
|
row := q.db.QueryRow(ctx, getBotPreauthKey, token)
|
|
var i BotPreauthKey
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.BotID,
|
|
&i.Token,
|
|
&i.IssuedByUserID,
|
|
&i.ExpiresAt,
|
|
&i.UsedAt,
|
|
&i.CreatedAt,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const markBotPreauthKeyUsed = `-- name: MarkBotPreauthKeyUsed :one
|
|
UPDATE bot_preauth_keys
|
|
SET used_at = now()
|
|
WHERE id = $1
|
|
RETURNING id, bot_id, token, issued_by_user_id, expires_at, used_at, created_at
|
|
`
|
|
|
|
func (q *Queries) MarkBotPreauthKeyUsed(ctx context.Context, id pgtype.UUID) (BotPreauthKey, error) {
|
|
row := q.db.QueryRow(ctx, markBotPreauthKeyUsed, id)
|
|
var i BotPreauthKey
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.BotID,
|
|
&i.Token,
|
|
&i.IssuedByUserID,
|
|
&i.ExpiresAt,
|
|
&i.UsedAt,
|
|
&i.CreatedAt,
|
|
)
|
|
return i, err
|
|
}
|