db

package
v0.9.0-rc.53 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 23, 2026 License: AGPL-3.0 Imports: 21 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package db is the only place in pwikit that issues SQL.

Index

Constants

View Source
const (
	TicketKind          = "ticket"
	MembershipApplyKind = "membershipapply"

	TicketPending = "pending"
)
View Source
const (
	AdminCreated = "create"
	AdminChanged = "change"
	AdminDeleted = "delete"
)
View Source
const (
	RenumberedCategory = "category"
	RenumberedThread   = "thread"
	RenumberedPost     = "post"
)
View Source
const (
	LogNew    = "new"
	LogSource = "source"
	LogParent = "parent"
	LogTitle  = "title"
	LogName   = "name"

	LogAuthorship = "authorship"

	LogFileAdded   = "file_added"
	LogFileDeleted = "file_deleted"
	LogFileRenamed = "file_renamed"
)
View Source
const (
	ThemeInline   = "inline"
	ThemeExternal = "external"
)
View Source
const (
	MirrorOK      = "ok"
	MirrorMissing = "missing"
	MirrorFailed  = "failed"
)
View Source
const (
	LinkInclude = "include"
	LinkPlain   = "link"
)
View Source
const (
	TimeRange        = "range"
	TimeExcludeRange = "exclude_range"
	TimeLT           = "lt"
	TimeLTE          = "lte"
	TimeGT           = "gt"
	TimeGTE          = "gte"
)
View Source
const (
	NumEQ  = "eq"
	NumNE  = "ne"
	NumLT  = "lt"
	NumLTE = "lte"
	NumGT  = "gt"
	NumGTE = "gte"
)
View Source
const (
	SortCreatedAt  = "created_at"
	SortCreatedBy  = "created_by"
	SortName       = "name"
	SortTitle      = "title"
	SortUpdatedAt  = "updated_at"
	SortFullName   = "fullname"
	SortRating     = "rating"
	SortVotes      = "votes"
	SortPopularity = "popularity"
	SortRandom     = "random"
	SortSize       = "size"
	SortRevisions  = "revisions"
	SortComments   = "comments"
)
View Source
const (
	PageTypeNormal = "normal"
	PageTypeHidden = "hidden"
)
View Source
const (
	NotifyTicketResult = "ticket_result"
	ReportKind         = "report"
)
View Source
const (
	NotifyWelcome            = "welcome"
	NotifyNewPostReply       = "new_post_reply"
	NotifyNewThreadPost      = "new_thread_post"
	NotifyNewArticleRevision = "new_article_revision"
	NotifyForumMention       = "forum_mention"
	NotifyDirectMessage      = "direct_message"
	NotifyPostLike           = "post_like"
	NotifyReleaseAvailable   = "release_available"
	NotifyUpdateRolledBack   = "update_rolled_back"
	NotifyNewTicket          = "new_ticket"
	NotifyPageDeleted        = "page_deleted"
	NotifyExternal           = "external"
)
View Source
const (
	CreateTagsDefault  = "default"
	CreateTagsDisabled = "disabled"
	CreateTagsEnabled  = "enabled"
)
View Source
const (
	ReportReviewed  = "reviewed"
	ReportDismissed = "dismissed"
)
View Source
const (
	EmailRequired = "required"
	EmailOptional = "optional"
)
View Source
const (
	TicketApproved = "approved"
	TicketRejected = "rejected"
	TicketClosed   = "closed"
)
View Source
const (
	UserTypeNormal  = "normal"
	UserTypeWikidot = "wikidot"
	UserTypeSystem  = "system"
	UserTypeBot     = "bot"
)
View Source
const DefaultCategory = "_default"
View Source
const DefaultFolder int64 = 0

Every favourite lands here until its owner moves it.

View Source
const DeviceQuiet = 5 * time.Minute
View Source
const EnvDSN = "PWIKIT_TEST_DSN"

EnvDSN points database-backed tests at a live Postgres. It lives here rather than in a _test.go file because other packages' tests gate on the same name.

View Source
const EnvWriteDSN = "PWIKIT_TEST_WRITE_DSN"

A test that writes needs a database of its own. Rows it leaves standing for a moment are visible to every other package's tests while they run.

View Source
const LedgerTable = "pwikit_migration"

The migration ledger is rebuilt by replaying the migrations a restore names, so carrying its rows would fight with that.

View Source
const LogRevert = "revert"
View Source
const LogTags = "tags"
View Source
const (
	LogVotesDeleted = "votes_deleted"
)
View Source
const LogWikidot = "wikidot"

LogWikidot marks a revision an import carried over whose kind this engine has no word for, such as a rename Wikidot recorded without keeping the source.

View Source
const MaxFavouriteFolders = 50
View Source
const MaxPins = 6
View Source
const NotifyAnnouncement = "announcement"
View Source
const NotifySection = "notify"
View Source
const ReportPending = "pending"

Variables

View Source
var (
	ErrTooManyFolders = errors.New("too many favourite folders")
	ErrFolderExists   = errors.New("a favourite folder by that name exists")
)
View Source
var (
	ErrTagTaken              = errors.New("db: tag already exists in its category")
	ErrTagCategorySlugTaken  = errors.New("db: tag category slug already in use")
	ErrTagCategoryOrderTaken = errors.New("db: tag category priority already in use")
	ErrTagCategoryNotEmpty   = errors.New("db: tag category still holds tags")
)

Every kind outside these, bar direct messages, is a notice.

View Source
var ErrMergeSame = errors.New("the two accounts are the same account")
View Source
var ErrMergeTwoWikidot = errors.New("both accounts carry a Wikidot identity")
View Source
var ErrNotFound = errors.New("db: not found")
View Source
var ErrSiteMissing = errors.New("no such site")
View Source
var ErrThemeSlugTaken = errors.New("db: theme slug already in use")

A deletion notice carries the only copy of the source, and tickets and welcomes need to be seen, so none of those can be turned off.

View Source
var ProfileFieldKeys = []string{"region", "gender", "birthday", "website"}

Functions

func AppliedMigrations

func AppliedMigrations(ctx context.Context, conn *pgx.Conn) ([]string, error)

func BackupTables

func BackupTables(ctx context.Context, conn *pgx.Conn) ([]string, error)

These take a connection rather than the pool, because a backup streams COPY and rebuilds the schema inside one transaction.

func BuiltinPermissions

func BuiltinPermissions(slug string) []string

Resetting everyone or registered goes back to what a new site gives them.

func CopyIn

func CopyIn(ctx context.Context, tx pgx.Tx, r io.Reader, table string) (int64, error)

func CopyOut

func CopyOut(ctx context.Context, tx pgx.Tx, w io.Writer, table, query string) (int64, error)

func CreatingTagsAllowed

func CreatingTagsAllowed(siteMode, categoryMode string) bool

Creating tags is off unless something turns it on, and the category has the last word.

func DeletedWikidotName

func DeletedWikidotName(wikidotID int64) string

func EnsureDatabase

func EnsureDatabase(ctx context.Context, conn *pgx.Conn, name string) error

func MediaName

func MediaName() (string, error)

MediaName picks the name a file is stored under, which an importer needs before it copies the bytes into place.

func MissingTagGroups

func MissingTagGroups(groups [][]string, tags []string) [][]string

func NonEmptyTables

func NonEmptyTables(ctx context.Context, conn *pgx.Conn, tables []string) ([]string, error)

func OtherConnections

func OtherConnections(ctx context.Context, conn *pgx.Conn) (int, error)

func ParseTagGroups

func ParseTagGroups(raw string) [][]string

ParseTagGroups reads one group per line, the tags of a group split by spaces. A page needs at least one tag out of every group.

func QuoteLiteral

func QuoteLiteral(ctx context.Context, tx pgx.Tx, value string) (string, error)

CopyTo takes no arguments, so a value the query needs is put into the text after Postgres has quoted it.

func QuoteName

func QuoteName(name string) string

func ResetIdentities

func ResetIdentities(ctx context.Context, tx pgx.Tx, tables map[string]bool) error

The rows carry their own ids, so every identity column has to be told where to carry on from or the next insert collides with row one.

func ResetSchema

func ResetSchema(ctx context.Context, tx pgx.Tx) error

func RestoreForeignKeys

func RestoreForeignKeys(ctx context.Context, tx pgx.Tx, keys []ForeignKey) error

Putting them back checks every row in bulk rather than a trigger at a time.

func ServerVersion

func ServerVersion(ctx context.Context, conn *pgx.Conn) (int, error)

func SiteExportQuery

func SiteExportQuery(ctx context.Context, conn *pgx.Conn, table string, keepPasswords bool) (string, error)

An empty return means the table does not travel.

func SiteScopeRuled

func SiteScopeRuled() []string

SiteScopeRuled lets a test hold the schema and this file to each other.

func SiteSlugExists

func SiteSlugExists(ctx context.Context, conn *pgx.Conn, slug string) (bool, error)

func TagFullName

func TagFullName(raw string) string

func TruncateAll

func TruncateAll(ctx context.Context, tx pgx.Tx, tables []string) error

Types

type AccountEmail

type AccountEmail struct {
	Email      string
	Pending    string
	Previous   string
	VerifiedAt *time.Time
	ChangedAt  *time.Time
	Held       string
	HeldUntil  *time.Time
	HeldSite   *int64
}

type ActivityDay

type ActivityDay struct {
	Day   time.Time
	Count int
}

type AdminNote

type AdminNote struct {
	UserID *int64
	Name   string
	Action string
	Screen string
	Target string
	Label  string
	SiteID int64
	At     time.Time
}

type AdminNoteRow

type AdminNoteRow struct {
	ID        int64
	User      string
	Stale     string
	Action    string
	Screen    string
	Target    string
	Label     string
	CreatedAt time.Time
}

type AdminPageRow

type AdminPageRow struct {
	ID        int64
	Category  string
	Name      string
	Title     string
	Revisions int
	UpdatedAt time.Time
}

func (*AdminPageRow) FullName

func (p *AdminPageRow) FullName() string

type AdminUserRow

type AdminUserRow struct {
	ID              int64
	Type            string
	Username        string
	WikidotUsername string
	DisplayName     string
	Email           string
	Bio             string
	Avatar          string
	APIKey          string

	IsActive           bool
	InactiveUntil      *time.Time
	IsForumActive      bool
	ForumInactiveUntil *time.Time
	CanSendDM          bool
	DMUntil            *time.Time
	IsSuperuser        bool
	SiteSuperuser      bool
	BotOfSite          bool
	Unclaimed          bool
	Banned             bool

	OperationIndex int
	Roles          []int64
}

func (AdminUserRow) ActiveAt

func (u AdminUserRow) ActiveAt(now time.Time) bool

func (AdminUserRow) ForumActiveAt

func (u AdminUserRow) ForumActiveAt(now time.Time) bool

func (AdminUserRow) MessagesAt

func (u AdminUserRow) MessagesAt(now time.Time) bool

type Announcement

type Announcement struct {
	ID       int64
	Title    string
	Author   string
	Instance bool
	SentAt   time.Time
}

type Article

type Article struct {
	ID        int64
	Category  string
	Name      string
	Title     string
	ParentID  *int64
	Locked    bool
	CreatedAt time.Time
	UpdatedAt time.Time
	MediaName string
}

func (*Article) DisplayName

func (a *Article) DisplayName() string

DisplayName is what a breadcrumb or a link label shows when the page has no title of its own.

func (*Article) FullName

func (a *Article) FullName() string

FullName drops the _default category, which exists in the column but never in a URL or a page reference.

type ArticleFile

type ArticleFile struct {
	ArticleMediaName string
	MediaName        string
	MimeType         string
	Size             int64
}

type ArticleFileEntry

type ArticleFileEntry struct {
	ID       int64
	Name     string
	MimeType string
	Size     int64
}

type ArticleHead

type ArticleHead struct {
	RevNumber int
	At        time.Time
}
type ArticleLink struct {
	To   string
	Kind string

	// ToSiteID is nil for a target on the same site, which is every link that
	// does not name one.
	ToSiteID *int64
}

type ArticleTag

type ArticleTag struct {
	ID       int64
	Category string
	Name     string
}

func (ArticleTag) FullName

func (t ArticleTag) FullName() string

type ArticleVote

type ArticleVote struct {
	User       User
	Rate       float64
	Date       *time.Time
	RoleID     *int64
	GroupTitle string
	GroupIndex *int
}

type AuthorRankFilter

type AuthorRankFilter struct {
	Categories     []string
	SkipCategories []string
	Tags           []string
	Negate         []string
	Exclude        []string
	Hidden         []string
}

type AuthorRankRow

type AuthorRankRow struct {
	UserID int64
	Score  float64
	Pages  int
	Place  int
	Total  int
	// Place repeats on ties, so Pos is what finds the page a row is on.
	Pos int
}

type AuthorStats

type AuthorStats struct {
	Pages int
	Score float64
	Edits int
	Posts int
}

type AuthoredPage

type AuthoredPage struct {
	ArticleID  int64
	Title      string
	Path       string
	SiteID     int64
	Category   string
	SiteTitle  string
	SiteDomain string
	CreatedAt  time.Time
	Pinned     bool
}

