From 843dff97a6ea146f5ed1291563703987a337845a Mon Sep 17 00:00:00 2001 From: levlam Date: Tue, 13 Aug 2024 21:08:08 +0300 Subject: [PATCH] Add supergroup.has_sensitive_content. --- td/generate/scheme/td_api.tl | 3 ++- td/telegram/ChatManager.cpp | 7 ++++--- td/telegram/RestrictionReason.cpp | 4 ++++ td/telegram/RestrictionReason.h | 2 ++ 4 files changed, 12 insertions(+), 4 deletions(-) diff --git a/td/generate/scheme/td_api.tl b/td/generate/scheme/td_api.tl index 76f9d2db5..66e16d25d 100644 --- a/td/generate/scheme/td_api.tl +++ b/td/generate/scheme/td_api.tl @@ -1354,12 +1354,13 @@ basicGroupFullInfo photo:chatPhoto description:string creator_user_id:int53 memb //@is_broadcast_group True, if the supergroup is a broadcast group, i.e. only administrators can send messages and there is no limit on the number of members //@is_forum True, if the supergroup is a forum with topics //@is_verified True, if the supergroup or channel is verified +//@has_sensitive_content True, if content of media messages in the supergroup or channel chat must be hidden with 18+ spoiler //@restriction_reason If non-empty, contains a human-readable description of the reason why access to this supergroup or channel must be restricted //@is_scam True, if many users reported this supergroup or channel as a scam //@is_fake True, if many users reported this supergroup or channel as a fake account //@has_active_stories True, if the supergroup or channel has non-expired stories available to the current user //@has_unread_active_stories True, if the supergroup or channel has unread non-expired stories available to the current user -supergroup id:int53 usernames:usernames date:int32 status:ChatMemberStatus member_count:int32 boost_level:int32 has_linked_chat:Bool has_location:Bool sign_messages:Bool show_message_sender:Bool join_to_send_messages:Bool join_by_request:Bool is_slow_mode_enabled:Bool is_channel:Bool is_broadcast_group:Bool is_forum:Bool is_verified:Bool restriction_reason:string is_scam:Bool is_fake:Bool has_active_stories:Bool has_unread_active_stories:Bool = Supergroup; +supergroup id:int53 usernames:usernames date:int32 status:ChatMemberStatus member_count:int32 boost_level:int32 has_linked_chat:Bool has_location:Bool sign_messages:Bool show_message_sender:Bool join_to_send_messages:Bool join_by_request:Bool is_slow_mode_enabled:Bool is_channel:Bool is_broadcast_group:Bool is_forum:Bool is_verified:Bool has_sensitive_content:Bool restriction_reason:string is_scam:Bool is_fake:Bool has_active_stories:Bool has_unread_active_stories:Bool = Supergroup; //@description Contains full information about a supergroup or channel //@photo Chat photo; may be null if empty or unknown. If non-null, then it is the same photo as in chat.photo diff --git a/td/telegram/ChatManager.cpp b/td/telegram/ChatManager.cpp index ad3a75a87..8f48822e6 100644 --- a/td/telegram/ChatManager.cpp +++ b/td/telegram/ChatManager.cpp @@ -8851,8 +8851,8 @@ td_api::object_ptr ChatManager::get_update_unknown_sup bool is_megagroup = min_channel == nullptr ? false : min_channel->is_megagroup_; return td_api::make_object(td_api::make_object( channel_id.get(), nullptr, 0, DialogParticipantStatus::Banned(0).get_chat_member_status_object(), 0, 0, false, - false, false, false, !is_megagroup, false, false, !is_megagroup, false, false, false, string(), false, false, - false, false)); + false, false, false, !is_megagroup, false, false, !is_megagroup, false, false, false, false, string(), false, + false, false, false)); } int64 ChatManager::get_supergroup_id_object(ChannelId channel_id, const char *source) const { @@ -8891,7 +8891,8 @@ tl_object_ptr ChatManager::get_supergroup_object(ChannelId c get_channel_status(c).get_chat_member_status_object(), c->participant_count, c->boost_level, c->has_linked_channel, c->has_location, c->sign_messages, c->show_message_sender, get_channel_join_to_send(c), get_channel_join_request(c), c->is_slow_mode_enabled, !c->is_megagroup, c->is_gigagroup, c->is_forum, - c->is_verified, get_restriction_reason_description(c->restriction_reasons), c->is_scam, c->is_fake, + c->is_verified, get_restriction_reason_has_sensitive_content(c->restriction_reasons), + get_restriction_reason_description(c->restriction_reasons), c->is_scam, c->is_fake, c->max_active_story_id.is_valid(), get_channel_has_unread_stories(c)); } diff --git a/td/telegram/RestrictionReason.cpp b/td/telegram/RestrictionReason.cpp index c2368e573..c187a70bd 100644 --- a/td/telegram/RestrictionReason.cpp +++ b/td/telegram/RestrictionReason.cpp @@ -74,6 +74,10 @@ const RestrictionReason *get_restriction_reason(const vector return nullptr; } +bool get_restriction_reason_has_sensitive_content(const vector &restriction_reasons) { + return get_restriction_reason(restriction_reasons, true) != nullptr; +} + string get_restriction_reason_description(const vector &restriction_reasons) { const auto *restriction_reason = get_restriction_reason(restriction_reasons, false); if (restriction_reason == nullptr) { diff --git a/td/telegram/RestrictionReason.h b/td/telegram/RestrictionReason.h index 45e81601f..391a0983c 100644 --- a/td/telegram/RestrictionReason.h +++ b/td/telegram/RestrictionReason.h @@ -67,6 +67,8 @@ inline bool operator!=(const RestrictionReason &lhs, const RestrictionReason &rh return !(lhs == rhs); } +bool get_restriction_reason_has_sensitive_content(const vector &restriction_reasons); + string get_restriction_reason_description(const vector &restriction_reasons); vector get_restriction_reasons(Slice legacy_restriction_reason);