Skip to content

Commit

Permalink
feat: sendCheckType
Browse files Browse the repository at this point in the history
  • Loading branch information
jonalan7 committed Sep 30, 2021
1 parent 67e6d86 commit dd10fea
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 3 deletions.
4 changes: 4 additions & 0 deletions src/lib/wapi/functions/check-number-status.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
export async function checkNumberStatus(id) {
const checkType = WAPI.sendCheckType(id);
if (!!checkType && checkType.status === 404) {
return checkType;
}
try {
const result = await window.Store.WapQuery.queryExist(id);
if (result.status === 404) {
Expand Down
13 changes: 12 additions & 1 deletion src/lib/wapi/functions/check-send-exist.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,10 @@ export async function getchatId(chatId) {
}
}

export async function sendExist(chatId, returnChat = true, Send = true) {
export function sendCheckType(chatId = undefined) {
if (!chatId) {
return WAPI.scope(chatId, true, 404, 'It is necessary to pass a number!');
}
if (typeof chatId === 'string') {
const contact = '@c.us';
const broadcast = '@broadcast';
Expand Down Expand Up @@ -138,8 +141,16 @@ export async function sendExist(chatId, returnChat = true, Send = true) {
'incorrect parameters! Use as an example: 00000000-000000@g.us'
);
}
} else {
return WAPI.scope(chatId, true, 404, 'The number must be string!');
}
}

export async function sendExist(chatId, returnChat = true, Send = true) {
const checkType = WAPI.sendCheckType(chatId);
if (!!checkType && checkType.status === 404) {
return checkType;
}
let ck = await window.WAPI.checkNumberStatus(chatId);

if (ck.status === 404 && !chatId.includes('@g.us')) {
Expand Down
2 changes: 1 addition & 1 deletion src/lib/wapi/functions/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ export { setTheme, getTheme } from './theme';
export { restartService } from './restart-service';
export { killServiceWorker } from './kill-service-worker';
export { sendLinkPreview } from './send-link-preview';
export { sendExist, scope, getchatId } from './check-send-exist';
export { sendExist, scope, getchatId, sendCheckType } from './check-send-exist';
export { sendContactVcardList } from './send-contact-vcard-list';
export { setProfilePic } from './set-profile-pic';
export { pinChat } from './fix-chat';
Expand Down
4 changes: 3 additions & 1 deletion src/lib/wapi/wapi.js
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,8 @@ import {
sendButtons,
sendListMenu,
checkChat,
checkNumberStatus
checkNumberStatus,
sendCheckType
} from './functions';
import {
base64ToFile,
Expand Down Expand Up @@ -240,6 +241,7 @@ if (typeof window.WAPI === 'undefined') {
window.WAPI.getStore = getStore;
window.WAPI.checkChat = checkChat;
window.WAPI.checkNumberStatus = checkNumberStatus;
window.WAPI.sendCheckType = sendCheckType;

//Profile
window.WAPI.setProfilePic = setProfilePic;
Expand Down

0 comments on commit dd10fea

Please sign in to comment.