summaryrefslogtreecommitdiff
path: root/protocols/Telegram
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2023-12-04 18:33:22 +0300
committerGeorge Hazan <george.hazan@gmail.com>2023-12-04 18:33:22 +0300
commitedf1ce9f204c266af0fca606cbf692675018395b (patch)
tree1bc20fe650f3c25dfd998eae03a95b794ebbb154 /protocols/Telegram
parent03b94ae84e786dac1eff683f03f8849bc589df93 (diff)
Telegram: added support for reading typing notifications
Diffstat (limited to 'protocols/Telegram')
-rw-r--r--protocols/Telegram/src/proto.h1
-rw-r--r--protocols/Telegram/src/server.cpp24
2 files changed, 25 insertions, 0 deletions
diff --git a/protocols/Telegram/src/proto.h b/protocols/Telegram/src/proto.h
index 45839832a5..3c1661d3f9 100644
--- a/protocols/Telegram/src/proto.h
+++ b/protocols/Telegram/src/proto.h
@@ -247,6 +247,7 @@ class CTelegramProto : public PROTO<CTelegramProto>
void ProcessBasicGroup(TD::updateBasicGroup *pObj);
void ProcessBasicGroupInfo(TD::updateBasicGroupFullInfo *pObj);
void ProcessChat(TD::updateNewChat *pObj);
+ void ProcessChatAction(TD::updateChatAction *pObj);
void ProcessChatLastMessage(TD::updateChatLastMessage *pObj);
void ProcessChatNotification(TD::updateChatNotificationSettings *pObj);
void ProcessChatPosition(TD::updateChatPosition *pObj);
diff --git a/protocols/Telegram/src/server.cpp b/protocols/Telegram/src/server.cpp
index 75e4fa0cdc..89b8787f07 100644
--- a/protocols/Telegram/src/server.cpp
+++ b/protocols/Telegram/src/server.cpp
@@ -201,6 +201,10 @@ void CTelegramProto::ProcessResponse(td::ClientManager::Response response)
ProcessBasicGroupInfo((TD::updateBasicGroupFullInfo *)response.object.get());
break;
+ case TD::updateChatAction::ID:
+ ProcessChatAction((TD::updateChatAction *)response.object.get());
+ break;
+
case TD::updateChatFolders::ID:
ProcessGroups((TD::updateChatFolders *)response.object.get());
break;
@@ -490,6 +494,26 @@ void CTelegramProto::ProcessChat(TD::updateNewChat *pObj)
else debugLogA("Unknown user id %lld, ignoring", userId);
}
+void CTelegramProto::ProcessChatAction(TD::updateChatAction *pObj)
+{
+ auto *pChat = FindChat(pObj->chat_id_);
+ if (pChat == nullptr) {
+ debugLogA("Unknown chat, skipping");
+ return;
+ }
+
+ if (pChat->hContact == INVALID_CONTACT_ID) {
+ debugLogA("Last message for a temporary contact, skipping");
+ return;
+ }
+
+ switch (pObj->action_->get_id()) {
+ case TD::chatActionTyping::ID:
+ CallService(MS_PROTO_CONTACTISTYPING, pChat->hContact, 1);
+ break;
+ }
+}
+
void CTelegramProto::ProcessChatLastMessage(TD::updateChatLastMessage *pObj)
{
auto *pUser = FindChat(pObj->chat_id_);