Fork anchor, strip all push notification code (APNs, FCM, WebPush), rename from anchor to mailship, add new database schema for subscriptions + events tables, and add HTTP API for email notification registration and NIP-9a relay push callbacks. - POST /subscription/email — register for email digests - DELETE /subscription/:key — unsubscribe - POST /notify/:id — NIP-9a relay push callback - GET /confirm?token=... — confirm email - GET /unsubscribe?token=... — unsubscribe Co-authored-by: mplorentz
28 lines
No EOL
637 B
TypeScript
28 lines
No EOL
637 B
TypeScript
import { last } from '@welshman/lib'
|
|
import type { Subscription } from './alert.js'
|
|
import { getSubscriptionByKey } from './database.js'
|
|
import { runJob } from './worker/email.js'
|
|
|
|
const key = last(process.argv)
|
|
|
|
if (!key) {
|
|
console.error('Please provide a subscription key')
|
|
process.exit(1)
|
|
}
|
|
|
|
getSubscriptionByKey(key)
|
|
.then((sub: Subscription | undefined) => {
|
|
if (!sub) {
|
|
console.error('Invalid subscription key')
|
|
return false
|
|
}
|
|
|
|
return runJob(sub)
|
|
})
|
|
.then((success: boolean) => {
|
|
process.exit(success ? 0 : 1)
|
|
})
|
|
.catch((error: Error) => {
|
|
console.error(error)
|
|
process.exit(1)
|
|
}) |