db

package
v2.2.2 Latest Latest
Warning

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

Go to latest
Published: Oct 2, 2022 License: AGPL-3.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BlacklistImage

func BlacklistImage(hash [16]byte) (err error)

Add image to blacklist so that it is not fetched again

func CheckSolution

func CheckSolution(id [64]byte, solution []byte) (solved bool, err error)

Check, if a solution to a captcha is valid

func Close

func Close() error

Close database connection

func CountPending

func CountPending(tag string) (n int, err error)

Count pending images for tag

func GenerateCaptcha

func GenerateCaptcha(f Filters) (id [64]byte, images [9][16]byte, err error)

Generate a new captcha and return its ID and image list in order

func GetSolution

func GetSolution(id [64]byte) (solution []byte, err error)

Get solution for captcha by ID

func ImageCount

func ImageCount(f Filters) (n int, err error)

Return count of images matching selectors

func InTransaction

func InTransaction(fn func(*sql.Tx) error) (err error)

Runs function inside a transaction and handles comminting and rollback on error

func InsertImage

func InsertImage(img Image) (err error)

Write image to database

func InsertPendingImage

func InsertPendingImage(img PendingImage) (err error)

Insert a new image pending processing

func IsInDatabase

func IsInDatabase(md5 [16]byte) (bool, error)

Return, if file is not already registered in the DB as valid thumbnail or in a blacklist

func IsPendingImage

func IsPendingImage(md5 [16]byte) (bool, error)

Check, if image is already on the list of pending images

func IsSolved

func IsSolved(id [64]byte) (is bool, err error)

Return, if captcha exists and is solved. The captcha is deleted on a successful check to prevent replayagain attacks.

func Open

func Open() (err error)

Open a database connection

func OpenForTests

func OpenForTests()

Open database for testing purposes

Types

type Filters

type Filters struct {
	common.FetchRequest
	Explicitness []boorufetch.Rating
}

Filters for querying an image for a captcha

type Image

type Image struct {
	Rating boorufetch.Rating
	Source common.DataSource
	MD5    [16]byte
	Tags   []string
}

type PendingImage

type PendingImage struct {
	Rating         boorufetch.Rating
	MD5            [16]byte
	TargetTag, URL string
	Tags           []string
}

Image data fetched from boorus pending processing by random selection

func PopRandomPendingImage

func PopRandomPendingImage(tag string) (img PendingImage, err error)

Deletes random pending pending image for tag and returns it, if any

Jump to

Keyboard shortcuts

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