mirror of
https://github.com/cheveguerra/whatsapp-web.js.git
synced 2026-04-20 04:29:15 +00:00
feat: Get corresponding Chat from Contact object and vice versa
close #269
This commit is contained in:
7
index.d.ts
vendored
7
index.d.ts
vendored
@@ -610,6 +610,11 @@ declare namespace WAWebJS {
|
|||||||
|
|
||||||
/** Returns the contact's profile picture URL, if privacy settings allow it */
|
/** Returns the contact's profile picture URL, if privacy settings allow it */
|
||||||
getProfilePicUrl: () => Promise<string>,
|
getProfilePicUrl: () => Promise<string>,
|
||||||
|
|
||||||
|
/** Returns the Chat that corresponds to this Contact.
|
||||||
|
* Will return null when getting chat for currently logged in user.
|
||||||
|
*/
|
||||||
|
getChat: () => Promise<Chat>,
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ContactId {
|
export interface ContactId {
|
||||||
@@ -688,6 +693,8 @@ declare namespace WAWebJS {
|
|||||||
unarchive: () => Promise<void>,
|
unarchive: () => Promise<void>,
|
||||||
/** Unmutes this chat */
|
/** Unmutes this chat */
|
||||||
unmute: () => Promise<void>,
|
unmute: () => Promise<void>,
|
||||||
|
/** Returns the Contact that corresponds to this Chat. */
|
||||||
|
getContact: () => Promise<Contact>,
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface MessageSearchOptions {
|
export interface MessageSearchOptions {
|
||||||
|
|||||||
@@ -186,6 +186,14 @@ class Chat extends Base {
|
|||||||
return true;
|
return true;
|
||||||
}, this.id._serialized);
|
}, this.id._serialized);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the Contact that corresponds to this Chat.
|
||||||
|
* @returns {Promise<Contact>}
|
||||||
|
*/
|
||||||
|
async getContact() {
|
||||||
|
return await this.client.getContactById(this.id._serialized);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = Chat;
|
module.exports = Chat;
|
||||||
|
|||||||
@@ -106,6 +106,17 @@ class Contact extends Base {
|
|||||||
return await this.client.getProfilePicUrl(this.id._serialized);
|
return await this.client.getProfilePicUrl(this.id._serialized);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the Chat that corresponds to this Contact.
|
||||||
|
* Will return null when getting chat for currently logged in user.
|
||||||
|
* @returns {Promise<Chat>}
|
||||||
|
*/
|
||||||
|
async getChat() {
|
||||||
|
if(this.isMe) return null;
|
||||||
|
|
||||||
|
return await this.client.getChatById(this.id._serialized);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = Contact;
|
module.exports = Contact;
|
||||||
Reference in New Issue
Block a user