Files
Memoh/internal/message/types.go
T
BBQ ca5c6a1866 refactor(core): restructure conversation, channel and message domains
- Rename chat module to conversation with flow-based architecture
- Move channelidentities into channel/identities subpackage
- Add channel/route for routing logic
- Add message service with event hub
- Add MCP providers: container, directory, schedule
- Refactor Feishu/Telegram adapters with directory and stream support
- Add platform management page and channel badges in web UI
- Update database schema for conversations, messages and channel routes
- Add @memoh/shared package for cross-package type definitions
2026-02-12 15:34:40 +08:00

53 lines
2.0 KiB
Go

package message
import (
"context"
"encoding/json"
"time"
)
// Message represents a single persisted bot message.
type Message struct {
ID string `json:"id"`
BotID string `json:"bot_id"`
RouteID string `json:"route_id,omitempty"`
SenderChannelIdentityID string `json:"sender_channel_identity_id,omitempty"`
SenderUserID string `json:"sender_user_id,omitempty"`
Platform string `json:"platform,omitempty"`
ExternalMessageID string `json:"external_message_id,omitempty"`
SourceReplyToMessageID string `json:"source_reply_to_message_id,omitempty"`
Role string `json:"role"`
Content json.RawMessage `json:"content"`
Metadata map[string]any `json:"metadata,omitempty"`
CreatedAt time.Time `json:"created_at"`
}
// PersistInput is the input for persisting a message.
type PersistInput struct {
BotID string
RouteID string
SenderChannelIdentityID string
SenderUserID string
Platform string
ExternalMessageID string
SourceReplyToMessageID string
Role string
Content json.RawMessage
Metadata map[string]any
}
// Writer defines write behavior needed by the inbound router.
type Writer interface {
Persist(ctx context.Context, input PersistInput) (Message, error)
}
// Service defines message read/write behavior.
type Service interface {
Writer
List(ctx context.Context, botID string) ([]Message, error)
ListSince(ctx context.Context, botID string, since time.Time) ([]Message, error)
ListLatest(ctx context.Context, botID string, limit int32) ([]Message, error)
ListBefore(ctx context.Context, botID string, before time.Time, limit int32) ([]Message, error)
DeleteByBot(ctx context.Context, botID string) error
}