Skip to content

Commit

Permalink
fix: Fixed return of getStatus (fix #822)
Browse files Browse the repository at this point in the history
  • Loading branch information
edgardmessias committed Jan 22, 2022
1 parent a8bd58b commit c0fc6d6
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions src/api/layers/retriever.layer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,12 @@ import { Page } from 'puppeteer';
import { CreateConfig } from '../../config/create-config';
import { SessionToken } from '../../token-store';
import { evaluateAndReturn } from '../helpers';
import { Chat, ProfilePicThumbObj, WhatsappProfile } from '../model';
import {
Chat,
ContactStatus,
ProfilePicThumbObj,
WhatsappProfile,
} from '../model';
import { SenderLayer } from './sender.layer';

export class RetrieverLayer extends SenderLayer {
Expand Down Expand Up @@ -262,10 +267,17 @@ export class RetrieverLayer extends SenderLayer {
* @category Contact
* @param contactId
*/
public async getStatus(contactId: string) {
return evaluateAndReturn(
public async getStatus(contactId: string): Promise<ContactStatus> {
return await evaluateAndReturn(
this.page,
(contactId) => WPP.contact.getStatus(contactId),
async (contactId) => {
const status = await WPP.contact.getStatus(contactId);

return {
id: status.id.toString(),
status: status.status,
};
},
contactId
);
}
Expand Down

0 comments on commit c0fc6d6

Please sign in to comment.