You've already forked agentic-coding-workflow
改动
This commit is contained in:
@@ -84,7 +84,8 @@ func (s *conversationService) Create(ctx context.Context, userID uuid.UUID, in C
|
||||
}
|
||||
|
||||
// Get returns a conversation and its most recent messages, enforcing ownership.
|
||||
func (s *conversationService) Get(ctx context.Context, userID, id uuid.UUID) (*Conversation, []Message, error) {
|
||||
// limit caps the number of returned messages (defaults to 50 when non-positive).
|
||||
func (s *conversationService) Get(ctx context.Context, userID, id uuid.UUID, limit int) (*Conversation, []Message, error) {
|
||||
c, err := s.repo.GetConversation(ctx, id)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
@@ -92,10 +93,21 @@ func (s *conversationService) Get(ctx context.Context, userID, id uuid.UUID) (*C
|
||||
if c.UserID != userID {
|
||||
return nil, nil, errs.New(errs.CodeForbidden, "not conversation owner")
|
||||
}
|
||||
msgs, err := s.repo.ListMessagesByConversation(ctx, id, nil, 50)
|
||||
if limit <= 0 {
|
||||
limit = 50
|
||||
}
|
||||
msgs, err := s.repo.ListMessagesByConversation(ctx, id, nil, limit)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
// Populate each message's attachments for the user-facing read path.
|
||||
for i := range msgs {
|
||||
atts, err := s.repo.ListAttachmentsForMessage(ctx, msgs[i].ID)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
msgs[i].Attachments = atts
|
||||
}
|
||||
return c, msgs, nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user