diff options
Diffstat (limited to 'protocols')
-rw-r--r-- | protocols/Telegram/src/menus.cpp | 6 | ||||
-rw-r--r-- | protocols/Telegram/src/proto.cpp | 9 | ||||
-rw-r--r-- | protocols/Telegram/src/utils.cpp | 11 | ||||
-rw-r--r-- | protocols/Telegram/src/utils.h | 1 |
4 files changed, 19 insertions, 8 deletions
diff --git a/protocols/Telegram/src/menus.cpp b/protocols/Telegram/src/menus.cpp index 5a58072f46..742ca9df91 100644 --- a/protocols/Telegram/src/menus.cpp +++ b/protocols/Telegram/src/menus.cpp @@ -118,7 +118,7 @@ public: for (auto &it : m_ids) { DB::EventInfo dbei(it, false); if (dbei && dbei.szId) - message_ids.push_back(_atoi64(dbei.szId)); + message_ids.push_back(dbei2id(dbei)); } for (auto &hContact : m_proto->AccContacts()) { @@ -178,7 +178,7 @@ public: auto *pMessage = new TD::sendMessage(); pMessage->chat_id_ = m_pUser->chatId; pMessage->input_message_content_ = std::move(pContent); - pMessage->reply_to_message_id_ = _atoi64(dbei.szId); + pMessage->reply_to_message_id_ = dbei2id(dbei); m_proto->SendQuery(pMessage, &CTelegramProto::OnSendMessage); return true; } @@ -212,7 +212,7 @@ public: bool OnApply() override { DB::EventInfo dbei(m_hEvent, false); - __int64 msgId = (dbei && dbei.szId) ? _atoi64(dbei.szId) : 0; + __int64 msgId = ::dbei2id(dbei); char *pszEmoji = (char *)cmbReactions.GetCurData(); auto reaction = TD::make_object<TD::reactionTypeEmoji>(pszEmoji); diff --git a/protocols/Telegram/src/proto.cpp b/protocols/Telegram/src/proto.cpp index 08f7f102ad..3f5037e65f 100644 --- a/protocols/Telegram/src/proto.cpp +++ b/protocols/Telegram/src/proto.cpp @@ -218,8 +218,7 @@ void CTelegramProto::OnEventDeleted(MCONTACT hContact, MEVENT hDbEvent) if (!pUser) return; - DBEVENTINFO dbei = {}; - db_event_get(hDbEvent, &dbei); + DB::EventInfo dbei(hDbEvent, false); if (dbei.szId) { mir_cslock lck(m_csDeleteMsg); if (m_deleteChatId) { @@ -230,7 +229,7 @@ void CTelegramProto::OnEventDeleted(MCONTACT hContact, MEVENT hDbEvent) } m_deleteChatId = pUser->chatId; - m_deleteIds.push_back(_atoi64(dbei.szId)); + m_deleteIds.push_back(dbei2id(dbei)); m_impl.m_deleteMsg.Start(500); } } @@ -247,7 +246,7 @@ void CTelegramProto::OnEventEdited(MCONTACT hContact, MEVENT, const DBEVENTINFO if (dbei.szId && dbei.cbBlob && dbei.pBlob && dbei.eventType == EVENTTYPE_MESSAGE) { auto text = formatBbcodes((char*)dbei.pBlob); auto content = TD::make_object<TD::inputMessageText>(std::move(text), false, false); - SendQuery(new TD::editMessageText(pUser->chatId, _atoi64(dbei.szId), 0, std::move(content))); + SendQuery(new TD::editMessageText(pUser->chatId, dbei2id(dbei), 0, std::move(content))); } } @@ -271,7 +270,7 @@ void CTelegramProto::OnMarkRead(MCONTACT hContact, MEVENT hDbEvent) } m_markChatId = pUser->chatId; - m_markIds.push_back(_atoi64(dbei.szId)); + m_markIds.push_back(dbei2id(dbei)); m_impl.m_markRead.Start(500); } } diff --git a/protocols/Telegram/src/utils.cpp b/protocols/Telegram/src/utils.cpp index e468d58c68..e110d1c5a0 100644 --- a/protocols/Telegram/src/utils.cpp +++ b/protocols/Telegram/src/utils.cpp @@ -112,6 +112,17 @@ CMStringA msg2id(const TD::message *pMsg) return CMStringA(FORMAT, "%lld_%lld", pMsg->chat_id_, pMsg->id_);
}
+TD::int53 dbei2id(const DBEVENTINFO &dbei)
+{
+ if (dbei.szId == nullptr)
+ return -1;
+
+ auto *p = strchr(dbei.szId, '_');
+ return _atoi64(p ? p + 1 : dbei.szId);
+}
+
+/////////////////////////////////////////////////////////////////////////////////////////
+
const char *getName(const TD::usernames *pName)
{
return (pName == nullptr) ? TranslateU("none") : pName->editable_username_.c_str();
diff --git a/protocols/Telegram/src/utils.h b/protocols/Telegram/src/utils.h index 1af5f4ee4c..b6b3bd62da 100644 --- a/protocols/Telegram/src/utils.h +++ b/protocols/Telegram/src/utils.h @@ -10,3 +10,4 @@ TG_FILE_REQUEST::Type AutoDetectType(const wchar_t *pwszFilename); CMStringA msg2id(const TD::message *pMsg);
CMStringA msg2id(TD::int53 chatId, TD::int53 msgId);
+TD::int53 dbei2id(const DBEVENTINFO &dbei);
|