-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Ignore events that are not messages (like EPHEMERAL_SYNC_RESPONSE) #1732
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
rafwell
wants to merge
5
commits into
EvolutionAPI:develop
Choose a base branch
from
rafwell:testmsg
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+32
−1
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Reviewer's GuideEnhances ChatwootService to gracefully handle non-message events and missing key properties by adding type-based filtering, null-checks with logging, and standardizing method calls to prevent runtime errors. Sequence diagram for handling non-message events in eventWhatsappsequenceDiagram
participant Client
participant ChatwootService
participant Logger
participant waMonitor
Client->>ChatwootService: eventWhatsapp(event, instance, body)
alt body.type is not 'message' or 'conversation'
ChatwootService->>Logger: verbose("Ignoring non-message event type: ...")
ChatwootService-->>Client: return
else body.type is 'message' or 'conversation'
ChatwootService->>waMonitor: access waInstances
Note over ChatwootService,waMonitor: Continue normal processing
end
Sequence diagram for handling missing key in createConversation and messages.upsertsequenceDiagram
participant Client
participant ChatwootService
participant Logger
Client->>ChatwootService: createConversation(instance, body)
alt body.key is null or undefined
ChatwootService->>Logger: warn("body.key is null or undefined in createConversation...")
ChatwootService-->>Client: return null
else body.key exists
Note over ChatwootService: Continue normal processing
end
Client->>ChatwootService: eventWhatsapp('messages.upsert', instance, body)
alt body.key is null or undefined
ChatwootService->>Logger: warn("body.key is null or undefined...")
ChatwootService-->>Client: return
else body.key exists
Note over ChatwootService: Continue normal processing
end
Sequence diagram for handling messages.edit with missing key.id or non-message typesequenceDiagram
participant Client
participant ChatwootService
participant Logger
Client->>ChatwootService: eventWhatsapp('messages.edit', instance, body)
alt body.type is not 'message'
ChatwootService->>Logger: verbose("Ignoring non-message event type: ...")
ChatwootService-->>Client: return
else body.key.id is null or undefined
ChatwootService->>Logger: warn("body.key.id is null or undefined in messages.edit...")
ChatwootService-->>Client: return
else body.type is 'message' and body.key.id exists
Note over ChatwootService: Continue normal processing
end
File-Level Changes
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
In some cases the body.key.id doesn't exists. That cause an error.
Look my log for debug purposes.
Summary by Sourcery
Add guard clauses to prevent errors from non-message events and missing body.key or key.id across ChatwootService methods
Bug Fixes: