Support separate chat permissions for different media types.

This commit is contained in:
levlam 2023-01-06 14:16:34 +03:00
parent 69760f891a
commit ad8ecec67c
8 changed files with 191 additions and 68 deletions

View File

@ -563,7 +563,12 @@ inputChatPhotoAnimation animation:InputFile main_frame_timestamp:double = InputC
//@description Describes actions that a user is allowed to take in a chat
//@can_send_messages True, if the user can send text messages, contacts, invoices, locations, and venues
//@can_send_media_messages True, if the user can send audio files, documents, photos, videos, video notes, and voice notes. Implies can_send_messages permissions
//@can_send_audios True, if the user can send music files. Implies can_send_messages permissions
//@can_send_documents True, if the user can send documents. Implies can_send_messages permissions
//@can_send_photos True, if the user can send audio photos. Implies can_send_messages permissions
//@can_send_videos True, if the user can send audio videos. Implies can_send_messages permissions
//@can_send_video_notes True, if the user can send video notes. Implies can_send_messages permissions
//@can_send_voice_notes True, if the user can send voice notes. Implies can_send_messages permissions
//@can_send_polls True, if the user can send polls. Implies can_send_messages permissions
//@can_send_other_messages True, if the user can send animations, games, stickers, and dice and use inline bots. Implies can_send_messages permissions
//@can_add_web_page_previews True, if the user may add a web page preview to their messages. Implies can_send_messages permissions
@ -571,7 +576,7 @@ inputChatPhotoAnimation animation:InputFile main_frame_timestamp:double = InputC
//@can_invite_users True, if the user can invite new users to the chat
//@can_pin_messages True, if the user can pin messages
//@can_manage_topics True, if the user can manage topics
chatPermissions can_send_messages:Bool can_send_media_messages:Bool can_send_polls:Bool can_send_other_messages:Bool can_add_web_page_previews:Bool can_change_info:Bool can_invite_users:Bool can_pin_messages:Bool can_manage_topics:Bool = ChatPermissions;
chatPermissions can_send_messages:Bool can_send_audios:Bool can_send_documents:Bool can_send_photos:Bool can_send_videos:Bool can_send_video_notes:Bool can_send_voice_notes:Bool can_send_polls:Bool can_send_other_messages:Bool can_add_web_page_previews:Bool can_change_info:Bool can_invite_users:Bool can_pin_messages:Bool can_manage_topics:Bool = ChatPermissions;
//@description Describes rights of the administrator
//@can_manage_chat True, if the administrator can get chat event log, get chat statistics, get message statistics in channels, get channel members, see anonymous administrators in supergroups and ignore slow mode. Implied by any other privilege; applicable to supergroups and channels only

View File