type CategoryLook

type CategoryLook struct {
	ThemeID *int64
	NavTop  string
	NavSide string
}

type CategoryOverride

type CategoryOverride struct {
	RoleID   int64
	RoleName string
	Allow    []string
	Deny     []string
	Withhold []string
}

type CategoryRow

type CategoryRow struct {
	ID        int64
	Name      string
	IsIndexed bool
	Articles  int

	ThemeID *int64
	NavTop  string
	NavSide string

	Settings  SiteSettings
	Overrides []CategoryOverride
}

type ClaimOutcome

type ClaimOutcome int
const (
	ClaimMatched ClaimOutcome = iota
	ClaimMissing
	ClaimExpired
	ClaimWrong
	ClaimLocked
)

type CloudTag

type CloudTag struct {
	Name         string
	FullName     string
	Articles     int
	CategoryID   int64
	CategoryName string
	CategorySlug string
	CategoryText string
	Priority     *int
}

type CommentInfo

type CommentInfo struct {
	ThreadID int64
	Count    int
}

type Conversation

type Conversation struct {
	PartnerID int64
	Last      DirectMessage
	Unread    int
}

type DB

type DB struct {
	// contains filtered or unexported fields
}

func Open

func Open(ctx context.Context, dsn string) (*DB, error)

func (*DB) AccessCandidates

func (d *DB) AccessCandidates(ctx context.Context, siteID int64, now time.Time, limit int) ([]int64, error)

func (*DB) AccountEmail

func (d *DB) AccountEmail(ctx context.Context, id int64) (AccountEmail, error)
func (d *DB) ActivateInviteLink(ctx context.Context, token, username string, at time.Time) error

func (*DB) ActivateUser

func (d *DB) ActivateUser(ctx context.Context, id int64, username string, displayName *string, hash string) error

func (*DB) ActiveSanctions

func (d *DB) ActiveSanctions(ctx context.Context, siteID, userID int64, now time.Time) ([]string, error)

func (*DB) ActiveSites

func (d *DB) ActiveSites(ctx context.Context, userID int64) (map[int64]bool, error)

func (*DB) ActiveUsersByNames

func (d *DB) ActiveUsersByNames(ctx context.Context, names []string) ([]User, error)

A mention names someone by the name they type, which is matched without case so a post that writes it differently still reaches them.

func (*DB) ActivityDays

func (d *DB) ActivityDays(ctx context.Context, userID int64, siteID *int64, since time.Time, zone *time.Location, hidden []string) ([]ActivityDay, error)

func (*DB) AddArticleFile

func (d *DB) AddArticleFile(ctx context.Context, w FileWrite) (int64, error)

func (*DB) AddArticleLogEntry

func (d *DB) AddArticleLogEntry(ctx context.Context, articleID int64, userID *int64,
	kind, comment, meta string, at time.Time) (Revision, error)

The revision is numbered under a lock on this article alone, so two writers cannot pick the same number and neither waits on a page it is not touching.

func (*DB) AddArticleVersion

func (d *DB) AddArticleVersion(ctx context.Context, articleID int64, source string, at time.Time) (int64, error)

The revision a revert writes names every piece it moved, so the pieces themselves leave no revisions of their own.

func (*DB) AddFavourite

func (d *DB) AddFavourite(ctx context.Context, articleID, userID int64, at time.Time) error

func (*DB) AddImportedVote

func (d *DB) AddImportedVote(ctx context.Context, articleID, userID int64, rate float64) (int64, error)

func (*DB) AddQuizAttempt

func (d *DB) AddQuizAttempt(ctx context.Context, siteID, userID int64, at time.Time, passed bool) error

func (*DB) AddressCount

func (d *DB) AddressCount(ctx context.Context) (int, error)

func (*DB) AdminCategories

func (d *DB) AdminCategories(ctx context.Context, siteID int64) ([]CategoryRow, error)

func (*DB) AdminCategory

func (d *DB) AdminCategory(ctx context.Context, siteID, id int64) (CategoryRow, error)

func (*DB) AdminForumCategories

func (d *DB) AdminForumCategories(ctx context.Context, siteID int64) ([]ForumCategoryRow, error)

func (*DB) AdminForumCategory

func (d *DB) AdminForumCategory(ctx context.Context, siteID, id int64) (ForumCategoryRow, error)

func (*DB) AdminForumSection

func (d *DB) AdminForumSection(ctx context.Context, siteID, id int64) (ForumSectionRow, error)

func (*DB) AdminForumSections

func (d *DB) AdminForumSections(ctx context.Context, siteID int64) ([]ForumSectionRow, error)

func (*DB) AdminInvites

func (d *DB) AdminInvites(ctx context.Context, siteID int64, limit, offset int) ([]InviteRow, int, error)

func (*DB) AdminNoteScreens

func (d *DB) AdminNoteScreens(ctx context.Context, siteID int64) ([]string, error)

func (*DB) AdminNotes

func (d *DB) AdminNotes(ctx context.Context, siteID int64, screen string, limit, offset int) ([]AdminNoteRow, error)

func (*DB) AdminPageCategories

func (d *DB) AdminPageCategories(ctx context.Context, siteID int64) ([]PageCategoryCount, error)

func (*DB) AdminPages

func (d *DB) AdminPages(ctx context.Context, siteID int64, query, category string, tagID int64, limit, offset int) ([]AdminPageRow, int, error)

func (*DB) AdminReport

func (d *DB) AdminReport(ctx context.Context, siteID, id int64) (ReportRow, error)

func (*DB) AdminReports

func (d *DB) AdminReports(ctx context.Context, siteID int64, status string, limit, offset int) ([]ReportRow, int, error)

func (*DB) AdminRole

func (d *DB) AdminRole(ctx context.Context, siteID, id int64) (RoleRow, error)

func (*DB) AdminRoles

func (d *DB) AdminRoles(ctx context.Context, siteID int64) ([]RoleRow, error)

func (*DB) AdminTag

func (d *DB) AdminTag(ctx context.Context, siteID, id int64) (TagRow, error)

func (*DB) AdminTagCategories

func (d *DB) AdminTagCategories(ctx context.Context, siteID int64) ([]TagCategoryRow, error)

func (*DB) AdminTagCategory

func (d *DB) AdminTagCategory(ctx context.Context, siteID, id int64) (TagCategoryRow, error)

func (*DB) AdminTags

func (d *DB) AdminTags(ctx context.Context, siteID int64, query string, categoryID int64, limit, offset int) ([]TagRow, int, error)

func (*DB) AdminTicket

func (d *DB) AdminTicket(ctx context.Context, siteID, id int64) (TicketRow, error)

func (*DB) AdminTickets

func (d *DB) AdminTickets(ctx context.Context, siteID int64, kind, status string, limit, offset int) ([]TicketRow, int, error)

func (*DB) AdminUser

func (d *DB) AdminUser(ctx context.Context, siteID, id int64) (AdminUserRow, error)

func (*DB) AdminUsers

func (d *DB) AdminUsers(ctx context.Context, siteID int64, query, kind string, roleID int64, bannedOnly, byEmail, siteOnly bool, limit, offset int) ([]AdminUserRow, int, error)

Matching on email is a lookup by email, so it is only done for someone who may see the addresses anyway.

func (*DB) AllRoles

func (d *DB) AllRoles(ctx context.Context, siteID int64) ([]RoleChoice, error)

func (*DB) AllTags

func (d *DB) AllTags(ctx context.Context, siteID int64) ([]NamedTag, error)

func (*DB) AllUsers

func (d *DB) AllUsers(ctx context.Context) ([]User, error)

func (*DB) Announcement

func (d *DB) Announcement(ctx context.Context, siteID, id int64) (Announcement, string, error)

Announcement answers with ErrNotFound for one sent on another site, which this site's staff have no business reading.

func (*DB) AnnouncementAudience

func (d *DB) AnnouncementAudience(ctx context.Context, siteID *int64) ([]int64, error)

func (*DB) Announcements

func (d *DB) Announcements(ctx context.Context, siteID int64) ([]Announcement, error)

func (*DB) AppendImportedPost

func (d *DB) AppendImportedPost(ctx context.Context, threadID int64, post ImportPost, replyTo *int64) (int64, *Renumbered, error)

func (*DB) ApplyPendingEmail

func (d *DB) ApplyPendingEmail(ctx context.Context, id int64, pending string, at time.Time) (bool, error)

func (*DB) ArticleAuthorIDs

func (d *DB) ArticleAuthorIDs(ctx context.Context, articleID int64) ([]int64, error)

func (*DB) ArticleAuthors

func (d *DB) ArticleAuthors(ctx context.Context, articleID int64) ([]User, error)

func (*DB) ArticleByID

func (d *DB) ArticleByID(ctx context.Context, siteID, id int64) (*Article, error)

func (*DB) ArticleByName

func (d *DB) ArticleByName(ctx context.Context, siteID int64, ref string) (*Article, error)

ArticleByName takes a page reference the way a URL spells it; dumbName puts the implicit category back so the generated column can match.

func (*DB) ArticleCategories

func (d *DB) ArticleCategories(ctx context.Context, siteID int64, hidden []string) ([]string, error)

func (*DB) ArticleChildren

func (d *DB) ArticleChildren(ctx context.Context, articleID int64) ([]Article, error)

func (*DB) ArticleFavouriteCount

func (d *DB) ArticleFavouriteCount(ctx context.Context, articleID int64) (int, error)

func (*DB) ArticleFile

func (d *DB) ArticleFile(ctx context.Context, siteID int64, articleRef, fileName string) (*ArticleFile, error)

ArticleFile resolves an attachment's on-disk names. ORDER BY id only makes an already-unique row deterministic.

func (*DB) ArticleFileList

func (d *DB) ArticleFileList(ctx context.Context, articleID int64) ([]FileRecord, error)

func (*DB) ArticleFileNames

func (d *DB) ArticleFileNames(ctx context.Context, articleID int64) (map[string]bool, error)

func (*DB) ArticleFiles

func (d *DB) ArticleFiles(ctx context.Context, articleID int64) ([]ArticleFileEntry, error)

The name is unique per article only among the rows still alive, so the id breaks the tie for a name that was deleted and uploaded again.

func (*DB) ArticleHasAuthor

func (d *DB) ArticleHasAuthor(ctx context.Context, articleID, userID int64) (bool, error)

func (*DB) ArticleHead

func (d *DB) ArticleHead(ctx context.Context, articleID int64) (ArticleHead, error)

func (*DB) ArticleLastComment

func (d *DB) ArticleLastComment(ctx context.Context, articleID int64) (*ForumLastPost, error)

func (*DB) ArticleLog

func (d *DB) ArticleLog(ctx context.Context, articleID int64, offset int, limit *int) ([]LogEntry, error)

func (*DB) ArticleLogAbove

func (d *DB) ArticleLogAbove(ctx context.Context, articleID int64, revNumber int) ([]LogEntry, error)

func (*DB) ArticleLogCount

func (d *DB) ArticleLogCount(ctx context.Context, articleID int64) (int, error)

func (*DB) ArticleSources

func (d *DB) ArticleSources(ctx context.Context, siteID int64, refs []string) (map[string]string, error)

ArticleSources returns the newest version's source per article, keyed by the caller's own ref strings.

func (*DB) ArticleSubscribers

func (d *DB) ArticleSubscribers(ctx context.Context, articleID int64) ([]int64, error)

func (*DB) ArticleTagCategories

func (d *DB) ArticleTagCategories(ctx context.Context, articleID int64) ([]TagCategory, error)

A category with no priority sorts under the page's tag count, which is the number it is compared with.

func (*DB) ArticleTagIDs

func (d *DB) ArticleTagIDs(ctx context.Context, articleID int64) ([]int64, error)

func (*DB) ArticleTagNames

func (d *DB) ArticleTagNames(ctx context.Context, articleID int64) ([]string, error)

ArticleTagNames is the list ftml is told about, where a tag outside the default category appears twice, prefixed and bare. Hidden tags stay in.

func (*DB) ArticleTags

func (d *DB) ArticleTags(ctx context.Context, articleID int64) ([]string, error)

ArticleTags returns full names unsorted; the caller lowercases and sorts, because that pass belongs to whoever renders them.

func (*DB) ArticleTitles

func (d *DB) ArticleTitles(ctx context.Context, siteID int64, refs []string) (map[string]string, error)

ArticleTitles keys its result by the caller's own ref strings. Refs with no article are absent from the map rather than present-and-empty: fetch_internal_links drops missing pages instead of reporting them as non-existent.

func (*DB) ArticleVotes

func (d *DB) ArticleVotes(ctx context.Context, articleID int64) ([]ArticleVote, error)

func (*DB) ArticlesByTag

func (d *DB) ArticlesByTag(ctx context.Context, siteID int64, categorySlug, name string, hidden []string) ([]Article, error)

ArticlesByTag leaves out the categories the visitor cannot see, which the caller resolves because permissions are not a database question.

func (*DB) AuthorRank

func (d *DB) AuthorRank(ctx context.Context, siteID int64, f AuthorRankFilter, offset, limit int) ([]AuthorRankRow, error)

func (*DB) AuthorRankOf

