diff --git a/pages/notifications/api.go b/pages/notifications/api.go index 604f16b2..ff144ec2 100644 --- a/pages/notifications/api.go +++ b/pages/notifications/api.go @@ -17,14 +17,7 @@ func CountUnseen(ctx *aero.Context) string { return ctx.Error(http.StatusBadRequest, "Not logged in", nil) } - notifications := user.Notifications().Notifications() - unseen := 0 - - for _, notification := range notifications { - if notification.Seen == "" { - unseen++ - } - } + unseen := user.Notifications().CountUnseen() return ctx.Text(strconv.Itoa(unseen)) } diff --git a/patches/notification-emails/notification-emails.go b/patches/notification-emails/notification-emails.go new file mode 100644 index 00000000..3c5f973e --- /dev/null +++ b/patches/notification-emails/notification-emails.go @@ -0,0 +1,17 @@ +package main + +import ( + "fmt" + + "github.com/animenotifier/arn" +) + +func main() { + defer arn.Node.Close() + + for user := range arn.StreamUsers() { + if user.Notifications().CountUnseen() <= 10 && !user.IsActive() && user.Email != "" && len(user.AnimeList().Items) > 0 { + fmt.Println(user.Email) + } + } +}