Repository navigation
Conversation
Reviewer's GuideAdds a guarded POST endpoint that validates a chat and boolean limit-sharing flag, forwards the toggle as a Baileys WhatsApp message, and returns structured success or internal-error responses. Sequence diagram for the limit-sharing chat updatesequenceDiagram
actor Client
participant Router as ChatRouter
participant Controller as ChatController
participant Service as BaileysStartupService
participant WhatsApp as BaileysWhatsApp
Client->>Router: POST /chat/updateLimitSharing/{instance}
Router->>Router: dataValidate(request, limitSharingSchema)
Router->>Controller: updateLimitSharing(instanceName, data)
Controller->>Service: updateLimitSharing(data)
Service->>Service: createJid(data.chat)
Service->>WhatsApp: sendMessage(remoteJid, limitSharing)
WhatsApp-->>Service: response
Service-->>Controller: chatId, limitSharing, message
Controller-->>Client: 201 Created
Flow diagram for limit-sharing validation and error handlingflowchart TD
A[POST updateLimitSharing] --> B{Valid chat and boolean limitSharing?}
B -->|No| C[Validation error]
B -->|Yes| D[Baileys sendMessage]
D -->|Success| E[Return chatId, limitSharing, message]
D -->|Failure| F[InternalServerErrorException]
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
|
please @piwel , we will only accept this PR if its to develop |
53d5862 to
f402aa0
Compare
|
@dpaes This PR now targets |
There was a problem hiding this comment.
Hey - I've found 3 issues
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="src/api/integrations/channel/whatsapp/whatsapp.baileys.service.ts" line_range="4280" />
<code_context>
+ } catch (error) {
+ throw new InternalServerErrorException({
+ limitSharing: false,
+ message: ['An error occurred while updating advanced chat privacy.', error.toString()],
+ });
+ }
</code_context>
<issue_to_address>
**Error message uses wrong language**
When the Baileys send operation fails, the `InternalServerErrorException` returns an English error message to the API caller, so the user-facing error is not in Portuguese.
Return a Portuguese user-facing error message and keep any technical error details out of the public response.
</issue_to_address>
### Comment 2
<location path="src/api/dto/chat.dto.ts" line_range="93-96" />
<code_context>
chat?: string;
}
+export class LimitSharingDto {
+ chat: string;
+ limitSharing: boolean;
+}
+
export class PrivacySettingDto {
</code_context>
<issue_to_address>
**DTO contract lacks documentation**
`LimitSharingDto` has no class-level or property-level JSDoc, so its purpose and the meaning or constraints of its fields are undocumented for maintainers and consumers.
Add class-level JSDoc for the DTO purpose and property-level JSDoc describing the fields and their constraints.
</issue_to_address>
### Comment 3
<location path="src/api/routes/chat.router.ts" line_range="110-119" />
<code_context>
return res.status(HttpStatus.CREATED).json(response);
})
+ .post(this.routerPath('updateLimitSharing'), ...guards, async (req, res) => {
+ const response = await this.dataValidate<LimitSharingDto>({
+ request: req,
+ schema: limitSharingSchema,
+ ClassRef: LimitSharingDto,
+ execute: (instance, data) => chatController.updateLimitSharing(instance, data),
+ });
+
+ return res.status(HttpStatus.CREATED).json(response);
+ })
.delete(this.routerPath('deleteMessageForEveryone'), ...guards, async (req, res) => {
const response = await this.dataValidate<DeleteMessage>({
</code_context>
<issue_to_address>
**New endpoint is undocumented**
The new route is registered without its required JSDoc route documentation, leaving the public endpoint’s path, request body, response, and errors undocumented for API consumers.
Add the required JSDoc documenting the method, path, description, instance parameter, DTO body, response, and errors.
</issue_to_address>Sourcery assessment
Needs a human reviewer. This sends the requested sharing setting to the chat, where it can change whether participants are restricted from sharing chat content. If the setting is wrong, copies shared while the restriction is off cannot be taken back; reverting the endpoint does not undo them.
|
The three review comments have been addressed in commit 3c485e0, and all three conversations are resolved. Both |
|
@dpaes I have moved this PR back to draft because the underlying functionality is not validated. In our July 3 test, This is tracked upstream in WhiskeySockets/Baileys#2685. That issue was closed after inactivity without a technical resolution. The three review comments are fixed, and the build and lint pass locally, but these checks do not demonstrate that WhatsApp applies the setting. This PR should remain a draft until a supported setting update is available and verified against the official WhatsApp UI. |
📋 Description
Adds a chat API endpoint to toggle WhatsApp Advanced Chat Privacy / Limit Sharing for a chat or group.
Baileys already supports sending
{ limitSharing: boolean }and emits aLIMIT_SHARINGprotocol message. This change exposes that capability through Evolution API with request DTO and JSON schema validation.Endpoint:
Payload:
{ "chat": "120363000000000000@g.us", "limitSharing": true }🔗 Related Issue
N/A
🧪 Type of Change
🧪 Testing
Validation performed:
📸 Screenshots (if applicable)
N/A
✅ Checklist
📝 Additional Notes
No live WhatsApp account manual test was performed from this checkout. Existing npm install audit/deprecation warnings are unrelated to this change.
Summary by Sourcery
Expose WhatsApp Advanced Chat Privacy controls through a validated chat API endpoint.
New Features: