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

View File

@@ -0,0 +1,45 @@
package models
import (
"time"
)
type Message struct {
ID int64 `json:"id"`
ChatID int64 `json:"chat_id"`
SenderID int64 `json:"sender_id"`
EncryptedBody []byte `json:"-"` // never send raw encrypted body
Plaintext string `json:"plaintext,omitempty"` // используется только после расшифровки
AttachmentID *int64 `json:"attachment_id,omitempty"`
IsRead bool `json:"is_read"`
CreatedAt time.Time `json:"created_at"`
}
// MessageResponse используется для отправки сообщений клиенту
type MessageResponse struct {
ID int64 `json:"id"`
ChatID int64 `json:"chat_id"`
SenderID int64 `json:"sender_id"`
Plaintext string `json:"plaintext"` // расшифрованный текст
Attachment *Attachment `json:"attachment,omitempty"`
IsRead bool `json:"is_read"`
CreatedAt time.Time `json:"created_at"`
}
// SendMessageRequest DTO для отправки сообщения
type SendMessageRequest struct {
ChatID int64 `json:"chat_id"`
Plaintext string `json:"plaintext"`
AttachmentID *int64 `json:"attachment_id,omitempty"`
}
// EditMessageRequest DTO для редактирования сообщения
type EditMessageRequest struct {
Plaintext string `json:"plaintext"`
}
// GetMessagesRequest DTO для запроса истории
type GetMessagesRequest struct {
Limit int `json:"limit"` // количество сообщений
Before string `json:"before"` // timestamp (RFC3339)
}