mirror of
https://github.com/cheveguerra/whatsapp-web.js.git
synced 2026-04-18 11:39:14 +00:00
Add eslint config and fix linting issues
This commit is contained in:
@@ -14,7 +14,7 @@ class Base {
|
||||
|
||||
_clone() {
|
||||
return Object.assign(Object.create(this), this);
|
||||
}
|
||||
}
|
||||
|
||||
_patch(data) { return data; }
|
||||
}
|
||||
|
||||
@@ -46,7 +46,7 @@ class GroupChat extends Chat {
|
||||
*/
|
||||
async addParticipants(participantIds) {
|
||||
return await this.client.pupPage.evaluate((chatId, participantIds) => {
|
||||
return Store.Wap.addParticipants(chatId, participantIds);
|
||||
return window.Store.Wap.addParticipants(chatId, participantIds);
|
||||
}, this.id._serialized, participantIds);
|
||||
}
|
||||
|
||||
@@ -56,7 +56,7 @@ class GroupChat extends Chat {
|
||||
*/
|
||||
async removeParticipants(participantIds) {
|
||||
return await this.client.pupPage.evaluate((chatId, participantIds) => {
|
||||
return Store.Wap.removeParticipants(chatId, participantIds);
|
||||
return window.Store.Wap.removeParticipants(chatId, participantIds);
|
||||
}, this.id._serialized, participantIds);
|
||||
}
|
||||
|
||||
@@ -66,7 +66,7 @@ class GroupChat extends Chat {
|
||||
*/
|
||||
async promoteParticipants(participantIds) {
|
||||
return await this.client.pupPage.evaluate((chatId, participantIds) => {
|
||||
return Store.Wap.promoteParticipants(chatId, participantIds);
|
||||
return window.Store.Wap.promoteParticipants(chatId, participantIds);
|
||||
}, this.id._serialized, participantIds);
|
||||
}
|
||||
|
||||
@@ -76,7 +76,7 @@ class GroupChat extends Chat {
|
||||
*/
|
||||
async demoteParticipants(participantIds) {
|
||||
return await this.client.pupPage.evaluate((chatId, participantIds) => {
|
||||
return Store.Wap.demoteParticipants(chatId, participantIds);
|
||||
return window.Store.Wap.demoteParticipants(chatId, participantIds);
|
||||
}, this.id._serialized, participantIds);
|
||||
}
|
||||
|
||||
@@ -86,7 +86,7 @@ class GroupChat extends Chat {
|
||||
*/
|
||||
async setSubject(subject) {
|
||||
let res = await this.client.pupPage.evaluate((chatId, subject) => {
|
||||
return Store.Wap.changeSubject(chatId, subject);
|
||||
return window.Store.Wap.changeSubject(chatId, subject);
|
||||
}, this.id._serialized, subject);
|
||||
|
||||
if(res.status == 200) {
|
||||
@@ -100,8 +100,8 @@ class GroupChat extends Chat {
|
||||
*/
|
||||
async setDescription(description) {
|
||||
let res = await this.client.pupPage.evaluate((chatId, description) => {
|
||||
let descId = Store.GroupMetadata.get(chatId).descId;
|
||||
return Store.Wap.setGroupDescription(chatId, description, Store.genId(), descId);
|
||||
let descId = window.Store.GroupMetadata.get(chatId).descId;
|
||||
return window.Store.Wap.setGroupDescription(chatId, description, window.Store.genId(), descId);
|
||||
}, this.id._serialized, description);
|
||||
|
||||
if (res.status == 200) {
|
||||
@@ -114,14 +114,14 @@ class GroupChat extends Chat {
|
||||
*/
|
||||
async getInviteCode() {
|
||||
let res = await this.client.pupPage.evaluate(chatId => {
|
||||
return Store.Wap.groupInviteCode(chatId);
|
||||
return window.Store.Wap.groupInviteCode(chatId);
|
||||
}, this.id._serialized);
|
||||
|
||||
if (res.status == 200) {
|
||||
return res.code;
|
||||
}
|
||||
|
||||
throw new Error('Not authorized')
|
||||
throw new Error('Not authorized');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -129,8 +129,8 @@ class GroupChat extends Chat {
|
||||
*/
|
||||
async revokeInvite() {
|
||||
return await this.client.pupPage.evaluate(chatId => {
|
||||
return Store.Wap.revokeGroupInvite(chatId);
|
||||
}, chatId);
|
||||
return window.Store.Wap.revokeGroupInvite(chatId);
|
||||
}, this.id._serialized);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -139,7 +139,7 @@ class GroupChat extends Chat {
|
||||
*/
|
||||
static async getInviteInfo(inviteCode) {
|
||||
return await this.client.pupPage.evaluate(inviteCode => {
|
||||
return Store.Wap.groupInviteInfo(inviteCode);
|
||||
return window.Store.Wap.groupInviteInfo(inviteCode);
|
||||
}, inviteCode);
|
||||
}
|
||||
|
||||
@@ -149,7 +149,7 @@ class GroupChat extends Chat {
|
||||
*/
|
||||
static async join(inviteCode) {
|
||||
return await this.client.pupPage.evaluate(inviteCode => {
|
||||
return Store.Wap.acceptGroupInvite(inviteCode);
|
||||
return window.Store.Wap.acceptGroupInvite(inviteCode);
|
||||
}, inviteCode);
|
||||
}
|
||||
|
||||
@@ -158,7 +158,7 @@ class GroupChat extends Chat {
|
||||
*/
|
||||
async leave() {
|
||||
return await this.client.pupPage.evaluate(chatId => {
|
||||
return Store.Wap.leaveGroup(chatId);
|
||||
return window.Store.Wap.leaveGroup(chatId);
|
||||
}, this.id._serialized);
|
||||
}
|
||||
|
||||
|
||||
@@ -19,9 +19,9 @@ class Message extends Base {
|
||||
this.body = this.hasMedia ? data.caption || '' : data.body || '';
|
||||
this.type = data.type;
|
||||
this.timestamp = data.t;
|
||||
this.from = typeof (data.from) === "object" ? data.from._serialized : data.from;
|
||||
this.to = typeof (data.to) === "object" ? data.to._serialized : data.to;
|
||||
this.author = typeof (data.author) === "object" ? data.author._serialized : data.author;
|
||||
this.from = typeof (data.from) === 'object' ? data.from._serialized : data.from;
|
||||
this.to = typeof (data.to) === 'object' ? data.to._serialized : data.to;
|
||||
this.author = typeof (data.author) === 'object' ? data.author._serialized : data.author;
|
||||
this.isForwarded = data.isForwarded;
|
||||
this.broadcast = data.broadcast;
|
||||
this.fromMe = data.id.fromMe;
|
||||
@@ -48,7 +48,7 @@ class Message extends Base {
|
||||
if (!this.hasQuotedMsg) return undefined;
|
||||
|
||||
const quotedMsg = await this.client.pupPage.evaluate((msgId) => {
|
||||
let msg = Store.Msg.get(msgId);
|
||||
let msg = window.Store.Msg.get(msgId);
|
||||
return msg.quotedMsgObj().serialize();
|
||||
}, this.id._serialized);
|
||||
|
||||
@@ -68,10 +68,10 @@ class Message extends Base {
|
||||
}
|
||||
|
||||
const newMessage = await this.client.pupPage.evaluate(async (chatId, quotedMessageId, message) => {
|
||||
let quotedMessage = Store.Msg.get(quotedMessageId);
|
||||
let quotedMessage = window.Store.Msg.get(quotedMessageId);
|
||||
if(quotedMessage.canReply()) {
|
||||
const chat = Store.Chat.get(chatId);
|
||||
const newMessage = await WWebJS.sendMessage(chat, message, quotedMessage.msgContextInfo(chat));
|
||||
const chat = window.Store.Chat.get(chatId);
|
||||
const newMessage = await window.WWebJS.sendMessage(chat, message, quotedMessage.msgContextInfo(chat));
|
||||
return newMessage.serialize();
|
||||
} else {
|
||||
throw new Error('This message cannot be replied to.');
|
||||
@@ -87,16 +87,16 @@ class Message extends Base {
|
||||
}
|
||||
|
||||
return await this.client.pupPage.evaluate(async (msgId) => {
|
||||
const msg = Store.Msg.get(msgId);
|
||||
const buffer = await WWebJS.downloadBuffer(msg.clientUrl);
|
||||
const decrypted = await Store.CryptoLib.decryptE2EMedia(msg.type, buffer, msg.mediaKey, msg.mimetype);
|
||||
const data = await WWebJS.readBlobAsync(decrypted._blob);
|
||||
const msg = window.Store.Msg.get(msgId);
|
||||
const buffer = await window.WWebJS.downloadBuffer(msg.clientUrl);
|
||||
const decrypted = await window.Store.CryptoLib.decryptE2EMedia(msg.type, buffer, msg.mediaKey, msg.mimetype);
|
||||
const data = await window.WWebJS.readBlobAsync(decrypted._blob);
|
||||
|
||||
return {
|
||||
data,
|
||||
mimetype: msg.mimetype,
|
||||
filename: msg.filename
|
||||
}
|
||||
};
|
||||
|
||||
}, this.id._serialized);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user