Documentation
¶
Index ¶
- Constants
- Variables
- func AddMessage(userID int64, chatID int64, content string, docs []int64, ...) (int64, error)
- func BeginDB(logger *log.Logger) error
- func CheckFileRights(userID int64, fileID int64) (string, error)
- func CheckUserInChatDeleted(userID int64, chatID int64) (bool, error)
- func CheckUserRights(userID int64, chatID int64) error
- func Create(name string, authorID int64, chattype ChatMode) (int64, error)
- func CreateDialog(userID int64, yetuserID int64) (int64, error)
- func CreateFile(name string, size int64, userID int64, chatID int64, ratio float64, ...) (int64, string, error)
- func CreateUser(login string, pass string, name string) (int64, error)
- func DBE(text string, err error) error
- func DeleteChatFromList(userID int64, chatID int64) error
- func DeleteFile(fileID int64, userID int64) (string, error)
- func DeleteUsersInChat(usersIDs []int64, chatID int64, deleteByYourself bool) error
- func GetChatSettings(chatID int64) (models.ChatSettings, error)
- func GetChatUsersInfo(chatID int64) (*[]models.FolkChatsInfo, error)
- func GetChatsUsers(chatID int64) (*[]int64, error)
- func GetMessages(userID int64, chatID int64, tranches bool, lastID int64) (*[]models.NewMessageToUser, error)
- func GetOnlineUsersIDsInChat(chatsID *[]int64, usersOnlineID *[]int64) (*[]int64, error)
- func GetUserChats(userID int64) (*[]models.UserChatInfo, error)
- func GetUserSettings(userID int64) (models.UserSettings, error)
- func GetUsersChatsIDs(userID int64) (*[]int64, error)
- func GetUsersForAddByName(chatID int64, name string) (*[]models.User, error)
- func GetUsersForCreateDialog(userID int64, name string) (*[]models.User, error)
- func HaveAlreadyDialog(userID int64, yetuserID int64) (int64, error)
- func InsertUserInChat(userID int64, chatID int64, invited bool) error
- func RecoveryUsersInChat(userIDs []int64, chatID int64, recoveryByYourself bool) error
- func SetChatSettings(chatID int64, settings models.ChatSettings) error
- func SetUserSettigns(userID int64, settings models.UserSettings) error
- type Chat
- type ChatMode
- type ChatUser
- type DBError
- type Dialog
- type File
- type Message
- type System
- type User
Constants ¶
const ( //GetUserError - cannot get user GetUserError = "Get user error ->" //InsertChatError - cannot make insert InsertChatError = "Insert chat error ->" //InsertUserInChatError - cannot insert user in chat InsertUserInChatError = "Insert user in chat error ->" //InsertUserInDialogError - cannot insert user in dialog InsertUserInDialogError = "Insert user in dialog error ->" //InsertUserInChannelError - cannot insert user in cahnnel InsertUserInChannelError = "Insert user in channel error ->" //UserAlreadyExistInChatError - cannot insert user in chat user already in UserAlreadyExistInChatError = "User already in chat ->" //AddMessageError - cannot send message AddMessageError = "Send message error ->" //GetChatError - getting chat failed GetChatError = "Getting chat failed ->" //UserIsntAuthorError - user havent rights UserIsntAuthorError = "User isnt author ->" //GetChatUserError - cannot get chat's user GetChatUserError = "Gettings chat user failed ->" //GetDeletePointsError - getting delete points failed GetDeletePointsError = "Failed get delete points ->" //SetDeletePointsError - settings delete points failed SetDeletePointsError = "Failed set delete points ->" //UpdateChatUserError - updating chat user failed UpdateChatUserError = "Failed update chat user ->" //UpdateChatError - updating chat failed UpdateChatError = "Failed update chat ->" //UserYetDidntDeleteError - user wasn't deleted UserYetDidntDeleteError = "User wasn't delete ->" //WrongChatType - got wrong chat's type WrongChatType = "Got wrong chat't type ->" //GettingUsersChatInfoFailed - getting user's chat info failed GettingUsersChatInfoFailed = "Getting user's chat info failed ->" //CheckingUserDeletedInChatFailed - checking user deleted in chat failed CheckingUserDeletedInChatFailed = "Checking user deleted in chat failed ->" //GetChatsUsersFailed - getting chat's users failed GetChatsUsersFailed = "Getting chat's users failed ->" )
const ( //DialogAlreadyCreated - dialog was already created DialogAlreadyCreated = "Dialog already created ->" //CreatingChatFailed - chat creating failed CreatingChatFailed = "Chat creating failed ->" //InsertingDialogFailed - inserting dialog in db failed InsertingDialogFailed = "Dialog inserting into db failed ->" //GettingDialogFailed - dialog getting failed GettingDialogFailed = "Dialog getting failed ->" //CheckingDialogExistsFailed - checking dialog exists failed CheckingDialogExistsFailed = "Checking dialog exists failed ->" //UsersDontHaveDialog - users dont have dialog UsersDontHaveDialog = "Users doent have dialog ->" )
const ( //CannotReadRandomBytes - reading reandom bytes failed CannotReadRandomBytes = "Reading random bytes failed ->" //FileInsertingFailed = inserting file into db failed FileInsertingFailed = "Inserting file into db failed ->" //CannotFindFile = file not found CannotFindFile = "File not found ->" //CannotDeleteFile = file deleting failed CannotDeleteFile = "File deleting failed ->" )
const ( //MarshalingFailed - marshaling failed MarshalingFailed = "Marshaling failed ->" //UnmarshalingFailed - unmarshaling failed UnmarshalingFailed = "Unmarshaling failed ->" //AddingMessageFailed - inserting message failed AddingMessageFailed = "Adding message failed ->" //CheckingUserInChatFailed - checking user in chat failed CheckingUserInChatFailed = "Checking user in chat faile ->" //UserDeletedFromChat - user was deleted from chat UserDeletedFromChat = "User deleted from chat ->" //MessageInsertingFailed - message inserting was failed MessageInsertingFailed = "Message insert error ->" //GettingFileInfoFailed - cannot get file's info GettingFileInfoFailed = "Getting file's information failed ->" )
const ( //UserInsertError - User insertion into DB failed UserInsertError = "User insert error ->" //UserUpdateError - User updation into DB failed UserUpdateError = "User updating failed ->" //UserWithThisLoginAlreadyExists - User with this login already exists in DB UserWithThisLoginAlreadyExists = "User with this login already exists ->" //GetChatInfoError - Getting chat's info failed GetChatInfoError = "Getting chat info failed ->" //UserNotFound - User with this data doesnt exist UserNotFound = "User not found ->" //PasswordEncodingFailed - Password encoding failed PasswordEncodingFailed = "Pass encoding failed ->" //GetMessageError - getting message failed GetMessageError = "Getting message failed ->" //MessageContentDecodeError - decoding message was failed MessageContentDecodeError = "Message's content decoding failed ->" )
Variables ¶
var ( //UserInsertedToChat - is a callback triggered when user requesting in chat(uses for sending notifications by WS) UserInsertedToChat userInsertedCallback //ChatCreated - is a callback triggered when user creating chat(uses for sending notifications by WS) ChatCreated chatCreatedCallback // SendUserMessageToSocket - using for sending message SendUserMessageToSocket sendUserMessage // UserLeaveChat - using as callback after user get banned UserLeaveChat userLeaveChatCallback // UserReturnToChat - using as callback after user was unbanned UserReturnToChat userReturnToChatCallback )
Functions ¶
func AddMessage ¶
func AddMessage(userID int64, chatID int64, content string, docs []int64, mtype models.MessageType, command models.MessageCommand) (int64, error)
AddMessage - handle inserting message into db
func CheckFileRights ¶
CheckFileRights - checking if user have rights for getting file (e.g. user is in a chat where file is), return path to file
func CheckUserInChatDeleted ¶
CheckUserInChatDeleted - check user delete stat, if users deleted return true, else false
func CheckUserRights ¶
CheckUserRights - return is user author of the chat (error - no, nil - yes)
func CreateDialog ¶
CreateDialog - creating dialog between two users
func CreateFile ¶
func CreateFile(name string, size int64, userID int64, chatID int64, ratio float64, duration int64) (int64, string, error)
CreateFile - insert file data into db
func CreateUser ¶
CreateUser - creating creating user record in DB by his login, Pass and name pass will be encoding to sha256
func DeleteChatFromList ¶
DeleteChatFromList - delete chat from certain user's menu
func DeleteFile ¶
DeleteFile - delete file info into db and return path to file
func DeleteUsersInChat ¶
DeleteUsersInChat - delete users from certain chat or ban them(if deleteByYourself = false)
func GetChatSettings ¶
func GetChatSettings(chatID int64) (models.ChatSettings, error)
GetChatSettings - return chat settings by chat's ID
func GetChatUsersInfo ¶
func GetChatUsersInfo(chatID int64) (*[]models.FolkChatsInfo, error)
GetChatUsersInfo - returning user's chat info by certain chat
func GetChatsUsers ¶
GetChatsUsers - returning user's ids in the certain chat
func GetMessages ¶
func GetMessages(userID int64, chatID int64, tranches bool, lastID int64) (*[]models.NewMessageToUser, error)
GetMessages - retrun user's messages in certain chat, supporting tranches(pages)
func GetOnlineUsersIDsInChat ¶
GetOnlineUsersIDsInChat - return online users IDs in chats by online usesrs slice
func GetUserChats ¶
func GetUserChats(userID int64) (*[]models.UserChatInfo, error)
GetUserChats - return users chats
func GetUserSettings ¶
func GetUserSettings(userID int64) (models.UserSettings, error)
GetUserSettings - return user's settings
func GetUsersChatsIDs ¶
GetUsersChatsIDs - return user's chats ID
func GetUsersForAddByName ¶
GetUsersForAddByName - return users for add to certain chat if yet aren't there
func GetUsersForCreateDialog ¶
GetUsersForCreateDialog - return pointer to users slice for probably starting dialog with supporting of name/login search
func HaveAlreadyDialog ¶
HaveAlreadyDialog - return dialog ID if users have a dialog
func InsertUserInChat ¶
InsertUserInChat - adding user to chat
func RecoveryUsersInChat ¶
RecoveryUsersInChat - recovery users for chats if they're was deleted, but not banned
func SetChatSettings ¶
func SetChatSettings(chatID int64, settings models.ChatSettings) error
SetChatSettings - apply settigns for certain chat
func SetUserSettigns ¶
func SetUserSettigns(userID int64, settings models.UserSettings) error
SetUserSettigns - save settings to DB
Types ¶
type Chat ¶
type ChatMode ¶
type ChatMode int
ChatMode - type for decalring chat's modesChatMode
func GetChatMode ¶
GetChatMode - returning chat's type
type ChatUser ¶
type File ¶
type Message ¶
type User ¶
type User struct { ID int64 Login string `gorm:"size:32"` Name string `gorm:"size:100"` Pass string `gorm:"size:45"` Language string `gorm:"size:5;DEFAULT:en"` Chats []ChatUser `gorm:"PRELOAD:false"` Messages []Message `gorm:"PRELOAD:false"` Files []File `gorm:"PRELOAD:false"` MyChats []Chat `gorm:"PRELOAD:false"` Dialogs []Dialog `gorm:"PRELOAD:false"` }
func GetUserByID ¶
GetUserByID - getting user by his ID or retrun error
func GetUserByLoginAndPass ¶
GetUserByLoginAndPass - getting user by his login and pass or return error