mirror of
https://github.com/EvolutionAPI/evolution-api.git
synced 2025-12-25 22:57:44 -06:00
feat: Added fetch profile endpoint in chat controller and link preview option in send text message
This commit is contained in:
@@ -48,6 +48,14 @@ export class ChatController {
|
||||
return await this.waMonitor.waInstances[instanceName].profilePicture(data.number);
|
||||
}
|
||||
|
||||
public async fetchProfile({ instanceName }: InstanceDto, data: NumberDto) {
|
||||
logger.verbose('requested fetchProfile from ' + instanceName + ' instance');
|
||||
return await this.waMonitor.waInstances[instanceName].fetchProfile(
|
||||
instanceName,
|
||||
data.number,
|
||||
);
|
||||
}
|
||||
|
||||
public async fetchContacts({ instanceName }: InstanceDto, query: ContactQuery) {
|
||||
logger.verbose('requested fetchContacts from ' + instanceName + ' instance');
|
||||
return await this.waMonitor.waInstances[instanceName].fetchContacts(query);
|
||||
|
||||
@@ -210,30 +210,41 @@ export class InstanceController {
|
||||
|
||||
this.logger.verbose('state: ' + state);
|
||||
|
||||
switch (state) {
|
||||
case 'close':
|
||||
this.logger.verbose('connecting');
|
||||
await instance.connectToWhatsapp();
|
||||
let pairingCode = null;
|
||||
if (number) {
|
||||
this.logger.verbose('creating pairing code');
|
||||
await delay(5000);
|
||||
pairingCode = await instance.client.requestPairingCode(number);
|
||||
}
|
||||
|
||||
if (pairingCode) {
|
||||
return {
|
||||
pairingCode,
|
||||
};
|
||||
}
|
||||
|
||||
await delay(2000);
|
||||
return instance.qrCode;
|
||||
case 'connecting':
|
||||
return instance.qrCode;
|
||||
default:
|
||||
return await this.connectionState({ instanceName });
|
||||
if (state == 'open') {
|
||||
return await this.connectionState({ instanceName });
|
||||
}
|
||||
|
||||
if (state == 'connecting') {
|
||||
return instance.qrCode;
|
||||
}
|
||||
|
||||
if (state == 'close') {
|
||||
this.logger.verbose('connecting');
|
||||
await instance.connectToWhatsapp();
|
||||
let pairingCode = null;
|
||||
if (number) {
|
||||
this.logger.verbose('creating pairing code');
|
||||
await delay(5000);
|
||||
pairingCode = await instance.client.requestPairingCode(number);
|
||||
}
|
||||
|
||||
if (pairingCode) {
|
||||
return {
|
||||
pairingCode,
|
||||
};
|
||||
}
|
||||
|
||||
await delay(2000);
|
||||
return instance.qrCode;
|
||||
}
|
||||
|
||||
return {
|
||||
instance: {
|
||||
instanceName: instanceName,
|
||||
status: state,
|
||||
},
|
||||
qrcode: instance?.qrCode,
|
||||
};
|
||||
} catch (error) {
|
||||
this.logger.error(error);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user