func (d *DB) AuthorRankOf(ctx context.Context, siteID int64, f AuthorRankFilter, userID int64) (*AuthorRankRow, error)

Nil means the author has no page that counts.

func (*DB) AuthorScoreTrend

func (d *DB) AuthorScoreTrend(ctx context.Context, userID int64, siteID *int64, hidden []string) ([]TrendPoint, error)

func (*DB) AuthorStats

func (d *DB) AuthorStats(ctx context.Context, userID int64, siteID *int64, hidden []string) (AuthorStats, error)

func (*DB) AuthoredPages

func (d *DB) AuthoredPages(ctx context.Context, userID int64, pinnedOnly bool, from, before *time.Time, limit int) ([]AuthoredPage, error)

func (*DB) AuthorsOfArticles

func (d *DB) AuthorsOfArticles(ctx context.Context, ids []int64) (map[int64][]User, error)

func (*DB) BlockUser

func (d *DB) BlockUser(ctx context.Context, blockerID, blockedID int64, at time.Time) (bool, error)

func (*DB) BotByAPIKey

func (d *DB) BotByAPIKey(ctx context.Context, key string) (*User, error)

func (*DB) Breadcrumbs

func (d *DB) Breadcrumbs(ctx context.Context, articleID int64) ([]Article, error)

Breadcrumbs walks up the parent chain and returns the root first. The seen array is what keeps a page that is its own ancestor from looping forever.

func (*DB) BumpForumSequences

func (d *DB) BumpForumSequences(ctx context.Context) error

func (*DB) CategoryCanCreateTags

func (d *DB) CategoryCanCreateTags(ctx context.Context, siteID int64, category string) (string, error)

A category with no row of its own reads the same as one left on default. Both hand the question back to the site.

func (*DB) CategoryExists

func (d *DB) CategoryExists(ctx context.Context, siteID int64, name string) (bool, error)

The page skips the permission check entirely when neither it nor its category has a row, which is how a 404 wins over a 403 there.

func (*DB) CategoryIndexed

func (d *DB) CategoryIndexed(ctx context.Context, siteID int64, name string) (bool, error)

func (*DB) CategoryLook

func (d *DB) CategoryLook(ctx context.Context, siteID int64, name string) (CategoryLook, error)

A category nobody has saved yet has no row, and it looks like the site.

func (*DB) CategoryNames

func (d *DB) CategoryNames(ctx context.Context, siteID int64) ([]string, error)

func (*DB) CategoryOverrides

func (d *DB) CategoryOverrides(ctx context.Context, siteID int64, category string) ([]perms.Override, error)

func (*DB) CategoryRatingMode

func (d *DB) CategoryRatingMode(ctx context.Context, siteID int64, category string) (string, error)

CategoryRatingMode reports ErrNotFound for a category that has no row of its own as well as for one that exists without settings; both fall back to the site.

func (*DB) CategoryRatingModes

func (d *DB) CategoryRatingModes(ctx context.Context, siteID int64) (map[string]string, error)

func (*DB) ChildCount

func (d *DB) ChildCount(ctx context.Context, articleID int64) (int, error)

func (*DB) ClearAddresses

func (d *DB) ClearAddresses(ctx context.Context, userID *int64) (int64, error)

func (*DB) ClearConversations

func (d *DB) ClearConversations(ctx context.Context, userID int64, partnerIDs []int64) ([]int64, error)

func (*DB) ClearSanction

func (d *DB) ClearSanction(ctx context.Context, siteID, userID int64, kind string) error

func (*DB) Close

func (d *DB) Close()

func (*DB) CommentCount

func (d *DB) CommentCount(ctx context.Context, articleID int64) (int, error)

func (*DB) CommentCountsOfArticles

func (d *DB) CommentCountsOfArticles(ctx context.Context, ids []int64) (map[int64]int, error)

func (*DB) CommentInfo

func (d *DB) CommentInfo(ctx context.Context, articleID int64) (CommentInfo, error)

A page whose thread has never been created reports the zero value rather than having one written for it on a read.

func (*DB) CommentThreadFor

func (d *DB) CommentThreadFor(ctx context.Context, siteID, articleID int64) (int64, error)

A page gets its comment thread the first time a reader asks for the discussion, so reading the page never writes and the link still lands.

func (*DB) ConfirmEmailHold

func (d *DB) ConfirmEmailHold(ctx context.Context, id int64, email string, until time.Time) (bool, error)

func (*DB) ConversationAfter

func (d *DB) ConversationAfter(ctx context.Context, userID, partnerID, after int64, limit int) ([]DirectMessage, error)

func (*DB) ConversationBefore

func (d *DB) ConversationBefore(ctx context.Context, userID, partnerID int64, before *int64, limit int) ([]DirectMessage, error)

func (*DB) Conversations

func (d *DB) Conversations(ctx context.Context, userID int64) ([]Conversation, error)

func (*DB) CountArticles

func (d *DB) CountArticles(ctx context.Context, f ListFilter, offset int, limit *int) (int, error)

Counted before pagination narrows it, so offset and limit still apply.

func (*DB) CreateArticle

func (d *DB) CreateArticle(ctx context.Context, siteID int64, category, name, title string, authorID *int64, at time.Time) (int64, error)

func (*DB) CreateArticleVersion

func (d *DB) CreateArticleVersion(ctx context.Context, w VersionWrite) (Revision, error)

The version and the revision naming it go in together, so a failed write cannot leave behind a version nothing points at.

func (*DB) CreateBot

func (d *DB) CreateBot(ctx context.Context, siteID int64, username, apiKey string, at time.Time) (int64, error)

A bot signs in with its key rather than a password, so the password column holds the marker that makes every comparison fail.

func (*DB) CreateFavouriteFolder

func (d *DB) CreateFavouriteFolder(ctx context.Context, userID int64, name string, public bool, at time.Time) (int64, error)

func (*DB) CreateForumPost

func (d *DB) CreateForumPost(ctx context.Context, w ForumPostWrite) (int64, error)

The post, its first version and the thread's timestamp move together, so a post that fails halfway leaves no body-less row behind.

func (*DB) CreateForumThread

func (d *DB) CreateForumThread(ctx context.Context, siteID int64, w ForumThreadWrite, source string) (int64, int64, error)

The thread and its first post go in together, so a thread that fails halfway does not show up empty in the category listing.

func (d *DB) CreateInviteLink(ctx context.Context, siteID int64, kind, delivery, email, wikidotName,
	token, uid string, createdBy *int64, target int64, at time.Time) (int64, error)

func (*DB) CreateInvitedUser

func (d *DB) CreateInvitedUser(ctx context.Context, email string, at time.Time) (int64, error)

func (*DB) CreateReport

func (d *DB) CreateReport(ctx context.Context, siteID, reporterID, reportedID int64, reason, snapshot string, at time.Time) (int64, error)

func (*DB) CreateSite

func (d *DB) CreateSite(ctx context.Context, s NewSite) (int64, error)

func (*DB) CreateTicket

func (d *DB) CreateTicket(ctx context.Context, siteID int64, kind, subject, body, page string, authorID int64, at time.Time) (int64, error)

func (*DB) CreateTypedUser

func (d *DB) CreateTypedUser(ctx context.Context, username, displayName, hash, kind string, active bool, at time.Time) (int64, error)

func (*DB) CreateUser

func (d *DB) CreateUser(ctx context.Context, username, displayName, hash string, active bool, at time.Time) (int64, error)

func (*DB) DefaultFolderPublic

func (d *DB) DefaultFolderPublic(ctx context.Context, userID int64) (bool, error)

The default folder has no row of its own, so whether it is public is kept with the owner's other profile switches.

func (*DB) DeleteAllNotifications

func (d *DB) DeleteAllNotifications(ctx context.Context, userID int64, kinds []string) (int64, error)

func (*DB) DeleteArticle

func (d *DB) DeleteArticle(ctx context.Context, siteID, articleID int64, fullName string) error

The files on disk are left to the caller, which is the only layer that knows where the state directory is.

func (*DB) DeleteArticleVotes

func (d *DB) DeleteArticleVotes(ctx context.Context, articleID int64) error

func (*DB) DeleteCategory

func (d *DB) DeleteCategory(ctx context.Context, siteID, id int64) error

func (*DB) DeleteFavouriteFolder

func (d *DB) DeleteFavouriteFolder(ctx context.Context, userID, folderID int64) error

The pages in it go back to the default folder rather than being unfavourited.

func (*DB) DeleteForumCategory

func (d *DB) DeleteForumCategory(ctx context.Context, siteID, id int64) error

func (*DB) DeleteForumPost

func (d *DB) DeleteForumPost(ctx context.Context, postID int64) error

func (*DB) DeleteForumSection

func (d *DB) DeleteForumSection(ctx context.Context, siteID, id int64) error

The overrides go in the same step as the section, so a section that cannot be deleted because categories remain keeps its permissions.

func (*DB) DeleteIPBan

func (d *DB) DeleteIPBan(ctx context.Context, siteID, id int64) (string, error)

func (*DB) DeleteInvite

func (d *DB) DeleteInvite(ctx context.Context, siteID, id int64) error

func (*DB) DeleteMirror

func (d *DB) DeleteMirror(ctx context.Context, id int64) error

func (*DB) DeleteNotifications

func (d *DB) DeleteNotifications(ctx context.Context, userID int64, ids []int64) (int64, error)

func (*DB) DeleteRole

func (d *DB) DeleteRole(ctx context.Context, siteID, id int64) error

func (*DB) DeleteRoleCategory

func (d *DB) DeleteRoleCategory(ctx context.Context, siteID, id int64) error

func (*DB) DeleteSession

func (d *DB) DeleteSession(ctx context.Context, key string) error

func (*DB) DeleteSite

func (d *DB) DeleteSite(ctx context.Context, slug string) ([]string, error)

Rows elsewhere that pointed at what went are cleared, or removed when the pointer cannot be empty. An account is never removed.

func (*DB) DeleteTag

func (d *DB) DeleteTag(ctx context.Context, siteID, id int64) error

func (*DB) DeleteTagCategory

func (d *DB) DeleteTagCategory(ctx context.Context, siteID, id int64) error

func (*DB) DeleteTheme

func (d *DB) DeleteTheme(ctx context.Context, siteID, id int64) error

func (*DB) DeleteUnreferencedWikidotUsers

func (d *DB) DeleteUnreferencedWikidotUsers(ctx context.Context, ids []int64) (int64, error)

func (*DB) Devices

func (d *DB) Devices(ctx context.Context, userID int64) ([]Device, error)

func (*DB) DirectMessageBlocked

func (d *DB) DirectMessageBlocked(ctx context.Context, blockerID, blockedID int64) (bool, error)

func (*DB) DropClaimCode

func (d *DB) DropClaimCode(ctx context.Context, userID int64, hash string) error

func (*DB) DropEmailHold

func (d *DB) DropEmailHold(ctx context.Context, id int64, email string) (bool, error)

func (*DB) EnabledPlugins

func (d *DB) EnabledPlugins(ctx context.Context, siteID int64) ([]string, error)

func (*DB) EndDevice

func (d *DB) EndDevice(ctx context.Context, userID, id int64) (bool, error)

func (*DB) EndOtherDevices

func (d *DB) EndOtherDevices(ctx context.Context, userID int64, keep string) (int64, error)

func (*DB) EnsureTags

func (d *DB) EnsureTags(ctx context.Context, siteID int64, names []string) ([]int64, error)

EnsureTags resolves the tag names an archive carries, creating the ones this site has never had. It is the import's way in to the same resolution the editor uses, so a tag written here is the tag the editor would have made.

func (*DB) EnsureWikidotUsers

func (d *DB) EnsureWikidotUsers(ctx context.Context, users []ImportUser, at time.Time) (map[int64]int64, error)

EnsureWikidotUsers answers the local id of every account the archive names, creating the ones this database has never seen.

func (*DB) FavouriteCountOf

func (d *DB) FavouriteCountOf(ctx context.Context, userID, folderID int64) (int, error)

func (*DB) FavouriteFolders

func (d *DB) FavouriteFolders(ctx context.Context, userID int64) ([]FavouriteFolder, error)

func (*DB) FavouritesOf

func (d *DB) FavouritesOf(ctx context.Context, userID, folderID int64, offset, limit int) ([]Favourite, error)

Only the owner ever reads this, so no permission filter runs here. Whoever calls it has already established that the rows belong to the reader.

func (*DB) FileByID

func (d *DB) FileByID(ctx context.Context, fileID int64) (*FileRow, error)

func (*DB) FileSpaceUsage

func (d *DB) FileSpaceUsage(ctx context.Context) (live, total int64, err error)

func (*DB) FillArticleAuthor

func (d *DB) FillArticleAuthor(ctx context.Context, articleID, userID int64) (int64, error)

func (*DB) FillFileAuthor

func (d *DB) FillFileAuthor(ctx context.Context, articleID int64, name string, at time.Time, userID int64) (int64, error)

func (*DB) FillPostAuthor

func (d *DB) FillPostAuthor(ctx context.Context, postID, userID int64) (int64, error)

func (*DB) FillPostVersionAuthor

func (d *DB) FillPostVersionAuthor(ctx context.Context, versionID, userID int64) (int64, error)

