Skip to content
This repository was archived by the owner on Sep 3, 2025. It is now read-only.

Conversation

@whitdog47
Copy link
Contributor

This pull request introduces a new scheduled task to ensure that the participant list for incidents is kept in sync with the members of associated Slack conversations. Additionally, it optimizes Slack API calls by implementing a caching mechanism to improve efficiency.

Key Changes

  1. Scheduled Task for Member Sync:

    • Added a new scheduled task incident_sync_members that runs every hour.
    • This task checks all active and stable incidents to ensure that all members of the associated Slack conversations are included in the incident's participant list.
    • If any members are missing, they are automatically added as observers.
  2. Slack API Enhancements:

    • Introduced a WebClientWrapper class to ensure that Slack API client instances with the same token are treated as equal for caching purposes.
    • Implemented caching for several Slack API calls to reduce redundant requests and improve performance.
    • Added a new method get_all_member_emails to fetch all member emails from a Slack conversation, which is utilized in the member sync task.
  3. Code Refactoring:

    • Refactored existing Slack API methods to use the new caching mechanism.
    • Updated the SlackAPIGetEndpoints enum to include the conversations_members endpoint.

Files Changed

  • src/dispatch/incident/scheduled.py: Added the incident_sync_members function.
  • src/dispatch/plugins/dispatch_slack/enums.py: Updated to include the new Slack API endpoint.
  • src/dispatch/plugins/dispatch_slack/plugin.py: Added the get_all_member_emails method.
  • src/dispatch/plugins/dispatch_slack/service.py: Implemented caching for Slack API calls and refactored existing methods.

Fixes DISDEV-66.

@whitdog47 whitdog47 added enhancement New feature or request techdebt labels Nov 13, 2024
@whitdog47 whitdog47 changed the title Enhancement/keep participant list in sync feat(scheduler): keep participant list in sync Nov 13, 2024
@whitdog47 whitdog47 marked this pull request as ready for review November 13, 2024 04:06
@mvilanova
Copy link
Contributor

Looks good to me. Do we know why conversation and incident membership is getting out of sync?

@whitdog47 whitdog47 merged commit 1971a33 into master Nov 14, 2024
8 checks passed
@whitdog47 whitdog47 deleted the enhancement/keep-participant-list-in-sync branch November 14, 2024 04:23
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

enhancement New feature or request techdebt

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants