Initial commit: Эфир мессенджер

This commit is contained in:
2026-04-06 14:57:36 +03:00
commit ff93679b6d
50 changed files with 5642 additions and 0 deletions

70
internal/models/chat.go Normal file
View File

@@ -0,0 +1,70 @@
package models
import (
"time"
)
type ChatType string
const (
ChatTypePrivate ChatType = "private"
ChatTypeGroup ChatType = "group"
)
type MemberRole string
const (
MemberRoleMember MemberRole = "member"
MemberRoleAdmin MemberRole = "admin"
)
type Chat struct {
ID int64 `json:"id"`
Type ChatType `json:"type"`
Title *string `json:"title,omitempty"` // только для групп
CreatedAt time.Time `json:"created_at"`
}
type ChatMember struct {
ChatID int64 `json:"chat_id"`
UserID int64 `json:"user_id"`
Role MemberRole `json:"role"`
JoinedAt time.Time `json:"joined_at"`
}
// ChatWithDetails используется для возврата чата с дополнительной информацией
type ChatWithDetails struct {
ID int64 `json:"id"`
Type ChatType `json:"type"`
Title *string `json:"title,omitempty"`
CreatedAt time.Time `json:"created_at"`
LastMessage *Message `json:"last_message,omitempty"`
UnreadCount int `json:"unread_count,omitempty"`
ParticipantIDs []int64 `json:"participant_ids,omitempty"`
}
// CreatePrivateChatRequest DTO для создания личного чата
type CreatePrivateChatRequest struct {
TargetLogin string `json:"target_login"`
}
// CreateGroupChatRequest DTO для создания группового чата
type CreateGroupChatRequest struct {
Title string `json:"title"`
MemberLogins []string `json:"member_logins"`
}
// AddMembersRequest DTO для добавления участников в группу
type AddMembersRequest struct {
UserLogins []string `json:"user_logins"`
}
// UpdateMemberRoleRequest DTO для обновления роли участника
type UpdateMemberRoleRequest struct {
Role MemberRole `json:"role"`
}
// UpdateChatTitleRequest DTO для обновления названия чата
type UpdateChatTitleRequest struct {
Title string `json:"title"`
}