Documentation
¶
Index ¶
- Variables
- func Init(key int) error
- type Client
- func (c *Client) ActivateUser(otp string) error
- func (c *Client) DeleteForMeAllMsgsForConversation(senderId, receiverId string) error
- func (c *Client) DeleteMsgForEveryone(msg *domain.Message) error
- func (c *Client) DeleteMsgForMe(msgId string) error
- func (c *Client) GetCurrentActiveUser() (*domain.User, int, error)
- func (c *Client) GetMessagesAsPageAndMarkAsRead(senderID string, page int) ([]*domain.Message, *domain.Metadata, error)
- func (c *Client) Login(u domain.UserAuth) error
- func (c *Client) Logout() error
- func (*Client) Register(u *domain.UserRegister) error
- func (c *Client) ResendOtp(email string) error
- func (c *Client) SearchUser(param string, page int) (*PagedUserResponse, int, error)
- func (c *Client) SendMessage(msg domain.Message) error
- func (c *Client) SendTypingStatus(msg domain.Message)
- func (c *Client) SetMsgAsRead(msg *domain.Message) error
- func (c *Client) UpdateUser(u domain.UserUpdate) (*domain.ErrValidation, int, error)
- type Convos
- type ConvosBroadcaster
- type LoginBroadcaster
- type LoginState
- type PagedUserResponse
- type RecvMsgsBroadcaster
- type WsConnBroadcaster
- type WsConnState
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrServerValidation = errors.New("server validation error") ErrExpiredOTP = errors.New("expired otp") ErrNonActiveUser = errors.New("not activated") // ErrApplication code is 0 ErrApplication = errors.New("your side of application have encountered an error, if the error persists you may report this issue to the developer at https://github.com/MuhamedUsman/letschat") )
View Source
var (
ErrMsgNotSent = errors.New("message not sent, 2 sec ctx timed out")
)
Functions ¶
func Init ¶
Init initializes Storage Dirs, keyringManager to support access token storage at OS level, also opens a connection to sqlite DB, runs idempotent migrations, starts a goroutine to listen for user login, a goroutine to connect to Ws and listen for recvMsgs to get instance to a client use Get
Types ¶
type Client ¶
type Client struct {
// If zero valued -> requires login
// then we set this AuthToken in the OS credential manager of respected Operating systems
AuthToken string
// it's where all the application related files will live on the client side from db, logging anything
FilesDir string
// currently logged-in user we fetch and populates this once there is a read from UsrLogin chan
CurrentUsr *domain.User
WsConnState *WsConnBroadcaster
LoginState *LoginBroadcaster
RecvMsgs *RecvMsgsBroadcaster
// these are the conversations of the user displayed on the left side of the Conversations tab
// once there is a ws conn they will be updated by current online status updates
// if the connection is offline they will be fetched by the local db for offline view
// we've to wait for state change to get updated conversations, they will be auto updated on WsConnState changes
Conversations *ConvosBroadcaster
// runs the tasks that needs a graceful shutdown, using BackgroundTask.Run
BT *common.BackgroundTask
// RunStartupProcesses runs long living processes, which dies on shutdown, some chores and
// will be called from main method after there is write on RunningTui chan from tui.TabContainerModel
// initialized in Init func
RunStartupProcesses func()
// contains filtered or unexported fields
}
func (*Client) ActivateUser ¶
func (*Client) DeleteForMeAllMsgsForConversation ¶
func (*Client) DeleteMsgForEveryone ¶
func (*Client) DeleteMsgForMe ¶
func (*Client) GetCurrentActiveUser ¶
func (*Client) GetMessagesAsPageAndMarkAsRead ¶
func (*Client) Register ¶
func (*Client) Register(u *domain.UserRegister) error
Register will register the user & populate the *domain.UserRegister with validation errors in case of http.StatusUnprocessableEntity
func (*Client) SearchUser ¶
func (*Client) SendTypingStatus ¶
func (*Client) UpdateUser ¶
func (c *Client) UpdateUser(u domain.UserUpdate) (*domain.ErrValidation, int, error)
type Convos ¶
type Convos []*domain.Conversation
type ConvosBroadcaster ¶
type ConvosBroadcaster = sync.Broadcaster[Convos]
type LoginBroadcaster ¶
type LoginBroadcaster = sync.Broadcaster[LoginState]
type LoginState ¶
type LoginState bool
LoginState true -> successful login, false -> unauthorized requires login
type PagedUserResponse ¶
type RecvMsgsBroadcaster ¶
type RecvMsgsBroadcaster = sync.Broadcaster[*domain.Message]
type WsConnBroadcaster ¶
type WsConnBroadcaster = sync.Broadcaster[WsConnState]
type WsConnState ¶
type WsConnState int
WsConnState will be switch cased by tui.TabContainerModel, so making it unique
const ( Disconnected WsConnState = iota - 1 Idle WaitingForConnection Connecting Connected )
Source Files
¶
Click to show internal directories.
Click to hide internal directories.