Support giveaway forwarding.

This commit is contained in:
levlam 2023-10-13 12:47:34 +03:00
parent 4ef53487dc
commit 580e856f44
4 changed files with 21 additions and 8 deletions

View File

@ -632,7 +632,7 @@ inputChatPhotoSticker sticker:chatPhotoSticker = InputChatPhoto;
//@description Describes actions that a user is allowed to take in a chat
//@can_send_basic_messages True, if the user can send text messages, contacts, invoices, locations, and venues
//@can_send_basic_messages True, if the user can send text messages, contacts, giveaways, invoices, locations, and venues
//@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 photos

View File

@ -2551,6 +2551,8 @@ bool can_have_input_media(const Td *td, const MessageContent *content, bool is_s
auto dialog_id = story_full_id.get_dialog_id();
return td->messages_manager_->get_input_peer(dialog_id, AccessRights::Read) != nullptr;
}
case MessageContentType::Giveaway:
return is_server;
case MessageContentType::Unsupported:
case MessageContentType::ChatCreate:
case MessageContentType::ChatChangeTitle:
@ -2592,7 +2594,6 @@ bool can_have_input_media(const Td *td, const MessageContent *content, bool is_s
case MessageContentType::SetBackground:
case MessageContentType::WriteAccessAllowedByRequest:
case MessageContentType::GiftCode:
case MessageContentType::Giveaway:
return false;
case MessageContentType::Animation:
case MessageContentType::Audio:
@ -3103,6 +3104,14 @@ Status can_send_message_content(DialogId dialog_id, const MessageContent *conten
return Status::Error(400, "Not enough rights to send games to the chat");
}
break;
case MessageContentType::Giveaway:
if (!permissions.can_send_messages()) {
return Status::Error(400, "Not enough rights to send giveaways to the chat");
}
if (dialog_type == DialogType::SecretChat) {
return Status::Error(400, "Giveaways can't be sent to secret chats");
}
break;
case MessageContentType::Invoice:
if (!permissions.can_send_messages()) {
return Status::Error(400, "Not enough rights to send invoice messages to the chat");
@ -3234,7 +3243,6 @@ Status can_send_message_content(DialogId dialog_id, const MessageContent *conten
case MessageContentType::SetBackground:
case MessageContentType::WriteAccessAllowedByRequest:
case MessageContentType::GiftCode:
case MessageContentType::Giveaway:
UNREACHABLE();
}
return Status::OK();
@ -5328,6 +5336,11 @@ unique_ptr<MessageContent> dup_message_content(Td *td, DialogId dialog_id, const
}
case MessageContentType::Game:
return make_unique<MessageGame>(*static_cast<const MessageGame *>(content));
case MessageContentType::Giveaway:
if (type != MessageContentDupType::Forward && type != MessageContentDupType::ServerCopy) {
return nullptr;
}
return make_unique<MessageGiveaway>(*static_cast<const MessageGiveaway *>(content));
case MessageContentType::Invoice:
if (type == MessageContentDupType::Copy) {
return nullptr;
@ -5516,7 +5529,6 @@ unique_ptr<MessageContent> dup_message_content(Td *td, DialogId dialog_id, const
case MessageContentType::SetBackground:
case MessageContentType::WriteAccessAllowedByRequest:
case MessageContentType::GiftCode:
case MessageContentType::Giveaway:
return nullptr;
default:
UNREACHABLE();

View File

@ -289,13 +289,17 @@ bool is_service_message_content(MessageContentType content_type) {
case MessageContentType::Animation:
case MessageContentType::Audio:
case MessageContentType::Contact:
case MessageContentType::Dice:
case MessageContentType::Document:
case MessageContentType::Game:
case MessageContentType::Giveaway:
case MessageContentType::Invoice:
case MessageContentType::LiveLocation:
case MessageContentType::Location:
case MessageContentType::Photo:
case MessageContentType::Poll:
case MessageContentType::Sticker:
case MessageContentType::Story:
case MessageContentType::Text:
case MessageContentType::Unsupported:
case MessageContentType::Venue:
@ -304,10 +308,6 @@ bool is_service_message_content(MessageContentType content_type) {
case MessageContentType::VoiceNote:
case MessageContentType::ExpiredPhoto:
case MessageContentType::ExpiredVideo:
case MessageContentType::Poll:
case MessageContentType::Dice:
case MessageContentType::Story:
case MessageContentType::Giveaway:
return false;
case MessageContentType::ChatCreate:
case MessageContentType::ChatChangeTitle:

View File

@ -26276,6 +26276,7 @@ bool MessagesManager::can_edit_message(DialogId dialog_id, const Message *m, boo
case MessageContentType::Story:
case MessageContentType::Contact:
case MessageContentType::Dice:
case MessageContentType::Giveaway:
case MessageContentType::Location:
case MessageContentType::Sticker:
case MessageContentType::Venue: