database

package
v0.0.0-...-84686e3 Latest Latest
Warning

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

Go to latest
Published: Jan 18, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrCommentDoesNotExist = errors.New("Comment does not exist")
View Source
var ErrConversationDoesNotExist = errors.New("Conversation does not exist")
View Source
var ErrGroupDoesNotExist = errors.New("Group does not exist")
View Source
var ErrMessageDoesNotExist = errors.New("Message does not exist")
View Source
var ErrUnauthorizedToDeleteMessage = errors.New("Unauthorized To Delete Message")
View Source
var ErrUserNotFound = errors.New("User not found")

Functions

This section is empty.

Types

type AppDatabase

type AppDatabase interface {
	Ping() error
	FindUserByName(name string) (User, error)
	AddUser(u User) (User, error)
	ChangeUserName(userId string, newName string) (User, error)
	ChangeUserPhoto(userID string, photo []byte) error
	FindUsersByName(username string) ([]User, error)
	GetPrivateConversation(senderID, recipientID string) (string, error)
	StartDirectConversation(conversationID, senderID, recipientID string) error
	StoreMessage(conversationID, senderID, messageID, content string, attachment []byte, replyTo string) (Message, error)
	AddDeliveryReceipt(messageID, userID, deliveredAt string) error
	HasUserJoinedConversation(conversationID, userID string) (bool, error)
	FetchConversation(conversationID, currentUserID string) (Conversation, error)
	FetchConversationMessages(conversationID string) ([]Message, error)
	FetchUserConversations(userID string) ([]Conversation, error)
	FetchConversationMembers(conversationID string) ([]string, error)
	RetrieveUsersPhotos(userID string) (User, error)
	RemoveMessage(conversationID, messageID, userID string) error
	FetchMessage(messageID, userID string) (Message, error)
	StartGroupConversation(conversationID string, memberIDs []string, name string, photo []byte) error
	FetchUserGroups(userID string) ([]Conversation, error)
	FetchGroup(groupID string) (Conversation, error)
	ChangeGroupName(groupId, newName string) error
	SetGroupPhoto(groupID string, photo []byte) error
	ExitGroup(groupID, userID string) error
	AddGroupMember(conversationID string, userID string) error
	AddComment(commentID, messageID, authorID string) error
	UnaddComment(messageID, authorID string) error
	SetMessagesAsRead(conversationID, userID string) error
}

func New

func New(db *sql.DB) (AppDatabase, error)

type Comment

type Comment struct {
	Id       string `json:"id"`
	AuthorId string `json:"authorId"`
}

type Conversation

type Conversation struct {
	Id                string         `json:"id"`
	Name              string         `json:"name"`
	Type              string         `json:"type"`
	CreatedAt         string         `json:"createdAt"`
	Members           []string       `json:"members"`
	LastMessage       *Message       `json:"lastMessage,omitempty"`
	Messages          []Message      `json:"messages,omitempty"`
	ConversationPhoto sql.NullString `json:"conversationPhoto,omitempty"`
}

type Group

type Group struct {
	Id    string `json:"id"`
	Name  string `json:"name"`
	Photo []byte `json:"photo,omitempty"`
}

type Message

type Message struct {
	Id                string   `json:"id"`
	ConversationId    string   `json:"conversationId"`
	SenderId          string   `json:"senderId"`
	SenderName        string   `json:"senderName"`
	Content           string   `json:"content"`
	Timestamp         string   `json:"timestamp"`
	Attachment        []byte   `json:"attachment"`
	SenderPhoto       string   `json:"senderPhoto,omitempty"`
	ReactionCount     int      `json:"reactionCount"`
	ReactingUserNames []string `json:"reactingUserNames"`
	Status            string   `json:"status"`
	ReplyTo           string   `json:"replyTo,omitempty"`
	ReplyContent      string   `json:"replyContent,omitempty"`
	ReplySenderName   string   `json:"replySenderName,omitempty"`
	ReplyAttachment   []byte   `json:"replyAttachment,omitempty"`
}

type ReadReceipt

type ReadReceipt struct {
	MessageId   string  `json:"messageId"`
	UserId      string  `json:"userId"`
	DeliveredAt string  `json:"deliveredAt"`
	ReadAt      *string `json:"readAt,omitempty"`
}

type User

type User struct {
	Id    string `json:"id"`
	Name  string `json:"name"`
	Photo []byte `json:"photo,omitempty"`
}

Jump to

Keyboard shortcuts

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