Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
368 changes: 164 additions & 204 deletions apps/sim/app/api/chat/[identifier]/otp/route.ts

Large diffs are not rendered by default.

10 changes: 7 additions & 3 deletions apps/sim/app/api/notifications/poll/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,17 @@ export async function GET(request: NextRequest) {
const requestId = nanoid()
logger.info(`Inactivity alert polling triggered (${requestId})`)

let lockAcquired = false

try {
const authError = verifyCronAuth(request, 'Inactivity alert polling')
if (authError) {
return authError
}

const locked = await acquireLock(LOCK_KEY, requestId, LOCK_TTL_SECONDS)
lockAcquired = await acquireLock(LOCK_KEY, requestId, LOCK_TTL_SECONDS)

if (!locked) {
if (!lockAcquired) {
return NextResponse.json(
{
success: true,
Expand Down Expand Up @@ -57,6 +59,8 @@ export async function GET(request: NextRequest) {
{ status: 500 }
)
} finally {
await releaseLock(LOCK_KEY).catch(() => {})
if (lockAcquired) {
await releaseLock(LOCK_KEY, requestId).catch(() => {})
}
}
}
4 changes: 3 additions & 1 deletion apps/sim/app/api/webhooks/poll/gmail/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ export async function GET(request: NextRequest) {
{ status: 500 }
)
} finally {
await releaseLock(LOCK_KEY).catch(() => {})
if (lockValue) {
await releaseLock(LOCK_KEY, lockValue).catch(() => {})
}
}
}
4 changes: 3 additions & 1 deletion apps/sim/app/api/webhooks/poll/outlook/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ export async function GET(request: NextRequest) {
{ status: 500 }
)
} finally {
await releaseLock(LOCK_KEY).catch(() => {})
if (lockValue) {
await releaseLock(LOCK_KEY, lockValue).catch(() => {})
}
}
}
4 changes: 3 additions & 1 deletion apps/sim/app/api/webhooks/poll/rss/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ export async function GET(request: NextRequest) {
{ status: 500 }
)
} finally {
await releaseLock(LOCK_KEY).catch(() => {})
if (lockValue) {
await releaseLock(LOCK_KEY, lockValue).catch(() => {})
}
}
}
Loading