2023-01-08 06:21:09 +00:00
|
|
|
import type { mastodon } from 'masto'
|
2022-12-17 23:29:16 +00:00
|
|
|
|
|
|
|
import type { UserLogin } from '~/types'
|
|
|
|
|
2023-01-01 19:24:22 +00:00
|
|
|
export type SubscriptionResult = 'subscribed' | 'notification-denied' | 'not-supported' | 'invalid-vapid-key' | 'no-user'
|
2022-12-17 23:29:16 +00:00
|
|
|
export interface PushManagerSubscriptionInfo {
|
|
|
|
registration: ServiceWorkerRegistration
|
|
|
|
subscription: PushSubscription | null
|
|
|
|
}
|
|
|
|
|
|
|
|
export interface RequiredUserLogin extends Required<Omit<UserLogin, 'account' | 'pushSubscription'>> {
|
2023-01-08 06:21:09 +00:00
|
|
|
pushSubscription?: mastodon.v1.WebPushSubscription
|
2022-12-17 23:29:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
export interface CreatePushNotification {
|
2023-01-08 06:21:09 +00:00
|
|
|
alerts?: Partial<mastodon.v1.WebPushSubscriptionAlerts> | null
|
2024-01-09 08:56:15 +00:00
|
|
|
policy?: mastodon.v1.WebPushSubscriptionPolicy
|
2022-12-17 23:29:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
export type PushNotificationRequest = Record<string, boolean>
|
2024-01-09 08:56:15 +00:00
|
|
|
export type PushNotificationPolicy = Record<string, mastodon.v1.WebPushSubscriptionPolicy>
|
2022-12-23 22:56:16 +00:00
|
|
|
|
|
|
|
export interface CustomEmojisInfo {
|
|
|
|
lastUpdate: number
|
2023-01-08 06:21:09 +00:00
|
|
|
emojis: mastodon.v1.CustomEmoji[]
|
2022-12-23 22:56:16 +00:00
|
|
|
}
|
2023-01-13 12:54:30 +00:00
|
|
|
|
2023-02-04 18:43:24 +00:00
|
|
|
export type PushSubscriptionErrorCode = 'too_many_registrations' | 'vapid_not_supported' | 'invalid_vapid_key'
|
|
|
|
|
2023-01-13 12:54:30 +00:00
|
|
|
export class PushSubscriptionError extends Error {
|
|
|
|
code: PushSubscriptionErrorCode
|
|
|
|
constructor(code: PushSubscriptionErrorCode, message?: string) {
|
|
|
|
super(message)
|
|
|
|
this.code = code
|
|
|
|
}
|
|
|
|
}
|