Documentation ¶
Index ¶
- Variables
- func CheckUser(userDiscordId string) (err error, isUserExist bool, userId primitive.ObjectID)
- func CountScorePost(postRecord PostRecordFetchT, userId primitive.ObjectID) (globalVote int, userVote string)
- func DeletePost(postId, userId primitive.ObjectID, isBotAdmin bool) (err error)
- func GetDiscordId(userId primitive.ObjectID) (err error, userDiscordId string)
- func Post(userId primitive.ObjectID, postType, postUrl string) (postAlreadyExist bool, postId string)
- func RegisterUser(userDiscordId string) (err error)
- func SetVote(postId, userVote string, userId primitive.ObjectID) (error, bool)
- type PostRecordFetchT
- type UserInfoFetch
Constants ¶
This section is empty.
Variables ¶
var ErrFetchingPost = errors.New("somethings bad append while fetching post")
var ErrNoDocument = errors.New("the selected post doesn't exist")
var ErrNoPost = errors.New("the selected user has no post shared")
var ErrUserAlreadyRegistered = errors.New("the selected user is already registered in the database")
var ErrWrongUserDbId = errors.New("the provided user db id is different from the wanted one")
Functions ¶
func CheckUser ¶
CheckUser function check if a user exists in the database according to his discord id
func CountScorePost ¶
func CountScorePost(postRecord PostRecordFetchT, userId primitive.ObjectID) (globalVote int, userVote string)
CountScorePost function calculate the total score of a post according to the provided post (postRecord), it can also return the score of a specific user on this post according to the provided db id (userDbId)
func GetDiscordId ¶
GetDiscordId function get and return the user discord id according to the provided mongodb _id
func Post ¶
func Post(userId primitive.ObjectID, postType, postUrl string) (postAlreadyExist bool, postId string)
The Post function check if post exist in the database according to his link.
1. If it not exists the post will be added and the function will return (false, OBJECTID)
2. Else it will return (true, "")
func RegisterUser ¶
RegisterUser register a user if it doesn't exist in the database using his discord id
Types ¶
type PostRecordFetchT ¶
type UserInfoFetch ¶
type UserInfoFetch struct { ID primitive.ObjectID `bson:"_id" json:"id,omitempty"` Posts []PostRecordFetchT GlobalScore int }
func GetUserInfo ¶
func GetUserInfo(userId primitive.ObjectID) (err error, userStats UserInfoFetch)
GetUserInfo function get and return all the user infos according to the provided mongodb _id