Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DeleteMessage ¶
func DeleteMessage(messageID string)
DeleteMessage deletes the message from database. It does not remove it from any threads it is in. For that use Thread.DeleteMessage()
func DeleteThread ¶
func DeleteThread(threadID string)
DeleteThread removes a thread from database it also removes all messages associated with it
func ReadMessage ¶
ReadMessage marks the message as read in the database
Types ¶
type Message ¶
type Message struct { Sender string Date int64 Content string MessageID string ThreadID string ReadBy []string }
Message represents a text message sent from an user to another
How to send a message:
1. Create the thread with all the users that should recieve the message 2. Create the message with NewMessage and data from user 3. Call the threads SendMessage method with the created message 4. Profit.
func GetMessage ¶
GetMessage gets message from database based on message id
type Thread ¶
Thread represents a thread of messages
func CreateThread ¶
CreateThread creates a new thread with specified users and saves it to database
func GetThreadsForUser ¶
GetThreadsForUser returns all threas for specified user
func (*Thread) DeleteMessage ¶
DeleteMessage removes a specific message from the thread. Also removes the message from database
func (*Thread) GetMessages ¶
GetMessages gets all messages in the thread
func (*Thread) RemoveMember ¶
RemoveMember removes an user froms the threads Members slice.
func (*Thread) SendMessage ¶
SendMessage sends a response message to all members of the thread.
Basically saves the message to database and appends its id to the threads messages slice. Saves changes to database