Make it possible to resolve notifications

This commit is contained in:
Eli Ribble 2025-11-13 16:46:30 +00:00
parent 20186f65bf
commit fc40309dd0
No known key found for this signature in database
8 changed files with 266 additions and 96 deletions

33
html.go
View file

@ -15,7 +15,6 @@ import (
"strings"
"time"
enums "github.com/Gleipnir-Technology/nidus-sync/enums"
"github.com/Gleipnir-Technology/nidus-sync/models"
"github.com/aarondl/opt/null"
//"github.com/riverqueue/river/rivershared/util/slogutil"
@ -464,38 +463,6 @@ func timeSince(t *time.Time) string {
}
}
type Notification struct {
Link string
Message string
Time time.Time
Type string
}
func notificationsForUser(ctx context.Context, u *models.User) ([]Notification, error) {
results := make([]Notification, 0)
notifications, err := u.UserNotifications().All(ctx, PGInstance.BobDB)
if err != nil {
return results, fmt.Errorf("Failed to get notifications: %v", err)
}
for _, n := range notifications {
results = append(results, Notification{
Link: n.Link,
Message: n.Message,
Time: n.Created,
Type: notificationTypeName(n.Type),
})
}
return results, nil
}
func notificationTypeName(t enums.Notificationtype) string {
switch t {
case enums.NotificationtypeOauthTokenInvalidated:
return "alert"
default:
return "unknown-type"
}
}
func renderOrError(w http.ResponseWriter, template BuiltTemplate, context interface{}) {
buf := &bytes.Buffer{}
err := template.ExecuteTemplate(buf, context)