func (*DB) FillRevisionUser

func (d *DB) FillRevisionUser(ctx context.Context, articleID int64, revNumber int, userID int64) (int64, error)

func (*DB) FillThreadAuthor

func (d *DB) FillThreadAuthor(ctx context.Context, siteID, threadID, userID int64) (int64, error)

func (*DB) FirstActivity

func (d *DB) FirstActivity(ctx context.Context, userID int64) (time.Time, error)

Zero means the person has done nothing yet.

func (*DB) ForumCategories

func (d *DB) ForumCategories(ctx context.Context, siteID int64) ([]ForumCategory, error)

func (*DB) ForumCategory

func (d *DB) ForumCategory(ctx context.Context, siteID, id int64) (*ForumCategory, error)

func (*DB) ForumCategoryCounts

func (d *DB) ForumCategoryCounts(ctx context.Context, categoryID int64) (ForumCounts, error)

func (*DB) ForumCategoryLastPost

func (d *DB) ForumCategoryLastPost(ctx context.Context, categoryID int64) (*ForumLastPost, error)

func (*DB) ForumCommentCounts

func (d *DB) ForumCommentCounts(ctx context.Context, siteID int64) (ForumCounts, error)

func (*DB) ForumCommentLastPost

func (d *DB) ForumCommentLastPost(ctx context.Context, siteID int64) (*ForumLastPost, error)

func (*DB) ForumCommentThreads

func (d *DB) ForumCommentThreads(ctx context.Context, siteID int64, sort ForumThreadSort, offset, limit int) ([]ForumThread, error)

func (*DB) ForumFirstPosts

func (d *DB) ForumFirstPosts(ctx context.Context, threadIDs []int64) (map[int64]ForumThreadPost, error)

func (*DB) ForumPost

func (d *DB) ForumPost(ctx context.Context, siteID, id int64) (*ForumThreadPost, error)

func (*DB) ForumPostContents

func (d *DB) ForumPostContents(ctx context.Context, postIDs []int64) (map[int64]ForumPostContent, error)

func (*DB) ForumPostReplies

func (d *DB) ForumPostReplies(ctx context.Context, postID int64) ([]ForumThreadPost, error)

func (*DB) ForumPostSource

func (d *DB) ForumPostSource(ctx context.Context, postID int64, at *time.Time) (string, error)

A post with no version behind it reads as empty rather than as missing, which is the same thing the thread page shows for it.

func (*DB) ForumPostVersions

func (d *DB) ForumPostVersions(ctx context.Context, postID int64) ([]ForumPostVersion, error)

func (*DB) ForumRootPostCount

func (d *DB) ForumRootPostCount(ctx context.Context, threadID int64) (int, error)

func (*DB) ForumRootPostIDs

func (d *DB) ForumRootPostIDs(ctx context.Context, threadID int64) ([]int64, error)

func (*DB) ForumRootPosts

func (d *DB) ForumRootPosts(ctx context.Context, threadID int64, offset, limit int) ([]ForumThreadPost, error)

func (*DB) ForumSection

func (d *DB) ForumSection(ctx context.Context, siteID, id int64) (*ForumSection, error)

func (*DB) ForumSectionOverrides

func (d *DB) ForumSectionOverrides(ctx context.Context, siteID int64, sectionIDs []int64) (map[int64][]perms.Override, error)

func (*DB) ForumSections

func (d *DB) ForumSections(ctx context.Context, siteID int64) ([]ForumSection, error)

func (*DB) ForumThread

func (d *DB) ForumThread(ctx context.Context, siteID, id int64) (*ForumThread, error)

func (*DB) ForumThreadLastPost

func (d *DB) ForumThreadLastPost(ctx context.Context, threadID int64, count int) (*ForumPost, error)

func (*DB) ForumThreadPostCount

func (d *DB) ForumThreadPostCount(ctx context.Context, threadID int64) (int, error)

func (*DB) ForumThreadPostCounts

func (d *DB) ForumThreadPostCounts(ctx context.Context, threadIDs []int64) (map[int64]int, error)

func (*DB) ForumThreads

func (d *DB) ForumThreads(ctx context.Context, categoryID int64, sort ForumThreadSort, offset, limit int) ([]ForumThread, error)

func (*DB) ForumThreadsInCategories

func (d *DB) ForumThreadsInCategories(ctx context.Context, categoryIDs []int64, offset, limit int) ([]ForumThread, error)

func (*DB) GrantRole

func (d *DB) GrantRole(ctx context.Context, siteID, userID, roleID int64) error

func (*DB) HasFavourited

func (d *DB) HasFavourited(ctx context.Context, articleID, userID int64) (bool, error)

func (*DB) HasVoted

func (d *DB) HasVoted(ctx context.Context, articleID int64, userID *int64) (bool, error)

func (*DB) HideAllOwnTickets

func (d *DB) HideAllOwnTickets(ctx context.Context, userID int64, at time.Time) (int64, error)

func (*DB) HideOwnTickets

func (d *DB) HideOwnTickets(ctx context.Context, userID int64, refs []OwnTicketRef, at time.Time) (int64, error)

func (*DB) HoldEmail

func (d *DB) HoldEmail(ctx context.Context, id int64, email string, siteID int64) error

func (*DB) IPBanned

func (d *DB) IPBanned(ctx context.Context, siteID int64, addr netip.Addr, now time.Time) (bool, error)

func (*DB) IPBans

func (d *DB) IPBans(ctx context.Context, siteID int64) ([]IPBan, error)

func (*DB) ImportArticle

func (d *DB) ImportArticle(ctx context.Context, siteID int64, a ImportArticle) (int64, string, error)

ImportArticle writes one page and its whole history as the archive recorded it. It goes around the ordinary save path on purpose, since that one renumbers revisions, rebuilds links and tells subscribers about every one of them.

func (*DB) ImportForumCategory

func (d *DB) ImportForumCategory(ctx context.Context, siteID, sectionID, want int64, name, description string,
	order int, forComments bool) (int64, *Renumbered, error)

func (*DB) ImportForumSection

func (d *DB) ImportForumSection(ctx context.Context, siteID int64, name, description string) (int64, error)

func (*DB) ImportForumThread

func (d *DB) ImportForumThread(ctx context.Context, siteID int64, t ImportThread, posts []ImportPost,
	parents []int) (int, []Renumbered, error)

ImportForumThread writes a thread and its posts together. A reply names its parent by the position the parent holds in posts, so the caller flattens the tree with every parent ahead of its children.

func (*DB) ImportedCategory

func (d *DB) ImportedCategory(ctx context.Context, siteID, sectionID int64, name string) (int64, error)

func (*DB) ImportedCommentThread

func (d *DB) ImportedCommentThread(ctx context.Context, siteID, articleID int64) (int64, error)

func (*DB) ImportedSection

func (d *DB) ImportedSection(ctx context.Context, siteID int64, name string) (int64, error)

func (*DB) ImportedThread

func (d *DB) ImportedThread(ctx context.Context, siteID int64, section, category, name string, at time.Time) (int64, error)

func (*DB) InstanceSiteSlugs

func (d *DB) InstanceSiteSlugs(ctx context.Context) (map[string]bool, error)

func (*DB) IsBlocked

func (d *DB) IsBlocked(ctx context.Context, blockerID, blockedID int64) (bool, error)

func (*DB) IsSiteSuperuser

func (d *DB) IsSiteSuperuser(ctx context.Context, siteID, userID int64) (bool, error)

func (*DB) LastSeen

func (d *DB) LastSeen(ctx context.Context, userID int64) (LastSeen, error)

func (*DB) LatestEditor

func (d *DB) LatestEditor(ctx context.Context, articleID int64) (*User, error)

func (*DB) LatestEditorsOfArticles

func (d *DB) LatestEditorsOfArticles(ctx context.Context, ids []int64) (map[int64]User, error)

func (*DB) LatestRevNumber

func (d *DB) LatestRevNumber(ctx context.Context, articleID int64) (int, error)

func (*DB) LatestSource

func (d *DB) LatestSource(ctx context.Context, articleID int64) (string, error)

func (*DB) LikePost

func (d *DB) LikePost(ctx context.Context, postID, userID int64, at time.Time) (bool, error)

A false answer means the like was already there, which is how the caller knows not to tell the author a second time.

func (*DB) LikedPostCountOf

func (d *DB) LikedPostCountOf(ctx context.Context, userID int64) (int, error)

func (*DB) LikedPostsOf

func (d *DB) LikedPostsOf(ctx context.Context, userID int64, offset, limit int) ([]LikedPost, error)

func (*DB) LinksTo

func (d *DB) LinksTo(ctx context.Context, siteID int64, fullName string) ([]ExternalLink, error)

func (*DB) ListArticles

func (d *DB) ListArticles(ctx context.Context, f ListFilter, offset int, limit *int) ([]Article, error)

func (*DB) LiveFileNamed

func (d *DB) LiveFileNamed(ctx context.Context, articleID int64, name string) (int64, error)

func (*DB) LogEntryByID

func (d *DB) LogEntryByID(ctx context.Context, id int64) (LogEntry, error)

func (*DB) MarkConversationRead

func (d *DB) MarkConversationRead(ctx context.Context, userID, partnerID int64) (int64, error)

func (*DB) MarkEmailVerified

func (d *DB) MarkEmailVerified(ctx context.Context, id int64, email string, at time.Time) (bool, error)

func (*DB) MarkNotificationsViewed

func (d *DB) MarkNotificationsViewed(ctx context.Context, userID int64, ids []int64) error

func (*DB) MarkTokenUsed

func (d *DB) MarkTokenUsed(ctx context.Context, token string, caseSensitive bool) error

func (*DB) MemberCount

func (d *DB) MemberCount(ctx context.Context, siteID, roleID *int64) (int, error)

func (*DB) MemberSanctions

func (d *DB) MemberSanctions(ctx context.Context, siteID, userID int64) ([]MemberSanction, error)

func (*DB) Members

func (d *DB) Members(ctx context.Context, siteID, roleID *int64, offset, limit int) ([]Member, error)

func (*DB) MembershipQuiz

func (d *DB) MembershipQuiz(ctx context.Context, siteID int64) (MembershipQuiz, error)

A site that never saved a quiz gets the defaults, switched off.

func (*DB) MergeUsers

func (d *DB) MergeUsers(ctx context.Context, from, into int64) ([]MergeMove, error)

func (*DB) MessagesBetween

func (d *DB) MessagesBetween(ctx context.Context, userID, partnerID int64) ([]DirectMessage, error)

func (*DB) MessagesByIDs

func (d *DB) MessagesByIDs(ctx context.Context, userID, partnerID int64, ids []int64) ([]DirectMessage, error)

func (*DB) Mirror

func (d *DB) Mirror(ctx context.Context, id int64) (Mirror, error)

func (*DB) MirrorByName

func (d *DB) MirrorByName(ctx context.Context, wiki, page string) (Mirror, error)

func (*DB) MirrorReferrers

func (d *DB) MirrorReferrers(ctx context.Context, siteID int64, wiki, page string) ([]string, error)

func (*DB) MirrorSource

func (d *DB) MirrorSource(ctx context.Context, wiki, page string) (string, bool, error)

func (*DB) Mirrors

func (d *DB) Mirrors(ctx context.Context, siteID int64) ([]Mirror, error)

func (*DB) MissingIncludes

func (d *DB) MissingIncludes(ctx context.Context, siteID *int64) ([]MissingInclude, error)

func (*DB) MoveArticle

func (d *DB) MoveArticle(ctx context.Context, articleID int64, category, name, from string) error

func (*DB) MoveArticleParent

func (d *DB) MoveArticleParent(ctx context.Context, articleID int64, parentID *int64) error

func (*DB) MoveFavourite

func (d *DB) MoveFavourite(ctx context.Context, userID, articleID, folderID int64) error

func (*DB) MuteArticle

func (d *DB) MuteArticle(ctx context.Context, userID, articleID int64) error

func (*DB) MuteThread

func (d *DB) MuteThread(ctx context.Context, userID, threadID int64) error

func (*DB) MuteUser

func (d *DB) MuteUser(ctx context.Context, userID, mutedID int64) error

func (*DB) Mutes

func (d *DB) Mutes(ctx context.Context, userID int64) ([]NotifyMute, error)

func (*DB) NotificationOf

func (d *DB) NotificationOf(ctx context.Context, userID, id int64) ([]Notification, error)

func (*DB) NotificationsOf

func (d *DB) NotificationsOf(ctx context.Context, userID int64, cursor *int64,
	unread bool, kinds []string, limit int) ([]Notification, error)

func (*DB) OpenInviteCount

func (d *DB) OpenInviteCount(ctx context.Context, siteID int64) (int, error)

func (*DB) OperationIndex

func (d *DB) OperationIndex(ctx context.Context, siteID, userID int64) (int, error)

func (*DB) OwnTicketCount

func (d *DB) OwnTicketCount(ctx context.Context, userID int64) (int, error)

func (*DB) OwnTicketDetail

func (d *DB) OwnTicketDetail(ctx context.Context, userID int64, kind string, id int64) (OwnTicketDetail, error)

func (*DB) OwnTickets

