entity

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Feb 4, 2024 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrUserNotFound          = errors.New("user is not found")
	ErrSuchUserAlreadyExists = errors.New("user with such username or email already exists")
	ErrWrongCurrentPassword  = errors.New("wrong current password")

	ErrGroupNotFound                          = errors.New("group is not found")
	ErrGroupParticipantNotFound               = errors.New("group participant is not found")
	ErrDialogNotFound                         = errors.New("dialog is not found")
	ErrSuchDialogAlreadyExists                = errors.New("such a dialog already exists")
	ErrCreateDialogWithYourself               = errors.New("creating a dialog with yourself")
	ErrCreateDialogWithNonExistentUser        = errors.New("creating a dialog with a non-existent user")
	ErrIncorrectGroupParticipantStatusTransit = errors.New("incorrect group participant status transit")
	ErrSuchGroupParticipantAlreadyExists      = errors.New("such a group participant already exists")
	ErrAddNonExistentUserToGroup              = errors.New("addition non-existent user to group")
	ErrForbiddenPerformAction                 = errors.New("it's forbidden to perform this action")
)
View Source
var (
	MxActionOnSomeone = StatusMatrix{
		JoinedStatus: newStatusSet(KickedStatus),
		KickedStatus: newStatusSet(JoinedStatus),
	}
	MxActionOnOneself = StatusMatrix{
		JoinedStatus: newStatusSet(LeftStatus),
		LeftStatus:   newStatusSet(JoinedStatus),
	}
)

Functions

This section is empty.

Types

type ChatID

type ChatID struct {
	ID   int
	Type ChatType
}

type ChatType

type ChatType string
const (
	DialogChatType ChatType = "dialog"
	GroupChatType  ChatType = "group"
)

func (ChatType) String

func (ct ChatType) String() string

type ContentType

type ContentType string
const (
	TextContentType  ContentType = "text"
	ImageContentType ContentType = "image"
)

func (ContentType) String

func (ct ContentType) String() string

type Dialog

type Dialog struct {
	ID        int
	IsBlocked bool
	Partner   DialogPartner
	CreatedAt time.Time
}

type DialogPartner

type DialogPartner struct {
	UserID    int
	IsBlocked bool
}

type Group

type Group struct {
	ID          int
	Name        string
	Description string
	CreatedAt   time.Time
}

type GroupParticipant

type GroupParticipant struct {
	GroupID int
	UserID  int
	IsAdmin bool
	Status  GroupParticipantStatus
}

func (GroupParticipant) IsInGroup

func (p GroupParticipant) IsInGroup() bool

type GroupParticipantStatus

type GroupParticipantStatus string
const (
	JoinedStatus GroupParticipantStatus = "joined"
	KickedStatus GroupParticipantStatus = "kicked"
	LeftStatus   GroupParticipantStatus = "left"
)

func (GroupParticipantStatus) String

func (gps GroupParticipantStatus) String() string

type Message

type Message struct {
	ID          int
	ChatID      ChatID
	SenderID    int
	Content     string
	ContentType ContentType
	IsService   bool
	SentAt      time.Time
	DeliveredAt *time.Time
}

type ParticipantEvent

type ParticipantEvent struct {
	Type   ParticipantEventType
	ChatID ChatID
	UserID int
}

type ParticipantEventType

type ParticipantEventType string
const (
	AddedParticipant   ParticipantEventType = "added"
	RemovedParticipant ParticipantEventType = "removed"
)

func (ParticipantEventType) String

func (et ParticipantEventType) String() string

type StatusMatrix

type StatusMatrix map[GroupParticipantStatus]StatusSet

func (StatusMatrix) IsCorrectTransit

func (mx StatusMatrix) IsCorrectTransit(from, to GroupParticipantStatus) bool

type StatusSet

type StatusSet map[GroupParticipantStatus]bool

type User

type User struct {
	ID        int
	Username  string
	PwdHash   string
	Email     string
	FirstName string
	LastName  string
	BirthDate *time.Time
	Bio       string
	CreatedAt time.Time
}

Jump to

Keyboard shortcuts

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