Files
DowntownerArchive/shared/schema.ts
Tommy Parnell c7cd028f8c Assistant checkpoint: Add notification settings and subscription filtering
Assistant generated file changes:
- shared/schema.ts: Add notification settings table
- server/storage.ts: Add notification settings methods
- server/routes.ts: Use active subscriptions for notifications, Add notification settings endpoint

---

User prompt:

save notification settings and push notifications when newsletter is imported
2025-02-15 19:55:13 +00:00

56 lines
1.9 KiB
TypeScript

import { pgTable, text, serial, date, timestamp } from "drizzle-orm/pg-core";
import { createInsertSchema } from "drizzle-zod";
import { z } from "zod";
export const newsletters = pgTable("newsletters", {
id: serial("id").primaryKey(),
title: text("title").notNull(),
date: date("date").notNull(),
url: text("url").notNull(),
description: text("description"),
thumbnail: text("thumbnail"),
content: text("content"),
last_checked: timestamp("last_checked"),
});
export const insertNewsletterSchema = createInsertSchema(newsletters).pick({
title: true,
date: true,
url: true,
description: true,
thumbnail: true,
content: true,
});
export type InsertNewsletter = z.infer<typeof insertNewsletterSchema>;
export type Newsletter = typeof newsletters.$inferSelect;
// Schema for push notification subscriptions
export const subscriptions = pgTable("subscriptions", {
id: serial("id").primaryKey(),
endpoint: text("endpoint").notNull(),
auth: text("auth").notNull(),
p256dh: text("p256dh").notNull(),
created_at: timestamp("created_at").defaultNow(),
});
export const insertSubscriptionSchema = createInsertSchema(subscriptions).pick({
endpoint: true,
auth: true,
p256dh: true,
});
export type InsertSubscription = z.infer<typeof insertSubscriptionSchema>;
export type Subscription = typeof subscriptions.$inferSelect;
export const notificationSettings = pgTable("notification_settings", {
id: serial("id").primaryKey(),
subscription_id: serial("subscription_id").references(() => subscriptions.id),
newsletter_notifications: boolean("newsletter_notifications").default(true),
created_at: timestamp("created_at").defaultNow(),
updated_at: timestamp("updated_at").defaultNow(),
});
export const insertNotificationSettingsSchema = createInsertSchema(notificationSettings);
export type InsertNotificationSettings = z.infer<typeof insertNotificationSettingsSchema>;
export type NotificationSettings = typeof notificationSettings.$inferSelect;