actions

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Jul 4, 2025 License: GPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Slugify added in v0.3.0

func Slugify(str string) string

Types

type Actions

type Actions struct {
	// contains filtered or unexported fields
}

func New

func New(repo Repository, mailer Mailer, jwt JwtManager[TokenPayload], sitemap Sitemap) *Actions

func (*Actions) ApproveLyricsRequest added in v0.2.0

func (a *Actions) ApproveLyricsRequest(adminToken string, id uint) error

func (*Actions) AuthenticateAdmin added in v0.2.0

func (a *Actions) AuthenticateAdmin(params AuthenticateAdminParams) (AuthenticateAdminPayload, error)

func (*Actions) ConfirmAuth added in v0.2.0

func (a *Actions) ConfirmAuth(token string) error

func (*Actions) CreateLyrics

func (a *Actions) CreateLyrics(l models.Lyrics) (models.Lyrics, error)

func (*Actions) CreateLyricsRequest added in v0.2.0

func (a *Actions) CreateLyricsRequest(token string, l models.Lyrics) error

func (*Actions) GetLyricsByPublicId added in v0.3.0

func (a *Actions) GetLyricsByPublicId(id string) (models.Lyrics, error)

func (*Actions) GetLyricsBySongTitle

func (a *Actions) GetLyricsBySongTitle(title string) ([]models.Lyrics, error)

func (*Actions) GetLyricsBySongTitleAndAlbumTitle

func (a *Actions) GetLyricsBySongTitleAndAlbumTitle(title, albumTitle string) ([]models.Lyrics, error)

func (*Actions) GetLyricsBySongTitleAndArtistName

func (a *Actions) GetLyricsBySongTitleAndArtistName(title, artistName string) ([]models.Lyrics, error)

func (*Actions) GetLyricsBySongTitleArtistNameAndAlbumTitle

func (a *Actions) GetLyricsBySongTitleArtistNameAndAlbumTitle(title, artistName, albumTitle string) ([]models.Lyrics, error)

func (*Actions) GetLyricsRequest added in v0.2.0

func (a *Actions) GetLyricsRequest(adminToken string, id uint) (LyricsRequest, error)

func (*Actions) GetSitemap added in v0.3.0

func (a *Actions) GetSitemap() ([]SitemapUrl, error)

func (*Actions) ListLyricsRequests added in v0.2.0

func (a *Actions) ListLyricsRequests(adminToken string) ([]LyricsRequest, error)

func (*Actions) LoadLyricsPublicIds added in v0.3.0

func (a *Actions) LoadLyricsPublicIds() error

func (*Actions) RejectLyricsRequest added in v0.2.0

func (a *Actions) RejectLyricsRequest(adminToken string, id uint, reason string) error

func (*Actions) SendVerificationEmail added in v0.2.0

func (a *Actions) SendVerificationEmail(email string) error

type AuthenticateAdminParams added in v0.2.0

type AuthenticateAdminParams struct {
	Username string `json:"username"`
	Password string `json:"password"`
}

type AuthenticateAdminPayload added in v0.2.0

type AuthenticateAdminPayload struct {
	SessionToken string `json:"session_token"`
}

type JwtClaims added in v0.2.0

type JwtClaims[T any] struct {
	jwt.RegisteredClaims
	Payload T `json:"payload"`
}

JwtClaims is iondsa, it's just JWT claims blyat!

type JwtDecoder added in v0.2.0

type JwtDecoder[T any] interface {
	Decode(token string, subject Subject) (JwtClaims[T], error)
}

JwtDecoder is a wrapper to JWT decoding stuff, based on the implementation's claims, this interface is usually implemented with the other two(Signer and Validator), because reasons...

type JwtManager added in v0.2.0

type JwtManager[T any] interface {
	JwtSigner[T]
	JwtValidator
	JwtDecoder[T]
}

JwtManager is a wrapper to JWT operations, so I don't do much shit each time I work with JWT

type JwtSigner added in v0.2.0

type JwtSigner[T any] interface {
	Sign(data T, subject Subject, expTime time.Duration) (string, error)
}

JwtSigner is a wrapper to JWT signing method using the set JWT secret, claims are set(mostly unique) in each implementation of the thing

type JwtValidator added in v0.2.0

type JwtValidator interface {
	Validate(token string, subject Subject) error
}

JwtValidator is a wrapper to JWT validation stuff, also uses the claims for that current implementation

type LyricsRequest added in v0.2.0

type LyricsRequest struct {
	Id         uint              `json:"id"`
	SongTitle  string            `json:"song_title"`
	ArtistName string            `json:"artist_name"`
	AlbumTitle string            `json:"album_title"`
	Parts      []string          `json:"lyrics_plain,omitempty"`
	Synced     map[string]string `json:"lyrics_synced,omitempty"`
}

type Mailer added in v0.2.0

type Mailer interface {
	SendVerificationEmail(token, email string) error
	SendLyricsApprovedEmail(lyrics models.Lyrics, email string) error
	SendLyricsRejectedEmail(reason, email string) error
}

type Repository

type Repository interface {
	CreateLyrics(l models.Lyrics) (models.Lyrics, error)
	GetLyricsByPublicId(id string) (models.Lyrics, error)
	GetLyricsBySongTitle(Title string) ([]models.Lyrics, error)
	GetLyricsBySongTitleAndArtistName(songTitle, artistName string) ([]models.Lyrics, error)
	GetLyricsBySongAndAlbumTitle(songTitle, albumTitle string) ([]models.Lyrics, error)
	GetLyricsBySongTitleArtistNameAndAlbumTitle(songTitle, artistName, albumTitle string) ([]models.Lyrics, error)

	GetLyricses(page int) ([]models.Lyrics, error)

	CreateLyricsRequest(l models.LyricsRequest) (models.LyricsRequest, error)
	DeleteLyricsRequest(id uint) error
	GetLyricsRequestById(id uint) (models.LyricsRequest, error)
	GetLyricsRequests() ([]models.LyricsRequest, error)
	GetAdminByUsername(username string) (models.Admin, error)
}

type Sitemap added in v0.3.0

type Sitemap interface {
	GetLyricsEntries() ([]SitemapUrl, error)
	StoreLyricsesEntries(entries []SitemapUrl) error
	AddLyricsEntry(entry SitemapUrl) error
}

type SitemapUrl added in v0.3.0

type SitemapUrl struct {
	PublicId string `json:"public_id"`
	AddedAt  string `json:"added_at"`
}

type Subject added in v0.2.0

type Subject = string

Subject represents the token's subject

const (
	// JwtSessionToken used to verify that the user is authed to submit a lyrics.
	JwtSessionToken Subject = "SESSION_TOKEN"
	// JwtAdminToken used to verify that the user is an authed admin to do admin stuff.
	JwtAdminToken Subject = "ADMIN_TOKEN"
)

type TokenPayload added in v0.2.0

type TokenPayload struct {
	Email string `json:"email"`
}

Jump to

Keyboard shortcuts

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