chat

package
v0.4.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 13, 2023 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	FirestoreUsersCollection          = "users"
	FirestoreGroupChatCollection      = "gcs"
	FirestoreDirectMessagesCollection = "dms"
	FirestoreMessagesCollection       = "messages"
)
View Source
const (
	JoinChat joinQuitAction = "join"
	QuitChat joinQuitAction = "quit"
)

Variables

App is a global variable to hold the initialized Firebase App object

Functions

This section is empty.

Types

type DirectMessage

type DirectMessage struct {
	ID       string    `firestore:"id,omitempty"`
	User1    string    `firestore:"user1"`
	User2    string    `firestore:"user2"`
	Messages []Message `firestore:"-"` // subcollection
}

func GetDirectMessage

func GetDirectMessage(ID string) (chat *DirectMessage, err error)

type GroupChat

type GroupChat struct {
	ID       string    `firestore:"id,omitempty"`
	Owner    string    `firestore:"owner"`
	Users    []string  `firestore:"users"`
	Messages []Message `firestore:"-"` // subcollection
}

func GetGroupChat

func GetGroupChat(ID string) (chat *GroupChat, err error)

func (*GroupChat) HandleAccess

func (gc *GroupChat) HandleAccess(dataSubjectId string, currentDocumentID string) map[string]interface{}

func (*GroupChat) HandleDeletion

func (m *GroupChat) HandleDeletion(dataSubjectId string) (nodesToTraverse []pal.Locator, deleteNode bool, fieldsToUpdate []firestore.Update)

type Message

type Message struct {
	ID        string    `firestore:"id,omitempty"`
	UserID    string    `firestore:"userId"`
	Content   string    `firestore:"content"`
	Timestamp time.Time `firestore:"timestamp"`
}

func (*Message) HandleAccess

func (m *Message) HandleAccess(dataSubjectId string, currentDocumentID string) map[string]interface{}

func (*Message) HandleDeletion

func (m *Message) HandleDeletion(dataSubjectId string) (nodesToTraverse []pal.Locator, deleteNode bool, fieldsToUpdate []firestore.Update)

type User

type User struct {
	ID   string            `firestore:"id,omitempty"`
	Name string            `firestore:"name"`
	GCs  []string          `firestore:"gcs"`
	DMs  map[string]string `firestore:"dms"` // map from other user id to dm id
}

func CreateUser

func CreateUser(name string) (user *User, err error)

func GetUser

func GetUser(ID string) (user *User, err error)

func (*User) CreateDirectMessage

func (u *User) CreateDirectMessage(user2ID string) (chat *DirectMessage, err error)

func (*User) CreateGroupChat

func (u *User) CreateGroupChat() (chat *GroupChat, err error)

func (*User) HandleAccess

func (u *User) HandleAccess(dataSubjectId string, currentDocumentID string) map[string]interface{}

func (*User) HandleDeletion

func (u *User) HandleDeletion(dataSubjectId string) (nodesToTraverse []pal.Locator, deleteNode bool, fieldsToUpdate []firestore.Update)

func (*User) JoinOrQuitGroupChat

func (u *User) JoinOrQuitGroupChat(chatID string, action joinQuitAction) (err error)

func (*User) SendMessageToDirectMessage

func (u *User) SendMessageToDirectMessage(chatID string, message string) error

func (*User) SendMessageToGroupChat

func (u *User) SendMessageToGroupChat(chatID string, message string) error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL