Files

70 lines
2.0 KiB
Go
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
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"`
}