fix(swarm): Add error handling for notification creation in interactions
- Wrap notification creation in try-catch blocks for follow interactions - Wrap notification creation in try-catch blocks for like interactions - Wrap notification creation in try-catch blocks for repost interactions - Add console logging for successful notification creation with interaction details - Add error logging for failed notification creation to aid in debugging - Prevent interaction failures from cascading due to notification errors
This commit is contained in:
@@ -104,11 +104,16 @@ export async function POST(request: NextRequest) {
|
||||
}
|
||||
|
||||
// Create notification
|
||||
try {
|
||||
await db.insert(notifications).values({
|
||||
userId: targetUser.id,
|
||||
actorId: remoteUser.id,
|
||||
type: 'follow',
|
||||
});
|
||||
console.log(`[Swarm] Created follow notification for @${data.targetHandle} from ${remoteHandle}`);
|
||||
} catch (notifError) {
|
||||
console.error(`[Swarm] Failed to create notification:`, notifError);
|
||||
}
|
||||
|
||||
// Also notify bot owner if this is a bot being followed
|
||||
const { notifyBotOwnerForFollow } = await import('@/lib/notifications/botOwnerNotify');
|
||||
|
||||
@@ -77,12 +77,17 @@ export async function POST(request: NextRequest) {
|
||||
}
|
||||
|
||||
// Create notification
|
||||
try {
|
||||
await db.insert(notifications).values({
|
||||
userId: post.userId,
|
||||
actorId: remoteUser.id,
|
||||
postId: data.postId,
|
||||
type: 'like',
|
||||
});
|
||||
console.log(`[Swarm] Created like notification for post ${data.postId} from ${remoteHandle}`);
|
||||
} catch (notifError) {
|
||||
console.error(`[Swarm] Failed to create like notification:`, notifError);
|
||||
}
|
||||
|
||||
// Also notify bot owner if this is a bot's post
|
||||
const { notifyBotOwnerForPost } = await import('@/lib/notifications/botOwnerNotify');
|
||||
|
||||
@@ -72,12 +72,17 @@ export async function POST(request: NextRequest) {
|
||||
}
|
||||
|
||||
// Create notification
|
||||
try {
|
||||
await db.insert(notifications).values({
|
||||
userId: post.userId,
|
||||
actorId: remoteUser.id,
|
||||
postId: data.postId,
|
||||
type: 'repost',
|
||||
});
|
||||
console.log(`[Swarm] Created repost notification for post ${data.postId} from ${remoteHandle}`);
|
||||
} catch (notifError) {
|
||||
console.error(`[Swarm] Failed to create repost notification:`, notifError);
|
||||
}
|
||||
|
||||
// Also notify bot owner if this is a bot's post
|
||||
const { notifyBotOwnerForPost } = await import('@/lib/notifications/botOwnerNotify');
|
||||
|
||||
Reference in New Issue
Block a user