29 lines
530 B
Go
29 lines
530 B
Go
package api
|
|
|
|
import (
|
|
"reichard.io/aethera/internal/store"
|
|
"reichard.io/aethera/pkg/slices"
|
|
)
|
|
|
|
func toChat(c *store.Chat) *Chat {
|
|
chat := &Chat{
|
|
ID: c.ID,
|
|
CreatedAt: c.CreatedAt,
|
|
Title: c.Title,
|
|
MessageCount: len(c.Messages),
|
|
Messages: c.Messages,
|
|
}
|
|
|
|
if firstMessage, found := slices.First(c.Messages); found {
|
|
chat.InitialMessage = firstMessage.Content
|
|
}
|
|
|
|
return chat
|
|
}
|
|
|
|
func toChatNoMessages(c *store.Chat) *Chat {
|
|
chat := toChat(c)
|
|
chat.Messages = []*store.Message{}
|
|
return chat
|
|
}
|