summaryrefslogtreecommitdiff
path: root/protocols/Facebook
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2025-03-30 12:43:46 +0300
committerGeorge Hazan <george.hazan@gmail.com>2025-03-30 12:43:46 +0300
commitc0e1d45695a918796ad34118596f345098ec39b9 (patch)
tree80dd5b0b3d795957a33452f5f406ac5049510436 /protocols/Facebook
parent7d95e67308ee0abcce5c7bd66265146d3dfefd74 (diff)
code cleaning
Diffstat (limited to 'protocols/Facebook')
-rw-r--r--protocols/Facebook/src/db.h10
-rw-r--r--protocols/Facebook/src/groupchats.cpp4
-rw-r--r--protocols/Facebook/src/server.cpp14
3 files changed, 19 insertions, 9 deletions
diff --git a/protocols/Facebook/src/db.h b/protocols/Facebook/src/db.h
index 1842fc390a..3d75fae2fb 100644
--- a/protocols/Facebook/src/db.h
+++ b/protocols/Facebook/src/db.h
@@ -42,3 +42,13 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
// Hidden account DB keys (can't be changed through GUI)
#define DBKEY_LOCALE "Locale" // [HIDDEN] - (string) en_US, cs_CZ, etc. (requires restart to apply)
+
+struct FbReply : public JsonReply
+{
+ FbReply(MHttpResponse *response) :
+ JsonReply(response)
+ {
+ if (m_root)
+ m_errorCode = (*m_root)["error_code"].as_int();
+ }
+};
diff --git a/protocols/Facebook/src/groupchats.cpp b/protocols/Facebook/src/groupchats.cpp
index 047bee95e1..cc20fceb4e 100644
--- a/protocols/Facebook/src/groupchats.cpp
+++ b/protocols/Facebook/src/groupchats.cpp
@@ -87,7 +87,7 @@ public:
pReq << CHAR_PARAM("to", list.write().c_str()) << WCHAR_PARAM("id", CMStringW(FORMAT, L"t_%s", m_si->ptszID));
pReq->CalcSig();
- JsonReply reply(m_proto->ExecuteRequest(pReq));
+ FbReply reply(m_proto->ExecuteRequest(pReq));
return true;
}
};
@@ -233,7 +233,7 @@ int FacebookProto::Chat_KickUser(SESSION_INFO *si, const wchar_t *pwszUid)
}
pReq->CalcSig();
- JsonReply reply(ExecuteRequest(pReq));
+ FbReply reply(ExecuteRequest(pReq));
return reply.error();
}
diff --git a/protocols/Facebook/src/server.cpp b/protocols/Facebook/src/server.cpp
index f660fee8bd..6eebad7ec8 100644
--- a/protocols/Facebook/src/server.cpp
+++ b/protocols/Facebook/src/server.cpp
@@ -157,7 +157,7 @@ int FacebookProto::RefreshContacts()
pReq->flags |= NLHRF_NODUMPSEND;
pReq->CalcSig();
- JsonReply reply(ExecuteRequest(pReq));
+ FbReply reply(ExecuteRequest(pReq));
if (int iErrorCode = reply.error())
return iErrorCode; // unknown error
@@ -238,7 +238,7 @@ bool FacebookProto::RefreshSid()
pReq << CHAR_PARAM("query_params", root.write().c_str());
pReq->CalcSig();
- JsonReply reply(ExecuteRequest(pReq));
+ FbReply reply(ExecuteRequest(pReq));
if (reply.error())
return false;
@@ -320,7 +320,7 @@ FacebookUser* FacebookProto::RefreshThread(CMStringW &wszId)
pReq << WCHAR_PARAM("query_params", CMStringW(FORMAT, L"{\"0\":[\"%s\"], \"12\":0, \"13\":\"false\"}", wszId.c_str()));
pReq->CalcSig();
- JsonReply reply(ExecuteRequest(pReq));
+ FbReply reply(ExecuteRequest(pReq));
if (!reply.error()) {
auto &root = reply.data();
for (auto &n : root)
@@ -339,7 +339,7 @@ void FacebookProto::RefreshThreads()
pReq << CHAR_PARAM("query_params", json.write().c_str());
pReq->CalcSig();
- JsonReply reply(ExecuteRequest(pReq));
+ FbReply reply(ExecuteRequest(pReq));
if (!reply.error()) {
auto &root = reply.data()["viewer"]["message_threads"];
@@ -361,7 +361,7 @@ int FacebookProto::RefreshToken()
pReq << CHAR_PARAM("password", getMStringA(DBKEY_PASS));
pReq->CalcSig();
- JsonReply reply(ExecuteRequest(pReq));
+ FbReply reply(ExecuteRequest(pReq));
if (reply.error())
return reply.error();
@@ -659,7 +659,7 @@ void FacebookProto::FetchAttach(const CMStringA &mid, __int64 fbid, CMStringA &s
pReq << CHAR_PARAM("mid", mid) << INT64_PARAM("aid", fbid);
pReq->CalcSig();
- JsonReply reply(ExecuteRequest(pReq));
+ FbReply reply(ExecuteRequest(pReq));
switch (reply.error()) {
case 0:
{
@@ -751,7 +751,7 @@ void FacebookProto::OnPublishPrivateMessage(const JSONNode &root)
pReq << CHAR_PARAM("query_params", CMStringA(FORMAT, "{\"0\":[\"%s\"]}", stickerId.c_str()));
pReq->CalcSig();
- JsonReply reply(ExecuteRequest(pReq));
+ FbReply reply(ExecuteRequest(pReq));
if (!reply.error()) {
for (auto &sticker : reply.data()) {
std::string szUrl = sticker["thread_image"]["uri"].as_string();