File tree Expand file tree Collapse file tree 2 files changed +4
-4
lines changed
Expand file tree Collapse file tree 2 files changed +4
-4
lines changed Original file line number Diff line number Diff line change @@ -14,14 +14,14 @@ const logger = createLogger('TeamsSubscriptionRenewal')
1414 */
1515export 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 ( {
Original file line number Diff line number Diff 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 ) {
You can’t perform that action at this time.
0 commit comments