Browse Source

update fix do not validate group jid when sending message

pull/61/head v1.6.1
Dimas Restu H 2 years ago
parent
commit
9236cf7a11
  1. 63
      pkg/whatsapp/whatsapp.go

63
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

Loading…
Cancel
Save