...

Source file src/codeberg.org/tslocum/sriracha/database.go

Documentation: codeberg.org/tslocum/sriracha

     1  // Package sriracha is a plugin interface for the Sriracha imageboard and forum server.
     2  package sriracha
     3  
     4  import . "codeberg.org/tslocum/sriracha/model"
     5  
     6  // DB is an interface to the database used by plugins. This allows plugins to
     7  // avoid importing pgx and its dependencies redundantly. See database package
     8  // for method documentation.
     9  type DB interface {
    10  	// Config.
    11  	HaveConfig(key string) bool
    12  	GetString(key string) string
    13  	SaveString(key string, value string)
    14  	GetMultiString(key string) []string
    15  	SaveMultiString(key string, value []string)
    16  	GetBool(key string) bool
    17  	SaveBool(key string, value bool)
    18  	GetInt(key string) int
    19  	SaveInt(key string, value int)
    20  	GetMultiInt(key string) []int
    21  	SaveMultiInt(key string, values []int)
    22  	GetInt64(key string) int64
    23  	SaveInt64(key string, value int64)
    24  	GetFloat(key string) float64
    25  	SaveFloat(key string, value float64)
    26  
    27  	// Account.
    28  	AddAccount(a *Account, password string)
    29  	AccountByID(id int) *Account
    30  	AccountByUsername(username string) *Account
    31  	AccountBySessionKey(sessionKey string) *Account
    32  	AllAccounts() []*Account
    33  	UpdateAccountUsername(a *Account)
    34  	UpdateAccountRole(a *Account)
    35  	UpdateAccountPassword(id int, password string)
    36  	UpdateAccountLastActive(id int)
    37  	UpdateAccountStyle(id int, style string)
    38  	UpdateAccountLocale(id int, locale string)
    39  	LoginAccount(username string, password string) *Account
    40  
    41  	// Ban.
    42  	AddBan(b *Ban)
    43  	BanByID(id int) *Ban
    44  	BanByIP(ip string) *Ban
    45  	AllBans(rangeOnly bool) []*Ban
    46  	UpdateBan(b *Ban)
    47  	DeleteExpiredBans() int
    48  	DeleteBan(id int)
    49  
    50  	// File ban.
    51  	AddFileBan(fileHash string)
    52  	FileBanned(fileHash string) bool
    53  	LiftFileBan(fileHash string)
    54  
    55  	// Board.
    56  	AddBoard(b *Board)
    57  	BoardByID(id int) *Board
    58  	BoardByDir(dir string) *Board
    59  	UniqueUserPosts(b *Board) int
    60  	AllBoards() []*Board
    61  	DeleteBoard(id int)
    62  	UpdateBoard(b *Board)
    63  
    64  	// CAPTCHA.
    65  	AddCAPTCHA(c *CAPTCHA)
    66  	GetCAPTCHA(ip string) *CAPTCHA
    67  	UpdateCAPTCHA(c *CAPTCHA)
    68  	ExpiredCAPTCHAs() []*CAPTCHA
    69  	DeleteCAPTCHA(ip string)
    70  	NewCAPTCHAImage() string
    71  
    72  	// Keyword.
    73  	AddKeyword(k *Keyword)
    74  	KeywordByID(id int) *Keyword
    75  	KeywordByText(text string) *Keyword
    76  	AllKeywords() []*Keyword
    77  	UpdateKeyword(k *Keyword)
    78  	DeleteKeyword(id int)
    79  
    80  	// Log.
    81  	AddLog(l *Log)
    82  	LogCount() int
    83  	LogsByPage(page int) []*Log
    84  
    85  	// News.
    86  	AddNews(n *News)
    87  	NewsByID(id int) *News
    88  	AllNews(onlyPublished bool) []*News
    89  	UpdateNews(n *News)
    90  	DeleteNews(id int)
    91  
    92  	// Page.
    93  	AddPage(p *Page)
    94  	PageByID(id int) *Page
    95  	PageByPath(path string) *Page
    96  	AllPages() []*Page
    97  	UpdatePage(p *Page)
    98  	DeletePage(id int)
    99  
   100  	// Post.
   101  	AddPost(p *Post)
   102  	AllThreads(board *Board, moderated bool) [][2]int
   103  	TrimThreads(board *Board) []*Post
   104  	AllPostsInThread(postID int, moderated bool) []*Post
   105  	AllReplies(threadID int, limit int, moderated bool) []*Post
   106  	PendingPosts() []*Post
   107  	PostByID(postID int) *Post
   108  	PostsByIP(hash string) []*Post
   109  	PostsByFileHash(hash string, filterBoard *Board) []*Post
   110  	PostByField(b *Board, field string, value any) *Post
   111  	LastPostByIP(board *Board, ip string) *Post
   112  	ReplyCount(threadID int) int
   113  	BumpThread(threadID int, timestamp int64)
   114  	ModeratePost(postID int, moderated PostModerated)
   115  	StickyPost(postID int, sticky bool)
   116  	LockPost(postID int, lock bool)
   117  	UpdatePostBoard(postID int, boardID int)
   118  	UpdatePostNameblock(postID int, nameblock string)
   119  	UpdatePostMessage(postID int, message string)
   120  	DeletePost(postID int)
   121  
   122  	// Report.
   123  	AddReport(r *Report)
   124  	AllReports() []*Report
   125  	NumReports(p *Post) int
   126  	DeleteReports(p *Post)
   127  }
   128  

View as plain text