repo

package
v0.0.0-...-fce496f Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2024 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Counts

type Counts struct {
	TotalCount         int          `db:"total_count"`
	UnreadCount        int          `db:"unread_count"`
	TotalCommentCount  int          `db:"total_comment_count"`
	UnreadCommentCount int          `db:"unread_comment_count"`
	LastMessageTime    sql.NullTime `db:"last_message_time"`
}

type Message

type Message struct {
	ID                    string         `json:"id" db:"id"`
	ParentID              sql.NullString `json:"parent_id" db:"parent_id"`
	UserID                string         `json:"user_id" db:"user_id"`
	Text                  string         `json:"text" db:"text"`
	AttachmentID          string         `json:"attachment_id" db:"attachment_id"`
	AttachmentType        string         `json:"attachment_type" db:"attachment_type"`
	AttachmentThumbnailID string         `json:"attachment_thumbnail_id" db:"attachment_thumbnail_id"`
	CreatedAt             time.Time      `json:"created_at" db:"created_at"`
	UpdatedAt             time.Time      `json:"updated_at" db:"updated_at"`
	Likes                 int            `json:"likes" db:"likes"`
	LikedByMe             bool           `json:"liked_by_me" db:"liked_by_me"`
	GroupID               sql.NullString `json:"group_id" db:"group_id"`
	IsGuest               bool           `json:"is_guest" db:"is_guest"`
	FriendID              sql.NullString `json:"friend_id" db:"friend_id"`
	IsPublic              bool           `json:"is_public" db:"is_public"`
}

type MessageLike

type MessageLike struct {
	MessageID string    `json:"message_id" db:"message_id"`
	UserID    string    `json:"user_id" db:"user_id"`
	CreatedAt time.Time `json:"created_at" db:"created_at"`
}

type MessageRepo

type MessageRepo interface {
	Messages(currentUserID string, userIDs []string, from time.Time, count int) []Message
	PublicMessages(userID string, from time.Time, count int) []Message
	GroupMessages(currentUserID, groupID string, from time.Time, count int) []Message
	DirectMessages(currentUserID, friendID string, from time.Time, count int) []Message
	Message(currentUserID string, messageID string) *Message
	PublicMessage(messageID string) *Message
	AddMessage(parentID string, message Message)
	EditMessageText(userID, messageID, text string, updatedAt time.Time) bool
	EditMessageAttachment(userID, messageID, attachmentID, attachmentType, attachmentThumbnailID string, updatedAt time.Time) bool
	DeleteMessage(messageID string) bool
	Comments(currentUserID string, messageIDs []string) map[string][]Message
	LikeMessage(userID, messageID string) int
	UnlikeMessage(userID, messageID string) int
	MessagesLikes(messageIDs []string) map[string][]MessageLike
	MessageLikes(messageID string) []MessageLike
	SetMessageVisibility(userID, messageID string, visibility bool)
	ReportMessage(userID, messageID, report string) string
	MessageReport(reportID string) *MessageReport
	MessageReports() []MessageReport
	DeleteReportedMessage(reportID string) bool
	BlockReportedUser(reportID string) bool
	ResolveMessageReport(reportID string) bool
	DeleteExpiredMessages(until time.Time, onlyGuestMessages bool)
	MarkRead(userID string, messageIDs []string)
	Counts(currentUserID string, userIDs []string) Counts
	GroupCounts(currentUserID string, groupIDs []string) map[string]Counts
	DirectCounts(currentUserID string) map[string]*Counts
	DeleteUserData(tx *sqlx.Tx, userID string) error
}

func NewMessages

func NewMessages(db *sqlx.DB) MessageRepo

type MessageReport

type MessageReport struct {
	ID                    string       `json:"id" db:"id"`
	ReportedByID          string       `json:"reported_by" db:"reported_by"`
	Report                string       `json:"report" db:"report"`
	CreatedAt             time.Time    `json:"created_at" db:"created_at"`
	ResolvedAt            sql.NullTime `json:"resolved_at" db:"resolved_at"`
	MessageID             string       `json:"message_id" db:"message_id"`
	AuthorID              string       `json:"author_id" db:"author_id"`
	Text                  string       `json:"text" db:"text"`
	AttachmentType        string       `json:"attachment_type" db:"attachment_type"`
	AttachmentID          string       `json:"attachment_id" db:"attachment_id"`
	AttachmentThumbnailID string       `json:"attachment_thumbnail_id" db:"attachment_thumbnail_id"`
}

type Repos

type Repos struct {
	Message      MessageRepo
	Notification common.NotificationRepo
	User         UserRepo
	Setting      common.SettingRepo
	// contains filtered or unexported fields
}

func NewRepos

func NewRepos(db *sqlx.DB) Repos

func (Repos) DeleteUserData

func (r Repos) DeleteUserData(userID string)

type User

type User struct {
	ID        string       `json:"id" db:"id"`
	BlockedAt sql.NullTime `json:"blocked_at" db:"blocked_at"`
}

type UserRepo

type UserRepo interface {
	AddUser(id string) User
	BlockUser(userID string)
}

func NewUsers

func NewUsers(db *sqlx.DB) UserRepo

Jump to

Keyboard shortcuts

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