diff options
author | George Hazan <ghazan@miranda.im> | 2021-11-15 21:08:55 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2021-11-15 21:08:55 +0300 |
commit | e0a5da7f6ff3bffc243e61a99156a2a837bcb0d9 (patch) | |
tree | b4fbdbce9ff7e4ffc85b561438be667e0e740146 | |
parent | 70965c0f3ff0d7e7643fcbfbeea35c305f7c3f39 (diff) |
Twitter: fix for our own ID parsing
-rw-r--r-- | protocols/Twitter/src/connection.cpp | 19 | ||||
-rw-r--r-- | protocols/Twitter/src/proto.h | 1 | ||||
-rw-r--r-- | protocols/Twitter/src/version.h | 2 |
3 files changed, 20 insertions, 2 deletions
diff --git a/protocols/Twitter/src/connection.cpp b/protocols/Twitter/src/connection.cpp index a8c6651fca..bcd7274d00 100644 --- a/protocols/Twitter/src/connection.cpp +++ b/protocols/Twitter/src/connection.cpp @@ -192,9 +192,11 @@ bool CTwitterProto::NegotiateConnection() }
auto *req = new AsyncHttpRequest(REQUEST_GET, "/account/verify_credentials.json");
- if (Execute(req).code != 200) {
+ auto resp(Execute(req));
+ if (resp.code != 200) {
debugLogA("**NegotiateConnection - Verifying credentials failed! No internet maybe?");
+LBL_Error:
ProtoBroadcastAck(0, ACKTYPE_STATUS, ACKRESULT_FAILED, (HANDLE)old_status, m_iStatus);
// Set to offline
@@ -205,6 +207,13 @@ bool CTwitterProto::NegotiateConnection() return false;
}
+ JSONNode root = JSONNode::parse(resp.data.c_str());
+ if (!root) {
+ debugLogA("unable to parse response");
+ goto LBL_Error;
+ }
+
+ m_szMyId = root["id_str"].as_mstring();
m_iStatus = m_iDesiredStatus;
ProtoBroadcastAck(0, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE)old_status, m_iStatus);
return true;
@@ -556,8 +565,14 @@ void CTwitterProto::UpdateMessages(bool pre_read) if (type != "message_create")
continue;
+ bool bIsMe = false;
auto &msgCreate = one["message_create"];
std::string sender = msgCreate["sender_id"].as_string();
+ if (m_szMyId == sender.c_str()) {
+ bIsMe = true;
+ sender = msgCreate["target"]["recipient_id"].as_string();
+ }
+
MCONTACT hContact = FindContactById(sender.c_str());
if (hContact == INVALID_CONTACT_ID) {
hContact = AddToClientList(sender.c_str(), "");
@@ -578,6 +593,8 @@ void CTwitterProto::UpdateMessages(bool pre_read) PROTORECVEVENT recv = { 0 };
if (pre_read)
recv.flags |= PREF_CREATEREAD;
+ if (bIsMe)
+ recv.flags |= PREF_SENT;
recv.szMessage = const_cast<char*>(text.c_str());
recv.timestamp = static_cast<DWORD>(time);
recv.szMsgId = msgid.c_str();
diff --git a/protocols/Twitter/src/proto.h b/protocols/Twitter/src/proto.h index 3d195295ba..a33c4c1782 100644 --- a/protocols/Twitter/src/proto.h +++ b/protocols/Twitter/src/proto.h @@ -77,6 +77,7 @@ class CTwitterProto : public PROTO<CTwitterProto> http::response Execute(AsyncHttpRequest *req);
CMStringA m_szUserName;
+ CMStringA m_szMyId;
CMStringA m_szPassword;
CMStringA m_szConsumerKey;
CMStringA m_szConsumerSecret;
diff --git a/protocols/Twitter/src/version.h b/protocols/Twitter/src/version.h index 61a0406849..093632cee2 100644 --- a/protocols/Twitter/src/version.h +++ b/protocols/Twitter/src/version.h @@ -1,7 +1,7 @@ #define __MAJOR_VERSION 1
#define __MINOR_VERSION 3
#define __RELEASE_NUM 1
-#define __BUILD_NUM 5
+#define __BUILD_NUM 6
#include <stdver.h>
|