func (d *DB) OwnTickets(ctx context.Context, userID int64, offset, limit int) ([]OwnTicket, error)

func (*DB) PermissionCatalog

func (d *DB) PermissionCatalog(ctx context.Context) ([]string, error)

func (*DB) PluginKVCount

func (d *DB) PluginKVCount(ctx context.Context, siteID int64, plugin string) (int, error)

func (*DB) PluginKVDelete

func (d *DB) PluginKVDelete(ctx context.Context, siteID int64, plugin, key string) error

func (*DB) PluginKVGet

func (d *DB) PluginKVGet(ctx context.Context, siteID int64, plugin, key string) ([]byte, error)

func (*DB) PluginKVSet

func (d *DB) PluginKVSet(ctx context.Context, siteID int64, plugin, key string, value []byte) error

func (*DB) PostLikeCount

func (d *DB) PostLikeCount(ctx context.Context, postID int64) (int, error)

func (*DB) PostLikeCounts

func (d *DB) PostLikeCounts(ctx context.Context, postIDs []int64) (map[int64]int, error)

func (*DB) PostLikers

func (d *DB) PostLikers(ctx context.Context, postID int64, offset, limit int) ([]User, error)

func (*DB) PostVersionTimes

func (d *DB) PostVersionTimes(ctx context.Context, postID int64) ([]Stamped, error)

func (*DB) PostsLikedBy

func (d *DB) PostsLikedBy(ctx context.Context, userID int64, postIDs []int64) (map[int64]bool, error)

func (*DB) PreviousVersionSource

func (d *DB) PreviousVersionSource(ctx context.Context, versionID int64) (string, error)

func (*DB) ProfileByID

func (d *DB) ProfileByID(ctx context.Context, id int64) (*Profile, error)

func (*DB) ProfileByName

func (d *DB) ProfileByName(ctx context.Context, name string) (*Profile, error)

func (*DB) ProfileExtras

func (d *DB) ProfileExtras(ctx context.Context, userID int64) ([]ProfileField, []ProfileLink, error)

func (*DB) PublicFavourites

func (d *DB) PublicFavourites(ctx context.Context, userID int64, defaultPublic bool, limit int) ([]PublicFavourite, error)

The caller still filters out pages the viewer may not see.

func (*DB) QuizAttempts

func (d *DB) QuizAttempts(ctx context.Context, siteID, userID int64) ([]quiz.Attempt, error)

func (*DB) RatedBy

func (d *DB) RatedBy(ctx context.Context, siteID, userID int64, offset, limit int) ([]RatedArticle, error)

func (*DB) RatedByCountOf

func (d *DB) RatedByCountOf(ctx context.Context, userID int64) (int, error)

func (*DB) RatedByOnEverySite

func (d *DB) RatedByOnEverySite(ctx context.Context, userID int64, offset, limit int) ([]RatedArticle, error)

func (*DB) RatingTrend

func (d *DB) RatingTrend(ctx context.Context, siteID, articleID int64, average bool) ([]TrendPoint, error)

Votes from before the history was kept count from when they were cast, or from the page's creation when that is unknown, so the last point is the rating now.

func (*DB) RecentPostCount

func (d *DB) RecentPostCount(ctx context.Context, siteID int64, categoryIDs []int64, comments bool) (int, error)

func (*DB) RecentPosts

func (d *DB) RecentPosts(ctx context.Context, siteID int64, categoryIDs []int64, comments bool, offset, limit int) ([]RecentPost, error)

func (*DB) ReleaseAudience

func (d *DB) ReleaseAudience(ctx context.Context) ([]int64, error)

func (*DB) RemoveFavourite

func (d *DB) RemoveFavourite(ctx context.Context, articleID, userID int64) error

func (*DB) RenameArticle

func (d *DB) RenameArticle(ctx context.Context, siteID, articleID int64, category, name, from string,
	userID *int64, at time.Time) (Revision, error)

What a page points at moves with it, but what points at the page does not. Everyone who linked to the old name keeps linking to the old name.

func (*DB) RenameFile

func (d *DB) RenameFile(ctx context.Context, fileID int64, name string) (string, bool, error)

A file that is already in the asked-for state reports no name, which is how the caller knows to leave it out of the revision it writes.

func (*DB) RenameUser

func (d *DB) RenameUser(ctx context.Context, id int64, username, displayName string) error
func (d *DB) ReplaceArticleLinks(ctx context.Context, siteID int64, from string, links []ArticleLink) error

The whole set is replaced under one transaction, so nobody reads a page as having no links at all while it is being saved.

func (*DB) ReplaceIncludeRefs

func (d *DB) ReplaceIncludeRefs(ctx context.Context, siteID int64, refs []IncludeRef) error

func (*DB) ReplaceVote

func (d *DB) ReplaceVote(ctx context.Context, articleID, userID int64, rate *float64, roleID *int64, at time.Time) (*Vote, error)

The vote that was there comes back, since the action log records what changed rather than what it changed to.

func (*DB) Report

func (d *DB) Report(ctx context.Context, siteID, id int64) (*Report, error)

func (*DB) ReportsSince

func (d *DB) ReportsSince(ctx context.Context, siteID, reporterID, reportedID int64, since time.Time) (int, error)

func (*DB) RequiredTags

func (d *DB) RequiredTags(ctx context.Context, siteID int64, category string, roleIDs []int64) ([][]string, error)

RequiredTags is nil when the category asks for nothing or one of the roles is exempt.

func (*DB) ReserveClaimCode

func (d *DB) ReserveClaimCode(ctx context.Context, userID int64, hash string, now, expires, notBefore time.Time) (bool, error)

The check and the write are one statement, so two sends racing for the same account cannot both get through.

func (*DB) ResetFields

func (d *DB) ResetFields(ctx context.Context, id int64) (string, *time.Time, string, error)

func (*DB) ResetUserVotes

func (d *DB) ResetUserVotes(ctx context.Context, siteID, userID int64) (int64, error)

func (*DB) RestoreArticleVotes

func (d *DB) RestoreArticleVotes(ctx context.Context, articleID int64, votes []RestoredVote) error

A vote whose voter is gone is dropped rather than failing the restore, since the row it would need points at a user that no longer exists.

func (*DB) RestoreFile

func (d *DB) RestoreFile(ctx context.Context, fileID int64) (string, bool, error)

func (*DB) RevertEmail

func (d *DB) RevertEmail(ctx context.Context, id int64, previous string, at time.Time) (bool, error)

func (*DB) ReviewReport

func (d *DB) ReviewReport(ctx context.Context, siteID, id int64, status, notes, reply string, by int64, at time.Time) error

func (*DB) ReviewTicket

func (d *DB) ReviewTicket(ctx context.Context, siteID, id int64, status, notes, reply string, by int64, role *int64, at time.Time) error

func (*DB) RevisionCount

func (d *DB) RevisionCount(ctx context.Context, articleID int64) (int, error)

func (*DB) RoleByRef

func (d *DB) RoleByRef(ctx context.Context, siteID int64, ref string) (*roles.Role, error)

func (*DB) RoleCategories

func (d *DB) RoleCategories(ctx context.Context, siteID int64) ([]RoleCategoryRow, error)

func (*DB) RoleIDsBySlug

func (d *DB) RoleIDsBySlug(ctx context.Context, siteID int64, slugs []string) (map[string]int64, error)

A slug with no row is left out rather than created, because a read path must not write.

func (*DB) RoleIDsForUser

func (d *DB) RoleIDsForUser(ctx context.Context, siteID, userID int64) ([]int64, error)

func (*DB) RolePermissions

func (d *DB) RolePermissions(ctx context.Context, ids []int64) ([]perms.Role, error)

RolePermissions answers in the order the ids arrived, and a role with no rows of its own still comes back so the merge sees it.

func (*DB) RolesByUser

func (d *DB) RolesByUser(ctx context.Context, siteID, userID int64) ([]roles.Role, error)

Ordered the way the name tail and showcase queries both consume it. The tie- break on id covers the rows whose index is not unique.

func (*DB) RolesByUsers

func (d *DB) RolesByUsers(ctx context.Context, siteID int64, userIDs []int64) (map[int64][]roles.Role, error)

func (*DB) RolesOfUserOnEverySite

func (d *DB) RolesOfUserOnEverySite(ctx context.Context, userID int64) ([]SiteRoles, error)

func (*DB) SaveAdminUser

func (d *DB) SaveAdminUser(ctx context.Context, siteID int64, u AdminUserRow, builtin []string, withRoles, withSuperuser bool) error

func (*DB) SaveCategory

func (d *DB) SaveCategory(ctx context.Context, siteID int64, c CategoryRow) error

func (*DB) SaveCategoryOverrides

func (d *DB) SaveCategoryOverrides(ctx context.Context, categoryID int64, list []CategoryOverride) error

func (*DB) SaveForumCategory

func (d *DB) SaveForumCategory(ctx context.Context, siteID int64, c ForumCategoryRow) error

func (*DB) SaveForumSection

func (d *DB) SaveForumSection(ctx context.Context, siteID int64, s ForumSectionRow) (int64, error)

func (*DB) SaveForumSectionOverrides

func (d *DB) SaveForumSectionOverrides(ctx context.Context, sectionID int64, list []CategoryOverride) error

func (*DB) SaveMembershipQuiz

func (d *DB) SaveMembershipQuiz(ctx context.Context, siteID int64, q MembershipQuiz) error

func (*DB) SaveMirror

func (d *DB) SaveMirror(ctx context.Context, m Mirror) error

func (*DB) SaveProfileExtras

func (d *DB) SaveProfileExtras(ctx context.Context, userID int64, fields []ProfileField, links []ProfileLink) error

func (*DB) SaveRole

func (d *DB) SaveRole(ctx context.Context, siteID int64, r RoleRow, withGrants bool) (int64, error)

func (*DB) SaveRoleCategory

func (d *DB) SaveRoleCategory(ctx context.Context, siteID int64, c RoleCategoryRow) error

func (*DB) SaveSession

func (d *DB) SaveSession(ctx context.Context, key, data string, expires time.Time) error

func (*DB) SaveSite

func (d *DB) SaveSite(ctx context.Context, s *Site, settings SiteSettings, withRoles bool) error

func (*DB) SaveTag

func (d *DB) SaveTag(ctx context.Context, siteID int64, t TagRow) error

func (*DB) SaveTagCategory

func (d *DB) SaveTagCategory(ctx context.Context, siteID int64, c TagCategoryRow) error

func (*DB) SaveTagRule

func (d *DB) SaveTagRule(ctx context.Context, categoryID int64, groups string, exempt []int64) error

func (*DB) SaveTheme

func (d *DB) SaveTheme(ctx context.Context, siteID int64, t ThemeRow) (int64, error)

func (*DB) SaveToolbarHiddenRoles

func (d *DB) SaveToolbarHiddenRoles(ctx context.Context, categoryID int64, roleIDs []int64) error

func (*DB) SaveUpdateState

func (d *DB) SaveUpdateState(ctx context.Context, s UpdateState) error

func (*DB) SearchArticles

func (d *DB) SearchArticles(ctx context.Context, f SearchFilter, offset, limit int) ([]SearchHit, error)

func (*DB) SearchCount

func (d *DB) SearchCount(ctx context.Context, f SearchFilter) (int, error)

func (*DB) SearchForum

func (d *DB) SearchForum(ctx context.Context, siteID int64, f ForumSearchFilter, offset, limit int) ([]ForumSearchHit, error)

func (*DB) SeenAddress

func (d *DB) SeenAddress(ctx context.Context, userID int64, address *netip.Addr, at time.Time) error

func (*DB) SeenDevice

func (d *DB) SeenDevice(ctx context.Context, key string, userID int64, siteID *int64, signedIn bool,
	address *netip.Addr, agent string, at time.Time) error

func (*DB) SendDirectMessage

func (d *DB) SendDirectMessage(ctx context.Context, senderID, recipientID int64, body string, at time.Time) (DirectMessage, error)

func (*DB) SendNotification

func (d *DB) SendNotification(ctx context.Context, siteID int64, kind, meta string, recipients []int64, at time.Time) error

The notification and the rows naming its readers go in together, so nobody ends up with a notification that reaches no one.

func (*DB) SessionByKey

func (d *DB) SessionByKey(ctx context.Context, key string) (string, time.Time, error)

func (*DB) SetArticleAuthors

func (d *DB) SetArticleAuthors(ctx context.Context, articleID int64, authorIDs []int64,
	userID *int64, at time.Time) (Revision, bool, error)

An empty list means the caller had nothing to say, not that the page should lose the credit it has.

func (*DB) SetArticleIndexed

func (d *DB) SetArticleIndexed(ctx context.Context, siteID, id int64, indexed bool) error

func (*DB) SetArticleLock

func (d *DB) SetArticleLock(ctx context.Context, articleID int64, locked bool) error

func (*DB) SetArticleParent

func (d *DB) SetArticleParent(ctx context.Context, articleID int64, parentID *int64,
	userID *int64, meta string, at time.Time) (Revision, error)

func (*DB) SetArticleTagIDs

func (d *DB) SetArticleTagIDs(ctx context.Context, articleID int64, tagIDs []int64) error

