Something went wrong. Try again.
(READ ONLY) Margin is an open annotation layer for the internet. Powered by the AT Protocol.
margin.at
extension web atproto comments
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772// Code generated by sqlc. DO NOT EDIT.// versions:// sqlc v1.31.1// source: moderation.sql
package sqlcdb
import ( "context" "time")
const banAccount = `-- name: BanAccount :execINSERT 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 :execINSERT 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 :execINSERT 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 :execINSERT 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 :execINSERT 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 :oneINSERT 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 :execDELETE 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 :execDELETE 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 :execDELETE 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 :execDELETE 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 :manySELECT 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 :manySELECT 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 :manySELECT 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 :manySELECT 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 :manySELECT 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 :manySELECT 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 :manySELECT id, src, uri, val, neg, created_by, created_at FROM content_labelsWHERE uri = ANY($1::text[]) AND neg = 0ORDER 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 :manySELECT id, src, uri, val, neg, created_by, created_at FROM content_labelsWHERE 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 :manySELECT 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 :manySELECT 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 :oneSELECT 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 :manySELECT 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 :oneSELECT 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 :oneSELECT 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 :manySELECT id, reporter_did, subject_did, subject_uri, reason_type, reason_text, status, created_at, resolved_at, resolved_byFROM moderation_reportsORDER 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 :manySELECT id, reporter_did, subject_did, subject_uri, reason_type, reason_text, status, created_at, resolved_at, resolved_byFROM moderation_reportsWHERE status = $1ORDER 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 :oneSELECT 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 :oneSELECT 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 :oneSELECT 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 :oneSELECT 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 :oneSELECT 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 :execINSERT 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 :execUPDATE 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 :execUPDATE 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 :execDELETE 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}