feat: notify on successful autoupdate (#13903)

This commit is contained in:
Marcin Tojek
2024-07-18 15:19:12 +02:00
committed by GitHub
parent 44924cd8d8
commit fbd1d7f9a7
8 changed files with 130 additions and 11 deletions
+1
View File
@@ -9,4 +9,5 @@ import "github.com/google/uuid"
var (
TemplateWorkspaceDeleted = uuid.MustParse("f517da0b-cdc9-410f-ab89-a86107c420ed")
WorkspaceAutobuildFailed = uuid.MustParse("381df2a9-c0c0-4749-420f-80a9280c66f9")
WorkspaceAutoUpdated = uuid.MustParse("c34a0c09-0704-4cac-bd1c-0c0146811c2b")
)
@@ -0,0 +1,37 @@
package notiffake
import (
"context"
"sync"
"github.com/google/uuid"
)
type FakeNotificationEnqueuer struct {
mu sync.Mutex
Sent []*Notification
}
type Notification struct {
UserID, TemplateID uuid.UUID
Labels map[string]string
CreatedBy string
Targets []uuid.UUID
}
func (f *FakeNotificationEnqueuer) Enqueue(_ context.Context, userID, templateID uuid.UUID, labels map[string]string, createdBy string, targets ...uuid.UUID) (*uuid.UUID, error) {
f.mu.Lock()
defer f.mu.Unlock()
f.Sent = append(f.Sent, &Notification{
UserID: userID,
TemplateID: templateID,
Labels: labels,
CreatedBy: createdBy,
Targets: targets,
})
id := uuid.New()
return &id, nil
}