The revision that records this is written by the caller, so nothing is logged here.

func (*DB) SetArticleTags

func (d *DB) SetArticleTags(ctx context.Context, siteID, articleID int64, tags []string,
	allowCreate bool, userID *int64, at time.Time) (Revision, bool, error)

A name with a space in it is dropped rather than refused, so one bad entry does not cost the page the rest of its tags.

func (*DB) SetArticleTitle

func (d *DB) SetArticleTitle(ctx context.Context, articleID int64, title string) error

func (*DB) SetDefaultFolderPublic

func (d *DB) SetDefaultFolderPublic(ctx context.Context, userID int64, public bool) error

func (*DB) SetEmail

func (d *DB) SetEmail(ctx context.Context, id int64, email string) error

func (*DB) SetFavouriteFolderPublic

func (d *DB) SetFavouriteFolderPublic(ctx context.Context, userID, folderID int64, public bool) error

func (*DB) SetIPBan

func (d *DB) SetIPBan(ctx context.Context, siteID int64, network netip.Prefix, until *time.Time,
	reason string, by *int64, at time.Time) (int64, error)

func (*DB) SetImportedParent

func (d *DB) SetImportedParent(ctx context.Context, siteID, articleID, parentID int64) error

func (*DB) SetLastLogin

func (d *DB) SetLastLogin(ctx context.Context, id int64, at time.Time, lang string) error

func (*DB) SetPassword

func (d *DB) SetPassword(ctx context.Context, id int64, hash string) error

func (*DB) SetPendingEmail

func (d *DB) SetPendingEmail(ctx context.Context, id int64, email string) error

func (*DB) SetPins

func (d *DB) SetPins(ctx context.Context, userID int64, articleIDs []int64) error

Pages pinned before keep their pin time, and anything past MaxPins or not written by the user is left out.

func (*DB) SetPluginEnabled

func (d *DB) SetPluginEnabled(ctx context.Context, siteID int64, plugin string, on bool) error

func (*DB) SetSanction

func (d *DB) SetSanction(ctx context.Context, siteID, userID int64, kind string, until *time.Time,
	reason string, by *int64, at time.Time) error

func (*DB) SetSiteHosts

func (d *DB) SetSiteHosts(ctx context.Context, slug, domain, mediaDomain string) error

func (*DB) SetSiteSuperuser

func (d *DB) SetSiteSuperuser(ctx context.Context, siteID, userID int64, on bool, by int64, at time.Time) (bool, error)

func (*DB) SetSuperuser

func (d *DB) SetSuperuser(ctx context.Context, id int64, on bool) error

func (*DB) SetUserPreference

func (d *DB) SetUserPreference(ctx context.Context, userID int64, section, name, raw string) error

func (*DB) SetUsername

func (d *DB) SetUsername(ctx context.Context, id int64, username, displayName string, at time.Time) error

func (*DB) SettleEmailHolds

func (d *DB) SettleEmailHolds(ctx context.Context, now time.Time) ([]SettledEmail, error)

Rows are locked and skipped rather than waited on, so two requests settling at once never apply the same hold twice.

func (*DB) SiteByHosts

func (d *DB) SiteByHosts(ctx context.Context, hosts []string) (*Site, error)

SiteByHosts tries each host in turn and returns the first that matches. Callers pass site.LookupHosts, whose ordering carries the host:port round that has to run before the bare-host one.

func (*DB) SiteBySlug

func (d *DB) SiteBySlug(ctx context.Context, slug string) (*Site, error)

func (*DB) SiteCanCreateTags

func (d *DB) SiteCanCreateTags(ctx context.Context, siteID int64) (string, error)

SiteCanCreateTags reads the site row alone. The page asks Site.settings, which never merges the category or the built-in defaults into it.

func (*DB) SiteChangeCount

func (d *DB) SiteChangeCount(ctx context.Context, f SiteChangeFilter) (int, error)

func (*DB) SiteChanges

func (d *DB) SiteChanges(ctx context.Context, f SiteChangeFilter, offset, limit int) ([]SiteChange, error)

func (*DB) SiteDomains

func (d *DB) SiteDomains(ctx context.Context) ([]string, error)

func (*DB) SiteHostExists

func (d *DB) SiteHostExists(ctx context.Context, host string) (bool, error)

func (*DB) SiteHosts

func (d *DB) SiteHosts(ctx context.Context) ([]string, error)

func (*DB) SiteRatingMode

func (d *DB) SiteRatingMode(ctx context.Context, siteID int64) (string, error)

func (*DB) SiteSettings

func (d *DB) SiteSettings(ctx context.Context, siteID int64) (SiteSettings, error)

func (*DB) SiteSize

func (d *DB) SiteSize(ctx context.Context, siteID int64) (SiteSize, error)

func (*DB) SiteSlugs

func (d *DB) SiteSlugs(ctx context.Context) ([]string, error)

func (*DB) SiteSources

func (d *DB) SiteSources(ctx context.Context, siteID int64) (map[int64]string, error)

func (*DB) SiteStaff

func (d *DB) SiteStaff(ctx context.Context, siteID int64) ([]int64, error)

func (*DB) SiteSuperusers

func (d *DB) SiteSuperusers(ctx context.Context, siteID int64, among []int64) (map[int64]bool, error)

func (*DB) SitemapArticles

func (d *DB) SitemapArticles(ctx context.Context, siteID int64, hidden []string) ([]Article, error)

func (*DB) SitemapThreads

func (d *DB) SitemapThreads(ctx context.Context, siteID int64, sectionIDs []int64) ([]SitemapThread, error)

func (*DB) Sites

func (d *DB) Sites(ctx context.Context) ([]Site, error)

func (*DB) SoftDeleteFile

func (d *DB) SoftDeleteFile(ctx context.Context, fileID int64, at time.Time, byUserID *int64) (string, bool, error)

func (*DB) SourceAtRevision

func (d *DB) SourceAtRevision(ctx context.Context, articleID int64, revNumber int) (string, error)

A revision that only renamed or retagged the page records no version, so the source of the newest earlier revision that does is the source it had.

func (*DB) StaffSitesOf

func (d *DB) StaffSitesOf(ctx context.Context, userID int64) ([]int64, error)

func (*DB) SubscribeToArticle

func (d *DB) SubscribeToArticle(ctx context.Context, userID, articleID int64) error

func (*DB) SubscribeToThread

func (d *DB) SubscribeToThread(ctx context.Context, userID, threadID int64) error

func (*DB) SubscribedToArticle

func (d *DB) SubscribedToArticle(ctx context.Context, userID, articleID int64) (bool, error)

func (*DB) SubscribedToThread

func (d *DB) SubscribedToThread(ctx context.Context, userID, threadID int64) (bool, error)

func (*DB) SuggestAuthors

func (d *DB) SuggestAuthors(ctx context.Context, siteID int64, typed string, limit int) ([]Suggestion, error)

func (*DB) SuggestCategories

func (d *DB) SuggestCategories(ctx context.Context, siteID int64, hidden []string, typed string, limit int) ([]Suggestion, error)

func (*DB) SuggestTags

func (d *DB) SuggestTags(ctx context.Context, siteID int64, typed string, limit int) ([]Suggestion, error)

func (*DB) SuperuserCount

func (d *DB) SuperuserCount(ctx context.Context) (int, error)

func (*DB) SuperuserRecipients

func (d *DB) SuperuserRecipients(ctx context.Context) ([]Recipient, error)

func (*DB) SuspiciousUsers

func (d *DB) SuspiciousUsers(ctx context.Context) ([]SuspiciousUser, error)

func (*DB) TagCategoryBySlug

func (d *DB) TagCategoryBySlug(ctx context.Context, siteID int64, slug string) (TagCategory, error)

func (*DB) TagCloud

func (d *DB) TagCloud(ctx context.Context, siteID int64, limit *int) ([]CloudTag, error)

The limit lands after the busiest tags come first, so it decides which tags are in the cloud and not just how many.

func (*DB) TagIDsByFullName

func (d *DB) TagIDsByFullName(ctx context.Context, siteID int64, category, name string) ([]int64, error)

A name without a category matches that tag in every category, which is what makes one name able to name several tags.

func (*DB) TagIDsByName

func (d *DB) TagIDsByName(ctx context.Context, siteID int64, categorySlug, name string) ([]int64, error)

func (*DB) TagRule

func (d *DB) TagRule(ctx context.Context, categoryID int64) (string, []int64, error)

func (*DB) TagsCategories

func (d *DB) TagsCategories(ctx context.Context, siteID int64) ([]TagsCategory, error)

func (*DB) TagsOfArticles

func (d *DB) TagsOfArticles(ctx context.Context, ids []int64) (map[int64][]ArticleTag, error)

func (*DB) Theme

func (d *DB) Theme(ctx context.Context, siteID, id int64) (ThemeRow, error)

func (*DB) ThemeByID

func (d *DB) ThemeByID(ctx context.Context, id int64) (*Theme, error)

func (*DB) Themes

func (d *DB) Themes(ctx context.Context, siteID int64) ([]ThemeRow, error)

func (*DB) ThreadPostKeys

func (d *DB) ThreadPostKeys(ctx context.Context, threadID int64) ([]PostKey, error)

func (*DB) ThreadPostTimes

func (d *DB) ThreadPostTimes(ctx context.Context, threadID int64) ([]Stamped, error)

func (*DB) ThreadSubscribers

func (d *DB) ThreadSubscribers(ctx context.Context, threadID int64) ([]int64, error)

func (*DB) TokenUsed

func (d *DB) TokenUsed(ctx context.Context, token string) (bool, error)

func (*DB) ToolbarHidden

func (d *DB) ToolbarHidden(ctx context.Context, siteID int64, category string, roleIDs []int64) (bool, error)

func (*DB) ToolbarHiddenRoles

func (d *DB) ToolbarHiddenRoles(ctx context.Context, categoryID int64) ([]int64, error)

func (*DB) UnblockUser

func (d *DB) UnblockUser(ctx context.Context, blockerID, blockedID int64) (bool, error)

func (*DB) UnclaimedWikidotUsers

func (d *DB) UnclaimedWikidotUsers(ctx context.Context) ([]UserChoice, error)

func (*DB) UnknownTags

func (d *DB) UnknownTags(ctx context.Context, siteID int64, tags []string) ([]string, error)

func (*DB) UnlikePost

func (d *DB) UnlikePost(ctx context.Context, postID, userID int64) error

func (*DB) Unmute

func (d *DB) Unmute(ctx context.Context, userID int64, articleID, threadID, mutedID *int64) error

func (*DB) UnreadCounts

func (d *DB) UnreadCounts(ctx context.Context, userID int64) (Unread, error)

func (*DB) UnreadMessages

func (d *DB) UnreadMessages(ctx context.Context, userID int64) (int, error)

func (*DB) UnreadNotifications

func (d *DB) UnreadNotifications(ctx context.Context, userID int64) (int, error)

func (*DB) UnreferencedWikidotUsers

func (d *DB) UnreferencedWikidotUsers(ctx context.Context) ([]UnusedUser, error)

func (*DB) UnsubscribeFromArticle

func (d *DB) UnsubscribeFromArticle(ctx context.Context, userID, articleID int64) (bool, error)

func (*DB) UnsubscribeFromThread

func (d *DB) UnsubscribeFromThread(ctx context.Context, userID, threadID int64) (bool, error)

func (*DB) UpdateArticleTitle

func (d *DB) UpdateArticleTitle(ctx context.Context, articleID int64, title string,
	userID *int64, at time.Time) (Revision, error)

The old title is read under the same lock that replaces it, so the revision cannot name a title some other writer has already moved past.

func (*DB) UpdateForumPost

func (d *DB) UpdateForumPost(ctx context.Context, postID int64, name, source, previous string,
	authorID *int64, at time.Time) error

A body that did not change leaves no version, so the edit history only holds the times the text actually moved.

func (*DB) UpdateForumThread

func (d *DB) UpdateForumThread(ctx context.Context, threadID int64, e ForumThreadEdit) error

func (*DB) UpdateImportedArticle

func (d *DB) UpdateImportedArticle(ctx context.Context, siteID, articleID int64, u ImportUpdate) error

func (*DB) UpdateProfile

func (d *DB) UpdateProfile(ctx context.Context, id int64, firstName, lastName, bio string, avatar *string, language string) error

func (*DB) UpdateSearchIndex

func (d *DB) UpdateSearchIndex(ctx context.Context, articleID int64, source, plaintext string) error

func (*DB) UpdateState

func (d *DB) UpdateState(ctx context.Context) (UpdateState, error)

func (*DB) UseClaimCode

func (d *DB) UseClaimCode(ctx context.Context, userID int64, hash string, now time.Time, maxAttempts int) (ClaimOutcome, error)

func (*DB) UserByAnyName

func (d *DB) UserByAnyName(ctx context.Context, canonical, raw string) (*User, error)

func (*DB) UserByDisplayName

func (d *DB) UserByDisplayName(ctx context.Context, name string) (*User, error)

The oldest row wins so a later account cannot take over a name a page already points at.

func (*DB) UserByEmail

func (d *DB) UserByEmail(ctx context.Context, email string) (*User, error)

