Skip to content

Commit

Permalink
Update notification target to be included in model (de-)serialization (
Browse files Browse the repository at this point in the history
…#1397)

Signed-off-by: carlobortolan <[email protected]>
  • Loading branch information
carlobortolan authored Nov 5, 2024
1 parent 9945687 commit 675eb86
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
3 changes: 1 addition & 2 deletions model/notification.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,9 @@ const (
// Notification is a message (e.g. a feature alert) that is displayed to users
type Notification struct {
Model

Title *string `json:"title,omitempty"`
Body string `json:"-" gorm:"not null"`
Target NotificationTarget `json:"-" gorm:"not null; default:1"`
Target NotificationTarget `json:"target" gorm:"not null; default:1"`

// SanitizedBody is the body of the notification, converted from markdown to HTML
SanitizedBody string `json:"body" gorm:"-"`
Expand Down
6 changes: 5 additions & 1 deletion web/ts/notification-management.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@ export function createNotification(body: string, target: number, title: string |
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify(notification),
body: JSON.stringify({
title: notification.title,
body: notification.body,
target: Number(notification.target),
}),
})
.then((r) => r.json())
.then((r) => {
Expand Down

0 comments on commit 675eb86

Please sign in to comment.