Initial commit: Эфир мессенджер
This commit is contained in:
45
internal/models/message.go
Normal file
45
internal/models/message.go
Normal 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)
|
||||
}
|
||||
Reference in New Issue
Block a user