Skip to content

Commit

Permalink
Notification verbosity increased
Browse files Browse the repository at this point in the history
  • Loading branch information
frikky committed Jun 24, 2024
1 parent bb87029 commit 0d82a69
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions notifications.go
Original file line number Diff line number Diff line change
Expand Up @@ -628,12 +628,18 @@ func CreateOrgNotification(ctx context.Context, title, description, referenceUrl
_, err := GetCache(ctx, cacheKey)
if err == nil {
// Avoiding duplicates for the same workflow+execution
//log.Printf("[DEBUG] Found cached notification for %s", referenceUrl)
if project.Environment != "cloud" {
log.Printf("[DEBUG] Found cached notification for %s", referenceUrl)
}

return nil

} else {
//log.Printf("[DEBUG] No cached notification for %s. Creating one", referenceUrl)
err := SetCache(ctx, cacheKey, []byte("1"), 31)
if project.Environment != "cloud" {
log.Printf("[DEBUG] No cached notification for %s. Creating one", referenceUrl)
}

err := SetCache(ctx, cacheKey, []byte("1"), 5)
if err != nil {
log.Printf("[ERROR] Failed saving cached notification %s: %s", cacheKey, err)
}
Expand Down Expand Up @@ -672,7 +678,6 @@ func CreateOrgNotification(ctx context.Context, title, description, referenceUrl
return err
}


generatedId := uuid.NewV4().String()
mainNotification := Notification{
Title: title,
Expand Down Expand Up @@ -725,6 +730,9 @@ func CreateOrgNotification(ctx context.Context, title, description, referenceUrl

if len(matchingNotifications) > 0 {
// FIXME: This may have bugs for old workflows with new users (not being rediscovered)
if project.Environment != "cloud" {
log.Printf("[INFO] Reopening notification with title %#v for users in org %s", title, orgId)
}

usersHandled := []string{}
// Make sure to only reopen one per user
Expand Down Expand Up @@ -1014,7 +1022,7 @@ func HandleCreateNotification(resp http.ResponseWriter, request *http.Request) {
}
}


log.Printf("[DEBUG] User %s (%s) in org %s (%s) is creating notification '%s'", user.Username, user.Id, user.ActiveOrg.Name, user.ActiveOrg.Id, notification.Title)
err = CreateOrgNotification(
ctx,
notification.Title,
Expand All @@ -1034,8 +1042,6 @@ func HandleCreateNotification(resp http.ResponseWriter, request *http.Request) {
return
}

log.Printf("[DEBUG] User %s (%s) created notification %s", user.Username, user.Id, notification.Title)

resp.WriteHeader(200)
resp.Write([]byte(`{"success": true}`))
}

0 comments on commit 0d82a69

Please sign in to comment.