// Code generated by sqlc. DO NOT EDIT. // versions: // sqlc v1.31.1 // source: moderation.sql package sqlcdb import ( "context" "time" ) const banAccount = `-- name: BanAccount :exec INSERT INTO banned_accounts (did, reason, banned_by, banned_at) VALUES ($1, $2, $3, $4) ON CONFLICT(did) DO UPDATE SET reason = EXCLUDED.reason, banned_by = EXCLUDED.banned_by, banned_at = EXCLUDED.banned_at ` type BanAccountParams struct { Did string `json:"did"` Reason *string `json:"reason"` BannedBy string `json:"bannedBy"` BannedAt time.Time `json:"bannedAt"` } func (q *Queries) BanAccount(ctx context.Context, arg BanAccountParams) error { _, err := q.db.Exec(ctx, banAccount, arg.Did, arg.Reason, arg.BannedBy, arg.BannedAt, ) return err } const createBlock = `-- name: CreateBlock :exec INSERT INTO blocks (actor_did, subject_did, created_at) VALUES ($1, $2, $3) ON CONFLICT(actor_did, subject_did) DO NOTHING ` type CreateBlockParams struct { ActorDid string `json:"actorDid"` SubjectDid string `json:"subjectDid"` CreatedAt time.Time `json:"createdAt"` } func (q *Queries) CreateBlock(ctx context.Context, arg CreateBlockParams) error { _, err := q.db.Exec(ctx, createBlock, arg.ActorDid, arg.SubjectDid, arg.CreatedAt) return err } const createContentLabel = `-- name: CreateContentLabel :exec INSERT INTO content_labels (src, uri, val, neg, created_by, created_at) VALUES ($1, $2, $3, 0, $4, $5) ` type CreateContentLabelParams struct { Src string `json:"src"` Uri string `json:"uri"` Val string `json:"val"` CreatedBy string `json:"createdBy"` CreatedAt time.Time `json:"createdAt"` } func (q *Queries) CreateContentLabel(ctx context.Context, arg CreateContentLabelParams) error { _, err := q.db.Exec(ctx, createContentLabel, arg.Src, arg.Uri, arg.Val, arg.CreatedBy, arg.CreatedAt, ) return err } const createModerationAction = `-- name: CreateModerationAction :exec INSERT INTO moderation_actions (report_id, actor_did, action, comment, created_at) VALUES ($1, $2, $3, $4, $5) ` type CreateModerationActionParams struct { ReportID int32 `json:"reportId"` ActorDid string `json:"actorDid"` Action string `json:"action"` Comment *string `json:"comment"` CreatedAt time.Time `json:"createdAt"` } func (q *Queries) CreateModerationAction(ctx context.Context, arg CreateModerationActionParams) error { _, err := q.db.Exec(ctx, createModerationAction, arg.ReportID, arg.ActorDid, arg.Action, arg.Comment, arg.CreatedAt, ) return err } const createMute = `-- name: CreateMute :exec INSERT INTO mutes (actor_did, subject_did, created_at) VALUES ($1, $2, $3) ON CONFLICT(actor_did, subject_did) DO NOTHING ` type CreateMuteParams struct { ActorDid string `json:"actorDid"` SubjectDid string `json:"subjectDid"` CreatedAt time.Time `json:"createdAt"` } func (q *Queries) CreateMute(ctx context.Context, arg CreateMuteParams) error { _, err := q.db.Exec(ctx, createMute, arg.ActorDid, arg.SubjectDid, arg.CreatedAt) return err } const createReport = `-- name: CreateReport :one INSERT INTO moderation_reports (reporter_did, subject_did, subject_uri, reason_type, reason_text, status, created_at) VALUES ($1, $2, $3, $4, $5, 'pending', $6) RETURNING id ` type CreateReportParams struct { ReporterDid string `json:"reporterDid"` SubjectDid string `json:"subjectDid"` SubjectUri *string `json:"subjectUri"` ReasonType string `json:"reasonType"` ReasonText *string `json:"reasonText"` CreatedAt time.Time `json:"createdAt"` } func (q *Queries) CreateReport(ctx context.Context, arg CreateReportParams) (int32, error) { row := q.db.QueryRow(ctx, createReport, arg.ReporterDid, arg.SubjectDid, arg.SubjectUri, arg.ReasonType, arg.ReasonText, arg.CreatedAt, ) var id int32 err := row.Scan(&id) return id, err } const deleteBlock = `-- name: DeleteBlock :exec DELETE FROM blocks WHERE actor_did = $1 AND subject_did = $2 ` type DeleteBlockParams struct { ActorDid string `json:"actorDid"` SubjectDid string `json:"subjectDid"` } func (q *Queries) DeleteBlock(ctx context.Context, arg DeleteBlockParams) error { _, err := q.db.Exec(ctx, deleteBlock, arg.ActorDid, arg.SubjectDid) return err } const deleteContentLabel = `-- name: DeleteContentLabel :exec DELETE FROM content_labels WHERE id = $1 ` func (q *Queries) DeleteContentLabel(ctx context.Context, id int32) error { _, err := q.db.Exec(ctx, deleteContentLabel, id) return err } const deleteMute = `-- name: DeleteMute :exec DELETE FROM mutes WHERE actor_did = $1 AND subject_did = $2 ` type DeleteMuteParams struct { ActorDid string `json:"actorDid"` SubjectDid string `json:"subjectDid"` } func (q *Queries) DeleteMute(ctx context.Context, arg DeleteMuteParams) error { _, err := q.db.Exec(ctx, deleteMute, arg.ActorDid, arg.SubjectDid) return err } const deleteSelfLabels = `-- name: DeleteSelfLabels :exec DELETE FROM content_labels WHERE src = $1 AND uri = $2 AND created_by = $3 ` type DeleteSelfLabelsParams struct { Src string `json:"src"` Uri string `json:"uri"` CreatedBy string `json:"createdBy"` } func (q *Queries) DeleteSelfLabels(ctx context.Context, arg DeleteSelfLabelsParams) error { _, err := q.db.Exec(ctx, deleteSelfLabels, arg.Src, arg.Uri, arg.CreatedBy) return err } const getAllContentLabels = `-- name: GetAllContentLabels :many SELECT id, src, uri, val, neg, created_by, created_at FROM content_labels ORDER BY created_at DESC LIMIT $1 OFFSET $2 ` type GetAllContentLabelsParams struct { Limit int32 `json:"limit"` Offset int32 `json:"offset"` } func (q *Queries) GetAllContentLabels(ctx context.Context, arg GetAllContentLabelsParams) ([]ContentLabel, error) { rows, err := q.db.Query(ctx, getAllContentLabels, arg.Limit, arg.Offset) if err != nil { return nil, err } defer rows.Close() var items []ContentLabel for rows.Next() { var i ContentLabel if err := rows.Scan( &i.ID, &i.Src, &i.Uri, &i.Val, &i.Neg, &i.CreatedBy, &i.CreatedAt, ); err != nil { return nil, err } items = append(items, i) } if err := rows.Err(); err != nil { return nil, err } return items, nil } const getBannedAccounts = `-- name: GetBannedAccounts :many SELECT did, reason, banned_by, banned_at FROM banned_accounts ORDER BY banned_at DESC ` func (q *Queries) GetBannedAccounts(ctx context.Context) ([]BannedAccount, error) { rows, err := q.db.Query(ctx, getBannedAccounts) if err != nil { return nil, err } defer rows.Close() var items []BannedAccount for rows.Next() { var i BannedAccount if err := rows.Scan( &i.Did, &i.Reason, &i.BannedBy, &i.BannedAt, ); err != nil { return nil, err } items = append(items, i) } if err := rows.Err(); err != nil { return nil, err } return items, nil } const getBannedDIDs = `-- name: GetBannedDIDs :many SELECT did FROM banned_accounts ` func (q *Queries) GetBannedDIDs(ctx context.Context) ([]string, error) { rows, err := q.db.Query(ctx, getBannedDIDs) if err != nil { return nil, err } defer rows.Close() var items []string for rows.Next() { var did string if err := rows.Scan(&did); err != nil { return nil, err } items = append(items, did) } if err := rows.Err(); err != nil { return nil, err } return items, nil } const getBlockedByDIDs = `-- name: GetBlockedByDIDs :many SELECT actor_did FROM blocks WHERE subject_did = $1 ` func (q *Queries) GetBlockedByDIDs(ctx context.Context, subjectDid string) ([]string, error) { rows, err := q.db.Query(ctx, getBlockedByDIDs, subjectDid) if err != nil { return nil, err } defer rows.Close() var items []string for rows.Next() { var actor_did string if err := rows.Scan(&actor_did); err != nil { return nil, err } items = append(items, actor_did) } if err := rows.Err(); err != nil { return nil, err } return items, nil } const getBlockedDIDs = `-- name: GetBlockedDIDs :many SELECT subject_did FROM blocks WHERE actor_did = $1 ` func (q *Queries) GetBlockedDIDs(ctx context.Context, actorDid string) ([]string, error) { rows, err := q.db.Query(ctx, getBlockedDIDs, actorDid) if err != nil { return nil, err } defer rows.Close() var items []string for rows.Next() { var subject_did string if err := rows.Scan(&subject_did); err != nil { return nil, err } items = append(items, subject_did) } if err := rows.Err(); err != nil { return nil, err } return items, nil } const getBlocks = `-- name: GetBlocks :many SELECT id, actor_did, subject_did, created_at FROM blocks WHERE actor_did = $1 ORDER BY created_at DESC ` func (q *Queries) GetBlocks(ctx context.Context, actorDid string) ([]Block, error) { rows, err := q.db.Query(ctx, getBlocks, actorDid) if err != nil { return nil, err } defer rows.Close() var items []Block for rows.Next() { var i Block if err := rows.Scan( &i.ID, &i.ActorDid, &i.SubjectDid, &i.CreatedAt, ); err != nil { return nil, err } items = append(items, i) } if err := rows.Err(); err != nil { return nil, err } return items, nil } const getContentLabelsForURIs = `-- name: GetContentLabelsForURIs :many SELECT id, src, uri, val, neg, created_by, created_at FROM content_labels WHERE uri = ANY($1::text[]) AND neg = 0 ORDER BY created_at DESC ` func (q *Queries) GetContentLabelsForURIs(ctx context.Context, dollar_1 []string) ([]ContentLabel, error) { rows, err := q.db.Query(ctx, getContentLabelsForURIs, dollar_1) if err != nil { return nil, err } defer rows.Close() var items []ContentLabel for rows.Next() { var i ContentLabel if err := rows.Scan( &i.ID, &i.Src, &i.Uri, &i.Val, &i.Neg, &i.CreatedBy, &i.CreatedAt, ); err != nil { return nil, err } items = append(items, i) } if err := rows.Err(); err != nil { return nil, err } return items, nil } const getContentLabelsForURIsBySrc = `-- name: GetContentLabelsForURIsBySrc :many SELECT id, src, uri, val, neg, created_by, created_at FROM content_labels WHERE uri = ANY($1::text[]) AND neg = 0 AND src = ANY($2::text[]) ORDER BY created_at DESC ` type GetContentLabelsForURIsBySrcParams struct { Column1 []string `json:"column1"` Column2 []string `json:"column2"` } func (q *Queries) GetContentLabelsForURIsBySrc(ctx context.Context, arg GetContentLabelsForURIsBySrcParams) ([]ContentLabel, error) { rows, err := q.db.Query(ctx, getContentLabelsForURIsBySrc, arg.Column1, arg.Column2) if err != nil { return nil, err } defer rows.Close() var items []ContentLabel for rows.Next() { var i ContentLabel if err := rows.Scan( &i.ID, &i.Src, &i.Uri, &i.Val, &i.Neg, &i.CreatedBy, &i.CreatedAt, ); err != nil { return nil, err } items = append(items, i) } if err := rows.Err(); err != nil { return nil, err } return items, nil } const getMutedDIDs = `-- name: GetMutedDIDs :many SELECT subject_did FROM mutes WHERE actor_did = $1 ` func (q *Queries) GetMutedDIDs(ctx context.Context, actorDid string) ([]string, error) { rows, err := q.db.Query(ctx, getMutedDIDs, actorDid) if err != nil { return nil, err } defer rows.Close() var items []string for rows.Next() { var subject_did string if err := rows.Scan(&subject_did); err != nil { return nil, err } items = append(items, subject_did) } if err := rows.Err(); err != nil { return nil, err } return items, nil } const getMutes = `-- name: GetMutes :many SELECT id, actor_did, subject_did, created_at FROM mutes WHERE actor_did = $1 ORDER BY created_at DESC ` func (q *Queries) GetMutes(ctx context.Context, actorDid string) ([]Mute, error) { rows, err := q.db.Query(ctx, getMutes, actorDid) if err != nil { return nil, err } defer rows.Close() var items []Mute for rows.Next() { var i Mute if err := rows.Scan( &i.ID, &i.ActorDid, &i.SubjectDid, &i.CreatedAt, ); err != nil { return nil, err } items = append(items, i) } if err := rows.Err(); err != nil { return nil, err } return items, nil } const getReport = `-- name: GetReport :one SELECT id, reporter_did, subject_did, subject_uri, reason_type, reason_text, status, created_at, resolved_at, resolved_by FROM moderation_reports WHERE id = $1 ` func (q *Queries) GetReport(ctx context.Context, id int32) (ModerationReport, error) { row := q.db.QueryRow(ctx, getReport, id) var i ModerationReport err := row.Scan( &i.ID, &i.ReporterDid, &i.SubjectDid, &i.SubjectUri, &i.ReasonType, &i.ReasonText, &i.Status, &i.CreatedAt, &i.ResolvedAt, &i.ResolvedBy, ) return i, err } const getReportActions = `-- name: GetReportActions :many SELECT id, report_id, actor_did, action, comment, created_at FROM moderation_actions WHERE report_id = $1 ORDER BY created_at DESC ` func (q *Queries) GetReportActions(ctx context.Context, reportID int32) ([]ModerationAction, error) { rows, err := q.db.Query(ctx, getReportActions, reportID) if err != nil { return nil, err } defer rows.Close() var items []ModerationAction for rows.Next() { var i ModerationAction if err := rows.Scan( &i.ID, &i.ReportID, &i.ActorDid, &i.Action, &i.Comment, &i.CreatedAt, ); err != nil { return nil, err } items = append(items, i) } if err := rows.Err(); err != nil { return nil, err } return items, nil } const getReportCount = `-- name: GetReportCount :one SELECT COUNT(*) FROM moderation_reports ` func (q *Queries) GetReportCount(ctx context.Context) (int64, error) { row := q.db.QueryRow(ctx, getReportCount) var count int64 err := row.Scan(&count) return count, err } const getReportCountByStatus = `-- name: GetReportCountByStatus :one SELECT COUNT(*) FROM moderation_reports WHERE status = $1 ` func (q *Queries) GetReportCountByStatus(ctx context.Context, status string) (int64, error) { row := q.db.QueryRow(ctx, getReportCountByStatus, status) var count int64 err := row.Scan(&count) return count, err } const getReports = `-- name: GetReports :many SELECT id, reporter_did, subject_did, subject_uri, reason_type, reason_text, status, created_at, resolved_at, resolved_by FROM moderation_reports ORDER BY created_at DESC LIMIT $1 OFFSET $2 ` type GetReportsParams struct { Limit int32 `json:"limit"` Offset int32 `json:"offset"` } func (q *Queries) GetReports(ctx context.Context, arg GetReportsParams) ([]ModerationReport, error) { rows, err := q.db.Query(ctx, getReports, arg.Limit, arg.Offset) if err != nil { return nil, err } defer rows.Close() var items []ModerationReport for rows.Next() { var i ModerationReport if err := rows.Scan( &i.ID, &i.ReporterDid, &i.SubjectDid, &i.SubjectUri, &i.ReasonType, &i.ReasonText, &i.Status, &i.CreatedAt, &i.ResolvedAt, &i.ResolvedBy, ); err != nil { return nil, err } items = append(items, i) } if err := rows.Err(); err != nil { return nil, err } return items, nil } const getReportsByStatus = `-- name: GetReportsByStatus :many SELECT id, reporter_did, subject_did, subject_uri, reason_type, reason_text, status, created_at, resolved_at, resolved_by FROM moderation_reports WHERE status = $1 ORDER BY created_at DESC LIMIT $2 OFFSET $3 ` type GetReportsByStatusParams struct { Status string `json:"status"` Limit int32 `json:"limit"` Offset int32 `json:"offset"` } func (q *Queries) GetReportsByStatus(ctx context.Context, arg GetReportsByStatusParams) ([]ModerationReport, error) { rows, err := q.db.Query(ctx, getReportsByStatus, arg.Status, arg.Limit, arg.Offset) if err != nil { return nil, err } defer rows.Close() var items []ModerationReport for rows.Next() { var i ModerationReport if err := rows.Scan( &i.ID, &i.ReporterDid, &i.SubjectDid, &i.SubjectUri, &i.ReasonType, &i.ReasonText, &i.Status, &i.CreatedAt, &i.ResolvedAt, &i.ResolvedBy, ); err != nil { return nil, err } items = append(items, i) } if err := rows.Err(); err != nil { return nil, err } return items, nil } const isBanned = `-- name: IsBanned :one SELECT EXISTS(SELECT 1 FROM banned_accounts WHERE did = $1) ` func (q *Queries) IsBanned(ctx context.Context, did string) (bool, error) { row := q.db.QueryRow(ctx, isBanned, did) var exists bool err := row.Scan(&exists) return exists, err } const isBlocked = `-- name: IsBlocked :one SELECT EXISTS(SELECT 1 FROM blocks WHERE actor_did = $1 AND subject_did = $2) ` type IsBlockedParams struct { ActorDid string `json:"actorDid"` SubjectDid string `json:"subjectDid"` } func (q *Queries) IsBlocked(ctx context.Context, arg IsBlockedParams) (bool, error) { row := q.db.QueryRow(ctx, isBlocked, arg.ActorDid, arg.SubjectDid) var exists bool err := row.Scan(&exists) return exists, err } const isBlockedEither = `-- name: IsBlockedEither :one SELECT EXISTS(SELECT 1 FROM blocks WHERE (actor_did = $1 AND subject_did = $2) OR (actor_did = $2 AND subject_did = $1)) ` type IsBlockedEitherParams struct { ActorDid string `json:"actorDid"` SubjectDid string `json:"subjectDid"` } func (q *Queries) IsBlockedEither(ctx context.Context, arg IsBlockedEitherParams) (bool, error) { row := q.db.QueryRow(ctx, isBlockedEither, arg.ActorDid, arg.SubjectDid) var exists bool err := row.Scan(&exists) return exists, err } const isMuted = `-- name: IsMuted :one SELECT EXISTS(SELECT 1 FROM mutes WHERE actor_did = $1 AND subject_did = $2) ` type IsMutedParams struct { ActorDid string `json:"actorDid"` SubjectDid string `json:"subjectDid"` } func (q *Queries) IsMuted(ctx context.Context, arg IsMutedParams) (bool, error) { row := q.db.QueryRow(ctx, isMuted, arg.ActorDid, arg.SubjectDid) var exists bool err := row.Scan(&exists) return exists, err } const isTakenDown = `-- name: IsTakenDown :one SELECT EXISTS(SELECT 1 FROM taken_down_uris WHERE uri = $1) ` func (q *Queries) IsTakenDown(ctx context.Context, uri string) (bool, error) { row := q.db.QueryRow(ctx, isTakenDown, uri) var exists bool err := row.Scan(&exists) return exists, err } const markTakenDown = `-- name: MarkTakenDown :exec INSERT INTO taken_down_uris (uri, taken_down_at) VALUES ($1, $2) ON CONFLICT(uri) DO NOTHING ` type MarkTakenDownParams struct { Uri string `json:"uri"` TakenDownAt time.Time `json:"takenDownAt"` } func (q *Queries) MarkTakenDown(ctx context.Context, arg MarkTakenDownParams) error { _, err := q.db.Exec(ctx, markTakenDown, arg.Uri, arg.TakenDownAt) return err } const negateContentLabel = `-- name: NegateContentLabel :exec UPDATE content_labels SET neg = 1 WHERE id = $1 ` func (q *Queries) NegateContentLabel(ctx context.Context, id int32) error { _, err := q.db.Exec(ctx, negateContentLabel, id) return err } const resolveReport = `-- name: ResolveReport :exec UPDATE moderation_reports SET status = $1, resolved_at = $2, resolved_by = $3 WHERE id = $4 ` type ResolveReportParams struct { Status string `json:"status"` ResolvedAt *time.Time `json:"resolvedAt"` ResolvedBy *string `json:"resolvedBy"` ID int32 `json:"id"` } func (q *Queries) ResolveReport(ctx context.Context, arg ResolveReportParams) error { _, err := q.db.Exec(ctx, resolveReport, arg.Status, arg.ResolvedAt, arg.ResolvedBy, arg.ID, ) return err } const unbanAccount = `-- name: UnbanAccount :exec DELETE FROM banned_accounts WHERE did = $1 ` func (q *Queries) UnbanAccount(ctx context.Context, did string) error { _, err := q.db.Exec(ctx, unbanAccount, did) return err }