fix: remove pre-eslint unused-variable errors across src/
Remove 21 unused imports/variables that caused eslint failures:
- actions.ts (2): Subscription type import, getCronExpression import
- alert.ts (4): CronExpressionParser, tryCatch, int, HOUR
- digest.ts (12): now, nth, nthEq, dateToSeconds, getIdFilters,
getReplyFilters, Loader, AdapterContext, makeLoader, SocketAdapter,
call, loadRelaySelections
- env.ts (1): netContext
- worker/email.ts (1): purgeJob variable (kept CronJob side-effect)
All unused symbols were pre-existing, not related to changed files.
tsc --noEmit passes; script/checks now returns 0 on the src check.
2026-09-10 15:58:05 +00:00
|
|
|
|
2026-08-18 16:21:22 +00:00
|
|
|
|
|
|
|
|
export type Subscription = {
|
|
|
|
|
id: string
|
|
|
|
|
key: string
|
|
|
|
|
pubkey: string
|
|
|
|
|
email: string
|
|
|
|
|
frequency: string
|
|
|
|
|
created_at: number
|
|
|
|
|
confirmed_at?: number
|
|
|
|
|
unsubscribed_at?: number
|
|
|
|
|
last_digest_at?: number
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export const getSubscriptionError = (sub: Subscription) => {
|
|
|
|
|
if (!sub.email?.includes('@')) {
|
|
|
|
|
return 'Please provide a valid email address'
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!['daily', 'weekly'].includes(sub.frequency)) {
|
|
|
|
|
return 'Frequency must be "daily" or "weekly"'
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Daily: fire at 17:00 UTC. Weekly: fire Monday at 17:00 UTC.
|
|
|
|
|
// Validation: just ensure frequency is valid, cron is generated internally.
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export const getCronExpression = (frequency: string, hour = 17, minute = 0) => {
|
|
|
|
|
if (frequency === 'daily') {
|
|
|
|
|
return `0 ${minute} ${hour} * * *`
|
|
|
|
|
}
|
|
|
|
|
// Weekly on Monday
|
|
|
|
|
return `0 ${minute} ${hour} * * 1`
|
|
|
|
|
}
|