Documentation ¶
Index ¶
- Constants
- type BriefProfileCache
- type Cache
- func (c *Cache) AddBlock(ctx context.Context, targetUser, blocker uint) error
- func (c *Cache) AddFollower(ctx context.Context, targetUser, follower uint) error
- func (c *Cache) CachedCount(ctx context.Context) int
- func (c *Cache) Count(ctx context.Context) (int64, error)
- func (c *Cache) Get(ctx context.Context, username string) (*entity.User, error)
- func (c *Cache) GetBlockedBy(ctx context.Context, uid uint) ([]*entity.User, error)
- func (c *Cache) GetBlocks(ctx context.Context, uid uint) ([]*entity.User, error)
- func (c *Cache) GetBot(ctx context.Context, botType macondopb.BotRequest_BotCode) (*entity.User, error)
- func (c *Cache) GetBriefProfiles(ctx context.Context, uuids []string) (map[string]*pb.BriefProfile, error)
- func (c *Cache) GetByAPIKey(ctx context.Context, apikey string) (*entity.User, error)
- func (c *Cache) GetByEmail(ctx context.Context, email string) (*entity.User, error)
- func (c *Cache) GetByUUID(ctx context.Context, uuid string) (*entity.User, error)
- func (c *Cache) GetFollowedBy(ctx context.Context, uid uint) ([]*entity.User, error)
- func (c *Cache) GetFollows(ctx context.Context, uid uint) ([]*entity.User, error)
- func (c *Cache) GetFullBlocks(ctx context.Context, uid uint) ([]*entity.User, error)
- func (c *Cache) GetModList(ctx context.Context) (*pb.GetModListResponse, error)
- func (c *Cache) New(ctx context.Context, user *entity.User) error
- func (c *Cache) RemoveBlock(ctx context.Context, targetUser, blocker uint) error
- func (c *Cache) RemoveFollower(ctx context.Context, targetUser, follower uint) error
- func (c *Cache) ResetPersonalInfo(ctx context.Context, uuid string) error
- func (c *Cache) ResetProfile(ctx context.Context, uuid string) error
- func (c *Cache) ResetRatings(ctx context.Context, uuid string) error
- func (c *Cache) ResetStats(ctx context.Context, uuid string) error
- func (c *Cache) Set(ctx context.Context, u *entity.User) error
- func (c *Cache) SetAvatarUrl(ctx context.Context, uuid string, avatarUrl string) error
- func (c *Cache) SetNotoriety(ctx context.Context, u *entity.User, notoriety int) error
- func (c *Cache) SetPassword(ctx context.Context, uuid string, hashpass string) error
- func (c *Cache) SetPermissions(ctx context.Context, req *cpb.PermissionsRequest) error
- func (c *Cache) SetPersonalInfo(ctx context.Context, uuid string, email string, firstName string, ...) error
- func (c *Cache) SetRatings(ctx context.Context, p0uuid string, p1uuid string, variant entity.VariantKey, ...) error
- func (c *Cache) SetStats(ctx context.Context, p0uuid string, p1uuid string, variant entity.VariantKey, ...) error
- func (c *Cache) Username(ctx context.Context, uuid string) (string, bool, error)
- func (c *Cache) UsersByPrefix(ctx context.Context, prefix string) ([]*pb.BasicUser, error)
- type DBStore
- func (s *DBStore) AddBlock(ctx context.Context, targetUser, blocker uint) error
- func (s *DBStore) AddFollower(ctx context.Context, targetUser, follower uint) error
- func (s *DBStore) CachedCount(ctx context.Context) int
- func (s *DBStore) Count(ctx context.Context) (int64, error)
- func (s *DBStore) Disconnect()
- func (s *DBStore) Get(ctx context.Context, username string) (*entity.User, error)
- func (s *DBStore) GetBlockedBy(ctx context.Context, uid uint) ([]*entity.User, error)
- func (s *DBStore) GetBlocks(ctx context.Context, uid uint) ([]*entity.User, error)
- func (s *DBStore) GetBot(ctx context.Context, botType macondopb.BotRequest_BotCode) (*entity.User, error)
- func (s *DBStore) GetBriefProfiles(ctx context.Context, uuids []string) (map[string]*pb.BriefProfile, error)
- func (s *DBStore) GetByAPIKey(ctx context.Context, apikey string) (*entity.User, error)
- func (s *DBStore) GetByEmail(ctx context.Context, email string) (*entity.User, error)
- func (s *DBStore) GetByUUID(ctx context.Context, uuid string) (*entity.User, error)
- func (s *DBStore) GetFollowedBy(ctx context.Context, uid uint) ([]*entity.User, error)
- func (s *DBStore) GetFollows(ctx context.Context, uid uint) ([]*entity.User, error)
- func (s *DBStore) GetFullBlocks(ctx context.Context, uid uint) ([]*entity.User, error)
- func (s *DBStore) GetModList(ctx context.Context) (*pb.GetModListResponse, error)
- func (s *DBStore) ListAllIDs(ctx context.Context) ([]string, error)
- func (s *DBStore) New(ctx context.Context, u *entity.User) error
- func (s *DBStore) RemoveBlock(ctx context.Context, targetUser, blocker uint) error
- func (s *DBStore) RemoveFollower(ctx context.Context, targetUser, follower uint) error
- func (s *DBStore) ResetPersonalInfo(ctx context.Context, uuid string) error
- func (s *DBStore) ResetProfile(ctx context.Context, uid string) error
- func (s *DBStore) ResetRatings(ctx context.Context, uid string) error
- func (s *DBStore) ResetStats(ctx context.Context, uid string) error
- func (s *DBStore) ResetStatsAndRatings(ctx context.Context, uid string) error
- func (s *DBStore) Set(ctx context.Context, u *entity.User) error
- func (s *DBStore) SetAvatarUrl(ctx context.Context, uuid string, avatarUrl string) error
- func (s *DBStore) SetNotoriety(ctx context.Context, u *entity.User, notoriety int) error
- func (s *DBStore) SetPassword(ctx context.Context, uuid string, hashpass string) error
- func (s *DBStore) SetPermissions(ctx context.Context, req *cpb.PermissionsRequest) error
- func (s *DBStore) SetPersonalInfo(ctx context.Context, uuid string, email string, firstName string, ...) error
- func (s *DBStore) SetRatings(ctx context.Context, p0uuid string, p1uuid string, variant entity.VariantKey, ...) error
- func (s *DBStore) SetStats(ctx context.Context, p0uuid string, p1uuid string, variant entity.VariantKey, ...) error
- func (s *DBStore) Username(ctx context.Context, uuid string) (string, bool, error)
- func (s *DBStore) UsersByPrefix(ctx context.Context, prefix string) ([]*pb.BasicUser, error)
- type User
Constants ¶
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 Cache ¶ added in v0.1.2
Cache will reside in-memory, and will be per-node.
func (*Cache) AddFollower ¶ added in v0.1.2
func (*Cache) GetBlockedBy ¶ added in v0.1.2
func (*Cache) GetBriefProfiles ¶ added in v0.1.3
func (*Cache) GetByAPIKey ¶ added in v0.1.3
func (*Cache) GetByEmail ¶ added in v0.1.2
func (*Cache) GetFollowedBy ¶ added in v0.1.3
func (*Cache) GetFollows ¶ added in v0.1.2
func (*Cache) GetFullBlocks ¶ added in v0.1.2
func (*Cache) GetModList ¶ added in v0.1.3
func (*Cache) RemoveBlock ¶ added in v0.1.2
func (*Cache) RemoveFollower ¶ added in v0.1.2
func (*Cache) ResetPersonalInfo ¶ added in v0.1.3
func (*Cache) ResetProfile ¶ added in v0.1.3
func (*Cache) ResetRatings ¶ added in v0.1.3
func (*Cache) ResetStats ¶ added in v0.1.3
func (*Cache) SetAvatarUrl ¶ added in v0.1.3
func (*Cache) SetNotoriety ¶ added in v0.1.3
This was written to avoid the zero value trap
func (*Cache) SetPassword ¶ added in v0.1.2
func (*Cache) SetPermissions ¶ added in v0.1.3
func (*Cache) SetPersonalInfo ¶ added in v0.1.3
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
type DBStore ¶
type DBStore struct {
// contains filtered or unexported fields
}
DBStore is a postgres-backed store for users.
func (*DBStore) AddFollower ¶
AddFollower creates a follower -> target follow.
func (*DBStore) CachedCount ¶ added in v0.1.3
func (*DBStore) Disconnect ¶
func (s *DBStore) Disconnect()
func (*DBStore) GetBlockedBy ¶ added in v0.1.2
GetBlockedBy gets all the users that are blocking the passed-in user DB ID.
func (*DBStore) GetBlocks ¶ added in v0.1.2
GetBlocks gets all the users that the passed-in user DB ID is blocking.
func (*DBStore) GetBriefProfiles ¶ added in v0.1.3
func (*DBStore) GetByAPIKey ¶ added in v0.1.3
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
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) GetFollowedBy ¶ added in v0.1.3
GetFollowedBy gets all the users that are following the passed-in user DB ID.
func (*DBStore) GetFollows ¶
GetFollows gets all the users that the passed-in user DB ID is following.
func (*DBStore) GetFullBlocks ¶ added in v0.1.2
GetFullBlocks gets users uid is blocking AND users blocking uid
func (*DBStore) GetModList ¶ added in v0.1.3
func (*DBStore) ListAllIDs ¶ added in v0.1.2
List all user IDs.
func (*DBStore) RemoveBlock ¶ added in v0.1.2
func (*DBStore) RemoveFollower ¶
RemoveFollower removes a follower -> target follow.
func (*DBStore) ResetPersonalInfo ¶ added in v0.1.3
func (*DBStore) ResetProfile ¶ added in v0.1.3
func (*DBStore) ResetRatings ¶ added in v0.1.3
func (*DBStore) ResetStats ¶ added in v0.1.3
func (*DBStore) ResetStatsAndRatings ¶ added in v0.1.2
func (*DBStore) SetAvatarUrl ¶ added in v0.1.3
SetAvatarUrl sets the avatar_url (profile field) for the user.
func (*DBStore) SetNotoriety ¶ added in v0.1.3
This was written to avoid the zero value trap
func (*DBStore) SetPassword ¶
SetPassword sets the password for the user. The password is already hashed.
func (*DBStore) SetPermissions ¶ added in v0.1.3
func (*DBStore) SetPersonalInfo ¶ added in v0.1.3
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.
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.