@ -4645,8 +4645,9 @@ void ContactsManager::Chat::parse(ParserT &parser) {
} else {
status = DialogParticipantStatus::Member();
}
default_permissions = RestrictedRights(true, true, true, true, true, true, true, true, everyone_is_administrator,
everyone_is_administrator, everyone_is_administrator, false);
default_permissions =
RestrictedRights(true, true, true, true, true, true, true, true, true, true, true, true, true,
everyone_is_administrator, everyone_is_administrator, everyone_is_administrator, false);
}
if (has_default_permissions_version) {
parse(default_permissions_version, parser);
@ -4913,8 +4914,8 @@ void ContactsManager::Channel::parse(ParserT &parser) {
if (have_default_permissions) {
parse(default_permissions, parser);
} else {
default_permissions =
RestrictedRights(true, true, true, true, true, true, true, true, false, anyone_can_invite, false, false);
default_permissions = RestrictedRights(true, true, true, true, true, true, true, true, true, true, true, true,
true, false, anyone_can_invite, false, false);
}
}
if (has_cache_version) {
@ -5523,15 +5524,18 @@ string ContactsManager::get_secret_chat_title(SecretChatId secret_chat_id) const
RestrictedRights ContactsManager::get_user_default_permissions(UserId user_id) const {
auto u = get_user(user_id);
if (u == nullptr || user_id == get_replies_bot_user_id()) {
return RestrictedRights(false, false, false, false, false, false, false, false, false, false, u != nullptr, false);
return RestrictedRights(false, false, false, false, false, false, false, false, false, false, false, false, false,
false, false, u != nullptr, false);
}
return RestrictedRights(true, true, true, true, true, true, true, true, false, false, true, false);
return RestrictedRights(true, true, true, true, true, true, true, true, true, true, true, true, true, false, false,
true, false);
}
RestrictedRights ContactsManager::get_chat_default_permissions(ChatId chat_id) const {
auto c = get_chat(chat_id);
if (c == nullptr) {
return RestrictedRights(false, false, false, false, false, false, false, false, false, false, false, false);
return RestrictedRights(false, false, false, false, false, false, false, false, false, false, false, false, false,
false, false, false, false);
}
return c->default_permissions;
}
@ -5539,7 +5543,8 @@ RestrictedRights ContactsManager::get_chat_default_permissions(ChatId chat_id) c
RestrictedRights ContactsManager::get_channel_default_permissions(ChannelId channel_id) const {
auto c = get_channel(channel_id);
if (c == nullptr) {
return RestrictedRights(false, false, false, false, false, false, false, false, false, false, false, false);
return RestrictedRights(false, false, false, false, false, false, false, false, false, false, false, false, false,
false, false, false, false);
}
return c->default_permissions;
}
@ -5547,9 +5552,11 @@ RestrictedRights ContactsManager::get_channel_default_permissions(ChannelId chan
RestrictedRights ContactsManager::get_secret_chat_default_permissions(SecretChatId secret_chat_id) const {
auto c = get_secret_chat(secret_chat_id);
if (c == nullptr) {
return RestrictedRights(false, false, false, false, false, false, false, false, false, false, false, false);
return RestrictedRights(false, false, false, false, false, false, false, false, false, false, false, false, false,
false, false, false, false);
}
return RestrictedRights(true, true, true, true, true, true, true, true, false, false, false, false);
return RestrictedRights(true, true, true, true, true, true, true, true, true, true, true, true, true, false, false,
false, false);
}
bool ContactsManager::get_chat_has_protected_content(ChatId chat_id) const {
@ -11569,8 +11576,8 @@ void ContactsManager::update_channel(Channel *c, ChannelId channel_id, bool from
}
if (c->is_default_permissions_changed) {
td_->messages_manager_->on_dialog_default_permissions_updated(DialogId(channel_id));
if (c->default_permissions !=
RestrictedRights(false, false, false, false, false, false, false, false, false, false, false, false)) {
if (c->default_permissions != RestrictedRights(false, false, false, false, false, false, false, false, false, false,
false, false, false, false, false, false, false)) {
remove_dialog_suggested_action(SuggestedAction{SuggestedAction::Type::ConvertToGigagroup, DialogId(channel_id)});
}
c->is_default_permissions_changed = false;
@ -12562,9 +12569,9 @@ void ContactsManager::on_get_chat_full(tl_object_ptr<telegram_api::ChatFull> &&c
SuggestedAction suggested_action(action_str, DialogId(channel_id));
if (!suggested_action.is_empty()) {
if (suggested_action == SuggestedAction{SuggestedAction::Type::ConvertToGigagroup, DialogId(channel_id)} &&
(c->is_gigagroup ||
c->default_permissions != RestrictedRights(false, false, false, false, false, false, false, false,
false, false, false, false))) {
(c->is_gigagroup || c->default_permissions != RestrictedRights(false, false, false, false, false, false,
false, false, false, false, false, false,
false, false, false, false, false))) {
LOG(INFO) << "Skip ConvertToGigagroup suggested action";
} else {
suggested_actions.push_back(suggested_action);

View File

@ -841,8 +841,8 @@ class ContactsManager final : public Actor {
ChannelId migrated_to_channel_id;
DialogParticipantStatus status = DialogParticipantStatus::Banned(0);
RestrictedRights default_permissions{false, false, false, false, false, false,
false, false, false, false, false, false};
RestrictedRights default_permissions{false, false, false, false, false, false, false, false, false,
false, false, false, false, false, false, false, false};
static constexpr uint32 CACHE_VERSION = 4;
uint32 cache_version = 0;
@ -913,8 +913,8 @@ class ContactsManager final : public Actor {
Usernames usernames;
vector<RestrictionReason> restriction_reasons;
DialogParticipantStatus status = DialogParticipantStatus::Banned(0);
RestrictedRights default_permissions{false, false, false, false, false, false,
false, false, false, false, false, false};
RestrictedRights default_permissions{false, false, false, false, false, false, false, false, false,
false, false, false, false, false, false, false, false};
int32 date = 0;
int32 participant_count = 0;

View File

@ -197,10 +197,11 @@ RestrictedRights::RestrictedRights(const tl_object_ptr<telegram_api::chatBannedR
LOG_IF(ERROR, rights->until_date_ != std::numeric_limits<int32>::max())
<< "Have until date " << rights->until_date_ << " in restricted rights";
*this =
RestrictedRights(!rights->send_plain_, !rights->send_media_, !rights->send_stickers_, !rights->send_gifs_,
!rights->send_games_, !rights->send_inline_, !rights->embed_links_, !rights->send_polls_,
!rights->change_info_, !rights->invite_users_, !rights->pin_messages_, !rights->manage_topics_);
*this = RestrictedRights(!rights->send_plain_, !rights->send_audios_, !rights->send_docs_, !rights->send_photos_,
!rights->send_videos_, !rights->send_roundvideos_, !rights->send_voices_,
!rights->send_stickers_, !rights->send_gifs_, !rights->send_games_, !rights->send_inline_,
!rights->embed_links_, !rights->send_polls_, !rights->change_info_, !rights->invite_users_,
!rights->pin_messages_, !rights->manage_topics_);
}
RestrictedRights::RestrictedRights(const td_api::object_ptr<td_api::chatPermissions> &rights) {
@ -210,23 +211,36 @@ RestrictedRights::RestrictedRights(const td_api::object_ptr<td_api::chatPermissi
}
bool can_send_polls = rights->can_send_polls_;
bool can_send_media = rights->can_send_media_messages_;
bool can_send_messages = rights->can_send_messages_ || can_send_media || can_send_polls ||
bool can_send_audios = rights->can_send_audios_;
bool can_send_documents = rights->can_send_documents_;
bool can_send_photos = rights->can_send_photos_;
bool can_send_videos = rights->can_send_videos_;
bool can_send_video_notes = rights->can_send_video_notes_;
bool can_send_voice_notes = rights->can_send_voice_notes_;
bool can_send_messages = rights->can_send_messages_ || can_send_audios || can_send_documents || can_send_photos ||
can_send_videos || can_send_video_notes || can_send_voice_notes || can_send_polls ||
rights->can_send_other_messages_ || rights->can_add_web_page_previews_;
*this = RestrictedRights(can_send_messages, can_send_media, rights->can_send_other_messages_,
*this = RestrictedRights(can_send_messages, can_send_audios, can_send_documents, can_send_photos, can_send_videos,
can_send_video_notes, can_send_voice_notes, rights->can_send_other_messages_,
rights->can_send_other_messages_, rights->can_send_other_messages_,
rights->can_send_other_messages_, rights->can_add_web_page_previews_, can_send_polls,
rights->can_change_info_, rights->can_invite_users_, rights->can_pin_messages_,
rights->can_manage_topics_);
}
RestrictedRights::RestrictedRights(bool can_send_messages, bool can_send_media, bool can_send_stickers,
bool can_send_animations, bool can_send_games, bool can_use_inline_bots,
bool can_add_web_page_previews, bool can_send_polls,
bool can_change_info_and_settings, bool can_invite_users, bool can_pin_messages,
bool can_manage_topics) {
RestrictedRights::RestrictedRights(bool can_send_messages, bool can_send_audios, bool can_send_documents,
bool can_send_photos, bool can_send_videos, bool can_send_video_notes,
bool can_send_voice_notes, bool can_send_stickers, bool can_send_animations,
bool can_send_games, bool can_use_inline_bots, bool can_add_web_page_previews,
bool can_send_polls, bool can_change_info_and_settings, bool can_invite_users,
bool can_pin_messages, bool can_manage_topics) {
flags_ = (static_cast<uint64>(can_send_messages) * CAN_SEND_MESSAGES) |
(static_cast<uint64>(can_send_media) * CAN_SEND_MEDIA) |
(static_cast<uint64>(can_send_audios) * CAN_SEND_AUDIOS) |
(static_cast<uint64>(can_send_documents) * CAN_SEND_DOCUMENTS) |
(static_cast<uint64>(can_send_photos) * CAN_SEND_PHOTOS) |
(static_cast<uint64>(can_send_videos) * CAN_SEND_VIDEOS) |
(static_cast<uint64>(can_send_video_notes) * CAN_SEND_VIDEO_NOTES) |
(static_cast<uint64>(can_send_voice_notes) * CAN_SEND_VOICE_NOTES) |
(static_cast<uint64>(can_send_stickers) * CAN_SEND_STICKERS) |
(static_cast<uint64>(can_send_animations) * CAN_SEND_ANIMATIONS) |
(static_cast<uint64>(can_send_games) * CAN_SEND_GAMES) |
@ -241,7 +255,8 @@ RestrictedRights::RestrictedRights(bool can_send_messages, bool can_send_media,
td_api::object_ptr<td_api::chatPermissions> RestrictedRights::get_chat_permissions_object() const {
return td_api::make_object<td_api::chatPermissions>(
can_send_messages(), can_send_media(), can_send_polls(),
can_send_messages(), can_send_audios(), can_send_documents(), can_send_photos(), can_send_videos(),
can_send_video_notes(), can_send_voice_notes(), can_send_polls(),
can_send_stickers() || can_send_animations() || can_send_games() || can_use_inline_bots(),
can_add_web_page_previews(), can_change_info_and_settings(), can_invite_users(), can_pin_messages(),
can_manage_topics());
@ -252,8 +267,23 @@ tl_object_ptr<telegram_api::chatBannedRights> RestrictedRights::get_chat_banned_
if (!can_send_messages()) {
flags |= telegram_api::chatBannedRights::SEND_MESSAGES_MASK;
}
if (!can_send_media()) {
flags |= telegram_api::chatBannedRights::SEND_MEDIA_MASK;
if (!can_send_audios()) {
flags |= telegram_api::chatBannedRights::SEND_AUDIOS_MASK;
}
if (!can_send_documents()) {
flags |= telegram_api::chatBannedRights::SEND_DOCS_MASK;
}
if (!can_send_photos()) {
flags |= telegram_api::chatBannedRights::SEND_PHOTOS_MASK;
}
if (!can_send_videos()) {
flags |= telegram_api::chatBannedRights::SEND_VIDEOS_MASK;
}
if (!can_send_video_notes()) {
flags |= telegram_api::chatBannedRights::SEND_ROUNDVIDEOS_MASK;
}
if (!can_send_voice_notes()) {
flags |= telegram_api::chatBannedRights::SEND_VOICES_MASK;
}
if (!can_send_stickers()) {
flags |= telegram_api::chatBannedRights::SEND_STICKERS_MASK;
@ -307,8 +337,23 @@ StringBuilder &operator<<(StringBuilder &string_builder, const RestrictedRights
if (!status.can_send_messages()) {
string_builder << "(text)";
}
if (!status.can_send_media()) {
string_builder << "(media)";
if (!status.can_send_audios()) {
string_builder << "(audios)";
}
if (!status.can_send_documents()) {
string_builder << "(documents)";
}
if (!status.can_send_photos()) {
string_builder << "(photos)";
}
if (!status.can_send_videos()) {
string_builder << "(videos)";
}
if (!status.can_send_video_notes()) {
string_builder << "(video notes)";
}
if (!status.can_send_voice_notes()) {
string_builder << "(voice notes)";
}
if (!status.can_send_stickers()) {
string_builder << "(stickers)";
@ -438,9 +483,11 @@ DialogParticipantStatus::DialogParticipantStatus(bool is_member,
}
RestrictedRights DialogParticipantStatus::get_effective_restricted_rights() const {
return RestrictedRights(can_send_messages(), can_send_media(), can_send_stickers(), can_send_animations(),
can_send_games(), can_use_inline_bots(), can_add_web_page_previews(), can_send_polls(),
can_change_info_and_settings(), can_invite_users(), can_pin_messages(), can_create_topics());
return RestrictedRights(can_send_messages(), can_send_audios(), can_send_documents(), can_send_photos(),
can_send_videos(), can_send_video_notes(), can_send_voice_notes(), can_send_stickers(),
can_send_animations(), can_send_games(), can_use_inline_bots(), can_add_web_page_previews(),
can_send_polls(), can_change_info_and_settings(), can_invite_users(), can_pin_messages(),
can_create_topics());
}
tl_object_ptr<td_api::ChatMemberStatus> DialogParticipantStatus::get_chat_member_status_object() const {

View File

@ -143,7 +143,13 @@ StringBuilder &operator<<(StringBuilder &string_builder, const AdministratorRigh
class RestrictedRights {
static constexpr uint64 CAN_SEND_MESSAGES = 1 << 16;
static constexpr uint64 CAN_SEND_MEDIA = 1 << 17;
static constexpr uint64 LEGACY_CAN_SEND_MEDIA = 1 << 17;
static constexpr uint64 CAN_SEND_AUDIOS = static_cast<uint64>(1) << 32;
static constexpr uint64 CAN_SEND_DOCUMENTS = static_cast<uint64>(1) << 33;
static constexpr uint64 CAN_SEND_PHOTOS = static_cast<uint64>(1) << 34;
static constexpr uint64 CAN_SEND_VIDEOS = static_cast<uint64>(1) << 35;
static constexpr uint64 CAN_SEND_VIDEO_NOTES = static_cast<uint64>(1) << 36;
static constexpr uint64 CAN_SEND_VOICE_NOTES = static_cast<uint64>(1) << 37;
static constexpr uint64 CAN_SEND_STICKERS = 1 << 18;
static constexpr uint64 CAN_SEND_ANIMATIONS = 1 << 19;
static constexpr uint64 CAN_SEND_GAMES = 1 << 20;
@ -159,8 +165,9 @@ class RestrictedRights {
CAN_CHANGE_INFO_AND_SETTINGS | CAN_INVITE_USERS | CAN_PIN_MESSAGES | CAN_MANAGE_TOPICS;
static constexpr uint64 ALL_RESTRICTED_RIGHTS =
CAN_SEND_MESSAGES | CAN_SEND_MEDIA | CAN_SEND_STICKERS | CAN_SEND_ANIMATIONS | CAN_SEND_GAMES |
CAN_USE_INLINE_BOTS | CAN_ADD_WEB_PAGE_PREVIEWS | CAN_SEND_POLLS | ALL_ADMIN_PERMISSION_RIGHTS;
CAN_SEND_MESSAGES | CAN_SEND_STICKERS | CAN_SEND_ANIMATIONS | CAN_SEND_GAMES | CAN_USE_INLINE_BOTS |
CAN_ADD_WEB_PAGE_PREVIEWS | CAN_SEND_POLLS | ALL_ADMIN_PERMISSION_RIGHTS | CAN_SEND_AUDIOS | CAN_SEND_DOCUMENTS |
CAN_SEND_PHOTOS | CAN_SEND_VIDEOS | CAN_SEND_VIDEO_NOTES | CAN_SEND_VOICE_NOTES;
uint64 flags_;
@ -174,10 +181,11 @@ class RestrictedRights {
explicit RestrictedRights(const td_api::object_ptr<td_api::chatPermissions> &rights);
RestrictedRights(bool can_send_messages, bool can_send_media, bool can_send_stickers, bool can_send_animations,
bool can_send_games, bool can_use_inline_bots, bool can_add_web_page_previews, bool can_send_polls,
bool can_change_info_and_settings, bool can_invite_users, bool can_pin_messages,
bool can_manage_topics);
RestrictedRights(bool can_send_messages, bool can_send_audios, bool can_send_documents, bool can_send_photos,
bool can_send_videos, bool can_send_video_notes, bool can_send_voice_notes, bool can_send_stickers,
bool can_send_animations, bool can_send_games, bool can_use_inline_bots,
bool can_add_web_page_previews, bool can_send_polls, bool can_change_info_and_settings,
bool can_invite_users, bool can_pin_messages, bool can_manage_topics);
td_api::object_ptr<td_api::chatPermissions> get_chat_permissions_object() const;
@ -203,8 +211,28 @@ class RestrictedRights {
return (flags_ & CAN_SEND_MESSAGES) != 0;
}
bool can_send_media() const {
return (flags_ & CAN_SEND_MEDIA) != 0;
bool can_send_audios() const {
return (flags_ & CAN_SEND_AUDIOS) != 0;
}
bool can_send_documents() const {
return (flags_ & CAN_SEND_DOCUMENTS) != 0;
}
bool can_send_photos() const {
return (flags_ & CAN_SEND_PHOTOS) != 0;
}
bool can_send_videos() const {
return (flags_ & CAN_SEND_VIDEOS) != 0;
}
bool can_send_video_notes() const {
return (flags_ & CAN_SEND_VIDEO_NOTES) != 0;
}
bool can_send_voice_notes() const {
return (flags_ & CAN_SEND_VOICE_NOTES) != 0;
}
bool can_send_stickers() const {
@ -245,6 +273,10 @@ class RestrictedRights {
td::parse(legacy_flags, parser);
flags_ = legacy_flags;
}
if (flags_ & LEGACY_CAN_SEND_MEDIA) {
flags_ |= CAN_SEND_AUDIOS | CAN_SEND_DOCUMENTS | CAN_SEND_PHOTOS | CAN_SEND_VIDEOS | CAN_SEND_VIDEO_NOTES |
CAN_SEND_VOICE_NOTES;
}
}
friend bool operator==(const RestrictedRights &lhs, const RestrictedRights &rhs);
@ -401,8 +433,28 @@ class DialogParticipantStatus {
return get_restricted_rights().can_send_messages();
}
bool can_send_media() const {
return get_restricted_rights().can_send_media();
bool can_send_audios() const {
return get_restricted_rights().can_send_audios();
}
bool can_send_documents() const {
return get_restricted_rights().can_send_documents();
}
bool can_send_photos() const {
return get_restricted_rights().can_send_photos();
}
bool can_send_videos() const {
return get_restricted_rights().can_send_videos();
}
bool can_send_video_notes() const {
return get_restricted_rights().can_send_video_notes();
}
bool can_send_voice_notes() const {
return get_restricted_rights().can_send_voice_notes();
}
bool can_send_stickers() const {
@ -514,6 +566,12 @@ class DialogParticipantStatus {
flags_ = stored_flags;
if (flags_ & RestrictedRights::LEGACY_CAN_SEND_MEDIA) {
flags_ |= RestrictedRights::CAN_SEND_AUDIOS | RestrictedRights::CAN_SEND_DOCUMENTS |
RestrictedRights::CAN_SEND_PHOTOS | RestrictedRights::CAN_SEND_VIDEOS |
RestrictedRights::CAN_SEND_VIDEO_NOTES | RestrictedRights::CAN_SEND_VOICE_NOTES;
}
if (is_creator()) {
flags_ |= AdministratorRights::ALL_ADMINISTRATOR_RIGHTS | RestrictedRights::ALL_RESTRICTED_RIGHTS;
} else if (is_administrator()) {

View File

@ -2802,7 +2802,7 @@ Status can_send_message_content(DialogId dialog_id, const MessageContent *conten
}
break;
case MessageContentType::Audio:
if (!permissions.can_send_media()) {
if (!permissions.can_send_audios()) {
return Status::Error(400, "Not enough rights to send music to the chat");
}
break;
@ -2820,7 +2820,7 @@ Status can_send_message_content(DialogId dialog_id, const MessageContent *conten
}
break;
case MessageContentType::Document:
if (!permissions.can_send_media()) {
if (!permissions.can_send_documents()) {
return Status::Error(400, "Not enough rights to send documents to the chat");
}
break;
@ -2855,7 +2855,7 @@ Status can_send_message_content(DialogId dialog_id, const MessageContent *conten
}
break;
case MessageContentType::Photo:
if (!permissions.can_send_media()) {
if (!permissions.can_send_photos()) {
return Status::Error(400, "Not enough rights to send photos to the chat");
}
break;
@ -2895,12 +2895,12 @@ Status can_send_message_content(DialogId dialog_id, const MessageContent *conten
}
break;
case MessageContentType::Video:
if (!permissions.can_send_media()) {
if (!permissions.can_send_videos()) {
return Status::Error(400, "Not enough rights to send videos to the chat");
}
break;
case MessageContentType::VideoNote:
if (!permissions.can_send_media()) {
if (!permissions.can_send_video_notes()) {
return Status::Error(400, "Not enough rights to send video notes to the chat");
}
if (dialog_type == DialogType::User &&
@ -2909,7 +2909,7 @@ Status can_send_message_content(DialogId dialog_id, const MessageContent *conten
}
break;
case MessageContentType::VoiceNote:
if (!permissions.can_send_media()) {
if (!permissions.can_send_voice_notes()) {
return Status::Error(400, "Not enough rights to send voice notes to the chat");
}
if (dialog_type == DialogType::User &&

View File

@ -33929,7 +33929,8 @@ RestrictedRights MessagesManager::get_dialog_default_permissions(DialogId dialog
case DialogType::None:
default:
UNREACHABLE();
return RestrictedRights(false, false, false, false, false, false, false, false, false, false, false, false);
return RestrictedRights(false, false, false, false, false, false, false, false, false, false, false, false, false,
false, false, false, false);
}
}

View File

@ -4461,14 +4461,16 @@ class CliClient final : public Actor {
ChatId chat_id;
string permissions;
get_args(args, chat_id, permissions);
if (permissions.size() == 9) {
constexpr size_t EXPECTED_SIZE = 14;
if (permissions.size() == EXPECTED_SIZE) {
auto &s = permissions;
send_request(td_api::make_object<td_api::setChatPermissions>(
chat_id, td_api::make_object<td_api::chatPermissions>(s[0] == '1', s[1] == '1', s[2] == '1', s[3] == '1',
s[4] == '1', s[5] == '1', s[6] == '1', s[7] == '1',
s[8] == '1')));
s[8] == '1', s[9] == '1', s[10] == '1', s[11] == '1',
s[12] == '1', s[13] == '1')));
} else {
LOG(ERROR) << "Wrong permissions size, expected 8";
LOG(ERROR) << "Wrong permissions size, expected " << EXPECTED_SIZE;
}
} else if (op == "sctn") {
ChatId chat_id;
@ -4579,20 +4581,23 @@ class CliClient final : public Actor {
} else if (status_str == "rest") {
status = td_api::make_object<td_api::chatMemberStatusRestricted>(
true, static_cast<int32>(120 + std::time(nullptr)),
td_api::make_object<td_api::chatPermissions>(false, false, false, false, false, false, false, false,
false));
td_api::make_object<td_api::chatPermissions>(false, false, false, false, false, false, false, false, false,
false, false, false, false, false));
} else if (status_str == "restkick") {
status = td_api::make_object<td_api::chatMemberStatusRestricted>(
false, static_cast<int32>(120 + std::time(nullptr)),
td_api::make_object<td_api::chatPermissions>(true, false, false, false, false, false, false, false, false));
td_api::make_object<td_api::chatPermissions>(true, false, false, false, false, false, false, false, false,
false, false, false, false, false));
} else if (status_str == "restunkick") {
status = td_api::make_object<td_api::chatMemberStatusRestricted>(
true, static_cast<int32>(120 + std::time(nullptr)),
td_api::make_object<td_api::chatPermissions>(true, false, false, false, false, false, false, false, false));
td_api::make_object<td_api::chatPermissions>(true, false, false, false, false, false, false, false, false,
false, false, false, false, false));
} else if (status_str == "unrest") {
status = td_api::make_object<td_api::chatMemberStatusRestricted>(
true, 0,
td_api::make_object<td_api::chatPermissions>(true, true, true, true, true, true, true, true, true));
td_api::make_object<td_api::chatPermissions>(true, true, true, true, true, true, true, true, true, true,
true, true, true, true));
}
if (status != nullptr) {
send_request(