fix(instance): stop Connect/advanced-settings from wiping config - #136
Open
cesar-carlos wants to merge 1 commit into
Open
fix(instance): stop Connect/advanced-settings from wiping config#136cesar-carlos wants to merge 1 commit into
cesar-carlos wants to merge 1 commit 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
|
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
events,rabbitmqEnable, and advanced flags (Instance settings silently reset to defaults (rabbitmqEnable, events, flags) without container restart #111).POST /instance/connectis now a partial update: empty fields keep persisted values;MESSAGEis only the default wheneventsis empty.PUT /instance/{id}/advanced-settingsuses*boolso omitted keys are not written asfalse.Closes #111
Test plan
go test ./pkg/instance/service/ ./pkg/instance/repository/go vet ./pkg/instance/...go build ./cmd/evolution-go/POST /instance/connectwith{}/ empty strings and confirm settings stayPUT .../advanced-settingswith only{"alwaysOnline":true}and confirm other flags unchangedMade with Cursor
Summary by Sourcery
Make instance connect and advanced settings updates partial to avoid unintentionally resetting existing configuration.
Bug Fixes:
Enhancements:
Tests: