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: 25 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MaxFilesize = 1024 * 1024
)

Variables

This section is empty.

Functions

func ChatChannelReceiver added in v0.1.3

func ChatChannelReceiver(uid, name string) (string, error)

Types

type AutocompleteService added in v0.1.2

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

func NewAutocompleteService added in v0.1.2

func NewAutocompleteService(u Store) *AutocompleteService

func (*AutocompleteService) GetCompletion added in v0.1.2

type ChatStore added in v0.1.3

type ChatStore interface {
	AddChat(ctx context.Context, senderUsername, senderUID, msg, channel, channelFriendly string, regulateChat bool) (*pb.ChatMessage, error)
	OldChats(ctx context.Context, channel string, n int) ([]*pb.ChatMessage, error)
	LatestChannels(ctx context.Context, count, offset int, uid, tid string) (*upb.ActiveChatChannels, error)

	GetChat(ctx context.Context, channel string, msgID string) (*pb.ChatMessage, error)
	DeleteChat(ctx context.Context, channel string, msgID string) error
	SetEventChan(chan *entity.EventWrapper)
	EventChan() chan *entity.EventWrapper
}

ChatStore stores user and channel chats and messages

type PresenceStore

type PresenceStore interface {
	// SetPresence sets the presence. If channel is the string NULL this is
	// equivalent to saying the user logged off.
	SetPresence(ctx context.Context, uuid, username string, anon bool, channel string, connID string) ([]string, []string, error)
	ClearPresence(ctx context.Context, uuid, username string, anon bool, connID string) ([]string, []string, []string, error)
	GetPresence(ctx context.Context, uuid string) ([]string, error)
	// RenewPresence prevents the presence store from expiring the relevant keys.
	// Basically, we're telling the presence store "this user and connection are still here".
	// Otherwise, missing a few of these events will destroy the relevant presences.
	RenewPresence(ctx context.Context, uuid, username string, anon bool, connID string) ([]string, []string, error)

	CountInChannel(ctx context.Context, channel string) (int, error)
	GetInChannel(ctx context.Context, channel string) ([]*entity.User, error)
	// BatchGetPresence returns a list of the users with their presence.
	// Can use for buddy/follower lists.
	BatchGetPresence(ctx context.Context, users []*entity.User) ([]*entity.User, error)

	LastSeen(ctx context.Context, uuid string) (int64, error)

	SetEventChan(chan *entity.EventWrapper)
	EventChan() chan *entity.EventWrapper

	BatchGetChannels(ctx context.Context, uuids []string) ([][]string, error)
	UpdateFollower(ctx context.Context, followee, follower *entity.User, following bool) error
	UpdateActiveGame(ctx context.Context, activeGameEntry *pb.ActiveGameEntry) ([][][]string, error)
}

PresenceStore stores user presence. Since it is meant to be easily user-visible, we deal with unique usernames in addition to UUIDs. Presence applies to chat channels, as well as an overall site-wide presence. For example, we'd like to see who's online, as well as who's in our given channel (i.e. who's watching a certain game with us?)

type S3Uploader added in v0.1.3

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

func NewS3Uploader added in v0.1.3

func NewS3Uploader(bucket string) *S3Uploader

func (*S3Uploader) Delete added in v0.1.3

func (s *S3Uploader) Delete(ctx context.Context, url string) error

Delete wipes out the avatar at the given URL.

func (*S3Uploader) Upload added in v0.1.3

func (s *S3Uploader) Upload(ctx context.Context, prefix string, data []byte) (string, error)

Upload takes in JPG bytes

type SocializeService added in v0.1.2

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

func NewSocializeService added in v0.1.2

func NewSocializeService(u Store, c ChatStore, p PresenceStore) *SocializeService

func (*SocializeService) AddBlock added in v0.1.2

func (ss *SocializeService) AddBlock(ctx context.Context, req *pb.AddBlockRequest) (*pb.OKResponse, error)

blocks

func (*SocializeService) AddFollow added in v0.1.2

func (ss *SocializeService) AddFollow(ctx context.Context, req *pb.AddFollowRequest) (*pb.OKResponse, error)

func (*SocializeService) GetActiveChatChannels added in v0.1.3

func (ss *SocializeService) GetActiveChatChannels(ctx context.Context, req *pb.GetActiveChatChannelsRequest) (*pb.ActiveChatChannels, error)

func (*SocializeService) GetBlocks added in v0.1.2

func (*SocializeService) GetChatsForChannel added in v0.1.3

