Add HTTP /v1 MVC, TCP send path, groups with server-side member-avatar collage, object-storage upload, and friends/favorites around the architecture-v3 layout. Co-authored-by: Cursor <cursoragent@cursor.com>
37 lines
1.0 KiB
Go
37 lines
1.0 KiB
Go
// Package logic is the message send and history use-case layer.
|
|
package logic
|
|
|
|
import (
|
|
"context"
|
|
|
|
"spark-server/internal/module/message/entity"
|
|
)
|
|
|
|
type Repository interface {
|
|
Create(ctx context.Context, message *entity.Message) error
|
|
GetByID(ctx context.Context, id int64) (*entity.Message, error)
|
|
GetByClientMsgID(ctx context.Context, senderID, conversationID int64, clientMsgID string) (*entity.Message, error)
|
|
ListByConversation(ctx context.Context, conversationID, lastMsgID int64, limit int) ([]*entity.Message, error)
|
|
}
|
|
|
|
type SendRequest struct {
|
|
ConversationID int64
|
|
SenderID int64
|
|
DeviceID uint64
|
|
ClientMsgID string
|
|
MsgID int64
|
|
Content *entity.Content
|
|
}
|
|
|
|
type SendResponse struct {
|
|
MsgID int64
|
|
ClientMsgID string
|
|
ServerTimeMS int64
|
|
}
|
|
|
|
// Service owns persist + enqueue. SEND_ACK happens only after both succeed.
|
|
type Service interface {
|
|
GenerateMsgID(ctx context.Context) (int64, error)
|
|
SendMessage(ctx context.Context, req *SendRequest) (*SendResponse, error)
|
|
}
|