elemental

package
v0.0.0-...-531763a Latest Latest
Warning

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

Go to latest
Published: Oct 6, 2023 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateRandomBytes

func GenerateRandomBytes(n int) ([]byte, error)

GenerateRandomBytes returns securely generated random bytes. It will return an error if the system's secure random number generator fails to function correctly, in which case the caller should not continue.

func GenerateRandomString

func GenerateRandomString(n int) (string, error)

GenerateRandomString returns a securely generated random string. It will return an error if the system's secure random number generator fails to function correctly, in which case the caller should not continue.

func GenerateRandomStringURLSafe

func GenerateRandomStringURLSafe(n int) (string, error)

GenerateRandomStringURLSafe returns a URL-safe, base64 encoded securely generated random string. It will return an error if the system's secure random number generator fails to function correctly, in which case the caller should not continue.

Types

type AuthResponse

type AuthResponse struct {
	Success bool
	Data    string
}

AuthResponse is the response to CreateUser, LoginUser, and NewAnonymous

type Elemental

type Elemental struct {
	*pb.UnimplementedElementalServer
	// contains filtered or unexported fields
}

Elemental is the default server at https://elem7.tk

func InitElemental

func InitElemental(app *fiber.App, db *db.DB, grpc *grpc.Server) (*Elemental, error)

InitElemental initializes all of Elemental's handlers on the app.

func (*Elemental) AddFound

func (e *Elemental) AddFound(_ context.Context, req *pb.SuggestionRequest) (*emptypb.Empty, error)

func (*Elemental) CreateSugg

func (e *Elemental) CreateSugg(_ context.Context, req *pb.CreateRequest) (*emptypb.Empty, error)

func (*Elemental) CreateSuggestion

func (e *Elemental) CreateSuggestion(mark string, pioneer string, elem1 string, elem2 string, id string) (bool, string)

CreateSuggestion creates a suggestion

func (*Elemental) CreateUser

func (e *Elemental) CreateUser(name string, password string) AuthResponse

CreateUser creates a user

func (*Elemental) DownSuggestion

func (e *Elemental) DownSuggestion(_ context.Context, req *pb.SuggestionRequest) (*pb.VoteResponse, error)

func (*Elemental) DownvoteSuggestion

func (e *Elemental) DownvoteSuggestion(id, uid string) (bool, string)

DownvoteSuggestion downvotes a suggestion

func (*Elemental) GetAll

func (*Elemental) GetCombination

func (e *Elemental) GetCombination(_ context.Context, inp *pb.Combination) (*pb.CombinationResult, error)

func (*Elemental) GetCombo

func (e *Elemental) GetCombo(elem1, elem2 string) (string, bool, error)

GetCombo gets a combination

func (*Elemental) GetElem

func (e *Elemental) GetElem(_ context.Context, inp *wrapperspb.StringValue) (*pb.Element, error)

func (*Elemental) GetElement

func (e *Elemental) GetElement(elemName string) (*pb.Element, error)

GetElement gets an element from the database

func (*Elemental) GetFound

func (e *Elemental) GetFound(uid string) ([]string, error)

GetFound gets a user's found elements, based on their UID

func (*Elemental) GetInv

func (*Elemental) GetRec

func (e *Elemental) GetRec(_ context.Context, _ *emptypb.Empty) (*pb.Recents, error)

func (*Elemental) GetRecents

func (e *Elemental) GetRecents() ([]*pb.RecentCombination, error)

func (*Elemental) GetSuggestion

func (e *Elemental) GetSuggestion(_ context.Context, id *wrapperspb.StringValue) (*pb.Suggestion, error)

func (*Elemental) GetSuggestionCombos

func (e *Elemental) GetSuggestionCombos(_ context.Context, req *pb.Combination) (*pb.SuggestionCombinationResponse, error)

func (*Elemental) GetSuggestions

func (e *Elemental) GetSuggestions(elem1 string, elem2 string) ([]string, error)

GetSuggestions gets all of the suggestions for a given combo

func (*Elemental) LoginUser

func (e *Elemental) LoginUser(name string, password string) AuthResponse

func (*Elemental) NewAnonymousUser

func (e *Elemental) NewAnonymousUser() AuthResponse

func (*Elemental) NewFound

func (e *Elemental) NewFound(elem string, uid string) error

NewFound adds an element to a user's savefile

func (*Elemental) NewRecent

func (e *Elemental) NewRecent(recent *pb.RecentCombination) error

func (*Elemental) NewSugg

func (*Elemental) NewSuggestion

func (e *Elemental) NewSuggestion(elem1, elem2 string, suggestion *pb.Suggestion) (bool, error)

NewSuggestion makes a new suggestion

func (*Elemental) RandomLonely

func (*Elemental) RandomLonelySuggestion

func (e *Elemental) RandomLonelySuggestion(uid string) ([]string, error)

RandomLonelySuggestion gets a random lonely suggestion

func (*Elemental) RefreshElement

func (e *Elemental) RefreshElement(elemName string) (*pb.Element, error)

RefreshElement gets an element from the database and refreshes the local cache with that element

func (*Elemental) UpAndComing

Pretty much the same, just different first line

func (*Elemental) UpAndComingSuggestion

func (e *Elemental) UpAndComingSuggestion(uid string) ([]string, error)

UpAndComingSuggestion suggestion gets a suggestion that needs one vote

func (*Elemental) UpSuggestion

func (e *Elemental) UpSuggestion(_ context.Context, req *pb.SuggestionRequest) (*pb.VoteResponse, error)

func (*Elemental) UpvoteSuggestion

func (e *Elemental) UpvoteSuggestion(id, uid string) (bool, bool, string)

UpvoteSuggestion upvotes a suggestion

func (*Elemental) WaitForNextRecent

func (e *Elemental) WaitForNextRecent(_ *emptypb.Empty, stream pb.Elemental_WaitForNextRecentServer) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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