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
+16 -2
View File
@@ -263,15 +263,29 @@ export async function POST(request: Request, context: RouteContext) {
});
if (currentUser.id !== targetUser.id) {
// Create notification with actor info stored directly
await db.insert(notifications).values({
userId: targetUser.id,
actorId: currentUser.id,
actorHandle: currentUser.handle,
actorDisplayName: currentUser.displayName,
actorAvatarUrl: currentUser.avatarUrl,
actorNodeDomain: null, // Local user
type: 'follow',
});
// Also notify bot owner if this is a bot being followed
const { notifyBotOwnerForFollow } = await import('@/lib/notifications/botOwnerNotify');
await notifyBotOwnerForFollow(targetUser.id, currentUser.id);
if (targetUser.isBot && targetUser.botOwnerId) {
await db.insert(notifications).values({
userId: targetUser.botOwnerId,
actorId: currentUser.id,
actorHandle: currentUser.handle,
actorDisplayName: currentUser.displayName,
actorAvatarUrl: currentUser.avatarUrl,
actorNodeDomain: null,
type: 'follow',
});
}
}
// Update counts