Improved push notifications

This commit is contained in:
2017-07-15 01:32:06 +02:00
parent 92a540e024
commit 460d90d957
7 changed files with 78 additions and 22 deletions

View File

@ -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"
}

View File

@ -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")