package
4.0.0+incompatible
Repository: https://github.com/gochan-org/gochan.git
Documentation: pkg.go.dev
# Packages
No description provided by the author
# Functions
ApplyFilter inserts the given filter into the database if filter.ID == 0.
No description provided by the author
ApproveAppeal deactivates the ban that the appeal was submitted for.
BeginContextTx begins a new transaction for the gochan database, using the specified context.
BeginTx begins a new transaction for the gochan database.
ChangeThreadBoardByURI updates a thread's board ID, given the thread's post ID and the destination board's uri.
ChangeThreadBoardID updates the given thread's post ID and the destination board ID.
CheckAndInitializeDatabase checks the validity of the database and initialises it if it is empty.
CheckIPBan returns the latest active IP ban for the given IP, as well as any errors.
CheckPostReports checks to see if the given post ID has already been reported, and if a report of the post has been dismissed with prejudice (so that more reports of that post can't be made).
ClearFilterHits deletes the recorded match events for the given filter ID.
ClearReport dismisses the report with the given `id`.
Close closes the connection to the SQL database.
ConnectToDB initializes the database connection and exits if there are any errors.
CreateBoard inserts a new board into the database, using the fields from the given Board pointer.
CreateReport inserts a new report into the database and returns a Report pointer and any errors encountered.
CreateWordFilter inserts the given wordfilter data into the database and returns a pointer to a new WordFilter struct boards should be a comma separated list of board strings, or "*" for all boards.
No description provided by the author
DeleteFilter deletes the filter row from the database.
No description provided by the author
DoesBoardExistByDir returns a bool indicating whether a board with a given directory exists.
DoesBoardExistByID returns a bool indicating whether a board with a given id exists.
DoNonUploadFiltering runs the incoming post against filters before the post upload has been processed, limiting filters to ones that have no upload related conditions.
DoPostFiltering checks the filters (optionally excluding the given IDs) against the given post.
EndStaffSession deletes any session rows associated with the requests session cookie and then makes the cookie expire, essentially deleting it.
ExecContextSQL executes the given SQL statement with the given context, optionally with the given transaction (if non-nil)
Example:
ctx, cancel := context.WithTimeout(context.Background(), time.Duration(sqlCfg.DBTimeoutSeconds) * time.Second)
defer cancel()
var intVal int
var stringVal string
result, err := gcsql.ExecContextSQL(ctx, nil, "INSERT INTO tablename (intval,stringval) VALUES(?,?)",
intVal, stringVal)
*/.
ExecSQL executes the given SQL statement with the given parameters
Example:
var intVal int
var stringVal string
result, err := gcsql.ExecSQL("INSERT INTO tablename (intval,stringval) VALUES(?,?)",
intVal, stringVal)
*/.
No description provided by the author
ExecTxSQL automatically escapes the given values and caches the statement
Example:
tx, err := BeginTx()
// do error handling stuff
defer tx.Rollback()
var intVal int
var stringVal string
result, err := gcsql.ExecTxSQL(tx, "INSERT INTO tablename (intval,stringval) VALUES(?,?)",
intVal, stringVal)
*/.
GetAllBoards gets a list of all existing boards.
GetAllFilters returns an array of all post filters, and an error if one occured.
GetAllSections gets a list of all existing sections, optionally omitting hidden ones.
GetAppeals returns an array of appeals, optionally limiting them to a specific ban.
No description provided by the author
GetBoardFromPostID gets the boardURI that a given postid exists on.
GetBoardFromDir returns the board corresponding to a given dir.
GetBoardFromID returns the board corresponding to a given id.
GetIDFromDir returns the id of the board with the given dir value.
No description provided by the author
GetBoardURIs gets a list of all existing board URIs.
GetBoardWordfilters gets an array of wordfilters associated with the given board directory.
GetCompleteDatabaseVersion checks the database for any versions and errors that may exist.
GetFilterByID returns the filter with the given ID, and an error if one occured.
GetFilterHits returns an array of incidents where an attempted post matched a filter (excluding wordfilters).
GetFiltersByBoardDir returns the filters associated with the given board dir, optionally including filters not associated with a specific board.
GetFiltersByBoardID returns an array of post filters associated to the given board ID, including filters set to "All boards" if includeAllBoards is true.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
GetPostPassword returns the password checksum of the post with the given ID.
GetPostsFromIP gets the posts from the database with a matching IP address, specifying optionally requiring them to not be deleted.
GetPostThread returns a thread object from the database, given the ID of a post in the thread.
GetReports returns a Report array and any errors encountered.
No description provided by the author
GetStaffBySession gets the staff that is logged in in the given session.
No description provided by the author
GetStaffFromRequest returns the staff making the request.
No description provided by the author
No description provided by the author
GetThread returns a a thread object from the database, given its ID.
GetThreadFiles gets a list of the files owned by posts in the thread, including thumbnails for convenience.
No description provided by the author
GetThreadsWithBoardID queries the database for the threads with the given board ID from the database.
No description provided by the author
GetTopPostAndBoardDirFromPostID returns the ID of the top post and the board dir in postID's thread.
GetTopPostIDsInThreadIDs takes a variable number of threads and returns a map[threadID]topPostID.
GetTopPostThreadID gets the thread ID from the database, given the post ID of a top post.
GetUploadFilenameAndBoard returns the filename (or an empty string) and the board of the given post ID.
GetWordfilterByID returns the wordfilter with the given ID, and an error if one occured or if the filter ID is not a wordfilter (match_action is not "replace").
GetWordfilters gets a list of wordfilters from the database and returns an array of them and any errors encountered.
NewBoardSimple creates a new board in the database given the directory, title, subtitle, and description.
No description provided by the author
NewSection creates a new board section in the database and returns a *Section struct pointer.
No description provided by the author
Open opens and returns a new gochan database connection with the provided host, driver, DB name, username, password, and table prefix.
OptimizeDatabase peforms a database optimisation.
No description provided by the author
PermanentlyRemoveDeletedPosts removes all posts and files marked as deleted from the database.
No description provided by the author
No description provided by the author
PrepareSQL is used for generating a prepared SQL statement formatted according to the configured database driver.
QueryContextSQL queries the database with a prepared statement and the given parameters, using the given context
for a deadline
Example:
ctx, cancel := context.WithTimeout(context.Background(), time.Duration(sqlCfg.DBTimeoutSeconds) * time.Second)
defer cancel()
rows, err := gcsql.QueryContextSQL(ctx, nil, "SELECT name from posts where NOT is_deleted")
*/.
QueryRowContextSQL gets a row from the database with the values in values[] and fills the respective pointers in out[]
using the given context as a deadline, and the given transaction (if non-nil)
Example:
id := 32
var name string
ctx, cancel := context.WithTimeout(context.Background(), time.Duration(sqlCfg.DBTimeoutSeconds) * time.Second)
defer cancel()
err := gcsql..QueryRowContextSQL(ctx, nil, "SELECT name FROM DBPREFIXposts WHERE id = ? LIMIT 1",
[]any{id}, []any{&name})
*/.
QueryRowSQL gets a row from the db with the values in values[] and fills the respective pointers in out[]
Automatically escapes the given values and caches the query
Example:
id := 32
var intVal int
var stringVal string
err := gcsql.QueryRowSQL("SELECT intval,stringval FROM table WHERE id = ?",
[]any{id},
[]any{&intVal, &stringVal})
*/.
QueryRowTimeoutSQL is a helper function for querying a single row with the configured default timeout.
QueryRowTxSQL gets a row from the db with the values in values[] and fills the respective pointers in out[]
Automatically escapes the given values and caches the query
Example:
id := 32
var intVal int
var stringVal string
tx, err := BeginTx()
// do error handling stuff
defer tx.Rollback()
err = gcsql.QueryRowTxSQL(tx, "SELECT intval,stringval FROM table WHERE id = ?",
[]any{id}, []any{&intVal, &stringVal})
*/.
QuerySQL gets all rows from the db with the values in values[] and fills the respective pointers in out[]
Automatically escapes the given values and caches the query
Example:
rows, err := gcsql.QuerySQL("SELECT * FROM table")
if err == nil {
for rows.Next() {
var intVal int
var stringVal string
rows.Scan(&intVal, &stringVal)
// do something with intVal and stringVal
}
}
*/.
QueryTimeoutSQL creates a new context with the configured default timeout and passes it and the given transaction, query, and parameters to QueryContextSQL.
QueryTxSQL gets all rows from the db using the transaction tx with the values in values[] and fills the
respective pointers in out[].
No description provided by the author
No description provided by the author
ResetBoardSectionArrays is run when the board list needs to be changed (board/section is added, deleted, etc).
RunSQLFile cuts a given sql file into individual statements and runs it.
SetDB sets the global database connection (mainly used by gochan-migration).
SetFilterActive updates the filter with the given id, setting its active status and returning an error if one occured.
No description provided by the author
No description provided by the author
SetupSQLString applies the gochan databases keywords (DBPREFIX, DBNAME, etc) based on the database type (MySQL, Postgres, etc) to be passed to PrepareSQL.
SinceLastPost returns the number of seconds since the given IP address created a post (used for checking against the new reply cooldown).
SinceLastThread returns the number of seconds since the given IP address created a new thread/top post (used for checking against the new thread cooldown).
No description provided by the author
# Constants
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
ExactMatch represents a condition that checks if the field exactly matches string.
No description provided by the author
No description provided by the author
RegexMatch represents a condition that checks if the field matches a regular expression.
No description provided by the author
SubstrMatch represents a condition that checks if the field condtains a string, case sensitive.
SubstrMatchCaseInsensitive represents a condition that checks if the field condtains a string, not case sensitive.
No description provided by the author
No description provided by the author
# Variables
AllBoards provides a quick and simple way to access a list of all boards in non-hidden sections without having to do any SQL queries.
AllSections provides a quick and simple way to access a list of all non-hidden sections without having to do any SQL queries.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
ErrInvalidVersion is used when the db contains a database_version table but zero or more than one versions were found.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
TempPosts is a cached list of all of the posts in the temporary posts table, used for temporarily storing CAPTCHA.
# Structs
table: DBPREFIXannouncements.
table: DBPREFIXboards.
table: DBPREFIXboard_staff.
Filter represents an entry in gochan's new filter system which merges username bans, file bans, and filename bans, and will allow moderators to block posts based on the user's name, email, subject, message content, and other fields.
FilterCondition represents a condition to be checked against when a post is submitted table: DBPREFIXfilter_conditions.
FilterHit represents a match from a post filter to an attempted post table: DBPREFIXfilter_hits.
No description provided by the author
IPBan contains the information association with a specific ip ban.
table: DBPREFIXip_ban_appeals.
table: DBPREFIXip_ban_appeals_audit.
table: DBPREFIXip_ban_audit.
IPBanBase used to composition IPBan and IPBanAudit.
table: DBPREFIXsessions.
table: DBPREFIXposts.
table: DBPREFIXreports.
table: DBPREFIXreports_audit.
table: DBPREFIXsections.
table: DBPREFIXstaff.
table: DBPREFIXthreads.
Upload represents a file attached to a post.
Wordfilter is used for filters that are expected to have a single FilterCondition and a "replace" MatchAction.
# Interfaces
No description provided by the author
FilterConditionHandler handles filter conditions, providing support for checking a field.
# Type aliases
BooleanFilter is used for optionally limiting results to true, false, or both.
No description provided by the author
No description provided by the author
StringMatchMode is used when matching a string, determining how it should be checked (substring, regex, or exact match).