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:
@@ -87,16 +87,36 @@ export async function POST(request: Request, context: RouteContext) {
|
||||
.where(eq(users.id, user.id));
|
||||
|
||||
if (originalPost.userId !== user.id) {
|
||||
// Create notification with actor info stored directly
|
||||
await db.insert(notifications).values({
|
||||
userId: originalPost.userId,
|
||||
actorId: user.id,
|
||||
actorHandle: user.handle,
|
||||
actorDisplayName: user.displayName,
|
||||
actorAvatarUrl: user.avatarUrl,
|
||||
actorNodeDomain: null, // Local user
|
||||
postId,
|
||||
postContent: originalPost.content?.slice(0, 200) || null,
|
||||
type: 'repost',
|
||||
});
|
||||
|
||||
// Also notify bot owner if this is a bot's post
|
||||
const { notifyBotOwnerForPost } = await import('@/lib/notifications/botOwnerNotify');
|
||||
await notifyBotOwnerForPost(originalPost.userId, user.id, 'repost', postId);
|
||||
const postAuthor = await db.query.users.findFirst({
|
||||
where: eq(users.id, originalPost.userId),
|
||||
});
|
||||
if (postAuthor?.isBot && postAuthor.botOwnerId) {
|
||||
await db.insert(notifications).values({
|
||||
userId: postAuthor.botOwnerId,
|
||||
actorId: user.id,
|
||||
actorHandle: user.handle,
|
||||
actorDisplayName: user.displayName,
|
||||
actorAvatarUrl: user.avatarUrl,
|
||||
actorNodeDomain: null,
|
||||
postId,
|
||||
postContent: originalPost.content?.slice(0, 200) || null,
|
||||
type: 'repost',
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// SWARM-FIRST: Deliver repost to swarm node
|
||||
|
||||
Reference in New Issue
Block a user