utils

package
v1.7.12 Latest Latest
Warning

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

Go to latest
Published: Mar 8, 2024 License: MIT Imports: 31 Imported by: 1

Documentation

Overview

Package utils provides utilities for handlers

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateAvatar

func GenerateAvatar(uid uint) (err error)

GenerateAvatar this will create a random avatar

func Link(id uint, referer string) (host string, err error)

Link will create the redirect to the correct imageboard after post

func LoginCounter

func LoginCounter(userid uint, ip string) (err error)

LoginCounter will increment a counter in redis to limit login attempts

Types

type Akismet added in v1.2.0

type Akismet struct {
	IP      string
	Name    string
	Ua      string
	Referer string
	Comment string
}

Akismet holds information for an akismet query

func (*Akismet) Check added in v1.2.0

func (c *Akismet) Check() (err error)

Check comment for spam with akismet

type FileUploader

type FileUploader interface {
	// struct integrity
	IsValid() bool
	IsValidPost() bool

	// image processing
	SaveImage() (err error)

	// avatar functions
	SaveAvatar() (err error)
	// contains filtered or unexported methods
}

FileUploader defines the file processing functions

type ImageType

type ImageType struct {
	File        multipart.File
	Header      *multipart.FileHeader
	Ib          uint
	Filename    string
	Thumbnail   string
	Filepath    string
	Thumbpath   string
	Ext         string
	MD5         string
	SHA         string
	OrigWidth   int
	OrigHeight  int
	ThumbWidth  int
	ThumbHeight int
	// contains filtered or unexported fields
}

ImageType defines an image and its metadata for processing

func (*ImageType) IsValid

func (i *ImageType) IsValid() bool

IsValid will check struct integrity

func (*ImageType) IsValidPost

func (i *ImageType) IsValidPost() bool

IsValidPost will check final struct integrity

func (*ImageType) SaveAvatar

func (i *ImageType) SaveAvatar() (err error)

SaveAvatar will save a user provided avatar

func (*ImageType) SaveImage

func (i *ImageType) SaveImage() (err error)

SaveImage runs the entire file processing pipeline

Jump to

Keyboard shortcuts

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