summaryrefslogtreecommitdiff
path: root/protocols
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2023-06-22 22:59:47 +0300
committerGeorge Hazan <george.hazan@gmail.com>2023-06-22 22:59:47 +0300
commit253e80bc4b440589ead1f756daffa66ad3a045c3 (patch)
tree46a214f8bdb2748ba2348d8b71c18f12904eb8bb /protocols
parent9702654d785eecad86702562413f3ee32f5e423f (diff)
Telegram: fix for correct FirstName parsing
Diffstat (limited to 'protocols')
-rw-r--r--protocols/Telegram/src/server.cpp13
1 files changed, 11 insertions, 2 deletions
diff --git a/protocols/Telegram/src/server.cpp b/protocols/Telegram/src/server.cpp
index d40b6dc82f..b702e95177 100644
--- a/protocols/Telegram/src/server.cpp
+++ b/protocols/Telegram/src/server.cpp
@@ -786,8 +786,17 @@ void CTelegramProto::ProcessUser(TD::updateUser *pObj)
}
auto *pu = AddUser(pUser->id_, false);
- UpdateString(pu->hContact, "FirstName", pUser->first_name_);
- UpdateString(pu->hContact, "LastName", pUser->last_name_);
+ std::string szFirstName = pUser->first_name_, szLastName = pUser->last_name_;
+ if (szLastName.empty()) {
+ size_t p = szFirstName.rfind(' ');
+ if (p != -1) {
+ szLastName = szFirstName.substr(p + 1);
+ szFirstName = szFirstName.substr(0, p);
+ }
+ }
+
+ setUString(pu->hContact, "FirstName", szFirstName.c_str());
+ setUString(pu->hContact, "LastName", szLastName.c_str());
if (pu->hContact)
UpdateString(pu->hContact, "Phone", pUser->phone_number_);