diff options
author | George Hazan <ghazan@miranda.im> | 2023-02-15 13:37:01 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2023-02-15 13:37:01 +0300 |
commit | 85f62df34eb1a5c5310178cc0d08ad13132f5c7b (patch) | |
tree | 555eccb42321f40d7d8aa241ef5762ec29b1308a /protocols | |
parent | 976d7c7082d30d6811d776a4108e265fa608c0cf (diff) |
minor code optimization
Diffstat (limited to 'protocols')
-rw-r--r-- | protocols/Telegram/src/proto.h | 1 | ||||
-rw-r--r-- | protocols/Telegram/src/server.cpp | 8 | ||||
-rw-r--r-- | protocols/Telegram/src/utils.cpp | 13 |
3 files changed, 17 insertions, 5 deletions
diff --git a/protocols/Telegram/src/proto.h b/protocols/Telegram/src/proto.h index b0dc9645a0..4b5c1afa13 100644 --- a/protocols/Telegram/src/proto.h +++ b/protocols/Telegram/src/proto.h @@ -231,6 +231,7 @@ class CTelegramProto : public PROTO<CTelegramProto> TG_USER* FindUser(int64_t id); TG_USER* AddUser(int64_t id, bool bIsChat); TG_USER* AddFakeUser(int64_t id, bool bIsChat); + void SetId(MCONTACT, int64_t id); // Popups HANDLE m_hPopupClass; diff --git a/protocols/Telegram/src/server.cpp b/protocols/Telegram/src/server.cpp index 291cf9e056..66fcd2f6f8 100644 --- a/protocols/Telegram/src/server.cpp +++ b/protocols/Telegram/src/server.cpp @@ -480,9 +480,13 @@ void CTelegramProto::ProcessUser(TD::updateUser *pObj) if (pUser->phone_number_ == m_szFullPhone.c_str()) {
m_iOwnId = pUser->id_;
+ SetId(0, m_iOwnId);
- if (!FindUser(pUser->id_))
- m_arUsers.insert(new TG_USER(pUser->id_, 0));
+ if (!FindUser(pUser->id_)) {
+ auto *pMe = new TG_USER(pUser->id_, 0);
+ m_arUsers.insert(pMe);
+ m_arChats.insert(pMe);
+ }
}
if (!pUser->is_contact_) {
diff --git a/protocols/Telegram/src/utils.cpp b/protocols/Telegram/src/utils.cpp index 7dfe0c3096..8a5a1ddb87 100644 --- a/protocols/Telegram/src/utils.cpp +++ b/protocols/Telegram/src/utils.cpp @@ -82,6 +82,15 @@ void CTelegramProto::ReportSearchUser(TG_USER *pUser) /////////////////////////////////////////////////////////////////////////////////////////
+void CTelegramProto::SetId(MCONTACT hContact, int64_t id)
+{
+ char szId[100];
+ _i64toa(id, szId, 10);
+ setString(hContact, DBKEY_ID, szId);
+}
+
+/////////////////////////////////////////////////////////////////////////////////////////
+
void CTelegramProto::UpdateString(MCONTACT hContact, const char *pszSetting, const std::string &str)
{
if (str.empty())
@@ -126,9 +135,7 @@ TG_USER* CTelegramProto::AddUser(int64_t id, bool bIsChat) MCONTACT hContact = db_add_contact();
Proto_AddToContact(hContact, m_szModuleName);
- char szId[100];
- _i64toa(id, szId, 10);
- setString(hContact, DBKEY_ID, szId);
+ SetId(hContact, id);
if (bIsChat) {
Clist_SetGroup(hContact, TranslateT("Chat rooms"));
|