user

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 15, 2020 License: AGPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DBStore

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

DBStore is a postgres-backed store for users.

func NewDBStore

func NewDBStore(dbURL string) (*DBStore, error)

NewDBStore creates a new DB store

func (*DBStore) AddFollower

func (s *DBStore) AddFollower(ctx context.Context, targetUser, follower uint) error

AddFollower creates a follower -> target follow.

func (*DBStore) Disconnect

func (s *DBStore) Disconnect()

func (*DBStore) Get

func (s *DBStore) Get(ctx context.Context, username string) (*entity.User, error)

Get gets a user by username.

func (*DBStore) GetByUUID

func (s *DBStore) GetByUUID(ctx context.Context, uuid string) (*entity.User, error)

GetByUUID gets user by UUID

func (*DBStore) GetFollows

func (s *DBStore) GetFollows(ctx context.Context, uid uint) ([]*entity.User, error)

GetFollows gets all the users that the passed-in user DB ID is following.

func (*DBStore) New

func (s *DBStore) New(ctx context.Context, u *entity.User) error

New creates a new user in the DB.

func (*DBStore) RemoveFollower

func (s *DBStore) RemoveFollower(ctx context.Context, targetUser, follower uint) error

RemoveFollower removes a follower -> target follow.

func (*DBStore) SetPassword

func (s *DBStore) SetPassword(ctx context.Context, uuid string, hashpass string) error

SetPassword sets the password for the user. The password is already hashed.

func (*DBStore) SetRating

func (s *DBStore) SetRating(ctx context.Context, uuid string, variant entity.VariantKey,
	rating entity.SingleRating) error

SetRating sets the specific rating for the given variant.

func (*DBStore) SetStats

func (s *DBStore) SetStats(ctx context.Context, uuid string, variant entity.VariantKey,
	stats *entity.Stats) error

func (*DBStore) Username

func (s *DBStore) Username(ctx context.Context, uuid string) (string, error)

Username gets the username from the uuid. If not found, return a deterministic username.

type RedisPresenceStore

type RedisPresenceStore struct {
}

RedisPresenceStore implements a Redis store for user presence.

func (*RedisPresenceStore) SetPresence

func (s *RedisPresenceStore) SetPresence(ctx context.Context, uuid, channel string) error

SetPresence sets the user's channel. If blank, this means the user is offline.

type User

type User struct {
	gorm.Model

	UUID     string `gorm:"type:varchar(24);index"`
	Username string `gorm:"type:varchar(32);unique_index"`
	Email    string `gorm:"type:varchar(100);unique_index"`
	// Password will be hashed.
	Password string `gorm:"type:varchar(128)"`
}

User should be a minimal object. All information such as user profile, awards, ratings, records, etc should be in a profile object that joins 1-1 with this User object. User is exported as a Game has Foreign Keys to it.

Jump to

Keyboard shortcuts

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