Untie can_send_messages right from other rights.

This commit is contained in:
levlam 2023-01-17 18:13:27 +03:00
parent 696c7ef21d
commit 7288e90211
3 changed files with 18 additions and 31 deletions

View File

@ -563,15 +563,15 @@ 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_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
//@can_send_audios True, if the user can send music files
//@can_send_documents True, if the user can send documents
//@can_send_photos True, if the user can send audio photos
//@can_send_videos True, if the user can send audio videos
//@can_send_video_notes True, if the user can send video notes
//@can_send_voice_notes True, if the user can send voice notes
//@can_send_polls True, if the user can send polls
//@can_send_other_messages True, if the user can send animations, games, stickers, and dice and use inline bots
//@can_add_web_page_previews True, if the user may add a web page preview to their messages
//@can_change_info True, if the user can change the chat title, photo, and other settings
//@can_invite_users True, if the user can invite new users to the chat
//@can_pin_messages True, if the user can pin messages

View File

@ -210,22 +210,12 @@ RestrictedRights::RestrictedRights(const td_api::object_ptr<td_api::chatPermissi
return;
}
bool can_send_polls = rights->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_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_);
*this = RestrictedRights(
rights->can_send_messages_, rights->can_send_audios_, rights->can_send_documents_, rights->can_send_photos_,
rights->can_send_videos_, rights->can_send_video_notes_, rights->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_, rights->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_audios, bool can_send_documents,
@ -265,7 +255,7 @@ td_api::object_ptr<td_api::chatPermissions> RestrictedRights::get_chat_permissio
tl_object_ptr<telegram_api::chatBannedRights> RestrictedRights::get_chat_banned_rights() const {
int32 flags = 0;
if (!can_send_messages()) {
flags |= telegram_api::chatBannedRights::SEND_MESSAGES_MASK;
flags |= telegram_api::chatBannedRights::SEND_PLAIN_MASK;
}
if (!can_send_audios()) {
flags |= telegram_api::chatBannedRights::SEND_AUDIOS_MASK;
@ -335,7 +325,7 @@ bool operator!=(const RestrictedRights &lhs, const RestrictedRights &rhs) {
StringBuilder &operator<<(StringBuilder &string_builder, const RestrictedRights &status) {
string_builder << "Restricted: ";
if (!status.can_send_messages()) {
string_builder << "(text)";
string_builder << "(text+contact+invoice+location+venue)";
}
if (!status.can_send_audios()) {
string_builder << "(audios)";
@ -356,7 +346,7 @@ StringBuilder &operator<<(StringBuilder &string_builder, const RestrictedRights
string_builder << "(voice notes)";
}
if (!status.can_send_stickers()) {
string_builder << "(stickers)";
string_builder << "(stickers+dices)";
}
if (!status.can_send_animations()) {
string_builder << "(animations)";

View File

@ -25879,9 +25879,6 @@ Status MessagesManager::can_send_message(DialogId dialog_id) const {
switch (channel_type) {
case ChannelType::Unknown:
case ChannelType::Megagroup:
if (!channel_status.can_send_messages()) {
return Status::Error(400, "Have no rights to send a message");
}
break;
case ChannelType::Broadcast: {
if (!channel_status.can_post_messages()) {