summaryrefslogtreecommitdiff
path: root/protocols
diff options
context:
space:
mode:
authorElzorFox <elzorfox@ya.ru>2019-03-27 21:00:56 +0500
committerElzorFox <elzorfox@ya.ru>2019-03-27 21:01:45 +0500
commitdea61eb8592eab4e5e9f3cafb315fb8c9b61d5b2 (patch)
tree4f5932f75dffe3331ec4119b3cda1bebd0b802f3 /protocols
parentc5c5972135f392bd2ab5bacc6ce476e3aa267ca3 (diff)
VKontakte:
fix group users in muc fix link to profile for group users in forwarded messages version bump
Diffstat (limited to 'protocols')
-rw-r--r--protocols/VKontakte/src/misc.cpp10
-rw-r--r--protocols/VKontakte/src/version.h2
-rw-r--r--protocols/VKontakte/src/vk_chats.cpp34
-rw-r--r--protocols/VKontakte/src/vk_proto.h1
-rw-r--r--protocols/VKontakte/src/vk_struct.h2
5 files changed, 31 insertions, 18 deletions
diff --git a/protocols/VKontakte/src/misc.cpp b/protocols/VKontakte/src/misc.cpp
index 6951a76f56..0b55ba50a4 100644
--- a/protocols/VKontakte/src/misc.cpp
+++ b/protocols/VKontakte/src/misc.cpp
@@ -1304,9 +1304,8 @@ CMStringW CVkProto::GetFwdMessages(const JSONNode &jnMessages, const JSONNode &j
for (auto &jnUser : jnFUsers) {
int iUserId = jnUser["id"].as_int();
CMStringW wszNick(FORMAT, L"%s %s", jnUser["first_name"].as_mstring().c_str(), jnUser["last_name"].as_mstring().c_str());
- CMStringW wszLink(FORMAT, L"https://vk.com/id%d", iUserId);
- CVkUserInfo *vkUser = new CVkUserInfo(jnUser["id"].as_int(), false, wszNick, wszLink, FindUser(iUserId));
+ CVkUserInfo *vkUser = new CVkUserInfo(jnUser["id"].as_int(), false, wszNick, UserProfileUrl(iUserId), FindUser(iUserId));
vkUsers.insert(vkUser);
}
@@ -1326,7 +1325,7 @@ CMStringW CVkProto::GetFwdMessages(const JSONNode &jnMessages, const JSONNode &j
wszNick = ptrW(db_get_wsa(hContact, m_szModuleName, "Nick"));
else
wszNick = TranslateT("(Unknown contact)");
- wszUrl.AppendFormat(L"https://vk.com/id%d", uid);
+ wszUrl = UserProfileUrl(uid);
}
time_t datetime = (time_t)jnMsg["date"].as_int();
@@ -1593,3 +1592,8 @@ bool CVkProto::IsMessageExist(UINT iMsgId, VKMesType vkType)
return ((vkType == vkOUT) == (bool)(dbei.flags & DBEF_SENT));
}
+
+CMStringW CVkProto::UserProfileUrl(LONG iUserId)
+{
+ return CMStringW(FORMAT, L"https://vk.com/%s%d", iUserId > 0 ? L"id" : L"club", iUserId > 0 ? iUserId : -1 * iUserId);
+} \ No newline at end of file
diff --git a/protocols/VKontakte/src/version.h b/protocols/VKontakte/src/version.h
index 00bdeae82c..f3b9b3737d 100644
--- a/protocols/VKontakte/src/version.h
+++ b/protocols/VKontakte/src/version.h
@@ -1,7 +1,7 @@
#define __MAJOR_VERSION 0
#define __MINOR_VERSION 1
#define __RELEASE_NUM 9
-#define __BUILD_NUM 0
+#define __BUILD_NUM 1
#include <stdver.h>
diff --git a/protocols/VKontakte/src/vk_chats.cpp b/protocols/VKontakte/src/vk_chats.cpp
index e72a0e0634..2cbed48bf6 100644
--- a/protocols/VKontakte/src/vk_chats.cpp
+++ b/protocols/VKontakte/src/vk_chats.cpp
@@ -143,6 +143,10 @@ void CVkProto::OnReceiveChatInfo(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pRe
break;
int uid = jnUser["id"].as_int();
+ bool bIsGroup = jnUser["type"].as_mstring() == L"group";
+ if (bIsGroup)
+ uid *= -1;
+
wchar_t wszId[20];
_itow(uid, wszId, 10);
@@ -157,11 +161,12 @@ void CVkProto::OnReceiveChatInfo(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pRe
cu->m_bDel = false;
CMStringW wszNick(ptrW(db_get_wsa(cc->m_hContact, m_szModuleName, CMStringA(FORMAT, "nick%d", cu->m_uid))));
- if (wszNick.IsEmpty()) {
- CMStringW fName(jnUser["first_name"].as_mstring());
- CMStringW lName(jnUser["last_name"].as_mstring());
- wszNick = fName.Trim() + L" " + lName.Trim();
- }
+ if (wszNick.IsEmpty())
+ wszNick = bIsGroup ?
+ jnUser["name"].as_mstring() :
+ jnUser["first_name"].as_mstring().Trim() + L" " + jnUser["last_name"].as_mstring().Trim();
+
+
cu->m_wszNick = mir_wstrdup(wszNick);
cu->m_bUnknown = false;
@@ -190,7 +195,10 @@ void CVkProto::OnReceiveChatInfo(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pRe
gce.pszUID.w = wszId;
gce.dwFlags = GCEF_NOTNOTIFY;
gce.time = time(0);
- gce.pszNick.w = mir_wstrdup(CMStringW(FORMAT, L"%s (https://vk.com/id%s)", cu->m_wszNick, wszId));
+ gce.pszNick.w = mir_wstrdup(CMStringW(FORMAT, L"%s (%s)",
+ cu->m_wszNick,
+ UserProfileUrl(cu->m_uid).c_str()
+ ));
Chat_Event(&gce);
cc->m_users.remove(T.indexOf(&cu));
@@ -305,7 +313,7 @@ void CVkProto::AppendChatMessage(int id, const JSONNode &jnMsg, const JSONNode &
if (wszUid == wszActionMid) {
if (cc->m_bHistoryRead)
return;
- wszBody.AppendFormat(L" (https://vk.com/id%s) %s", wszUid.c_str(), TranslateT("left chat"));
+ wszBody.AppendFormat(L" (%s) %s", UserProfileUrl(uid).c_str(), TranslateT("left chat"));
}
else {
int a_uid = 0;
@@ -313,9 +321,9 @@ void CVkProto::AppendChatMessage(int id, const JSONNode &jnMsg, const JSONNode &
if (iReadCount == 1) {
CVkChatUser *cu = cc->m_users.find((CVkChatUser*)&a_uid);
if (cu == nullptr)
- wszBody.AppendFormat(L"%s (https://vk.com/id%d)", TranslateT("kick user"), a_uid);
+ wszBody.AppendFormat(L"%s (%s)", TranslateT("kick user"), UserProfileUrl(a_uid).c_str());
else
- wszBody.AppendFormat(L"%s %s (https://vk.com/id%d)", TranslateT("kick user"), cu->m_wszNick, a_uid);
+ wszBody.AppendFormat(L"%s %s (%s)", TranslateT("kick user"), cu->m_wszNick, UserProfileUrl(a_uid).c_str());
}
else
wszBody = TranslateT("kick user");
@@ -329,16 +337,16 @@ void CVkProto::AppendChatMessage(int id, const JSONNode &jnMsg, const JSONNode &
else {
CMStringW wszUid(FORMAT, L"%d", uid);
if (wszUid == wszActionMid)
- wszBody.AppendFormat(L" (https://vk.com/id%s) %s", wszUid.c_str(), TranslateT("returned to chat"));
+ wszBody.AppendFormat(L" (%s) %s", UserProfileUrl(uid).c_str(), TranslateT("returned to chat"));
else {
int a_uid = 0;
int iReadCount = swscanf(wszActionMid, L"%d", &a_uid);
if (iReadCount == 1) {
CVkChatUser *cu = cc->m_users.find((CVkChatUser*)&a_uid);
if (cu == nullptr)
- wszBody.AppendFormat(L"%s (https://vk.com/id%d)", TranslateT("invite user"), a_uid);
+ wszBody.AppendFormat(L"%s (%s)", TranslateT("invite user"), UserProfileUrl(a_uid).c_str());
else
- wszBody.AppendFormat(L"%s %s (https://vk.com/id%d)", TranslateT("invite user"), cu->m_wszNick, a_uid);
+ wszBody.AppendFormat(L"%s %s (%s)", TranslateT("invite user"), cu->m_wszNick, UserProfileUrl(a_uid).c_str());
}
else
wszBody = TranslateT("invite user");
@@ -720,7 +728,7 @@ void CVkProto::NickMenuHook(CVkChatInfo *cc, GCHOOK *gch)
case IDM_VISIT_PROFILE:
hContact = FindUser(cu->m_uid);
if (hContact == 0)
- Utils_OpenUrlW(CMStringW(FORMAT, L"https://vk.com/id%d", cu->m_uid));
+ Utils_OpenUrlW(UserProfileUrl(cu->m_uid));
else
SvcVisitProfile(hContact, 0);
break;
diff --git a/protocols/VKontakte/src/vk_proto.h b/protocols/VKontakte/src/vk_proto.h
index 4d28187caa..e50e42a2b6 100644
--- a/protocols/VKontakte/src/vk_proto.h
+++ b/protocols/VKontakte/src/vk_proto.h
@@ -365,6 +365,7 @@ private:
MEVENT GetMessageFromDb(const char * messageId, UINT &timestamp, CMStringW &msg);
int DeleteContact(MCONTACT hContact);
bool IsMessageExist(UINT iMsgId, VKMesType vkType = vkALL);
+ CMStringW UserProfileUrl(LONG iUserId);
void InitQueue();
void UninitQueue();
bool ExecuteRequest(AsyncHttpRequest*);
diff --git a/protocols/VKontakte/src/vk_struct.h b/protocols/VKontakte/src/vk_struct.h
index f6fb01ddc8..ee6b699b56 100644
--- a/protocols/VKontakte/src/vk_struct.h
+++ b/protocols/VKontakte/src/vk_struct.h
@@ -142,7 +142,7 @@ struct CVkUserInfo : public MZeroedObject {
m_bIsGroup(false)
{}
- CVkUserInfo(LONG _UserId, bool _bIsGroup, CMStringW& _wszUserNick, CMStringW& _wszLink, MCONTACT _hContact = 0) :
+ CVkUserInfo(LONG _UserId, bool _bIsGroup, const CMStringW& _wszUserNick, const CMStringW& _wszLink, MCONTACT _hContact = 0) :
m_UserId(_UserId),
m_bIsGroup(_bIsGroup),
m_wszUserNick(_wszUserNick),