attachments: Add a generated attachment conversation
This commit is contained in:
@@ -1,17 +1,24 @@
|
||||
package server
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
_ "embed"
|
||||
"io"
|
||||
"os"
|
||||
"path"
|
||||
"sort"
|
||||
"time"
|
||||
|
||||
"code.severnaya.net/kordophone-mock/v2/data"
|
||||
"code.severnaya.net/kordophone-mock/v2/model"
|
||||
"code.severnaya.net/kordophone-mock/v2/resources"
|
||||
"github.com/google/uuid"
|
||||
"github.com/rs/zerolog/log"
|
||||
)
|
||||
|
||||
const VERSION = "KordophoneMock-2.6"
|
||||
const VERSION string = "KordophoneMock-2.6"
|
||||
|
||||
var ATTACHMENT_CONVO_DISP_NAME string = "Attachments"
|
||||
|
||||
const (
|
||||
AUTH_USERNAME = "test"
|
||||
@@ -129,6 +136,26 @@ func (s *Server) PopulateWithTestData() {
|
||||
convo.LastMessagePreview = lastMessage.Text
|
||||
}
|
||||
|
||||
// Also add an "attachment" conversation
|
||||
attachmentConversation := model.Conversation{
|
||||
Participants: []string{"Attachments"},
|
||||
DisplayName: &ATTACHMENT_CONVO_DISP_NAME,
|
||||
UnreadCount: 0,
|
||||
Guid: uuid.New().String(),
|
||||
Date: model.Date(time.Now()),
|
||||
}
|
||||
|
||||
cs = append(cs, attachmentConversation)
|
||||
|
||||
reader := bytes.NewReader(resources.TestAttachmentData)
|
||||
attachmentGUID, err := s.attachmentStore.StoreAttachment("test.jpg", reader)
|
||||
if err != nil {
|
||||
log.Fatal().Msgf("Error storing test attachment: %s", err)
|
||||
} else {
|
||||
attachmentMessage := data.GenerateAttachmentMessage(attachmentConversation.Participants, *attachmentGUID)
|
||||
s.AppendMessageToConversation(&attachmentConversation, attachmentMessage)
|
||||
}
|
||||
|
||||
s.conversations = cs
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user