attachments: Add a generated attachment conversation
This commit is contained in:
@@ -342,20 +342,34 @@ func GenerateRandomConversation() model.Conversation {
|
||||
return conversation
|
||||
}
|
||||
|
||||
func GenerateRandomMessage(participants []string) model.Message {
|
||||
var sender *string = nil
|
||||
func randomParticipant(participants []string) *string {
|
||||
if len(participants) == 1 {
|
||||
if rand.Intn(2) == 0 {
|
||||
sender = &participants[0]
|
||||
return &participants[0]
|
||||
}
|
||||
} else {
|
||||
sender = &participants[rand.Intn(len(participants))]
|
||||
}
|
||||
|
||||
return &participants[rand.Intn(len(participants))]
|
||||
}
|
||||
|
||||
func GenerateRandomMessage(participants []string) model.Message {
|
||||
sender := randomParticipant(participants)
|
||||
|
||||
return model.Message{
|
||||
Text: GenerateRandomMessageBody(),
|
||||
Guid: uuid.New().String(),
|
||||
Guid: uuid.NewString(),
|
||||
Date: model.Date(time.Now().Add(-1 * time.Duration(rand.Intn(1000000)) * time.Second)),
|
||||
Sender: sender,
|
||||
}
|
||||
}
|
||||
|
||||
func GenerateAttachmentMessage(participants []string, attachmentGuid string) model.Message {
|
||||
sender := randomParticipant(participants)
|
||||
return model.Message{
|
||||
Text: "", // todo: try using attachment character here?
|
||||
Guid: uuid.NewString(),
|
||||
Date: model.Date(time.Now().Add(-1 * time.Duration(rand.Intn(1000000)) * time.Second)),
|
||||
Sender: sender,
|
||||
AttachmentGUIDs: []string{attachmentGuid},
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user