2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-08-31 14:38:15 +00:00

Fix polls forwarding to private chats.

This commit is contained in:
John Preston
2023-02-07 16:28:59 +04:00
parent d7aa18cb0a
commit d889cd0e72
7 changed files with 23 additions and 27 deletions

View File

@@ -9,6 +9,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "data/data_user.h"
#include "data/data_chat.h"
#include "data/data_chat_participant_status.h"
#include "data/data_channel.h"
#include "data/data_changes.h"
#include "data/data_photo.h"
@@ -475,6 +476,13 @@ bool PeerData::canPinMessages() const {
Unexpected("Peer type in PeerData::canPinMessages.");
}
bool PeerData::canCreatePolls() const {
if (const auto user = asUser()) {
return user->isBot() && !user->isSupport();
}
return Data::CanSend(this, ChatRestriction::SendPolls);
}
bool PeerData::canCreateTopics() const {
if (const auto channel = asChannel()) {
return channel->isForum()
@@ -940,10 +948,6 @@ Data::RestrictionCheckResult PeerData::amRestricted(
? ((user->flags() & UserDataFlag::VoiceMessagesForbidden)
? Result::Explicit()
: Result::Allowed())
: (right == ChatRestriction::SendPolls)
? ((!user->isBot() || user->isSupport())
? Result::Explicit()
: Result::Allowed())
: (right == ChatRestriction::PinMessages)
? ((user->flags() & UserDataFlag::CanPinMessages)
? Result::Allowed()