Adição de Profile Route

This commit is contained in:
Alan Mosko
2023-07-21 15:32:28 -03:00
parent 3e3a175bdc
commit e851696430
4 changed files with 64 additions and 0 deletions

View File

@@ -1436,6 +1436,36 @@ export class WAStartupService {
};
}
}
public async profile(instanceName: string) {
const jid = this.client?.user?.id;
this.logger.verbose('Getting profile with jid: ' + jid);
try {
this.logger.verbose('Getting profile info');
const info = await waMonitor.instanceInfo(instanceName);
const business = await this.fetchBusinessProfile(jid);
return {
wuid: jid,
name: info?.instance?.profileName,
picture: info?.instance?.profilePictureUrl,
status: info?.instance?.profileStatus,
os: this.client?.authState?.creds?.platform,
isBusiness: typeof business !== 'undefined',
};
} catch (error) {
this.logger.verbose('Profile not found');
return {
wuid: jid,
name: null,
picture: null,
status: null,
os: null,
isBusiness: false,
};
}
}
private async sendMessageWithTyping<T = proto.IMessage>(
number: string,