Documentation ¶
Index ¶
- Variables
- func Accept(userId, followerUserId int64) error
- func AcceptAll(userId int64) error
- func CanView(userId int64, sUser *session.Session) error
- func Decline(userId, followerUserId int64) error
- func Follow(userId int64, followUserId int64) error
- func FollowExt(userId int64, followUserId int64, accepted bool) error
- func Followers(userId int64) (followers int64, err error)
- func GetEmailByID(userID int64) (email string, err error)
- func GetIDByEmail(email string) (userID int64, err error)
- func GetIDByUserName(username string) (userID int64, err error)
- func GetUserNameByID(userID int64) (userName string, err error)
- func IsVerified(userID int64) (bool, error)
- func ListFollowers(userId int64) ([]int64, error)
- func ListFollowing(userId int64) ([]int64, error)
- func ListRequests(userId int64) (map[int64]int64, error)
- func Unfollow(userId, unfollowId int64) error
- func UpdateBio(userId int64, bio string) error
- func UpdateName(userId int64, name string) error
- func UpdateType(userID int64, t Types) error
- func ValidBio(bio string) error
- func ValidEmail(email string) error
- func ValidName(name string) error
- func ValidPassword(pass string, userInputs ...string) error
- type FollowStruct
- type List
- type ListUsers
- type Types
- func (z *Types) DecodeMsg(dc *msgp.Reader) (err error)
- func (z Types) EncodeMsg(en *msgp.Writer) (err error)
- func (z Types) MarshalMsg(b []byte) (o []byte, err error)
- func (z Types) Msgsize() (s int)
- func (t Types) Private() bool
- func (t Types) Public() bool
- func (z *Types) UnmarshalMsg(bts []byte) (o []byte, err error)
- func (t Types) Unverified() bool
- type User
- func (z *User) DecodeMsg(dc *msgp.Reader) (err error)
- func (z *User) EncodeMsg(en *msgp.Writer) (err error)
- func (u *User) Insert() error
- func (u *User) IsEmailUnique() error
- func (z *User) MarshalMsg(b []byte) (o []byte, err error)
- func (z *User) Msgsize() (s int)
- func (u *User) SetDefaultPerms()
- func (z *User) UnmarshalMsg(bts []byte) (o []byte, err error)
- func (u *User) ValidBio() error
- func (u *User) ValidEmail() error
- func (u *User) ValidName() error
- func (u *User) ValidPassword(pass string) error
- func (u *User) ValidUserName() error
- func (u *User) ValidatePublic() (v ValidationErrors)
- type ValidationErrStrings
- type ValidationErrors
Constants ¶
This section is empty.
Variables ¶
var ( // ErrUserNameLength 5 to 64 characters ErrUserNameLength = errtools.InvalidLen(5, 64) // ErrUserNameTaken characters ErrUserNameTaken = errors.New(taken) )
var ( // ErrEmailInvalid Invalid Email ErrEmailInvalid = errors.New("invalid-email") // ErrEmailTaken characters ErrEmailTaken = errors.New(taken) )
var ( ErrPasswordLength = errtools.InvalidLen(8, 1024) ErrPasswordStrength = errors.New("weak-password") )
ErrPasswordLength 8 to 1024
var ( // ErrBioLength 0 to 255 characters ErrBioLength = errtools.InvalidLen(0, 255) )
var ( // ErrNameLength 1 to 128 characters ErrNameLength = errtools.InvalidLen(1, 128) )
var ErrViewMeNot = errors.New("user/view: Error can't view user")
Functions ¶
func AcceptAll ¶
AcceptAll userId Accept all follow request Called when accounts goes from private to public
func GetEmailByID ¶
GetEmailByID get email by user id
func GetIDByEmail ¶
GetIDByEmail get user id by email
func GetIDByUserName ¶
GetIDByUserName get user id by username
func GetUserNameByID ¶
GetUserNameByID get userName by user id
func ListFollowers ¶
ListFollows return a slice of userId(s) that follow userId
func ListFollowing ¶
ListFollowing return a slice of userId(s) that userId follows
func ListRequests ¶
ListRequests return a ordered map of userId(s) that request to follow userId TODO limit
func UpdateName ¶
func ValidPassword ¶
ValidPassword check password
Types ¶
type FollowStruct ¶
type FollowStruct struct { Following bool `msg:"-" json:"following"` Requested bool `msg:"-" json:"requested"` }
func Following ¶
func Following(userId, followUserId int64) (follow FollowStruct, err error)
Following is userId following followUserId
func (*FollowStruct) DecodeMsg ¶
func (z *FollowStruct) DecodeMsg(dc *msgp.Reader) (err error)
DecodeMsg implements msgp.Decodable
func (FollowStruct) EncodeMsg ¶
func (z FollowStruct) EncodeMsg(en *msgp.Writer) (err error)
EncodeMsg implements msgp.Encodable
func (FollowStruct) MarshalMsg ¶
func (z FollowStruct) MarshalMsg(b []byte) (o []byte, err error)
MarshalMsg implements msgp.Marshaler
func (FollowStruct) Msgsize ¶
func (z FollowStruct) Msgsize() (s int)
Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message
func (*FollowStruct) UnmarshalMsg ¶
func (z *FollowStruct) UnmarshalMsg(bts []byte) (o []byte, err error)
UnmarshalMsg implements msgp.Unmarshaler
type List ¶
type List struct {
Users ListUsers `json:"users"`
}
type Types ¶
type Types int8
User Types
func (Types) MarshalMsg ¶
MarshalMsg implements msgp.Marshaler
func (Types) Msgsize ¶
Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message
func (*Types) UnmarshalMsg ¶
UnmarshalMsg implements msgp.Unmarshaler
type User ¶
type User struct { ID int64 `msg:"id" json:"id"` UserName string `msg:"userName" json:"userName"` Name string `msg:"name" json:"name"` Email string `msg:"email" json:"email,omitempty"` Avatar string `msg:"-" json:"avatar"` Bio string `msg:"bio" json:"bio,omitempty"` SelfFollow FollowStruct `msg:"-" json:"selfFollow,omitempty"` UserFollow FollowStruct `msg:"-" json:"userFollow,omitempty"` Followers int64 `msg:"followers" json:"followers"` Type Types `msg:"type" json:"type"` Permissions perms.Perms `msg:"permissions" json:"-"` Created int64 `msg:"created" json:"created,omitempty"` }
User Struct
func (*User) IsEmailUnique ¶
IsEmailUnique check if Email Exists
func (*User) MarshalMsg ¶
MarshalMsg implements msgp.Marshaler
func (*User) Msgsize ¶
Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message
func (*User) SetDefaultPerms ¶
func (u *User) SetDefaultPerms()
SetDefaultPerms sets default permissions
func (*User) UnmarshalMsg ¶
UnmarshalMsg implements msgp.Unmarshaler
func (*User) ValidPassword ¶
ValidPassword check password
func (*User) ValidatePublic ¶
func (u *User) ValidatePublic() (v ValidationErrors)
ValidatePublic values
type ValidationErrStrings ¶
type ValidationErrors ¶
func (*ValidationErrors) ToString ¶
func (v *ValidationErrors) ToString() *ValidationErrStrings