Skip to content

fix: reuse cached group metadata before sends - #2681

Open
oscarmtz1311 wants to merge 1 commit into
evolution-foundation:mainfrom
oscarmtz1311:codex/group-metadata-cache
Open

fix: reuse cached group metadata before sends#2681
oscarmtz1311 wants to merge 1 commit into
evolution-foundation:mainfrom
oscarmtz1311:codex/group-metadata-cache

Conversation

@oscarmtz1311

@oscarmtz1311 oscarmtz1311 commented Aug 9, 2026

Copy link
Copy Markdown

Summary\n- reuse the existing group metadata cache during WhatsApp group resolution\n- remove the redundant groupMetadata round-trip before group sends\n- preserve existing cache-miss validation and cache population behavior\n\n## Validation\n- npm run db:generate\n- npm run build\n- npm run lint:check -- --no-fix\n- targeted group-cache guard and git diff --check

Summary by Sourcery

Bug Fixes:

  • Ensure WhatsApp group resolution uses the same metadata cache as the send path, preventing unnecessary network calls while preserving cache-miss validation behavior.

@sourcery-ai

sourcery-ai Bot commented Aug 9, 2026

Copy link
Copy Markdown
Contributor
Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Reuse existing WhatsApp group metadata cache instead of performing an extra round-trip before group sends, while preserving cache-miss behavior.

Sequence diagram for WhatsApp group resolution using cached metadata

sequenceDiagram
  participant BaileysStartupService
  participant GroupMetadataCache

  loop jids_groups
    BaileysStartupService->>GroupMetadataCache: getGroupMetadataCache(jid)
    alt [cache hit]
      BaileysStartupService-->>BaileysStartupService: new OnWhatsAppDto(jid, true, number)
    else [cache miss]
      BaileysStartupService-->>BaileysStartupService: new OnWhatsAppDto(jid, false, number)
    end
  end
Loading

File-Level Changes

Change Details Files
Reuse shared group metadata cache for WhatsApp group resolution in startup service.
  • Replace findGroup inner lookup with getGroupMetadataCache during group JID resolution before sends
  • Add in-line documentation explaining reuse of send-path metadata cache and removal of redundant groupMetadata request
  • Ensure behavior on cache miss remains unchanged, still marking group as non-existent when metadata is unavailable
src/api/integrations/channel/whatsapp/whatsapp.baileys.service.ts

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Hey - I've left some high level feedback:

  • In the groups resolution path, replacing findGroup({ groupJid: jid }, 'inner') with getGroupMetadataCache(jid) changes behavior on cache misses; consider adding a fallback to the previous resolution logic (or explicitly ensuring cache population before this call) to avoid false negatives when metadata isn't yet cached.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- In the groups resolution path, replacing `findGroup({ groupJid: jid }, 'inner')` with `getGroupMetadataCache(jid)` changes behavior on cache misses; consider adding a fallback to the previous resolution logic (or explicitly ensuring cache population before this call) to avoid false negatives when metadata isn't yet cached.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

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.

1 participant