Documentation ¶
Overview ¶
Package models config models.
Index ¶
- Constants
- Variables
- func CreatePheme(pheme Pheme) (uint, error)
- func DeleteByID(userID uint) error
- func DeletePheme(phemeID uint, userID uint) (uint, error)
- func FetchAllPhemes(userID uint) (*[]Pheme, error)
- func FetchPhemes(phemeID uint, userID uint, visibility byte) (*[]Pheme, error)
- func FetchUserPhemes(userID uint, visibility byte) (*[]Pheme, error)
- func FindByName(userName string) (*[]User, error)
- func GetFollowers(userID uint) (*[]uint, error)
- func GetFollowings(userID uint) (*[]User, error)
- func GetFriends(userID uint) (*[]uint, error)
- func GetUsers() (*[]User, error)
- func IsFriend(userID uint, friendID uint) (bool, error)
- func PhemeVersion() uint
- func RemoveFollower(userID uint, followerID uint) error
- func RemoveFriend(userID uint, friendID uint) error
- func UserVersion() uint
- func UsersToUsersPublicData(users *[]User) *[]UserPublicData
- type DbConfig
- type Message
- type Network
- type Pheme
- type PhemeParamsID
- type PhemeParamsPost
- type ServerConfig
- type StandardClaims
- type User
- func AddFollower(userID uint, followerID uint) (*User, error)
- func AddFriend(userID uint, friendID uint) (*User, error)
- func FindByID(userID uint) (*User, error)
- func GetUser(c *fiber.Ctx, secretKey string) (*User, error)
- func GetUserByEmail(email string) (*User, error)
- func RegisterUser(username string, email string, avatar string, password string) (*User, error)
- type UserParamsID
- type UserParamsLogin
- type UserParamsName
- type UserParamsNew
- type UserPublicData
Constants ¶
const ( PUBLIC visibilty = 255 PROTECTED visibilty = 175 PRIVATE visibilty = 0 )
Variables ¶
var Db = database.Connect()
Db global db var
Functions ¶
func DeletePheme ¶
DeletePheme removes a pheme from a user.
func FetchAllPhemes ¶
FetchAllPhemes returns all the phemes of a user, friends and followers with equal or higher visibility.
func FetchPhemes ¶
FetchPhemes returns the phemes if are visible to the user.
func FetchUserPhemes ¶
FetchUserPhemes returns all the phemes of the logged user with equal or higher visibility.
func FindByName ¶
FindByName returns the users that contains the name.
func GetFollowers ¶
GetFollowers returns the followers of a user.
func GetFollowings ¶
GetFollowings returns the users following of a user.
func GetFriends ¶
GetFriends returns the friends of a user.
func RemoveFollower ¶
RemoveFollower removes a follower for a user.
func RemoveFriend ¶
RemoveFriend removes a friends for a user.
func UserVersion ¶
func UserVersion() uint
UserVersion returns the current version of the user schema.
func UsersToUsersPublicData ¶
func UsersToUsersPublicData(users *[]User) *[]UserPublicData
UsersToUsersPublicData convert a users array to a data public users array
Types ¶
type DbConfig ¶
type DbConfig struct { Host string `yaml:"host"` User string `yaml:"user"` Dbname string `yaml:"dbname"` }
DbConfig database configuration.
type Network ¶
type Network struct { Server ServerConfig `yaml:"server"` Db DbConfig `yaml:"db"` }
Network configuration.
type Pheme ¶
type Pheme struct { ID uint `json:"id"` Version uint `json:"version" gorm:"not null" validate:"required"` CreatedAt time.Time `json:"createdAt" gorm:"not null"` UpdatedAt time.Time `json:"updatedAt"` Visibility byte `json:"visibility" sql:"visibility" gorm:"not null" validate:"required"` Category string `json:"category" gorm:"not null" validate:"required"` Text string `json:"text" gorm:"not null" validate:"required"` CreatedBy uint `json:"createdBy" gorm:"not null"` UserID uint `json:"userId" gorm:"not null" validate:"required"` }
Pheme model info @Description Pheme content
func FetchPheme ¶
FetchPheme returns the pheme if is visible to the user.
func UpdatePheme ¶
func UpdatePheme(pheme PhemeParamsPost, phemeID uint, userID uint) (Pheme, error)
UpdatePheme updates the data of a pheme.
type PhemeParamsID ¶
type PhemeParamsID struct {
ID uint `json:"id" query:"id" validate:"required"`
}
PhemeParamsID param @Description id param
type PhemeParamsPost ¶
type PhemeParamsPost struct { Visibilty byte `json:"visibility" validate:"min=0,max=255"` Category string `json:"category" validate:"required"` Text string `json:"text" validate:"required"` UserID uint `json:"userID" validate:"required"` }
PhemeParamsPost params @Description post params
type ServerConfig ¶
ServerConfig server configuration.
type StandardClaims ¶
type StandardClaims struct { Audience string `json:"aud,omitempty"` ExpiresAt int64 `json:"exp,omitempty"` Id string `json:"jti,omitempty"` IssuedAt int64 `json:"iat,omitempty"` Issuer string `json:"iss,omitempty"` NotBefore int64 `json:"nbf,omitempty"` Subject string `json:"sub,omitempty"` }
StandardClaims from jwt
type User ¶
type User struct { ID uint `json:"id"` Version uint `json:"version" gorm:"not null"` UserName string `json:"username" gorm:"not null"` Email string `json:"email" gorm:"unique;not null"` Avatar string `json:"avatar"` Password []byte `json:"-" gorm:"not null"` PasswordDate time.Time `json:"-" gorm:"not null"` CreatedAt time.Time `json:"createdAt" gorm:"not null"` Followers []User `json:"-" gorm:"many2many:followship;association_jointable_foreignkey:follow_id"` Friends []User `json:"-" gorm:"many2many:friendship;association_jointable_foreignkey:friend_id"` }
User model info @Description User account
func AddFollower ¶
AddFollower adds a follower to a user.
func GetUserByEmail ¶
GetUserByEmail Gets the user of the email.
type UserParamsID ¶
type UserParamsID struct {
ID uint `query:"id" validate:"required"`
}
UserParamsID user id param. @Description name param
type UserParamsLogin ¶
type UserParamsLogin struct { Email string `query:"email" validate:"required"` Password string `query:"password" validate:"required"` }
UserParamsLogin login user params.
type UserParamsName ¶
type UserParamsName struct {
UserName string `query:"username" validate:"required"`
}
UserParamsName user name param.
type UserParamsNew ¶
type UserParamsNew struct { UserName string `query:"username" validate:"required"` Email string `query:"email" validate:"required"` Avatar string `query:"avatar"` Password string `query:"password" validate:"required"` }
UserParamsNew new user params.
type UserPublicData ¶
type UserPublicData struct { ID uint `json:"id" validate:"required"` UserName string `json:"username" validate:"required"` Avatar string `json:"avatar" validate:"required"` CreatedAt time.Time `json:"createdAt" validate:"required"` }
UserPublicData User public data.
func UserToUserPublicData ¶
func UserToUserPublicData(user *User) *UserPublicData
UserToUserPublicData convert a user to a data public user