Private
Public Access
1
0

prompt: adds ls, help, mark

This commit is contained in:
2023-06-23 00:32:17 -07:00
parent 191cffd4cf
commit 06046ac266
5 changed files with 209 additions and 80 deletions

View File

@@ -54,11 +54,21 @@ func (s *Server) Conversations() []model.Conversation {
return s.conversations
}
func (s *Server) SortedConversations() []model.Conversation {
conversations := s.Conversations()
sort.Slice(conversations, func(i, j int) bool {
return conversations[i].Date.After(conversations[j].Date)
})
return conversations
}
func (s *Server) ConversationForGUID(guid string) (*model.Conversation, error) {
var conversation *model.Conversation = nil
for _, c := range s.conversations {
for i := range s.conversations {
c := &s.conversations[i]
if c.Guid == guid {
conversation = &c
conversation = c
break
}
}
@@ -119,7 +129,7 @@ func (s *Server) CheckBearerToken(token string) bool {
return s.authenticateToken(token)
}
func (s *Server) MessagesForConversation(conversation model.Conversation) []model.Message {
func (s *Server) MessagesForConversation(conversation *model.Conversation) []model.Message {
messages := s.messageStore[conversation.Guid]
sort.Slice(messages, func(i int, j int) bool {
return messages[i].Date.Before(messages[j].Date)