initial commit
This commit is contained in:
28
backend/internal/api/convert.go
Normal file
28
backend/internal/api/convert.go
Normal file
@@ -0,0 +1,28 @@
|
||||
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
|
||||
}
|
||||
Reference in New Issue
Block a user