Improved push notifications
This commit is contained in:
@ -1,10 +1,10 @@
|
||||
package notifications
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
|
||||
"github.com/aerogo/aero"
|
||||
"github.com/animenotifier/arn"
|
||||
"github.com/animenotifier/notify.moe/utils"
|
||||
)
|
||||
|
||||
@ -16,13 +16,13 @@ func Test(ctx *aero.Context) string {
|
||||
return ctx.Error(http.StatusBadRequest, "Not logged in", nil)
|
||||
}
|
||||
|
||||
for _, sub := range user.PushSubscriptions().Items {
|
||||
err := sub.SendNotification("Yay, it works!")
|
||||
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
}
|
||||
notification := &arn.Notification{
|
||||
Title: "Anime Notifier",
|
||||
Message: "Yay, it works!",
|
||||
Icon: "https://" + ctx.App.Config.Domain + "/images/brand/300",
|
||||
}
|
||||
|
||||
user.SendNotification(notification)
|
||||
|
||||
return "ok"
|
||||
}
|
||||
|
@ -26,19 +26,19 @@ component Settings(user *arn.User)
|
||||
Icon("bell")
|
||||
span Notifications
|
||||
|
||||
.widget-input
|
||||
#enable-notifications.widget-input
|
||||
label Enable:
|
||||
button.action(data-action="enableNotifications", data-trigger="click")
|
||||
Icon("toggle-on")
|
||||
Icon("toggle-off")
|
||||
span Enable notifications
|
||||
|
||||
.widget-input
|
||||
#disable-notifications.widget-input
|
||||
label Disable:
|
||||
button.action(data-action="disableNotifications", data-trigger="click")
|
||||
Icon("toggle-off")
|
||||
Icon("toggle-on")
|
||||
span Disable notifications
|
||||
|
||||
.widget-input
|
||||
#test-notification.widget-input
|
||||
label Test:
|
||||
button.action(data-action="testNotification", data-trigger="click")
|
||||
Icon("paper-plane")
|
||||
|
Reference in New Issue
Block a user