func (ss *SocializeService) GetChatsForChannel(ctx context.Context, req *pb.GetChatsRequest) (*ipc.ChatMessages, error)

func (*SocializeService) GetFollows added in v0.1.2

func (*SocializeService) GetFullBlocks added in v0.1.2

func (*SocializeService) GetModList added in v0.1.3

func (*SocializeService) RemoveBlock added in v0.1.2

func (ss *SocializeService) RemoveBlock(ctx context.Context, req *pb.RemoveBlockRequest) (*pb.OKResponse, error)

func (*SocializeService) RemoveFollow added in v0.1.2

func (ss *SocializeService) RemoveFollow(ctx context.Context, req *pb.RemoveFollowRequest) (*pb.OKResponse, error)

type Store

type Store interface {
	Get(ctx context.Context, username string) (*entity.User, error)
	GetByUUID(ctx context.Context, uuid string) (*entity.User, error)
	GetByEmail(ctx context.Context, email string) (*entity.User, error)
	GetByAPIKey(ctx context.Context, apiKey string) (*entity.User, error)
	// Username by UUID. Good for fast lookups.
	Username(ctx context.Context, uuid string) (string, bool, error)
	New(ctx context.Context, user *entity.User) error
	SetPassword(ctx context.Context, uuid string, hashpass string) error
	SetAvatarUrl(ctx context.Context, uuid string, avatarUrl string) error
	GetBriefProfiles(ctx context.Context, uuids []string) (map[string]*upb.BriefProfile, error)
	SetPersonalInfo(ctx context.Context, uuid string, email string, firstName string, lastName string, birthDate string, countryCode string, about string) error
	SetRatings(ctx context.Context, p0uuid string, p1uuid string, variant entity.VariantKey,
		p1Rating entity.SingleRating, p2Rating entity.SingleRating) error
	SetStats(ctx context.Context, p0uuid string, p1uuid string, variant entity.VariantKey,
		p0stats *entity.Stats, p1stats *entity.Stats) error
	SetNotoriety(ctx context.Context, u *entity.User, notoriety int) error
	ResetRatings(ctx context.Context, uuid string) error
	ResetStats(ctx context.Context, uuid string) error
	ResetProfile(ctx context.Context, uuid string) error
	ResetPersonalInfo(ctx context.Context, uuid string) error
	GetBot(ctx context.Context, botType macondopb.BotRequest_BotCode) (*entity.User, error)

	AddFollower(ctx context.Context, targetUser, follower uint) error
	RemoveFollower(ctx context.Context, targetUser, follower uint) error
	// GetFollows gets all the users that the passed-in DB ID is following.
	GetFollows(ctx context.Context, uid uint) ([]*entity.User, error)
	GetFollowedBy(ctx context.Context, uid uint) ([]*entity.User, error)

	AddBlock(ctx context.Context, targetUser, blocker uint) error
	RemoveBlock(ctx context.Context, targetUser, blocker uint) error
	// GetBlocks gets all the users that the passed-in DB ID is blocking
	GetBlocks(ctx context.Context, uid uint) ([]*entity.User, error)
	GetBlockedBy(ctx context.Context, uid uint) ([]*entity.User, error)
	GetFullBlocks(ctx context.Context, uid uint) ([]*entity.User, error)

	UsersByPrefix(ctx context.Context, prefix string) ([]*upb.BasicUser, error)
	CachedCount(ctx context.Context) int
	Set(ctx context.Context, u *entity.User) error
	SetPermissions(ctx context.Context, req *cpb.PermissionsRequest) error

	GetModList(ctx context.Context) (*upb.GetModListResponse, error)
}

Store is an interface that user stores should implement.

type UploadResult added in v0.1.3

type UploadResult struct {
	AvatarUrl string `json:"avatar_url,omitempty"`
}

type UploadService added in v0.1.3

type UploadService interface {
	Upload(context.Context, string, []byte) (string, error)
	Delete(context.Context, string) error
}

type XTUploadService added in v0.1.3

type XTUploadService struct {
}

XTUploadService is a test service for uploading to cross-tables. Do not use in prod!

func NewXTUploadService added in v0.1.3

func NewXTUploadService() *XTUploadService

func (*XTUploadService) Delete added in v0.1.3

func (s *XTUploadService) Delete(ctx context.Context, url string) error

func (*XTUploadService) Upload added in v0.1.3

func (s *XTUploadService) Upload(ctx context.Context, prefix string, data []byte) (string, error)

Upload takes in JPG bytes

Jump to

Keyboard shortcuts

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