-
Couldn't load subscription status.
- Fork 4.6k
Downgrade 2.3.2 #2088
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
Downgrade 2.3.2 #2088
Conversation
β¦ecessary parameters - Refactored CORS middleware setup in main.ts for improved readability and maintainability. - Removed the 'force' parameter from assertSessions method in Baileys service for consistency. - Updated related calls in useVoiceCallsBaileys to align with the new method signature.
Reviewer's GuideRefactored CORS middleware setup, streamlined LID extraction and session assertion logic in the WhatsApp integration, and downgraded the package version. Sequence diagram for updated CORS middleware setup in bootstrapsequenceDiagram
participant App
participant ConfigService
participant CorsMiddleware
App->>ConfigService: get('CORS')
App->>CorsMiddleware: cors(corsOptions)
CorsMiddleware->>ConfigService: get('CORS')
CorsMiddleware-->>App: Allow/deny request origin
Class diagram for BaileysStartupService session assertion method changeclassDiagram
class BaileysStartupService {
+baileysAssertSessions(jids: string[]): Promise<any>
}
BaileysStartupService --> Client : uses
class Client {
+assertSessions(jids: string[]): Promise<any>
}
Class diagram for streamlined LID extraction in BaileysStartupServiceclassDiagram
class BaileysStartupService {
+extractLid(numberJid: string): string | undefined
}
BaileysStartupService : - lid extraction logic simplified
File-Level Changes
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey there - I've reviewed your changes - here's some feedback:
- Consider retrieving the CORS config once outside the origin callback to avoid hitting
configService.geton every request and improve performance. - The cast
compression() as anybypasses type safetyβimport or declare the correct middleware type instead of usingany. - Youβve removed the
forceparameter frombaileysAssertSessionsand its callersβdouble-check that this preserves the intended session assertion behavior and update related interfaces or logic if needed.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Consider retrieving the CORS config once outside the origin callback to avoid hitting `configService.get` on every request and improve performance.
- The cast `compression() as any` bypasses type safetyβimport or declare the correct middleware type instead of using `any`.
- Youβve removed the `force` parameter from `baileysAssertSessions` and its callersβdouble-check that this preserves the intended session assertion behavior and update related interfaces or logic if needed.
## Individual Comments
### Comment 1
<location> `src/api/integrations/channel/whatsapp/whatsapp.baileys.service.ts:3370` </location>
<code_context>
- : numberJid.includes('@lid')
- ? numberJid.split('@')[1]
- : undefined;
+ const lid = numberJid.includes('@lid') ? numberJid.split('@')[1] : undefined;
return new OnWhatsAppDto(
numberJid,
</code_context>
<issue_to_address>
**question:** The new lid extraction logic may not handle all edge cases.
The new logic may miss cases where numberVerified.lid is set but numberJid lacks '@lid'. Please review if this could impact functionality.
</issue_to_address>
### Comment 2
<location> `src/api/integrations/channel/whatsapp/voiceCalls/useVoiceCallsBaileys.ts:74` </location>
<code_context>
socket.on('assertSessions', async (jids, force, callback) => {
try {
- const response = await baileys_sock.assertSessions(jids, force);
+ const response = await baileys_sock.assertSessions(jids);
callback(response);
</code_context>
<issue_to_address>
**question (bug_risk):** The removal of the 'force' argument may affect voice call session assertions.
Verify that removing the 'force' parameter does not break any session assertion scenarios.
</issue_to_address>
### Comment 3
<location> `src/api/integrations/channel/whatsapp/whatsapp.baileys.service.ts:4560-4562` </location>
<code_context>
const response = await this.client.assertSessions(jids);
return response;
</code_context>
<issue_to_address>
**suggestion (code-quality):** Inline variable that is immediately returned ([`inline-immediately-returned-variable`](https://docs.sourcery.ai/Reference/Rules-and-In-Line-Suggestions/TypeScript/Default-Rules/inline-immediately-returned-variable))
```suggestion
return await this.client.assertSessions(jids);
```
<br/><details><summary>Explanation</summary>Something that we often see in people's code is assigning to a result variable
and then immediately returning it.
Returning the result directly shortens the code and removes an unnecessary
variable, reducing the mental load of reading the function.
Where intermediate variables can be useful is if they then get used as a
parameter or a condition, and the name can act like a comment on what the
variable represents. In the case where you're returning it from a function, the
function name is there to tell you what the result is, so the variable name
is unnecessary.
</details>
</issue_to_address>Help me be more useful! Please click π or π on each comment and I'll use the feedback to improve your reviews.
| : numberJid.includes('@lid') | ||
| ? numberJid.split('@')[1] | ||
| : undefined; | ||
| const lid = numberJid.includes('@lid') ? numberJid.split('@')[1] : undefined; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
question: The new lid extraction logic may not handle all edge cases.
The new logic may miss cases where numberVerified.lid is set but numberJid lacks '@lid'. Please review if this could impact functionality.
| socket.on('assertSessions', async (jids, force, callback) => { | ||
| try { | ||
| const response = await baileys_sock.assertSessions(jids, force); | ||
| const response = await baileys_sock.assertSessions(jids); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
question (bug_risk): The removal of the 'force' argument may affect voice call session assertions.
Verify that removing the 'force' parameter does not break any session assertion scenarios.
| const response = await this.client.assertSessions(jids); | ||
|
|
||
| return response; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion (code-quality): Inline variable that is immediately returned (inline-immediately-returned-variable)
| const response = await this.client.assertSessions(jids); | |
| return response; | |
| return await this.client.assertSessions(jids); | |
Explanation
Something that we often see in people's code is assigning to a result variableand then immediately returning it.
Returning the result directly shortens the code and removes an unnecessary
variable, reducing the mental load of reading the function.
Where intermediate variables can be useful is if they then get used as a
parameter or a condition, and the name can act like a comment on what the
variable represents. In the case where you're returning it from a function, the
function name is there to tell you what the result is, so the variable name
is unnecessary.
π Description
π Related Issue
Closes #(issue_number)
π§ͺ Type of Change
π§ͺ Testing
πΈ Screenshots (if applicable)
β Checklist
π Additional Notes
Summary by Sourcery
Refactor middleware and service logic in main and WhatsApp Baileys integration, remove unused parameters, and revert version to 2.3.2
Enhancements:
Chores: