diff options
author | George Hazan <george.hazan@gmail.com> | 2015-02-07 20:46:03 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2015-02-07 20:46:03 +0000 |
commit | 65ef9d3aaa306361f039679fcf73cdfbf10ec6b4 (patch) | |
tree | 2ac626cdf3f99326850f9ede059a4c478b28d59f /protocols/WhatsApp/src/WhatsAPI++ | |
parent | be396370409163efe1e1d8868100cf1a2020d068 (diff) |
fix for sending media messages to group chats
git-svn-id: http://svn.miranda-ng.org/main/trunk@12046 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/WhatsApp/src/WhatsAPI++')
-rw-r--r-- | protocols/WhatsApp/src/WhatsAPI++/WAConnection.cpp | 33 |
1 files changed, 16 insertions, 17 deletions
diff --git a/protocols/WhatsApp/src/WhatsAPI++/WAConnection.cpp b/protocols/WhatsApp/src/WhatsAPI++/WAConnection.cpp index e1e983cad0..60e585e801 100644 --- a/protocols/WhatsApp/src/WhatsAPI++/WAConnection.cpp +++ b/protocols/WhatsApp/src/WhatsAPI++/WAConnection.cpp @@ -382,12 +382,12 @@ void WAConnection::parseMessage(ProtocolTreeNode *messageNode) throw (WAExceptio const string &id = messageNode->getAttributeValue("id");
const string &attribute_t = messageNode->getAttributeValue("t");
const string &from = messageNode->getAttributeValue("from");
- const string &author = messageNode->getAttributeValue("author");
const string &typeAttribute = messageNode->getAttributeValue("type");
if (typeAttribute.empty())
return;
+ const string &participant = messageNode->getAttributeValue("participant");
if (typeAttribute == "error") {
int errorCode = 0;
std::vector<ProtocolTreeNode*> errorNodes(messageNode->getAllChildren("error"));
@@ -401,16 +401,21 @@ void WAConnection::parseMessage(ProtocolTreeNode *messageNode) throw (WAExceptio if (m_pEventHandler != NULL)
m_pEventHandler->onMessageError(message, errorCode);
+ return;
}
- else if (typeAttribute == "text") {
+
+ if (from.empty() || id.empty())
+ return;
+ FMessage fmessage(from, false, id);
+
+ if (typeAttribute == "text") {
ProtocolTreeNode *body = messageNode->getChild("body");
- if (from.empty() || body == NULL || body->data == NULL || body->data->empty())
+ if (body == NULL || body->data == NULL || body->data->empty())
return;
- FMessage fmessage(from, false, id);
fmessage.wants_receipt = false;
fmessage.timestamp = atoi(attribute_t.c_str());
- fmessage.remote_resource = messageNode->getAttributeValue("participant");
+ fmessage.remote_resource = participant;
fmessage.notifyname = messageNode->getAttributeValue("notify");
fmessage.data = body->getDataAsString();
fmessage.status = FMessage::STATUS_UNSENT;
@@ -418,27 +423,16 @@ void WAConnection::parseMessage(ProtocolTreeNode *messageNode) throw (WAExceptio fmessage.timestamp = time(NULL);
fmessage.offline = false;
}
-
- if (fmessage.remote_resource.empty()) {
- if (m_pEventHandler != NULL)
- m_pEventHandler->onMessageForMe(fmessage);
- }
- else if (m_pGroupEventHandler != NULL)
- m_pGroupEventHandler->onGroupMessage(fmessage);
}
else if (typeAttribute == "media") {
- if (from.empty() || id.empty())
- return;
-
ProtocolTreeNode *media = messageNode->getChild("media");
if (media == NULL)
return;
- FMessage fmessage(from, false, id);
fmessage.wants_receipt = false;
fmessage.timestamp = atoi(attribute_t.c_str());
fmessage.notifyname = messageNode->getAttributeValue("notify");
- fmessage.remote_resource = author;
+ fmessage.remote_resource = messageNode->getAttributeValue("participant");
fmessage.media_wa_type = FMessage::getMessage_WA_Type(media->getAttributeValue("type"));
fmessage.media_url = media->getAttributeValue("url");
fmessage.media_name = media->getAttributeValue("file");
@@ -488,10 +482,15 @@ void WAConnection::parseMessage(ProtocolTreeNode *messageNode) throw (WAExceptio else
fmessage.data = media->getAttributeValue("caption");
}
+ }
+ else return;
+ if (fmessage.remote_resource.empty()) {
if (m_pEventHandler != NULL)
m_pEventHandler->onMessageForMe(fmessage);
}
+ else if (m_pGroupEventHandler != NULL)
+ m_pGroupEventHandler->onGroupMessage(fmessage);
}
void WAConnection::parseNotification(ProtocolTreeNode *node) throw(WAException)
|