mirror of
https://github.com/multica-ai/multica.git
synced 2026-07-05 13:29:44 +02:00
Users can now mute specific notification categories (assignments, status changes, comments & mentions, priority/due-date updates, agent activity) from Settings > Notifications. Muted event types are silently filtered at notification creation time — no inbox items are created for muted groups. - Add notification_preference table (migration 064) - Add GET/PUT /api/notification-preferences endpoints - Filter notifications in notifyIssueSubscribers, notifyDirect, and notifyMentionedMembers based on user preferences - Add Notifications tab in Settings with per-group toggle switches
94 lines
2.6 KiB
Go
94 lines
2.6 KiB
Go
// Code generated by sqlc. DO NOT EDIT.
|
|
// versions:
|
|
// sqlc v1.30.0
|
|
// source: daemon_token.sql
|
|
|
|
package db
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/jackc/pgx/v5/pgtype"
|
|
)
|
|
|
|
const createDaemonToken = `-- name: CreateDaemonToken :one
|
|
INSERT INTO daemon_token (token_hash, workspace_id, daemon_id, expires_at)
|
|
VALUES ($1, $2, $3, $4)
|
|
RETURNING id, token_hash, workspace_id, daemon_id, expires_at, created_at
|
|
`
|
|
|
|
type CreateDaemonTokenParams struct {
|
|
TokenHash string `json:"token_hash"`
|
|
WorkspaceID pgtype.UUID `json:"workspace_id"`
|
|
DaemonID string `json:"daemon_id"`
|
|
ExpiresAt pgtype.Timestamptz `json:"expires_at"`
|
|
}
|
|
|
|
func (q *Queries) CreateDaemonToken(ctx context.Context, arg CreateDaemonTokenParams) (DaemonToken, error) {
|
|
row := q.db.QueryRow(ctx, createDaemonToken,
|
|
arg.TokenHash,
|
|
arg.WorkspaceID,
|
|
arg.DaemonID,
|
|
arg.ExpiresAt,
|
|
)
|
|
var i DaemonToken
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.TokenHash,
|
|
&i.WorkspaceID,
|
|
&i.DaemonID,
|
|
&i.ExpiresAt,
|
|
&i.CreatedAt,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const deleteDaemonTokensByWorkspaceAndDaemon = `-- name: DeleteDaemonTokensByWorkspaceAndDaemon :exec
|
|
DELETE FROM daemon_token
|
|
WHERE workspace_id = $1 AND daemon_id = $2
|
|
`
|
|
|
|
type DeleteDaemonTokensByWorkspaceAndDaemonParams struct {
|
|
WorkspaceID pgtype.UUID `json:"workspace_id"`
|
|
DaemonID string `json:"daemon_id"`
|
|
}
|
|
|
|
// Callers MUST also invalidate auth.DaemonTokenCache for each affected
|
|
// token_hash so the deletion takes effect before the cache TTL expires.
|
|
// Today this query has no caller; when a deregister / rotate flow lands,
|
|
// change this to :many RETURNING token_hash and call
|
|
// DaemonTokenCache.Invalidate(hash) for each row.
|
|
func (q *Queries) DeleteDaemonTokensByWorkspaceAndDaemon(ctx context.Context, arg DeleteDaemonTokensByWorkspaceAndDaemonParams) error {
|
|
_, err := q.db.Exec(ctx, deleteDaemonTokensByWorkspaceAndDaemon, arg.WorkspaceID, arg.DaemonID)
|
|
return err
|
|
}
|
|
|
|
const deleteExpiredDaemonTokens = `-- name: DeleteExpiredDaemonTokens :exec
|
|
DELETE FROM daemon_token
|
|
WHERE expires_at <= now()
|
|
`
|
|
|
|
func (q *Queries) DeleteExpiredDaemonTokens(ctx context.Context) error {
|
|
_, err := q.db.Exec(ctx, deleteExpiredDaemonTokens)
|
|
return err
|
|
}
|
|
|
|
const getDaemonTokenByHash = `-- name: GetDaemonTokenByHash :one
|
|
SELECT id, token_hash, workspace_id, daemon_id, expires_at, created_at FROM daemon_token
|
|
WHERE token_hash = $1 AND expires_at > now()
|
|
`
|
|
|
|
func (q *Queries) GetDaemonTokenByHash(ctx context.Context, tokenHash string) (DaemonToken, error) {
|
|
row := q.db.QueryRow(ctx, getDaemonTokenByHash, tokenHash)
|
|
var i DaemonToken
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.TokenHash,
|
|
&i.WorkspaceID,
|
|
&i.DaemonID,
|
|
&i.ExpiresAt,
|
|
&i.CreatedAt,
|
|
)
|
|
return i, err
|
|
}
|