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
+19 -3
View File
@@ -152,17 +152,33 @@ export async function POST(request: Request) {
});
if (mentionedUser && mentionedUser.id !== user.id && !mentionedUser.isSuspended) {
// Create notification for the mentioned user
// Create notification for the mentioned user with actor info stored directly
await db.insert(notifications).values({
userId: mentionedUser.id,
actorId: user.id,
actorHandle: user.handle,
actorDisplayName: user.displayName,
actorAvatarUrl: user.avatarUrl,
actorNodeDomain: null, // Local user
postId: post.id,
postContent: post.content?.slice(0, 200) || null,
type: 'mention',
});
// Also notify bot owner if this is a bot being mentioned
const { notifyBotOwnerForPost } = await import('@/lib/notifications/botOwnerNotify');
await notifyBotOwnerForPost(mentionedUser.id, user.id, 'mention', post.id);
if (mentionedUser.isBot && mentionedUser.botOwnerId) {
await db.insert(notifications).values({
userId: mentionedUser.botOwnerId,
actorId: user.id,
actorHandle: user.handle,
actorDisplayName: user.displayName,
actorAvatarUrl: user.avatarUrl,
actorNodeDomain: null,
postId: post.id,
postContent: post.content?.slice(0, 200) || null,
type: 'mention',
});
}
}
}
} catch (err) {