core

package
v0.0.0-...-6e9d5d6 Latest Latest
Warning

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

Go to latest
Published: Jan 12, 2023 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CalculateElo

func CalculateElo(elo1, elo2 float64) float64

func ConvertToJPEG

func ConvertToJPEG(w io.Writer, r io.Reader) error

Accepts formats of webp, png, jpeg and gif

func Errconv

func Errconv(err error) string

Converts an error to a string

func GenerateAPIKey

func GenerateAPIKey() string

Generates a custom API key.

func IsValidUUID

func IsValidUUID(u string) bool

Validation of uuid

func Split

func Split(input string) []string

Input r.Form.Get("Tags") Splits a single string into an array of lowercase letters without any whitespace

func ValidateKey

func ValidateKey(key string) bool

Initial validation to deter keys with wrong format

Types

type Credentials

type Credentials struct {
	Username     string   `json:"username" bson:"username"`
	Passwordhash string   `json:"passwordhash" bson:"passwordhash"`
	Uuid         string   `json:"uuid" bson:"uuid"`
	Key          string   `json:"key" bson:"key"`
	Created_At   string   `json:"created_at" bson:"created_at"`
	OwnedImages  []string `json:"owned_images" bson:"owned_images"`
}

func (*Credentials) CompareHash

func (c *Credentials) CompareHash(storedpassword string, password string) bool

Compares password from mongodb with input password

func (*Credentials) Hash

func (c *Credentials) Hash(password string) string

func (Credentials) Validate

func (c Credentials) Validate(crreds Credentials) error

Simple validation againt the credentials struct that checks if username, password and key are empty strings

type Image

type Image struct {
	Title      string        `json:"title" bson:"title"`
	Uuid       string        `json:"uuid" bson:"uuid"`
	Tags       []string      `json:"tags" bson:"tags"`
	Created_At string        `json:"created_at" bson:"created_at"`
	Filepath   string        `json:"filepath" bson:"filepath"`
	Filesize   int64         `json:"filesize" bson:"filesize"`
	Width      int           `json:"width" bson:"width"`
	Height     int           `json:"height" bson:"height"`
	BlurHash   string        `json:"blurhash" bson:"blurhash"`
	Hash       images4.IconT `json:"-" bson:"hash"`
	Elo        float64       `json:"elo" bson:"elo"`
	Owner      string        `json:"owner" bson:"owner"`
}

func (Image) BlurHashing

func (i Image) BlurHashing(img image.Image) string

returns the blurhash of an image

func (Image) FileSize

func (i Image) FileSize(buf bytes.Buffer) int64

func (Image) FindHeight

func (i Image) FindHeight(img image.Image) int

func (Image) FindWidth

func (i Image) FindWidth(img image.Image) int

func (Image) HashSet

func (i Image) HashSet(img image.Image) images4.IconT

Returns a hashed icon hash of an image

func (*Image) NewUUID

func (i *Image) NewUUID() string

Returns a newly generated uuid string

func (Image) ScaleDown

func (i Image) ScaleDown(img image.Image) image.Image

function that scales down an image.image to 32x32px

func (*Image) SetTime

func (i *Image) SetTime() string

Returns time.now as a string in the format RFC1123

func (Image) Validate

func (i Image) Validate(image Image) error

Simple validation againt the image struct that checks if name and tags are empty

Jump to

Keyboard shortcuts

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