Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "evolution-api",
"version": "2.3.4",
"version": "2.3.2",
"description": "Rest api for communication with WhatsApp",
"main": "./dist/main.js",
"type": "commonjs",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ export const useVoiceCallsBaileys = async (

socket.on('assertSessions', async (jids, force, callback) => {
try {
const response = await baileys_sock.assertSessions(jids, force);
const response = await baileys_sock.assertSessions(jids);
Copy link
Contributor

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.


callback(response);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3367,12 +3367,7 @@ export class BaileysStartupService extends ChannelStartupService {
}

const numberJid = numberVerified?.jid || user.jid;
const lid =
typeof numberVerified?.lid === 'string'
? numberVerified.lid
: numberJid.includes('@lid')
? numberJid.split('@')[1]
: undefined;
const lid = numberJid.includes('@lid') ? numberJid.split('@')[1] : undefined;
Copy link
Contributor

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.

return new OnWhatsAppDto(
numberJid,
!!numberVerified?.exists,
Expand Down Expand Up @@ -4561,8 +4556,8 @@ export class BaileysStartupService extends ChannelStartupService {
return response;
}

public async baileysAssertSessions(jids: string[], force: boolean) {
const response = await this.client.assertSessions(jids, force);
public async baileysAssertSessions(jids: string[]) {
const response = await this.client.assertSessions(jids);

return response;
Comment on lines +4560 to 4562
Copy link
Contributor

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)

Suggested change
const response = await this.client.assertSessions(jids);
return response;
return await this.client.assertSessions(jids);


ExplanationSomething 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.

}
Expand Down
38 changes: 19 additions & 19 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,25 +44,25 @@ async function bootstrap() {
const prismaRepository = new PrismaRepository(configService);
await prismaRepository.onModuleInit();

app.use(
cors({
origin(requestOrigin, callback) {
const { ORIGIN } = configService.get<Cors>('CORS');
if (ORIGIN.includes('*')) {
return callback(null, true);
}
if (ORIGIN.indexOf(requestOrigin) !== -1) {
return callback(null, true);
}
return callback(new Error('Not allowed by CORS'));
},
methods: [...configService.get<Cors>('CORS').METHODS],
credentials: configService.get<Cors>('CORS').CREDENTIALS,
}),
urlencoded({ extended: true, limit: '136mb' }),
json({ limit: '136mb' }),
compression(),
);
const corsOptions = {
origin: (requestOrigin: string | undefined, callback: (err: Error | null, allow?: boolean) => void) => {
const { ORIGIN } = configService.get<Cors>('CORS');
if (ORIGIN.includes('*')) {
return callback(null, true);
}
if (requestOrigin && ORIGIN.indexOf(requestOrigin) !== -1) {
return callback(null, true);
}
return callback(new Error('Not allowed by CORS'));
},
methods: [...configService.get<Cors>('CORS').METHODS],
credentials: configService.get<Cors>('CORS').CREDENTIALS,
};

app.use(cors(corsOptions));
app.use(urlencoded({ extended: true, limit: '136mb' }));
app.use(json({ limit: '136mb' }));
app.use(compression() as any);

app.set('view engine', 'hbs');
app.set('views', join(ROOT_DIR, 'views'));
Expand Down