Skip to content

Commit 3c012ed

Browse files
Adam GoughAdam Gough
authored andcommitted
greptile comments
1 parent 4555321 commit 3c012ed

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

apps/sim/background/teams-subscription-renewal.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,14 @@ const logger = createLogger('TeamsSubscriptionRenewal')
1414
*/
1515
export const renewTeamsSubscriptions = task({
1616
id: 'renew-teams-subscriptions',
17-
// Run every 2 days to catch subscriptions that expire in ~3 days
17+
// Job typically runs every 2 days; use a 48h renewal window so subs don't expire between runs
1818
run: async (_payload: Record<string, never>) => {
1919
logger.info('Starting Teams subscription renewal job')
2020

2121
try {
2222
// Find all Microsoft Teams webhooks with chat subscriptions that expire soon
23-
// Check for subscriptions expiring within the next 24 hours
24-
const expirationThreshold = new Date(Date.now() + 24 * 60 * 60 * 1000).toISOString()
23+
// Check for subscriptions expiring within the next 48 hours to align with a 2-day cadence
24+
const expirationThreshold = new Date(Date.now() + 48 * 60 * 60 * 1000).toISOString()
2525

2626
const webhooksWithWorkflows = await db
2727
.select({

apps/sim/lib/webhooks/teams-subscriptions.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ export async function createMicrosoftTeamsChatSubscription(
4444
const data = await listResponse.json()
4545
const allSubscriptions = data.value || []
4646
const chatSubscriptions = allSubscriptions.filter((sub: any) =>
47-
sub.resource?.includes('/chats/')
47+
sub.resource?.includes('/chats/') && sub.clientState === webhookData.id
4848
)
4949

5050
for (const sub of chatSubscriptions) {

0 commit comments

Comments
 (0)