user

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Jan 30, 2022 License: AGPL-3.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Allow for 400 simultaneously logged on users.
	CacheCap = 400
)

Variables

This section is empty.

Functions

This section is empty.

Types

type BriefProfileCache added in v0.1.3

type BriefProfileCache struct {
	sync.Mutex
	// contains filtered or unexported fields
}

type Cache added in v0.1.2

type Cache struct {
	sync.Mutex
	// contains filtered or unexported fields
}

Cache will reside in-memory, and will be per-node.

func NewCache added in v0.1.2

func NewCache(backing backingStore) *Cache

func (*Cache) AddBlock added in v0.1.2

func (c *Cache) AddBlock(ctx context.Context, targetUser, blocker uint) error

func (*Cache) AddFollower added in v0.1.2

func (c *Cache) AddFollower(ctx context.Context, targetUser, follower uint) error

func (*Cache) CachedCount added in v0.1.3

func (c *Cache) CachedCount(ctx context.Context) int

func (*Cache) Count added in v0.1.3

func (c *Cache) Count(ctx context.Context) (int64, error)

func (*Cache) Get added in v0.1.2

func (c *Cache) Get(ctx context.Context, username string) (*entity.User, error)

func (*Cache) GetBlockedBy added in v0.1.2

func (c *Cache) GetBlockedBy(ctx context.Context, uid uint) ([]*entity.User, error)

func (*Cache) GetBlocks added in v0.1.2

func (c *Cache) GetBlocks(ctx context.Context, uid uint) ([]*entity.User, error)

func (*Cache) GetBot added in v0.1.3

func (c *Cache) GetBot(ctx context.Context, botType macondopb.BotRequest_BotCode) (*entity.User, error)

func (*Cache) GetBriefProfiles added in v0.1.3

func (c *Cache) GetBriefProfiles(ctx context.Context, uuids []string) (map[string]*pb.BriefProfile, error)

func (*Cache) GetByAPIKey added in v0.1.3

func (c *Cache) GetByAPIKey(ctx context.Context, apikey string) (*entity.User, error)

func (*Cache) GetByEmail added in v0.1.2

func (c *Cache) GetByEmail(ctx context.Context, email string) (*entity.User, error)

func (*Cache) GetByUUID added in v0.1.2

func (c *Cache) GetByUUID(ctx context.Context, uuid string) (*entity.User, error)

func (*Cache) GetFollowedBy added in v0.1.3

func (c *Cache) GetFollowedBy(ctx context.Context, uid uint) ([]*entity.User, error)

func (*Cache) GetFollows added in v0.1.2

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

func (*Cache) GetFullBlocks added in v0.1.2

func (c *Cache) GetFullBlocks(ctx context.Context, uid uint) ([]*entity.User, error)

func (*Cache) GetModList added in v0.1.3

func (c *Cache) GetModList(ctx context.Context) (*pb.GetModListResponse, error)

func (*Cache) New added in v0.1.2

func (c *Cache) New(ctx context.Context, user *entity.User) error

func (*Cache) RemoveBlock added in v0.1.2

func (c *Cache) RemoveBlock(ctx context.Context, targetUser, blocker uint) error

func (*Cache) RemoveFollower added in v0.1.2

func (c *Cache) RemoveFollower(ctx context.Context, targetUser, follower uint) error

func (*Cache) ResetPersonalInfo added in v0.1.3

func (c *Cache) ResetPersonalInfo(ctx context.Context, uuid string) error

func (*Cache) ResetProfile added in v0.1.3

func (c *Cache) ResetProfile(ctx context.Context, uuid string) error

func (*Cache) ResetRatings added in v0.1.3

func (c *Cache) ResetRatings(ctx context.Context, uuid string) error

func (*Cache) ResetStats added in v0.1.3

func (c *Cache) ResetStats(ctx context.Context, uuid string) error

func (*Cache) Set added in v0.1.3

func (c *Cache) Set(ctx context.Context, u *entity.User) error

func (*Cache) SetAvatarUrl added in v0.1.3

func (c *Cache) SetAvatarUrl(ctx context.Context, uuid string, avatarUrl string) error

func (*Cache) SetNotoriety added in v0.1.3

func (c *Cache) SetNotoriety(ctx context.Context, u *entity.User, notoriety int) error

This was written to avoid the zero value trap

func (*Cache) SetPassword added in v0.1.2

func (c *Cache) SetPassword(ctx context.Context, uuid string, hashpass string) error

func (*Cache) SetPermissions added in v0.1.3

func (c *Cache) SetPermissions(ctx context.Context, req *cpb.PermissionsRequest) error

func (*Cache) SetPersonalInfo added in v0.1.3

func (c *Cache) SetPersonalInfo(ctx context.Context, uuid string, email string, firstName string, lastName string, birthDate string, countryCode string, about string) error

func (*Cache) SetRatings added in v0.1.2

func (c *Cache) SetRatings(ctx context.Context, p0uuid string, p1uuid string, variant entity.VariantKey, p0Rating entity.SingleRating, p1Rating entity.SingleRating) error

func (*Cache) SetStats added in v0.1.2

func (c *Cache) SetStats(ctx context.Context, p0uuid string, p1uuid string, variant entity.VariantKey,
	p0Stats *entity.Stats, p1Stats *entity.Stats) error

func (*Cache) Username added in v0.1.2

func (c *Cache) Username(ctx context.Context, uuid string) (string, bool, error)

func (*Cache) UsersByPrefix added in v0.1.3

