diff --git a/pkg/whatsapp/whatsapp.go b/pkg/whatsapp/whatsapp.go index 7dbe796..1e6092b 100644 --- a/pkg/whatsapp/whatsapp.go +++ b/pkg/whatsapp/whatsapp.go @@ -437,8 +437,11 @@ func WhatsAppSendText(ctx context.Context, jid string, rjid string, message stri // Compose New Remote JID remoteJID := WhatsAppComposeJID(rjid) - if WhatsAppGetJID(jid, remoteJID.String()).IsEmpty() { - return "", errors.New("WhatsApp Personal ID is Not Registered") + if remoteJID.Server != types.GroupServer { + // Validate JID if Remote JID is not Gorup JID + if WhatsAppGetJID(jid, remoteJID.String()).IsEmpty() { + return "", errors.New("WhatsApp Personal ID is Not Registered") + } } // Set Chat Presence @@ -478,8 +481,11 @@ func WhatsAppSendLocation(ctx context.Context, jid string, rjid string, latitude // Compose New Remote JID remoteJID := WhatsAppComposeJID(rjid) - if WhatsAppGetJID(jid, remoteJID.String()).IsEmpty() { - return "", errors.New("WhatsApp Personal ID is Not Registered") + if remoteJID.Server != types.GroupServer { + // Validate JID if Remote JID is not Gorup JID + if WhatsAppGetJID(jid, remoteJID.String()).IsEmpty() { + return "", errors.New("WhatsApp Personal ID is Not Registered") + } } // Set Chat Presence @@ -522,8 +528,11 @@ func WhatsAppSendDocument(ctx context.Context, jid string, rjid string, fileByte // Compose New Remote JID remoteJID := WhatsAppComposeJID(rjid) - if WhatsAppGetJID(jid, remoteJID.String()).IsEmpty() { - return "", errors.New("WhatsApp Personal ID is Not Registered") + if remoteJID.Server != types.GroupServer { + // Validate JID if Remote JID is not Gorup JID + if WhatsAppGetJID(jid, remoteJID.String()).IsEmpty() { + return "", errors.New("WhatsApp Personal ID is Not Registered") + } } // Set Chat Presence @@ -579,8 +588,11 @@ func WhatsAppSendImage(ctx context.Context, jid string, rjid string, imageBytes // Compose New Remote JID remoteJID := WhatsAppComposeJID(rjid) - if WhatsAppGetJID(jid, remoteJID.String()).IsEmpty() { - return "", errors.New("WhatsApp Personal ID is Not Registered") + if remoteJID.Server != types.GroupServer { + // Validate JID if Remote JID is not Gorup JID + if WhatsAppGetJID(jid, remoteJID.String()).IsEmpty() { + return "", errors.New("WhatsApp Personal ID is Not Registered") + } } // Set Chat Presence @@ -713,8 +725,11 @@ func WhatsAppSendAudio(ctx context.Context, jid string, rjid string, audioBytes // Compose New Remote JID remoteJID := WhatsAppComposeJID(rjid) - if WhatsAppGetJID(jid, remoteJID.String()).IsEmpty() { - return "", errors.New("WhatsApp Personal ID is Not Registered") + if remoteJID.Server != types.GroupServer { + // Validate JID if Remote JID is not Gorup JID + if WhatsAppGetJID(jid, remoteJID.String()).IsEmpty() { + return "", errors.New("WhatsApp Personal ID is Not Registered") + } } // Set Chat Presence @@ -768,8 +783,11 @@ func WhatsAppSendVideo(ctx context.Context, jid string, rjid string, videoBytes // Compose New Remote JID remoteJID := WhatsAppComposeJID(rjid) - if WhatsAppGetJID(jid, remoteJID.String()).IsEmpty() { - return "", errors.New("WhatsApp Personal ID is Not Registered") + if remoteJID.Server != types.GroupServer { + // Validate JID if Remote JID is not Gorup JID + if WhatsAppGetJID(jid, remoteJID.String()).IsEmpty() { + return "", errors.New("WhatsApp Personal ID is Not Registered") + } } // Set Chat Presence @@ -825,8 +843,11 @@ func WhatsAppSendContact(ctx context.Context, jid string, rjid string, contactNa // Compose New Remote JID remoteJID := WhatsAppComposeJID(rjid) - if WhatsAppGetJID(jid, remoteJID.String()).IsEmpty() { - return "", errors.New("WhatsApp Personal ID is Not Registered") + if remoteJID.Server != types.GroupServer { + // Validate JID if Remote JID is not Gorup JID + if WhatsAppGetJID(jid, remoteJID.String()).IsEmpty() { + return "", errors.New("WhatsApp Personal ID is Not Registered") + } } // Set Chat Presence @@ -872,8 +893,11 @@ func WhatsAppSendLink(ctx context.Context, jid string, rjid string, linkCaption // Compose New Remote JID remoteJID := WhatsAppComposeJID(rjid) - if WhatsAppGetJID(jid, remoteJID.String()).IsEmpty() { - return "", errors.New("WhatsApp Personal ID is Not Registered") + if remoteJID.Server != types.GroupServer { + // Validate JID if Remote JID is not Gorup JID + if WhatsAppGetJID(jid, remoteJID.String()).IsEmpty() { + return "", errors.New("WhatsApp Personal ID is Not Registered") + } } // Set Chat Presence @@ -950,8 +974,11 @@ func WhatsAppSendSticker(ctx context.Context, jid string, rjid string, stickerBy // Compose New Remote JID remoteJID := WhatsAppComposeJID(rjid) - if WhatsAppGetJID(jid, remoteJID.String()).IsEmpty() { - return "", errors.New("WhatsApp Personal ID is Not Registered") + if remoteJID.Server != types.GroupServer { + // Validate JID if Remote JID is not Gorup JID + if WhatsAppGetJID(jid, remoteJID.String()).IsEmpty() { + return "", errors.New("WhatsApp Personal ID is Not Registered") + } } // Set Chat Presence