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.
34 lines
No EOL
835 B
TypeScript
34 lines
No EOL
835 B
TypeScript
|
|
|
|
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`
|
|
} |