feat(notifications): Refactor notification system and consolidate interaction handlers

- Remove dedicated bot owner notification utility in favor of unified notification system
- Update all interaction endpoints (follow, like, mention, repost) to use consolidated notification flow
- Refactor notification route to handle all interaction types through single endpoint
- Update posts endpoints to trigger notifications through unified system
- Add database migration snapshot for notification schema changes
- Simplify notification logic by removing redundant bot owner notification module
- Improve notification consistency across all user interactions and post operations
This commit is contained in:
Christomatt
2026-01-26 12:45:35 +01:00
parent 17c68a99bf
commit 12f515b7fb
14 changed files with 3935 additions and 263 deletions
+8 -1
View File
@@ -325,8 +325,15 @@ export const likesRelations = relations(likes, ({ one }) => ({
export const notifications = pgTable('notifications', {
id: uuid('id').primaryKey().defaultRandom(),
userId: uuid('user_id').notNull().references(() => users.id, { onDelete: 'cascade' }),
actorId: uuid('actor_id').notNull().references(() => users.id, { onDelete: 'cascade' }),
// Actor info - stored directly instead of referencing placeholder users
actorId: uuid('actor_id').references(() => users.id, { onDelete: 'cascade' }), // Optional - only for local actors
actorHandle: text('actor_handle').notNull(), // e.g., "user" or "user@remote.node"
actorDisplayName: text('actor_display_name'),
actorAvatarUrl: text('actor_avatar_url'),
actorNodeDomain: text('actor_node_domain'), // null for local actors
// Post reference
postId: uuid('post_id').references(() => posts.id, { onDelete: 'cascade' }),
postContent: text('post_content'), // Cached content for display
type: text('type').notNull(), // follow | like | repost | mention
readAt: timestamp('read_at'),
createdAt: timestamp('created_at').defaultNow().notNull(),