Skip to content

Commit

Permalink
Merge pull request rquiroz#1 from Mostey/master
Browse files Browse the repository at this point in the history
Fix for receiving encrypted messages
  • Loading branch information
mgp25 committed Nov 30, 2014
2 parents c732675 + c5cc722 commit 7ac9d35
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions WhatsAppApi/Base/WhatsSendBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -305,13 +305,20 @@ protected void handleMessage(ProtocolTreeNode node, bool autoReceipt)
{
throw new NotImplementedException(node.NodeString());
}
if (node.GetChild("body") != null)
if (node.GetChild("body") != null || node.GetChild("enc") != null)
{
//text message
this.fireOnGetMessage(node, node.GetAttribute("from"), node.GetAttribute("id"), node.GetAttribute("notify"), System.Text.Encoding.UTF8.GetString(node.GetChild("body").GetData()), autoReceipt);
if (autoReceipt)
// text message
// encrypted messages have no body node. Instead, the encrypted cipher text is provided within the enc node
var contentNode = node.GetChild("body") ?? node.GetChild("enc");
if (contentNode != null)
{
this.sendMessageReceived(node);
this.fireOnGetMessage(node, node.GetAttribute("from"), node.GetAttribute("id"),
node.GetAttribute("notify"), System.Text.Encoding.UTF8.GetString(contentNode.GetData()),
autoReceipt);
if (autoReceipt)
{
this.sendMessageReceived(node);
}
}
}
if (node.GetChild("media") != null)
Expand Down

0 comments on commit 7ac9d35

Please sign in to comment.