func (*DB) UserByID

func (d *DB) UserByID(ctx context.Context, id int64) (*User, error)

func (*DB) UserByName

func (d *DB) UserByName(ctx context.Context, canonical string) (*User, error)

UserByName looks up a canonical username against both the local and the Wikidot name. Callers pass wikidot.CanonicalizeUsername output.

func (*DB) UserByUsername

func (d *DB) UserByUsername(ctx context.Context, name string) (*User, error)

A page list that filters by author names the account as it is spelled here, never as it was on the site an imported account came from.

func (*DB) UserByVerifiedEmail

func (d *DB) UserByVerifiedEmail(ctx context.Context, email string) (*User, error)

func (*DB) UserByWikidotAlias

func (d *DB) UserByWikidotAlias(ctx context.Context, name string) (*User, error)

func (*DB) UserByWikidotName

func (d *DB) UserByWikidotName(ctx context.Context, name string) (*User, error)

The stored name is whatever the other site displayed, so canonicalizing first would compare a spaced name against a hyphenated one and never match.

func (*DB) UserForLogin

func (d *DB) UserForLogin(ctx context.Context, username string) (*User, string, error)

func (*DB) UserForSession

func (d *DB) UserForSession(ctx context.Context, id int64) (*User, string, error)

UserForSession returns the password hash alongside the user because the session carries a hash of it; a session opened under an older password has to stop working. The hash is kept out of User so it cannot travel by accident.

func (*DB) UserIDsByName

func (d *DB) UserIDsByName(ctx context.Context, name string, partial bool) ([]int64, error)

func (*DB) UserMentions

func (d *DB) UserMentions(ctx context.Context) ([]string, error)

Pages and posts name accounts in [[user]] blocks, which hold no reference the database can see.

func (*DB) UserPostCount

func (d *DB) UserPostCount(ctx context.Context, authorID int64, categoryIDs, commentSites []int64, from, before *time.Time) (int, error)

func (*DB) UserPosts

func (d *DB) UserPosts(ctx context.Context, authorID int64, categoryIDs, commentSites []int64,
	from, before *time.Time, offset, limit int) ([]UserPost, error)

func (*DB) UserPreference

func (d *DB) UserPreference(ctx context.Context, userID int64, section, name string) (string, error)

func (*DB) UserToClaim

func (d *DB) UserToClaim(ctx context.Context, canonical, spelled string) (*User, string, error)

The hash comes back because an unusable one is what tells a row waiting to be claimed apart from somebody's live account.

func (*DB) UserVotes

func (d *DB) UserVotes(ctx context.Context, userID int64, siteID *int64, from, before time.Time, hidden []string, limit int) ([]UserVote, error)

func (*DB) UsernameChangedAt

func (d *DB) UsernameChangedAt(ctx context.Context, id int64) (*time.Time, error)

func (*DB) UsernameTaken

func (d *DB) UsernameTaken(ctx context.Context, name string) (bool, error)

func (*DB) UsernamesLower

func (d *DB) UsernamesLower(ctx context.Context) (map[string]bool, error)

func (*DB) UsersByIDs

func (d *DB) UsersByIDs(ctx context.Context, ids []int64) ([]User, error)

func (*DB) VerifiedEmailTaken

func (d *DB) VerifiedEmailTaken(ctx context.Context, email string, except int64) (bool, error)

func (*DB) VoteByUser

func (d *DB) VoteByUser(ctx context.Context, articleID int64, userID *int64) (float64, bool, error)

func (*DB) VoteGroupRole

func (d *DB) VoteGroupRole(ctx context.Context, siteID int64, userID *int64) (*int64, error)

VoteGroupRole answers which role a vote is filed under. The two built-in roles outrank the user's own, and for an anonymous reader only everyone can.

func (*DB) VoteStats

func (d *DB) VoteStats(ctx context.Context, articleID int64) (VoteStats, error)

func (*DB) VoteStatsOfArticles

func (d *DB) VoteStatsOfArticles(ctx context.Context, ids []int64) (map[int64]VoteStats, error)

func (*DB) WantedLinkCount

func (d *DB) WantedLinkCount(ctx context.Context, f WantedFilter) (int, error)
func (d *DB) WantedLinks(ctx context.Context, f WantedFilter, offset, limit int) ([]WantedLink, error)

The link table has no order of its own, so the row id is what keeps a page of results from reshuffling between requests.

func (*DB) WikidotUserID

func (d *DB) WikidotUserID(ctx context.Context, userID int64) (int64, error)

func (*DB) WithoutMuted

func (d *DB) WithoutMuted(ctx context.Context, readers []int64, articleID, threadID, actorID *int64) ([]int64, error)

WithoutMuted drops the readers who muted the page or thread a notice is about, or the person whose doing it is. Pass nil for whatever does not apply.

func (*DB) WriteAdminNote

func (d *DB) WriteAdminNote(ctx context.Context, n AdminNote) error

func (*DB) WriteRevertEntry

func (d *DB) WriteRevertEntry(ctx context.Context, w RevertWrite) (Revision, error)

type Device

type Device struct {
	ID         int64
	Key        string
	SiteID     *int64
	SiteTitle  string
	SignedInAt *time.Time
	SeenAt     time.Time
	Address    string
	Agent      string
}

type DirectMessage

type DirectMessage struct {
	ID          int64
	SenderID    int64
	RecipientID int64
	Body        string
	CreatedAt   time.Time
	IsRead      bool
}
type ExternalLink struct {
	From     string
	Type     string
	FromSite int64
}

type Favourite

type Favourite struct {
	SiteID  int64
	Article Article
	AddedAt time.Time
}

type FavouriteFolder

type FavouriteFolder struct {
	ID     int64
	Name   string
	Public bool
	Count  int
}

type FileRecord

type FileRecord struct {
	ID        int64
	Name      string
	MimeType  string
	Size      int64
	CreatedAt time.Time
	AuthorID  *int64
}

type FileRow

type FileRow struct {
	ID        int64
	ArticleID int64
	Name      string
	MediaName string
	Deleted   bool
}

type FileWrite

type FileWrite struct {
	ArticleID int64
	Name      string
	MediaName string
	MimeType  string
	Size      int64
	AuthorID  *int64
	At        time.Time
}

type ForeignKey

type ForeignKey struct {
	Table string
	Name  string
	Def   string
}

func LiftForeignKeys

func LiftForeignKeys(ctx context.Context, tx pgx.Tx) ([]ForeignKey, error)

LiftForeignKeys takes the references off so rows can arrive in any order. Two of them point at each other, so no load order satisfies every one.

type ForumCategory

type ForumCategory struct {
	ID            int64
	SectionID     int64
	Name          string
	Description   string
	IsForComments bool
}

type ForumCategoryRow

type ForumCategoryRow struct {
	ID            int64
	Name          string
	Description   string
	Order         int
	IsForComments bool
	SectionID     int64
	SectionName   string
	Threads       int
}

type ForumCounts

type ForumCounts struct {
	Threads int
	Posts   int
}

type ForumLastPost

type ForumLastPost struct {
	ID               int64
	CreatedAt        time.Time
	ThreadID         int64
	ThreadName       string
	ThreadCategoryID *int64
	ThreadArticleID  *int64
	AuthorID         *int64
}

ForumLastPost carries ids rather than rows so the caller can reach for the article and the author through the lookups it already has.

type ForumPost

type ForumPost struct {
	ID        int64
	CreatedAt time.Time
	AuthorID  *int64
}

type ForumPostContent

type ForumPostContent struct {
	Source   string
	AuthorID *int64
}

type ForumPostVersion

type ForumPostVersion struct {
	CreatedAt time.Time
	AuthorID  *int64
}

type ForumPostWrite

type ForumPostWrite struct {
	ThreadID  int64
	Name      string
	Source    string
	AuthorID  *int64
	ReplyToID *int64
	At        time.Time
}

type ForumSearchFilter

type ForumSearchFilter struct {
	Words      []string
	AuthorID   *int64
	From, To   *time.Time
	CategoryID *int64
	Comments   bool

	// A thread of its own matches only inside these sections, even by CategoryID.
	Sections []int64
}

Comments keeps to the threads under pages and wins over CategoryID.

type ForumSearchHit

type ForumSearchHit struct {
	PostID     int64
	PostName   string
	CreatedAt  time.Time
	AuthorID   *int64
	ThreadID   int64
	ThreadName string
	Where      string
	ArticleID  *int64
	Source     string
}

type ForumSection

type ForumSection struct {
	ID          int64
	Name        string
	Description string
	IsHidden    bool
	IsIndexed   bool
	Overrides   []perms.Override
}

type ForumSectionRow

type ForumSectionRow struct {
	ID          int64
	Name        string
	Description string
	Order       int
	IsHidden    bool
	IsIndexed   bool
	Categories  int

	Overrides []CategoryOverride
}

type ForumThread

type ForumThread struct {
	ID          int64
	Name        string
	Description string
	CategoryID  *int64
	ArticleID   *int64
	AuthorID    *int64
	IsPinned    bool
	IsLocked    bool
	CreatedAt   time.Time
}

type ForumThreadEdit

type ForumThreadEdit struct {
	Name        *string
	Description *string
	Locked      *bool
	Pinned      *bool
	CategoryID  *int64
}

type ForumThreadPost

type ForumThreadPost struct {
	ID        int64
	ThreadID  int64
	Name      string
	CreatedAt time.Time
	UpdatedAt time.Time
	AuthorID  *int64
	ReplyToID *int64
}

type ForumThreadSort

type ForumThreadSort int
const (
	ForumThreadsByReply ForumThreadSort = iota
	ForumThreadsByStart
)

type ForumThreadWrite

type ForumThreadWrite struct {
	CategoryID  int64
	Name        string
	Description string
	AuthorID    *int64
	At          time.Time
}

type IPBan

type IPBan struct {
	ID      int64
	Network netip.Prefix
	Until   *time.Time
	Reason  string
	SetBy   string
	SetAt   time.Time
}

type ImportArticle

type ImportArticle struct {
	Category  string
	Name      string
	Title     string
	Locked    bool
	CreatedAt time.Time
	UpdatedAt time.Time
	AuthorID  *int64

	// Indexed is the newest source. The import has no renderer, so the raw text
	// stands in for the rendering until the page is next edited.
	Indexed string

	Revisions []ImportRevision
	Votes     []ImportVote
	TagIDs    []int64
}

type ImportPost

type ImportPost struct {
	WantID    int64
	Name      string
	AuthorID  *int64
	ReplyTo   *int64
	CreatedAt time.Time
	Versions  []ImportPostVersion
}

type ImportPostVersion

type ImportPostVersion struct {
	Source   string
	AuthorID *int64
	At       time.Time
}

type ImportRevision

type ImportRevision struct {
	Number  int
	UserID  *int64
	Comment string
	At      time.Time

	// Source is nil for a revision Wikidot recorded without keeping the text,
	// which is most of them once a page has been renamed or retagged.
	Source *string
	IsNew  bool
}

type ImportThread

type ImportThread struct {
	WantID      int64
	CategoryID  *int64
	ArticleID   *int64
	Name        string
	Description string
	AuthorID    *int64
	CreatedAt   time.Time
	UpdatedAt   time.Time
	Pinned      bool
	Locked      bool
}

type ImportUpdate

type ImportUpdate struct {
	Title       string
	Locked      bool
	UpdatedAt   time.Time
	Indexed     string
	Revisions   []ImportRevision
	ReplaceTags bool
	TagIDs      []int64
}

type ImportUser

type ImportUser struct {
	WikidotID   int64
	Username    string
	DisplayName string
}

type ImportVote

type ImportVote struct {
	UserID int64
	Rate   float64
}

type IncludeRef

type IncludeRef struct {
	ArticleID int64
	Wiki      string
	Page      string
}

type InviteRow

type InviteRow struct {
	ID                int64
	Kind              string
	Delivery          string
	Email             string
	WikidotUsername   string
	Token             string
	UIDB64            string
	CreatedAt         time.Time
	ActivatedAt       *time.Time
	ActivatedUsername string
}

type LastSeen

type LastSeen struct {
	Login   *time.Time
	Address string
}

type LikedPost

type LikedPost struct {
	SiteID     int64
	Post       ForumThreadPost
	ThreadName string
	LikedAt    time.Time
}

type ListFilter

type ListFilter struct {
	SiteID int64

	Hidden []string

	PageType      string
	Name          string
	HasName       bool
	NamePrefix    string
	HasNamePrefix bool

	NoTags       bool
	RequiredTags []int64
	PresentTags  []int64
	AbsentTags   []int64
	ExactTags    []int64

	NotID *int64

	Categories    []string
	NotCategories []string

	HasParent    bool
	ParentID     *int64
	HasNotParent bool
	NotParentID  *int64

	AuthorID *int64

	SameAuthorsAs    *int64
	NotSameAuthorsAs *int64

	LinkTo    string
	HasLinkTo bool

	CreatedAt *TimeFilter
	UpdatedAt *TimeFilter

	Rating     *NumFilter
	Votes      *NumFilter
	Popularity *NumFilter

	RatingMode string

	Sort Sort
}

func (ListFilter) SelectSQL

