Files

496 lines
13 KiB
Go
Raw Permalink Normal View History

// Code generated by sqlc. DO NOT EDIT.
// versions:
// sqlc v1.30.0
// source: channels.sql
package dbgen
import (
"context"
"database/sql"
)
const adminUpdateChannel = `-- name: AdminUpdateChannel :exec
UPDATE channels
2026-08-01 22:06:14 +02:00
SET name = ?, topic = ?, category = ?, slow_mode = ?, position = ?, archived = ?,
nsfw = ?, voice_max_users = ?, voice_max_video = ?
WHERE id = ?
`
type AdminUpdateChannelParams struct {
2026-08-01 22:06:14 +02:00
Name string `json:"name"`
Topic *string `json:"topic"`
Category *string `json:"category"`
SlowMode int64 `json:"slowMode"`
Position int64 `json:"position"`
Archived int64 `json:"archived"`
Nsfw int64 `json:"nsfw"`
VoiceMaxUsers int64 `json:"voiceMaxUsers"`
VoiceMaxVideo int64 `json:"voiceMaxVideo"`
ID int64 `json:"id"`
}
func (q *Queries) AdminUpdateChannel(ctx context.Context, arg AdminUpdateChannelParams) error {
_, err := q.db.ExecContext(ctx, adminUpdateChannel,
arg.Name,
arg.Topic,
2026-08-01 22:06:14 +02:00
arg.Category,
arg.SlowMode,
arg.Position,
arg.Archived,
2026-08-01 22:06:14 +02:00
arg.Nsfw,
arg.VoiceMaxUsers,
arg.VoiceMaxVideo,
arg.ID,
)
return err
}
const createChannel = `-- name: CreateChannel :execresult
INSERT INTO channels (name, type, category, topic, position) VALUES (?, ?, ?, ?, ?)
`
type CreateChannelParams struct {
Name string `json:"name"`
Type string `json:"type"`
Category *string `json:"category"`
Topic *string `json:"topic"`
Position int64 `json:"position"`
}
func (q *Queries) CreateChannel(ctx context.Context, arg CreateChannelParams) (sql.Result, error) {
return q.db.ExecContext(ctx, createChannel,
arg.Name,
arg.Type,
arg.Category,
arg.Topic,
arg.Position,
)
}
const deleteChannel = `-- name: DeleteChannel :exec
DELETE FROM channels WHERE id = ?
`
func (q *Queries) DeleteChannel(ctx context.Context, id int64) error {
_, err := q.db.ExecContext(ctx, deleteChannel, id)
return err
}
const deleteChannelPermission = `-- name: DeleteChannelPermission :exec
DELETE FROM channel_overrides WHERE channel_id = ? AND role_id = ?
`
type DeleteChannelPermissionParams struct {
ChannelID int64 `json:"channelId"`
RoleID int64 `json:"roleId"`
}
func (q *Queries) DeleteChannelPermission(ctx context.Context, arg DeleteChannelPermissionParams) error {
_, err := q.db.ExecContext(ctx, deleteChannelPermission, arg.ChannelID, arg.RoleID)
return err
}
2026-08-01 22:06:14 +02:00
const deleteChannelUserPermission = `-- name: DeleteChannelUserPermission :exec
DELETE FROM channel_user_overrides WHERE channel_id = ? AND user_id = ?
`
type DeleteChannelUserPermissionParams struct {
ChannelID int64 `json:"channelId"`
UserID int64 `json:"userId"`
}
func (q *Queries) DeleteChannelUserPermission(ctx context.Context, arg DeleteChannelUserPermissionParams) error {
_, err := q.db.ExecContext(ctx, deleteChannelUserPermission, arg.ChannelID, arg.UserID)
return err
}
const getChannel = `-- name: GetChannel :one
SELECT id, name, type, COALESCE(category, '') AS category, COALESCE(topic, '') AS topic,
position, slow_mode, archived, created_at,
COALESCE(voice_max_users, 0) AS voice_max_users,
voice_quality,
mixing_threshold,
2026-08-01 22:06:14 +02:00
COALESCE(voice_max_video, 0) AS voice_max_video,
nsfw
FROM channels WHERE id = ?
`
type GetChannelRow struct {
ID int64 `json:"id"`
Name string `json:"name"`
Type string `json:"type"`
Category string `json:"category"`
Topic string `json:"topic"`
Position int64 `json:"position"`
SlowMode int64 `json:"slowMode"`
Archived int64 `json:"archived"`
CreatedAt string `json:"createdAt"`
VoiceMaxUsers int64 `json:"voiceMaxUsers"`
VoiceQuality *string `json:"voiceQuality"`
MixingThreshold *int64 `json:"mixingThreshold"`
VoiceMaxVideo int64 `json:"voiceMaxVideo"`
2026-08-01 22:06:14 +02:00
Nsfw int64 `json:"nsfw"`
}
func (q *Queries) GetChannel(ctx context.Context, id int64) (GetChannelRow, error) {
row := q.db.QueryRowContext(ctx, getChannel, id)
var i GetChannelRow
err := row.Scan(
&i.ID,
&i.Name,
&i.Type,
&i.Category,
&i.Topic,
&i.Position,
&i.SlowMode,
&i.Archived,
&i.CreatedAt,
&i.VoiceMaxUsers,
&i.VoiceQuality,
&i.MixingThreshold,
&i.VoiceMaxVideo,
2026-08-01 22:06:14 +02:00
&i.Nsfw,
)
return i, err
}
2026-08-01 22:06:14 +02:00
const getChannelOverrides = `-- name: GetChannelOverrides :many
SELECT role_id, allow, deny FROM channel_overrides WHERE channel_id = ?
`
type GetChannelOverridesRow struct {
RoleID int64 `json:"roleId"`
Allow int64 `json:"allow"`
Deny int64 `json:"deny"`
}
func (q *Queries) GetChannelOverrides(ctx context.Context, channelID int64) ([]GetChannelOverridesRow, error) {
rows, err := q.db.QueryContext(ctx, getChannelOverrides, channelID)
if err != nil {
return nil, err
}
defer rows.Close()
items := []GetChannelOverridesRow{}
for rows.Next() {
var i GetChannelOverridesRow
if err := rows.Scan(&i.RoleID, &i.Allow, &i.Deny); err != nil {
return nil, err
}
items = append(items, i)
}
if err := rows.Close(); err != nil {
return nil, err
}
if err := rows.Err(); err != nil {
return nil, err
}
return items, nil
}
const getChannelPermission = `-- name: GetChannelPermission :one
SELECT allow, deny FROM channel_overrides WHERE channel_id = ? AND role_id = ?
`
type GetChannelPermissionParams struct {
ChannelID int64 `json:"channelId"`
RoleID int64 `json:"roleId"`
}
type GetChannelPermissionRow struct {
Allow int64 `json:"allow"`
Deny int64 `json:"deny"`
}
func (q *Queries) GetChannelPermission(ctx context.Context, arg GetChannelPermissionParams) (GetChannelPermissionRow, error) {
row := q.db.QueryRowContext(ctx, getChannelPermission, arg.ChannelID, arg.RoleID)
var i GetChannelPermissionRow
err := row.Scan(&i.Allow, &i.Deny)
return i, err
}
2026-08-01 22:06:14 +02:00
const getChannelUserOverrides = `-- name: GetChannelUserOverrides :many
SELECT user_id, allow, deny FROM channel_user_overrides WHERE channel_id = ?
`
type GetChannelUserOverridesRow struct {
UserID int64 `json:"userId"`
Allow int64 `json:"allow"`
Deny int64 `json:"deny"`
}
func (q *Queries) GetChannelUserOverrides(ctx context.Context, channelID int64) ([]GetChannelUserOverridesRow, error) {
rows, err := q.db.QueryContext(ctx, getChannelUserOverrides, channelID)
if err != nil {
return nil, err
}
defer rows.Close()
items := []GetChannelUserOverridesRow{}
for rows.Next() {
var i GetChannelUserOverridesRow
if err := rows.Scan(&i.UserID, &i.Allow, &i.Deny); err != nil {
return nil, err
}
items = append(items, i)
}
if err := rows.Close(); err != nil {
return nil, err
}
if err := rows.Err(); err != nil {
return nil, err
}
return items, nil
}
const getChannelUserPermission = `-- name: GetChannelUserPermission :one
SELECT allow, deny FROM channel_user_overrides WHERE channel_id = ? AND user_id = ?
`
type GetChannelUserPermissionParams struct {
ChannelID int64 `json:"channelId"`
UserID int64 `json:"userId"`
}
type GetChannelUserPermissionRow struct {
Allow int64 `json:"allow"`
Deny int64 `json:"deny"`
}
func (q *Queries) GetChannelUserPermission(ctx context.Context, arg GetChannelUserPermissionParams) (GetChannelUserPermissionRow, error) {
row := q.db.QueryRowContext(ctx, getChannelUserPermission, arg.ChannelID, arg.UserID)
var i GetChannelUserPermissionRow
err := row.Scan(&i.Allow, &i.Deny)
return i, err
}
const getRoleChannelPermissions = `-- name: GetRoleChannelPermissions :many
SELECT channel_id, allow, deny FROM channel_overrides WHERE role_id = ?
`
type GetRoleChannelPermissionsRow struct {
ChannelID int64 `json:"channelId"`
Allow int64 `json:"allow"`
Deny int64 `json:"deny"`
}
func (q *Queries) GetRoleChannelPermissions(ctx context.Context, roleID int64) ([]GetRoleChannelPermissionsRow, error) {
rows, err := q.db.QueryContext(ctx, getRoleChannelPermissions, roleID)
if err != nil {
return nil, err
}
defer rows.Close()
items := []GetRoleChannelPermissionsRow{}
for rows.Next() {
var i GetRoleChannelPermissionsRow
if err := rows.Scan(&i.ChannelID, &i.Allow, &i.Deny); err != nil {
return nil, err
}
items = append(items, i)
}
if err := rows.Close(); err != nil {
return nil, err
}
if err := rows.Err(); err != nil {
return nil, err
}
return items, nil
}
2026-08-01 22:06:14 +02:00
const getUserChannelPermissions = `-- name: GetUserChannelPermissions :many
SELECT channel_id, allow, deny FROM channel_user_overrides WHERE user_id = ?
`
type GetUserChannelPermissionsRow struct {
ChannelID int64 `json:"channelId"`
Allow int64 `json:"allow"`
Deny int64 `json:"deny"`
}
func (q *Queries) GetUserChannelPermissions(ctx context.Context, userID int64) ([]GetUserChannelPermissionsRow, error) {
rows, err := q.db.QueryContext(ctx, getUserChannelPermissions, userID)
if err != nil {
return nil, err
}
defer rows.Close()
items := []GetUserChannelPermissionsRow{}
for rows.Next() {
var i GetUserChannelPermissionsRow
if err := rows.Scan(&i.ChannelID, &i.Allow, &i.Deny); err != nil {
return nil, err
}
items = append(items, i)
}
if err := rows.Close(); err != nil {
return nil, err
}
if err := rows.Err(); err != nil {
return nil, err
}
return items, nil
}
const listChannels = `-- name: ListChannels :many
SELECT id, name, type, COALESCE(category, '') AS category, COALESCE(topic, '') AS topic,
position, slow_mode, archived, created_at,
COALESCE(voice_max_users, 0) AS voice_max_users,
voice_quality,
mixing_threshold,
2026-08-01 22:06:14 +02:00
COALESCE(voice_max_video, 0) AS voice_max_video,
nsfw
FROM channels ORDER BY position ASC, id ASC
`
type ListChannelsRow struct {
ID int64 `json:"id"`
Name string `json:"name"`
Type string `json:"type"`
Category string `json:"category"`
Topic string `json:"topic"`
Position int64 `json:"position"`
SlowMode int64 `json:"slowMode"`
Archived int64 `json:"archived"`
CreatedAt string `json:"createdAt"`
VoiceMaxUsers int64 `json:"voiceMaxUsers"`
VoiceQuality *string `json:"voiceQuality"`
MixingThreshold *int64 `json:"mixingThreshold"`
VoiceMaxVideo int64 `json:"voiceMaxVideo"`
2026-08-01 22:06:14 +02:00
Nsfw int64 `json:"nsfw"`
}
func (q *Queries) ListChannels(ctx context.Context) ([]ListChannelsRow, error) {
rows, err := q.db.QueryContext(ctx, listChannels)
if err != nil {
return nil, err
}
defer rows.Close()
items := []ListChannelsRow{}
for rows.Next() {
var i ListChannelsRow
if err := rows.Scan(
&i.ID,
&i.Name,
&i.Type,
&i.Category,
&i.Topic,
&i.Position,
&i.SlowMode,
&i.Archived,
&i.CreatedAt,
&i.VoiceMaxUsers,
&i.VoiceQuality,
&i.MixingThreshold,
&i.VoiceMaxVideo,
2026-08-01 22:06:14 +02:00
&i.Nsfw,
); err != nil {
return nil, err
}
items = append(items, i)
}
if err := rows.Close(); err != nil {
return nil, err
}
if err := rows.Err(); err != nil {
return nil, err
}
return items, nil
}
const setChannelSlowMode = `-- name: SetChannelSlowMode :exec
UPDATE channels SET slow_mode = ? WHERE id = ?
`
type SetChannelSlowModeParams struct {
SlowMode int64 `json:"slowMode"`
ID int64 `json:"id"`
}
func (q *Queries) SetChannelSlowMode(ctx context.Context, arg SetChannelSlowModeParams) error {
_, err := q.db.ExecContext(ctx, setChannelSlowMode, arg.SlowMode, arg.ID)
return err
}
const setChannelVoiceMaxUsers = `-- name: SetChannelVoiceMaxUsers :exec
UPDATE channels SET voice_max_users = ? WHERE id = ?
`
type SetChannelVoiceMaxUsersParams struct {
VoiceMaxUsers int64 `json:"voiceMaxUsers"`
ID int64 `json:"id"`
}
func (q *Queries) SetChannelVoiceMaxUsers(ctx context.Context, arg SetChannelVoiceMaxUsersParams) error {
_, err := q.db.ExecContext(ctx, setChannelVoiceMaxUsers, arg.VoiceMaxUsers, arg.ID)
return err
}
const updateChannel = `-- name: UpdateChannel :exec
UPDATE channels SET name = ?, topic = ?, slow_mode = ? WHERE id = ?
`
type UpdateChannelParams struct {
Name string `json:"name"`
Topic *string `json:"topic"`
SlowMode int64 `json:"slowMode"`
ID int64 `json:"id"`
}
func (q *Queries) UpdateChannel(ctx context.Context, arg UpdateChannelParams) error {
_, err := q.db.ExecContext(ctx, updateChannel,
arg.Name,
arg.Topic,
arg.SlowMode,
arg.ID,
)
return err
}
const upsertChannelPermission = `-- name: UpsertChannelPermission :exec
INSERT INTO channel_overrides (channel_id, role_id, allow, deny)
VALUES (?, ?, ?, ?)
ON CONFLICT(channel_id, role_id) DO UPDATE SET
allow = excluded.allow,
deny = excluded.deny
`
type UpsertChannelPermissionParams struct {
ChannelID int64 `json:"channelId"`
RoleID int64 `json:"roleId"`
Allow int64 `json:"allow"`
Deny int64 `json:"deny"`
}
func (q *Queries) UpsertChannelPermission(ctx context.Context, arg UpsertChannelPermissionParams) error {
_, err := q.db.ExecContext(ctx, upsertChannelPermission,
arg.ChannelID,
arg.RoleID,
arg.Allow,
arg.Deny,
)
return err
}
2026-08-01 22:06:14 +02:00
const upsertChannelUserPermission = `-- name: UpsertChannelUserPermission :exec
INSERT INTO channel_user_overrides (channel_id, user_id, allow, deny)
VALUES (?, ?, ?, ?)
ON CONFLICT(channel_id, user_id) DO UPDATE SET
allow = excluded.allow,
deny = excluded.deny
`
type UpsertChannelUserPermissionParams struct {
ChannelID int64 `json:"channelId"`
UserID int64 `json:"userId"`
Allow int64 `json:"allow"`
Deny int64 `json:"deny"`
}
func (q *Queries) UpsertChannelUserPermission(ctx context.Context, arg UpsertChannelUserPermissionParams) error {
_, err := q.db.ExecContext(ctx, upsertChannelUserPermission,
arg.ChannelID,
arg.UserID,
arg.Allow,
arg.Deny,
)
return err
}