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. 27
      pkg/whatsapp/whatsapp.go

27
pkg/whatsapp/whatsapp.go

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

Loading…
Cancel
Save