func (f ListFilter) SelectSQL(offset int, limit *int) (string, []any)

Exposed so the schema-drift test can send a built statement to Postgres the way it sends the ones written out by hand.

type LogEntry

type LogEntry struct {
	RevNumber int
	Type      string
	Meta      []byte
	Comment   string
	CreatedAt time.Time
	UserID    *int64
}

type Member

type Member struct {
	User
	JoinedAt time.Time
}

type MemberSanction

type MemberSanction struct {
	Kind   string
	Until  *time.Time
	Reason string
	SetBy  *int64
	SetAt  time.Time
}

type MembershipQuiz

type MembershipQuiz struct {
	Enabled       bool
	RoleID        *int64
	Tries         int
	CooldownHours int
	Questions     string
}

type MergeMove

type MergeMove struct {
	Table   string
	Column  string
	Moved   int64
	Dropped int64
}

type Mirror

type Mirror struct {
	ID        int64
	Wiki      string
	Page      string
	RemoteID  *int64
	Source    string
	Status    string
	Problem   string
	FetchedAt time.Time
	Refs      int
}

type MissingInclude

type MissingInclude struct {
	Wiki    string
	Page    string
	Status  string
	Problem string
	Pages   []string
}

type NamedTag

type NamedTag struct {
	CategoryID int64
	Name       string
}

type NewSite

type NewSite struct {
	Slug        string
	Title       string
	Headline    string
	Domain      string
	MediaDomain string
	Language    string
	RoleNames   map[string]string
}

type Notification

type Notification struct {
	ID         int64
	Type       string
	Meta       []byte
	CreatedAt  time.Time
	IsViewed   bool
	SiteID     int64
	SiteTitle  string
	SiteDomain string
}

type NotifyMute

type NotifyMute struct {
	ID         int64
	ArticleID  *int64
	ThreadID   *int64
	UserID     *int64
	Title      string
	Path       string
	SiteTitle  string
	SiteDomain string
	CreatedAt  time.Time
}

type NumFilter

type NumFilter struct {
	Op    string
	Value float64
}

type OwnTicket

type OwnTicket struct {
	Kind       string
	ID         int64
	SiteID     int64
	Subject    string
	Status     string
	Reply      string
	CreatedAt  time.Time
	ReviewedAt *time.Time
}

type OwnTicketDetail

type OwnTicketDetail struct {
	OwnTicket
	Body       string
	SourcePage string
	Messages   string
}

type OwnTicketRef

type OwnTicketRef struct {
	Kind string
	ID   int64
}

type PageCategoryCount

type PageCategoryCount struct {
	Category string
	Pages    int
}

type PostKey

type PostKey struct {
	ID       int64
	At       time.Time
	AuthorID *int64
}

type Profile

type Profile struct {
	User
	Bio        string
	FirstName  string
	LastName   string
	DateJoined time.Time
}

type ProfileField

type ProfileField struct {
	Label string
	Value string
}
type ProfileLink struct {
	Platform string
	Value    string
}

type PublicFavourite

type PublicFavourite struct {
	FolderID int64
	Favourite
}

type RatedArticle

type RatedArticle struct {
	SiteID  int64
	Article Article
	Rate    float64
	VotedAt *time.Time
}

type RecentPost

type RecentPost struct {
	ID        int64
	Name      string
	CreatedAt time.Time
	AuthorID  *int64

	ThreadID         int64
	ThreadName       string
	ThreadCategoryID *int64
	ThreadArticleID  *int64
	ThreadAuthorID   *int64
}

type Recipient

type Recipient struct {
	Email    string
	Language string
}

type Renumbered

type Renumbered struct {
	Kind string
	From int64
	To   int64
}

type Report

type Report struct {
	ID         int64
	ReporterID *int64
	ReportedID *int64
	Reason     string
	Messages   string
	Status     string
	CreatedAt  time.Time
}

type ReportRow

type ReportRow struct {
	ID         int64
	Reporter   string
	Reported   string
	Reason     string
	Messages   string
	Status     string
	AdminNotes string
	CreatedAt  time.Time
	ReviewedAt *time.Time
	ReviewedBy string
	ReporterID *int64
	Reply      string
}

type RestoredVote

type RestoredVote struct {
	UserID int64
	RoleID *int64
	Rate   float64
	Date   *time.Time
}

type RevertWrite

type RevertWrite struct {
	ArticleID int64
	UserID    *int64
	Meta      json.RawMessage
	At        time.Time
}

type Revision

type Revision struct {
	VersionID int64
	EntryID   int64
	RevNumber int
}

type RoleCategoryRow

type RoleCategoryRow struct {
	ID    int64
	Name  string
	Roles int
}

type RoleChoice

type RoleChoice struct {
	ID      int64
	Slug    string
	Name    string
	IsStaff bool
}

func (RoleChoice) Label

func (c RoleChoice) Label() string

type RoleRow

type RoleRow struct {
	ID                int64
	Slug              string
	Name              string
	ShortName         string
	CategoryID        *int64
	Index             int
	IsStaff           bool
	GroupVotes        bool
	VotesTitle        string
	InlineVisualMode  string
	ProfileVisualMode string
	Color             string
	Icon              string
	BadgeText         string
	BadgeBg           string
	BadgeTextColor    string
	BadgeShowBorder   bool

	Allow []string
	Deny  []string
	Users int
}

type SearchFilter

type SearchFilter struct {
	Words    []string
	Category string
	AuthorID *int64
	Include  [][]int64
	Exclude  []int64
	From     *time.Time
	To       *time.Time
	Hidden   []string
	SiteID   int64
}

func (SearchFilter) CountSQL

func (f SearchFilter) CountSQL() (string, []any)

func (SearchFilter) SelectSQL

func (f SearchFilter) SelectSQL(offset, limit int) (string, []any)

type SearchHit

type SearchHit struct {
	Article   Article
	Plaintext string
}

type SettledEmail

type SettledEmail struct {
	UserID   int64
	Username string
	From     string
	To       string
	SiteID   *int64
	Taken    bool
	Pending  string
}

type Site

type Site struct {
	ID          int64
	Slug        string
	Title       string
	Headline    string
	Domain      string
	MediaDomain string
	HomePage    string
	Icon        string
	ThemeID     *int64

	SystemThemeID *int64

	AuthIcon      string
	FooterLicense string
	SignupNotice  string
	PasswordHelp  string
	Welcome       string
	SignupOpen    bool

	MembershipPasswordEnabled bool
	MembershipPassword        string
	MembershipPasswordRoleID  *int64
	ApplicationRoleID         *int64

	DefaultRoleID  *int64
	VerifiedRoleID *int64

	EmailPolicy            string
	Language               string
	TimeZone               string
	LanguageFollowsVisitor bool

	SelfVotesForbidden    bool
	EditForbiddenHint     string
	DeletionNoticeEnabled bool
	DeletionNotice        string
}

type SiteChange

type SiteChange struct {
	SiteID    int64
	RevNumber int
	Type      string
	Meta      []byte
	Comment   string
	CreatedAt time.Time
	UserID    *int64

	ArticleTitle    string
	ArticleCategory string
	ArticleName     string
}

type SiteChangeFilter

type SiteChangeFilter struct {
	SiteID int64

	Hidden []string

	AllSites     bool
	HiddenBySite map[int64][]string

	Types []string

	Category    string
	HasCategory bool

	HasUser    bool
	UserIDs    []int64
	WithSystem bool

	From, Before *time.Time
}

func (SiteChangeFilter) SelectSQL

func (f SiteChangeFilter) SelectSQL(offset, limit int) (string, []any)

Exposed so the schema-drift test can send a built statement to Postgres the way it sends the ones written out by hand.

type SiteRoles

type SiteRoles struct {
	SiteID int64
	Roles  []roles.Role
}

type SiteSettings

type SiteSettings struct {
	RatingMode string
	CreateTags string
}

type SiteSize

type SiteSize struct {
	Pages   int
	Posts   int
	Files   int
	Members int
}

type SitemapThread

type SitemapThread struct {
	ID        int64
	Name      string
	UpdatedAt time.Time
}

type Sort

type Sort struct {
	Column    string
	Ascending bool
}

type Stamped

type Stamped struct {
	ID int64
	At time.Time
}

type Suggestion

type Suggestion struct {
	Value string
	Label string
}

type SuspiciousUser

type SuspiciousUser struct {
	UserID   int64
	Username string
	IP       *string
}

type Tag

type Tag struct {
	Name     string
	FullName string
}

type TagCategory

type TagCategory struct {
	ID       int64
	Name     string
	Priority *int
	Tags     []Tag
}

type TagCategoryRow

type TagCategoryRow struct {
	ID          int64
	Name        string
	Slug        string
	Description string
	Priority    *int
	Tags        int
}

type TagRow

type TagRow struct {
	ID           int64
	Name         string
	CategoryID   *int64
	CategoryName string
	Articles     int
	IsIndexed    bool
}

type TagsCategory

type TagsCategory struct {
	ID          int64
	Name        string
	Description string
	Slug        string
}

type Theme

type Theme struct {
	Slug        string
	Mode        string
	ExternalURL string
	UpdatedAt   time.Time
}

type ThemeRow

type ThemeRow struct {
	ID          int64
	Name        string
	Slug        string
	Mode        string
	CSS         string
	ExternalURL string
	UpdatedAt   time.Time
}

type TicketRow

type TicketRow struct {
	ID         int64
	Kind       string
	Author     string
	Subject    string
	Body       string
	SourcePage string
	Status     string
	AdminNotes string
	CreatedAt  time.Time
	ReviewedAt *time.Time
	ReviewedBy string
	GrantedID  *int64
	AuthorID   *int64
	Reply      string
}

type TimeFilter

type TimeFilter struct {
	Op    string
	Start time.Time
	End   time.Time
}

End is the first moment after the period. Range and ExcludeRange read both ends, the rest read only the end the operator names.

type TrendPoint

type TrendPoint struct {
	At    time.Time
	Value float64
}

type UnknownTagsError

type UnknownTagsError struct {
	Names []string
}

func (*UnknownTagsError) Error

func (e *UnknownTagsError) Error() string

type Unread

type Unread struct {
	Notices  int
	Comments int
	Messages int
}

func (Unread) Total

func (u Unread) Total() int

type UnusedUser

type UnusedUser struct {
	ID              int64
	WikidotUsername string
	DisplayName     string
}

type UpdateState

type UpdateState struct {
	CheckedAt         *time.Time
	CheckError        string
	NextCheckAt       *time.Time
	LatestVersion     string
	LatestPublishedAt *time.Time
	LatestPostgres    string
	LatestNotes       string
	ScheduledVersion  string
	ScheduledAt       *time.Time
	ScheduledByHand   bool
	PostponedUntil    *time.Time
	SkippedVersion    string
	FailedVersions    []string
	PinnedVersion     string
	LastFrom          string
	LastTo            string
	LastOutcome       string
	LastError         string
	LastAt            *time.Time
	RollbackVersion   string
	RollbackKind      string
	RollbackExpiresAt *time.Time
}

type User

type User struct {
	ID              int64
	Type            string
	Username        string
	WikidotUsername string
	DisplayName     string
	Avatar          string
	IsActive        bool
	InactiveUntil   *time.Time
	IsSuperuser     bool

	IsForumActive      bool
	ForumInactiveUntil *time.Time

	CanSendDirectMessages bool
	DirectMessagesUntil   *time.Time
	EmailVerifiedAt       *time.Time

	Language string
}

func (*User) ActiveAt

func (u *User) ActiveAt(now time.Time) bool

A deadline in the future overrides the stored flag in both directions, so is_active is ignored whenever inactive_until is set.

func (*User) DisplayLabel

func (u *User) DisplayLabel() string

func (*User) ForumActiveAt

func (u *User) ForumActiveAt(now time.Time) bool

func (*User) MessagesAt

func (u *User) MessagesAt(now time.Time) bool

func (*User) URLName

func (u *User) URLName() string

type UserChoice

type UserChoice struct {
	ID   int64
	Name string
}

type UserPost

type UserPost struct {
	ID        int64
	SiteID    int64
	Name      string
	CreatedAt time.Time

	ThreadID         int64
	ThreadName       string
	ThreadCategoryID *int64

	ArticleTitle    *string
	ArticleName     *string
	ArticleCategory *string
}

type UserVote

type UserVote struct {
	SiteID   int64
	Category string
	Name     string
	Title    string
	Rate     float64
	At       time.Time
}

type VersionWrite

type VersionWrite struct {
	ArticleID int64
	Source    string
	UserID    *int64
	Kind      string
	Comment   string
	At        time.Time

	// Title rides along on the revision that created the page and nowhere else,
	// so an empty one still has to be written.
	Title string
}

type Vote

type Vote struct {
	ID     int64
	Rate   float64
	Date   *time.Time
	RoleID *int64
}

type VoteStats

type VoteStats struct {
	Sum        float64
	Count      int
	GoodUpDown int
	Average    float64
	GoodStars  int
}

type WantedFilter

type WantedFilter struct {
	From          []string
	Categories    []string
	NotCategories []string
}
type WantedLink struct {
	From  string
	To    string
	Title string
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL