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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user