func (c *Cache) UsersByPrefix(ctx context.Context, prefix string) ([]*pb.BasicUser, error)

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) AddBlock added in v0.1.2

func (s *DBStore) AddBlock(ctx context.Context, targetUser, blocker uint) error

func (*DBStore) AddFollower

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

AddFollower creates a follower -> target follow.

func (*DBStore) CachedCount added in v0.1.3

func (s *DBStore) CachedCount(ctx context.Context) int

func (*DBStore) Count added in v0.1.3

func (s *DBStore) Count(ctx context.Context) (int64, error)

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) GetBlockedBy added in v0.1.2

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

GetBlockedBy gets all the users that are blocking the passed-in user DB ID.

func (*DBStore) GetBlocks added in v0.1.2

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

GetBlocks gets all the users that the passed-in user DB ID is blocking.

func (*DBStore) GetBot added in v0.1.3

func (s *DBStore) GetBot(ctx context.Context, botType macondopb.BotRequest_BotCode) (*entity.User, error)

func (*DBStore) GetBriefProfiles added in v0.1.3

func (s *DBStore) GetBriefProfiles(ctx context.Context, uuids []string) (map[string]*pb.BriefProfile, error)

func (*DBStore) GetByAPIKey added in v0.1.3

func (s *DBStore) GetByAPIKey(ctx context.Context, apikey string) (*entity.User, error)

GetByAPIKey gets a user by api key. It does not try to fetch the profile. We only call this for API functions where we care about access levels, etc.

func (*DBStore) GetByEmail added in v0.1.1

func (s *DBStore) GetByEmail(ctx context.Context, email string) (*entity.User, error)

GetByEmail gets the user by email. It does not try to get the profile. We don't get the profile here because GetByEmail is only used for things like password resets and there is no need.

func (*DBStore) GetByUUID

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

GetByUUID gets user by UUID

func (*DBStore) GetFollowedBy added in v0.1.3

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

GetFollowedBy gets all the users that are following the passed-in user DB ID.

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) GetFullBlocks added in v0.1.2

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

GetFullBlocks gets users uid is blocking AND users blocking uid

func (*DBStore) GetModList added in v0.1.3

func (s *DBStore) GetModList(ctx context.Context) (*pb.GetModListResponse, error)

func (*DBStore) ListAllIDs added in v0.1.2

func (s *DBStore) ListAllIDs(ctx context.Context) ([]string, error)

List all user IDs.

func (*DBStore) New

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

New creates a new user in the DB.

func (*DBStore) RemoveBlock added in v0.1.2

func (s *DBStore) RemoveBlock(ctx context.Context, targetUser, blocker uint) error

func (*DBStore) RemoveFollower

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

RemoveFollower removes a follower -> target follow.

func (*DBStore) ResetPersonalInfo added in v0.1.3

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

func (*DBStore) ResetProfile added in v0.1.3

func (s *DBStore) ResetProfile(ctx context.Context, uid string) error

func (*DBStore) ResetRatings added in v0.1.3

func (s *DBStore) ResetRatings(ctx context.Context, uid string) error

func (*DBStore) ResetStats added in v0.1.3

func (s *DBStore) ResetStats(ctx context.Context, uid string) error

func (*DBStore) ResetStatsAndRatings added in v0.1.2

func (s *DBStore) ResetStatsAndRatings(ctx context.Context, uid string) error

func (*DBStore) Set added in v0.1.3

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

func (*DBStore) SetAvatarUrl added in v0.1.3

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

SetAvatarUrl sets the avatar_url (profile field) for the user.

func (*DBStore) SetNotoriety added in v0.1.3

func (s *DBStore) SetNotoriety(ctx context.Context, u *entity.User, notoriety int) error

This was written to avoid the zero value trap

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) SetPermissions added in v0.1.3

func (s *DBStore) SetPermissions(ctx context.Context, req *cpb.PermissionsRequest) error

func (*DBStore) SetPersonalInfo added in v0.1.3

func (s *DBStore) SetPersonalInfo(ctx context.Context, uuid string, email string, firstName string, lastName string, birthDate string, countryCode string, about string) error

func (*DBStore) SetRatings added in v0.1.2

func (s *DBStore) SetRatings(ctx context.Context, p0uuid string, p1uuid string, variant entity.VariantKey,
	p0Rating entity.SingleRating, p1Rating entity.SingleRating) error

SetRatings set the specific ratings for the given variant in a transaction.

func (*DBStore) SetStats

func (s *DBStore) SetStats(ctx context.Context, p0uuid string, p1uuid string, variant entity.VariantKey,
	p0Stats *entity.Stats, p1Stats *entity.Stats) error

func (*DBStore) Username

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

Username gets the username from the uuid. If not found, return a deterministic username, and return true for isAnonymous.

func (*DBStore) UsersByPrefix added in v0.1.3

func (s *DBStore) UsersByPrefix(ctx context.Context, prefix string) ([]*pb.BasicUser, error)

type User

type User struct {
	gorm.Model

	UUID     string `gorm:"type:varchar(24);index"`
	Username string `gorm:"type:varchar(32)"`
	Email    string `gorm:"type:varchar(100)"`
	// Password will be hashed.
	Password    string `gorm:"type:varchar(128)"`
	InternalBot bool   `gorm:"default:false;index"`
	IsAdmin     bool   `gorm:"default:false;index"`
	IsDirector  bool   `gorm:"default:false"`
	IsMod       bool   `gorm:"default:false;index"`
	ApiKey      string

	Notoriety int
	Actions   postgres.Jsonb
}

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