dto

package
v0.0.0-...-eb3de9a Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2024 License: AGPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Decode

func Decode[T Decodable](body []byte) (*T, error)

Types

type Auth

type Auth struct {
	Token      string //session token
	Expiration time.Time
	UserId     uuid.UUID
	AuthLvl    enum.AuthLvl
}

Auth is used internally to verify a user, auth level, and expiration of session. The token refers to a session token, not auth token. It should never be returned to a user

func (Auth) ToSession

func (a Auth) ToSession(user User, cookie http.Cookie) SessionAuth

type Comment

type Comment struct {
	UUID      uuid.UUID `json:"id"`
	UserId    uuid.UUID `json:"userId"`
	Text      string    `json:"text"`
	CreatedAt time.Time `json:"createdAt"`
	ReplyTo   *Comment  `json:"replyToComment,omitempty"`
}

func (Comment) Validate

func (c Comment) Validate() *errs.AppError

type CookieOpts

type CookieOpts struct {
	Path     string `json:"path"`
	MaxAge   int    `json:"maxAge"`
	Secure   bool   `json:"secure"`
	HttpOnly bool
	SameSite string
	Domain   string
}

type Country

type Country struct {
	Name          string `json:"name"`
	Slug          string `json:"slug"`
	BandName      string `json:"bandName"`
	SongName      string `json:"songName"`
	Flag          string `json:"flag"`
	Participating bool   `json:"participating"`
}

type CroppedImage

type CroppedImage struct {
	File          image.Image
	FileExtension string
	ID            uuid.UUID
}

type Decodable

type Decodable interface {
	Country | User | Vote | VoteSingle
}

type NewUser

type NewUser struct {
	Name  string    `json:"name"`
	Slug  string    `json:"slug"`
	UUID  uuid.UUID `json:"id"`
	Token string    `json:"token"`
}

func (*NewUser) Slugify

func (nu *NewUser) Slugify()

type Payload

type Payload[T Responsable] struct {
	Body  T      `json:"body"`
	Error string `json:"error"`
}

func NewPayload

func NewPayload[T Responsable](payload T, error string) Payload[T]

type Responsable

type Responsable interface {
	Comment | Country | User | Vote | NewUser | []*NewUser | SessionAuth |
		[]Comment | []Country | []User | []Vote | map[uuid.UUID]User | []Result
}

type Result

type Result struct {
	CountrySlug string `json:"countrySlug"`
	Costume     int    `json:"costume"`
	Song        int    `json:"song"`
	Performance int    `json:"performance"`
	Props       int    `json:"props"`
	Total       int    `json:"total"`
}

type SessionAuth

type SessionAuth struct {
	Name         string
	SessionToken string     `json:"token"`
	CookieOpts   CookieOpts `json:"opts"`
	User         User       `json:"user"`
	Bot          uuid.UUID  `json:"botId"`
}

SessionAuth gets returned to users when they log in

type SocketMessage

type SocketMessage struct {
	Category enum.ChatMsgType `json:"category"`
	Body     json.RawMessage  `json:"body"`
}

type UpdateMessage

type UpdateMessage struct {
	UpdatedUser User    `json:"updatedUser"`
	Comment     Comment `json:"comment"`
}

type User

type User struct {
	UUID    uuid.UUID    `json:"id"`
	Name    string       `json:"name"`
	Slug    string       `json:"slug"`
	Icon    string       `json:"icon"`
	AuthLvl enum.AuthLvl `json:"authLvl"`
}

func (User) Validate

func (u User) Validate() *errs.AppError

type UserAvatar

type UserAvatar struct {
	UUID    uuid.UUID
	File    multipart.File
	Header  *multipart.FileHeader
	CropBox image.Rectangle
}

type Vote

type Vote struct {
	UserId      uuid.UUID `json:"userId"`
	CountrySlug string    `json:"countrySlug"`
	Costume     uint8     `json:"costume"`
	Song        uint8     `json:"song"`
	Performance uint8     `json:"performance"`
	Props       uint8     `json:"props"`
}

type VoteSingle

type VoteSingle struct {
	UserId      uuid.UUID `json:"userId"`
	CountrySlug string    `json:"countrySlug"`
	Cat         string    `json:"cat"`
	Score       uint8     `json:"score"`
}

func (VoteSingle) Validate

func (v VoteSingle) Validate() *errs.AppError

Jump to

Keyboard shortcuts

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