Repository navigation
fix(instance): preserve partial settings and enforce instance scope - #136
Open
cesar-carlos wants to merge 3 commits into
Open
cesar-carlos wants to merge 3 commits into
cesar-carlos wants to merge 3 commits into
Conversation
Connect was a destructive upsert: empty subscribe forced events=MESSAGE and empty rabbitmqEnable/webhook/nats/websocket cleared persisted values via full Save. Advanced settings PUT wrote omitted bools as false. Apply connect fields only when explicitly provided, persist with column-selective Updates, and treat AdvancedSettings bools as pointers so partial PUTs leave untouched flags alone. Closes evolution-foundation#111 Co-authored-by: Cursor <cursoragent@cursor.com>
There was a problem hiding this comment.
Sorry @cesar-carlos, you have reached your weekly rate limit of 500000 diff characters.
Please try again later or upgrade to continue using Sourcery
Reviewer's GuideMakes /instance/connect a partial update that only changes explicitly provided fields (preserving existing events and producer flags), switches advanced settings to pointer-based booleans with selective DB updates, and adds tests/utilities to validate the new merge behavior. Sequence diagram for partial /instance/connect update behaviorsequenceDiagram
actor Client
participant InstanceHandler
participant InstanceService
participant applyConnectSettings
participant InstanceRepository
participant WhatsmeowService
Client->>InstanceHandler: POST /instance/connect
InstanceHandler->>InstanceService: Connect(data, instance)
InstanceService->>applyConnectSettings: applyConnectSettings(instance, data)
applyConnectSettings-->>InstanceService: updates map[string]interface{}
alt updates not empty
InstanceService->>InstanceRepository: UpdateConnectSettings(instance.Id, updates)
InstanceRepository-->>InstanceService: error or nil
end
InstanceService->>WhatsmeowService: UpdateInstanceSettings(instance.Id)
WhatsmeowService-->>InstanceService: error or nil
InstanceService-->>InstanceHandler: instance, instance.Jid, eventString
InstanceHandler-->>Client: 200 OK with events from splitSubscribedEvents(instance.Events)
File-Level Changes
Assessment against linked issues
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
C4rlos-Mor4n
pushed a commit
to C4rlos-Mor4n/evolution-go
that referenced
this pull request
Oct 13, 2026
… branch Symbol-level comparison (go tool nm) shows rc1 = upstream 0.7.2 + evolution-foundation#117 + evolution-foundation#136 + evolution-foundation#137 + websocket write serialization + a global ClientMapsMu; all covered (same or superset) by this branch. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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
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.
Summary
Connecting with an empty or partial body could reset persisted event and producer settings. Updating a single advanced flag could also overwrite omitted flags. This change makes these operations preserve existing settings and validates access to path-based advanced settings against the authenticated instance.
Closes #111
Compatibility
HTTP JSON field names and boolean/string value types are unchanged. PUT advanced-settings intentionally supports partial updates: omitted/null fields preserve saved values, false disables a flag, and msgRejectCall: "" clears the message. Bodies must be JSON objects. Advanced-settings clients must use the matching instance UUID and instance token.
Go callers constructing AdvancedSettings must provide pointer fields, including the newly optional *string MsgRejectCall. Database schema and dependencies are unchanged. Swagger was regenerated from current source; generated definition names now reflect the repository's current module path.
Persistence and runtime synchronization are separate operations: a sync failure or read failure after a successful write may leave the new values saved.
Validation
Executed in Docker with Go 1.25.0, CGO and native media tools:
Also verified the fork's updated local main with build, vet and race tests for instance, user and send packages. No real WhatsApp session or production database was used.