Skip to content

Conversation

@waleedlatif1
Copy link
Collaborator

Summary

  • fixed gmail and outlook polling to respect disabled status

Type of Change

  • Bug fix

Testing

Tested manually

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

@vercel
Copy link

vercel bot commented Dec 4, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Preview Comments Updated (UTC)
docs Skipped Skipped Dec 4, 2025 7:19pm

@waleedlatif1 waleedlatif1 marked this pull request as ready for review December 4, 2025 19:23
@greptile-apps
Copy link
Contributor

greptile-apps bot commented Dec 4, 2025

Greptile Overview

Greptile Summary

Fixed Gmail and Outlook polling services to respect workflow deployment status by adding an inner join with the workflow table and checking workflow.isDeployed = true in addition to webhook.isActive = true.

  • Added workflow import to both polling service files
  • Modified database queries to join webhook with workflow table using webhook.workflowId = workflow.id
  • Added workflow.isDeployed = true condition to webhook filtering logic
  • Removed unused pollingInterval field from config interfaces
  • Cleaned up excessive code comments for better readability
  • Improved error handling by throwing errors instead of silently returning empty results in fetch functions

Confidence Score: 5/5

  • This PR is safe to merge with no risk
  • The changes are straightforward and logically correct. The fix properly addresses the issue by adding the workflow deployment check, which prevents polling inactive/undeployed workflows. The implementation is consistent across both Gmail and Outlook services, and the additional cleanup (removing unused fields and comments) improves code quality without affecting functionality.
  • No files require special attention

Important Files Changed

File Analysis

Filename Score Overview
apps/sim/lib/webhooks/gmail-polling-service.ts 5/5 Added inner join with workflow table to check isDeployed status, ensuring webhooks are only polled when both webhook is active and workflow is deployed. Also cleaned up comments and removed unused pollingInterval config field.
apps/sim/lib/webhooks/outlook-polling-service.ts 5/5 Added inner join with workflow table to check isDeployed status, ensuring webhooks are only polled when both webhook is active and workflow is deployed. Also cleaned up comments and removed unused pollingInterval config field.

Sequence Diagram

sequenceDiagram
    participant PS as Polling Service
    participant DB as Database
    participant WF as Workflow Table
    participant WH as Webhook Table
    participant API as Email API (Gmail/Outlook)
    participant TRG as Webhook Trigger

    PS->>DB: Query active webhooks
    DB->>WH: SELECT webhook
    DB->>WF: INNER JOIN workflow
    Note over DB,WF: Filter: webhook.isActive = true<br/>AND workflow.isDeployed = true
    DB-->>PS: Return active webhooks for deployed workflows
    
    alt No active webhooks found
        PS-->>PS: Log and exit
    else Active webhooks found
        loop For each webhook (with concurrency limit)
            PS->>DB: Get credential/userId from providerConfig
            PS->>DB: Fetch access token
            DB-->>PS: Return access token
            
            PS->>API: Fetch new emails (with filters)
            API-->>PS: Return emails
            
            alt No new emails
                PS->>DB: Update lastCheckedTimestamp
                PS->>DB: Mark webhook success (reset failedCount)
            else Emails found
                loop For each email
                    PS->>TRG: POST /api/webhooks/trigger/{path}
                    TRG-->>PS: Response
                end
                
                PS->>DB: Update lastCheckedTimestamp
                
                alt All emails failed
                    PS->>DB: Increment failedCount
                    Note over PS,DB: Auto-disable webhook<br/>if failedCount >= 10
                else Some/all succeeded
                    PS->>DB: Reset failedCount to 0
                end
            end
        end
    end
Loading

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2 files reviewed, no comments

Edit Code Review Agent Settings | Greptile

@waleedlatif1 waleedlatif1 merged commit 6bfb643 into staging Dec 4, 2025
9 checks passed
@waleedlatif1 waleedlatif1 deleted the fix/polling branch December 4, 2025 19:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants