Skip to content

Commit

Permalink
feat(notifcations): add notification when style is removed
Browse files Browse the repository at this point in the history
  • Loading branch information
Gusted committed Aug 12, 2021
1 parent 2fb0b55 commit 9490916
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
13 changes: 13 additions & 0 deletions handlers/style/ban.go
Expand Up @@ -136,6 +136,19 @@ func BanPost(c *fiber.Ctx) error {
}

go func(baseURL string, style *models.APIStyle, modLogID uint) {
// Add notification to database.
notification := models.Notification{
Seen: false,
Kind: models.KindBannedStyle,
TargetID: int(modLogID),
UserID: int(u.ID),
StyleID: int(s.ID),
}

if err := notification.Create(); err != nil {
log.Warn.Printf("Failed to create a notification for ban removal %d: %v\n", style.ID, err)
}

// Delete from search index.
if err = search.DeleteStyle(style.ID); err != nil {
log.Warn.Printf("Failed to delete style %d: %s", style.ID, err.Error())
Expand Down
1 change: 1 addition & 0 deletions models/notification.go
Expand Up @@ -9,6 +9,7 @@ type Kind int
const (
KindReview Kind = iota
KindStylePromotion
KindBannedStyle
)

type Notification struct {
Expand Down

0 comments on commit 9490916

Please sign in to comment.