feat: star/unstar messages (#494)

This commit is contained in:
Marcelo Carvalho
2020-12-28 20:05:45 -03:00
committed by Pedro S. Lopez
parent 71dbe99023
commit 1b946940f4
2 changed files with 30 additions and 0 deletions

4
index.d.ts vendored
View File

@@ -524,6 +524,10 @@ declare namespace WAWebJS {
* Forwards this message to another chat
*/
forward: (chat: Chat | string) => Promise<void>,
/** Star this message */
star: () => Promise<void>
/** Unstar this message */
unstar: () => Promise<void>
}
/** ID that represents a message */

View File

@@ -278,6 +278,32 @@ class Message extends Base {
return window.Store.Cmd.sendDeleteMsgs(msg.chat, [msg], true);
}, this.id._serialized, everyone);
}
/**
* Stars this message
*/
async star() {
await this.pupPage.evaluate((msgId) => {
let msg = window.Store.Msg.get(msgId);
if (msg.canStar()) {
return msg.chat.sendStarMsgs([msg], true);
}
}, this.id._serialized);
}
/**
* Unstars this message
*/
async unstar() {
await this.pupPage.evaluate((msgId) => {
let msg = window.Store.Msg.get(msgId);
if (msg.canStar()) {
return msg.chat.sendStarMsgs([msg], false);
}
}, this.id._serialized);
}
}
module.exports = Message;