Private
Public Access
1
0

attachments: Add a generated attachment conversation

This commit is contained in:
2024-04-07 21:06:03 -07:00
parent fa76c7eac1
commit a1349eff1b
7 changed files with 69 additions and 13 deletions

View File

@@ -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},
}
}