pinafore/routes/_api/pushSubscription.js
Sorin Davidoi e45af16bf9 Push notifications (#579)
* feat: Push notifications

* feat: Feature-detect push notifications support

* feat: Prompt user to reauthenticate when missing push scope

* fix(service-worker): Add tags to notifications

* feat: Push notification actions for mentions
2018-10-06 13:06:10 -07:00

27 lines
914 B
JavaScript

import { auth, basename } from './utils'
import { post, put, get, del } from '../_utils/ajax'
export async function postSubscription (instanceName, accessToken, subscription, alerts) {
const url = `${basename(instanceName)}/api/v1/push/subscription`
return post(url, { subscription: subscription.toJSON(), data: { alerts } }, auth(accessToken))
}
export async function putSubscription (instanceName, accessToken, alerts) {
const url = `${basename(instanceName)}/api/v1/push/subscription`
return put(url, { data: { alerts } }, auth(accessToken))
}
export async function getSubscription (instanceName, accessToken) {
const url = `${basename(instanceName)}/api/v1/push/subscription`
return get(url, auth(accessToken))
}
export async function deleteSubscription (instanceName, accessToken) {
const url = `${basename(instanceName)}/api/v1/push/subscription`
return del(url, auth(accessToken))
}