aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorlevlam <levlam@telegram.org>2026-07-10 20:54:01 +0300
committerlevlam <levlam@telegram.org>2026-07-10 20:54:01 +0300
commit5e6beb57c2777190688cd5b369c3337af4951327 (patch)
treef0c7a700283f067f9a48e26c62dccd8c4f7cdeb5
parentfb671dce698f1fb7b470d782aabf33538892a8d8 (diff)
Accept messageActionChangeCommunity only with accessible communities.
-rw-r--r--td/telegram/CommunityManager.cpp5
-rw-r--r--td/telegram/CommunityManager.h2
-rw-r--r--td/telegram/UpdatesManager.cpp14
-rw-r--r--td/telegram/UpdatesManager.h3
4 files changed, 23 insertions, 1 deletions
diff --git a/td/telegram/CommunityManager.cpp b/td/telegram/CommunityManager.cpp
index 734ce999d..deda69dc5 100644
--- a/td/telegram/CommunityManager.cpp
+++ b/td/telegram/CommunityManager.cpp
@@ -346,6 +346,11 @@ bool CommunityManager::have_community(CommunityId community_id) const {
return communities_.count(community_id) > 0;
}
+bool CommunityManager::have_accessible_community(CommunityId community_id) const {
+ const auto *c = get_community(community_id);
+ return c != nullptr && c->access_hash != 0;
+}
+
const CommunityManager::Community *CommunityManager::get_community(CommunityId community_id) const {
return communities_.get_pointer(community_id);
}
diff --git a/td/telegram/CommunityManager.h b/td/telegram/CommunityManager.h
index c2d3a621b..92ae2718a 100644
--- a/td/telegram/CommunityManager.h
+++ b/td/telegram/CommunityManager.h
@@ -37,6 +37,8 @@ class CommunityManager final : public Actor {
bool have_community_force(CommunityId community_id, const char *source);
+ bool have_accessible_community(CommunityId community_id) const;
+
void reload_community(CommunityId community_id, Promise<Unit> &&promise, const char *source);
void on_get_community(telegram_api::community &community, const char *source);
diff --git a/td/telegram/UpdatesManager.cpp b/td/telegram/UpdatesManager.cpp
index 09562db8c..fe7769342 100644
--- a/td/telegram/UpdatesManager.cpp
+++ b/td/telegram/UpdatesManager.cpp
@@ -20,6 +20,7 @@
#include "td/telegram/ChannelType.h"
#include "td/telegram/ChatId.h"
#include "td/telegram/ChatManager.h"
+#include "td/telegram/CommunityManager.h"
#include "td/telegram/ConfigManager.h"
#include "td/telegram/DialogAction.h"
#include "td/telegram/DialogActionManager.h"
@@ -722,6 +723,11 @@ bool UpdatesManager::is_acceptable_channel(ChannelId channel_id) const {
return td_->chat_manager_->have_channel_force(channel_id, "is_acceptable_channel");
}
+bool UpdatesManager::is_acceptable_community(CommunityId community_id) const {
+ return td_->community_manager_->have_community_force(community_id, "is_acceptable_community") &&
+ td_->community_manager_->have_accessible_community(community_id);
+}
+
bool UpdatesManager::is_acceptable_peer(const tl_object_ptr<telegram_api::Peer> &peer) const {
if (peer == nullptr) {
return true;
@@ -992,7 +998,6 @@ bool UpdatesManager::is_acceptable_message(const telegram_api::Message *message_
case telegram_api::messageActionPollAppendAnswer::ID:
case telegram_api::messageActionPollDeleteAnswer::ID:
case telegram_api::messageActionManagedBotCreated::ID:
- case telegram_api::messageActionChangeCommunity::ID:
break;
case telegram_api::messageActionChatCreate::ID: {
auto action = static_cast<const telegram_api::messageActionChatCreate *>(action_ptr);
@@ -1110,6 +1115,13 @@ bool UpdatesManager::is_acceptable_message(const telegram_api::Message *message_
}
break;
}
+ case telegram_api::messageActionChangeCommunity::ID: {
+ auto action = static_cast<const telegram_api::messageActionChangeCommunity *>(action_ptr);
+ if (action->community_id_ != 0 && !is_acceptable_community(CommunityId(action->community_id_))) {
+ return false;
+ }
+ break;
+ }
default:
UNREACHABLE();
return false;
diff --git a/td/telegram/UpdatesManager.h b/td/telegram/UpdatesManager.h
index 6bb30d48d..9a47a007c 100644
--- a/td/telegram/UpdatesManager.h
+++ b/td/telegram/UpdatesManager.h
@@ -8,6 +8,7 @@
#include "td/telegram/ChannelId.h"
#include "td/telegram/ChatId.h"
+#include "td/telegram/CommunityId.h"
#include "td/telegram/DialogId.h"
#include "td/telegram/InputGroupCallId.h"
#include "td/telegram/MessageFullId.h"
@@ -491,6 +492,8 @@ class UpdatesManager final : public Actor {
bool is_acceptable_channel(ChannelId channel_id) const;
+ bool is_acceptable_community(CommunityId community_id) const;
+
bool is_acceptable_peer(const tl_object_ptr<telegram_api::Peer> &peer) const;
bool is_acceptable_message_entities(const vector<tl_object_ptr<telegram_api::MessageEntity>> &message_entities) const;