utils

package
v0.0.0-...-5c5c951 Latest Latest
Warning

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

Go to latest
Published: Mar 11, 2023 License: AGPL-3.0 Imports: 27 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Origins []string
View Source
var RememberMeTimeout time.Duration
View Source
var SessionCount int
View Source
var SessionTimeout time.Duration

Functions

func BindAndValidate

func BindAndValidate(req interface{}, c echo.Context) (err error, ok bool)

func CleanUpExpiredTokens

func CleanUpExpiredTokens() error

TODO: Use this function in timed tasks

func Contain

func Contain(obj interface{}, target interface{}) bool

func CreateBucket

func CreateBucket(name string) error

func CreateEmptyGrades

func CreateEmptyGrades(problemSet *models.ProblemSet) error

func FindProblem

func FindProblem(id string, user *models.User) (*models.Problem, error)

This function checks if the user has permission to get problems which are not public. nil user pointer is regarded as admin(skip the permission judgement).

func FindSubmission

func FindSubmission(id uint, includeProblemSet bool) (*models.Submission, error)

func FindTestCase

func FindTestCase(problemId string, testCaseIdStr string, user *models.User) (*models.TestCase, *models.Problem, error)

This function checks if the user has permission to get problems which are not public. nil user pointer is regarded as admin(skip the permission judgement).

func FindUser

func FindUser(id string) (*models.User, error)

func GenerateInviteCode

func GenerateInviteCode() (code string)

func GetPresignedURL

func GetPresignedURL(bucket string, path string, fileName string) (string, error)

func GetTestMessages

func GetTestMessages() []*mail.Message

func GetToken

func GetToken(tokenString string) (token models.Token, err error)

func HashPassword

func HashPassword(password string) (hashed string)

func InitOrigin

func InitOrigin()

func IsTokenExpired

func IsTokenExpired(token models.Token) bool

func MustGetObject

func MustGetObject(c echo.Context, bucket string, path string) *minio.Object

func MustPutObject

func MustPutObject(object *multipart.FileHeader, ctx context.Context, bucket string, path string)

func Paginator

func Paginator(query *gorm.DB, limit, offset int, requestURL *url.URL, output interface{}) (total int, prevUrl, nextUrl *string, err error)

func PanicIfDBError

func PanicIfDBError(db *gorm.DB, message string)

func RandStr

func RandStr(n int) string

RandStr generates a string with given length. Only contains a-z and A-Z.

func RefreshGrades

func RefreshGrades(problemSet *models.ProblemSet) error

func SendMail

func SendMail(address string, subject string, message string) error

func SetTest

func SetTest()

func Sorter

func Sorter(query *gorm.DB, orderBy string, columns ...string) (*gorm.DB, error)

func UpdateGrade

func UpdateGrade(submission *models.Submission) error

func VerifyPassword

func VerifyPassword(password, hashed string) bool

Types

type DialSender

type DialSender interface {
	DialAndSend(m ...*mail.Message) error
}

type HttpError

type HttpError struct {
	Code    int
	Message string
	Err     error
}

func (HttpError) Error

func (e HttpError) Error() string

func (HttpError) Response

func (e HttpError) Response(c echo.Context) error

Jump to

Keyboard shortcuts

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