parent
8da2234dbb
commit
6af09ec529
8 changed files with 41 additions and 18 deletions
|
|
@ -259,5 +259,6 @@
|
|||
"ktg_settings_remember_compress_images": "Remember compress images",
|
||||
"ktg_settings_compress_images_default": "Compress images by default",
|
||||
"ktg_pip_not_supported": "Sorry, Picture-in-Picture mode is not supported here.",
|
||||
"ktg_forward_quiz_unquoted": "Sorry, quizzes that are currently open and unvoted on cannot be forwarded unquoted.",
|
||||
"dummy_last_string": ""
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
*/
|
||||
#include "data/data_media_types.h"
|
||||
|
||||
#include "kotato/kotato_lang.h"
|
||||
#include "history/history.h"
|
||||
#include "history/history_item.h"
|
||||
#include "history/history_location_manager.h"
|
||||
|
|
@ -411,7 +412,7 @@ bool Media::forceForwardedInfo() const {
|
|||
return false;
|
||||
}
|
||||
|
||||
QString Media::errorTextForForward(not_null<PeerData*> peer) const {
|
||||
QString Media::errorTextForForward(not_null<PeerData*> peer, bool unquoted) const {
|
||||
return QString();
|
||||
}
|
||||
|
||||
|
|
@ -603,7 +604,7 @@ bool MediaPhoto::allowsEditMedia() const {
|
|||
return true;
|
||||
}
|
||||
|
||||
QString MediaPhoto::errorTextForForward(not_null<PeerData*> peer) const {
|
||||
QString MediaPhoto::errorTextForForward(not_null<PeerData*> peer, bool unquoted) const {
|
||||
return Data::RestrictionError(
|
||||
peer,
|
||||
ChatRestriction::SendMedia
|
||||
|
|
@ -911,7 +912,7 @@ bool MediaFile::dropForwardedInfo() const {
|
|||
return _document->isSong();
|
||||
}
|
||||
|
||||
QString MediaFile::errorTextForForward(not_null<PeerData*> peer) const {
|
||||
QString MediaFile::errorTextForForward(not_null<PeerData*> peer, bool unquoted) const {
|
||||
if (const auto sticker = _document->sticker()) {
|
||||
if (const auto error = Data::RestrictionError(
|
||||
peer,
|
||||
|
|
@ -1425,7 +1426,7 @@ TextForMimeData MediaGame::clipboardText() const {
|
|||
return TextForMimeData();
|
||||
}
|
||||
|
||||
QString MediaGame::errorTextForForward(not_null<PeerData*> peer) const {
|
||||
QString MediaGame::errorTextForForward(not_null<PeerData*> peer, bool unquoted) const {
|
||||
return Data::RestrictionError(
|
||||
peer,
|
||||
ChatRestriction::SendGames
|
||||
|
|
@ -1573,10 +1574,13 @@ TextForMimeData MediaPoll::clipboardText() const {
|
|||
return TextForMimeData::Simple(text);
|
||||
}
|
||||
|
||||
QString MediaPoll::errorTextForForward(not_null<PeerData*> peer) const {
|
||||
QString MediaPoll::errorTextForForward(not_null<PeerData*> peer, bool unquoted) const {
|
||||
if (_poll->publicVotes() && peer->isChannel() && !peer->isMegagroup()) {
|
||||
return tr::lng_restricted_send_public_polls(tr::now);
|
||||
}
|
||||
if (unquoted && _poll->quiz() && !_poll->voted() && !_poll->closed()) {
|
||||
return ktr("ktg_forward_quiz_unquoted");
|
||||
}
|
||||
return Data::RestrictionError(
|
||||
peer,
|
||||
ChatRestriction::SendPolls
|
||||
|
|
|
|||
|
|
@ -112,7 +112,7 @@ public:
|
|||
virtual bool forwardedBecomesUnread() const;
|
||||
virtual bool dropForwardedInfo() const;
|
||||
virtual bool forceForwardedInfo() const;
|
||||
virtual QString errorTextForForward(not_null<PeerData*> peer) const;
|
||||
virtual QString errorTextForForward(not_null<PeerData*> peer, bool unquoted = false) const;
|
||||
|
||||
[[nodiscard]] virtual bool consumeMessageText(
|
||||
const TextWithEntities &text);
|
||||
|
|
@ -167,7 +167,7 @@ public:
|
|||
TextForMimeData clipboardText() const override;
|
||||
bool allowsEditCaption() const override;
|
||||
bool allowsEditMedia() const override;
|
||||
QString errorTextForForward(not_null<PeerData*> peer) const override;
|
||||
QString errorTextForForward(not_null<PeerData*> peer, bool unquoted = false) const override;
|
||||
|
||||
bool updateInlineResultMedia(const MTPMessageMedia &media) override;
|
||||
bool updateSentMedia(const MTPMessageMedia &media) override;
|
||||
|
|
@ -207,7 +207,7 @@ public:
|
|||
bool allowsEditMedia() const override;
|
||||
bool forwardedBecomesUnread() const override;
|
||||
bool dropForwardedInfo() const override;
|
||||
QString errorTextForForward(not_null<PeerData*> peer) const override;
|
||||
QString errorTextForForward(not_null<PeerData*> peer, bool unquoted = false) const override;
|
||||
|
||||
bool updateInlineResultMedia(const MTPMessageMedia &media) override;
|
||||
bool updateSentMedia(const MTPMessageMedia &media) override;
|
||||
|
|
@ -366,7 +366,7 @@ public:
|
|||
QString notificationText() const override;
|
||||
QString pinnedTextSubstring() const override;
|
||||
TextForMimeData clipboardText() const override;
|
||||
QString errorTextForForward(not_null<PeerData*> peer) const override;
|
||||
QString errorTextForForward(not_null<PeerData*> peer, bool unquoted = false) const override;
|
||||
bool dropForwardedInfo() const override;
|
||||
|
||||
bool consumeMessageText(const TextWithEntities &text) override;
|
||||
|
|
@ -428,7 +428,7 @@ public:
|
|||
QString notificationText() const override;
|
||||
QString pinnedTextSubstring() const override;
|
||||
TextForMimeData clipboardText() const override;
|
||||
QString errorTextForForward(not_null<PeerData*> peer) const override;
|
||||
QString errorTextForForward(not_null<PeerData*> peer, bool unquoted = false) const override;
|
||||
|
||||
bool updateInlineResultMedia(const MTPMessageMedia &media) override;
|
||||
bool updateSentMedia(const MTPMessageMedia &media) override;
|
||||
|
|
|
|||
|
|
@ -127,14 +127,15 @@ QString GetErrorTextForSending(
|
|||
not_null<PeerData*> peer,
|
||||
const HistoryItemsList &items,
|
||||
const TextWithTags &comment,
|
||||
bool ignoreSlowmodeCountdown) {
|
||||
bool ignoreSlowmodeCountdown,
|
||||
bool unquoted) {
|
||||
if (!peer->canWrite()) {
|
||||
return tr::lng_forward_cant(tr::now);
|
||||
}
|
||||
|
||||
for (const auto &item : items) {
|
||||
if (const auto media = item->media()) {
|
||||
const auto error = media->errorTextForForward(peer);
|
||||
const auto error = media->errorTextForForward(peer, unquoted);
|
||||
if (!error.isEmpty() && error != qstr("skip")) {
|
||||
return error;
|
||||
}
|
||||
|
|
@ -415,8 +416,9 @@ MTPMessageReplyHeader NewMessageReplyHeader(const Api::SendAction &action) {
|
|||
QString GetErrorTextForSending(
|
||||
not_null<PeerData*> peer,
|
||||
const HistoryItemsList &items,
|
||||
bool ignoreSlowmodeCountdown) {
|
||||
return GetErrorTextForSending(peer, items, {}, ignoreSlowmodeCountdown);
|
||||
bool ignoreSlowmodeCountdown,
|
||||
bool unquoted) {
|
||||
return GetErrorTextForSending(peer, items, {}, ignoreSlowmodeCountdown, unquoted);
|
||||
}
|
||||
|
||||
struct HistoryMessage::CreateConfig {
|
||||
|
|
|
|||
|
|
@ -43,12 +43,14 @@ void RequestDependentMessageData(
|
|||
[[nodiscard]] QString GetErrorTextForSending(
|
||||
not_null<PeerData*> peer,
|
||||
const HistoryItemsList &items,
|
||||
bool ignoreSlowmodeCountdown = false);
|
||||
bool ignoreSlowmodeCountdown = false,
|
||||
bool unquoted = false);
|
||||
[[nodiscard]] QString GetErrorTextForSending(
|
||||
not_null<PeerData*> peer,
|
||||
const HistoryItemsList &items,
|
||||
const TextWithTags &comment,
|
||||
bool ignoreSlowmodeCountdown = false);
|
||||
bool ignoreSlowmodeCountdown = false,
|
||||
bool unquoted = false);
|
||||
void FastShareMessage(not_null<HistoryItem*> item);
|
||||
|
||||
class HistoryMessage final : public HistoryItem {
|
||||
|
|
|
|||
|
|
@ -5915,6 +5915,17 @@ void HistoryWidget::contextMenuEvent(QContextMenuEvent *e) {
|
|||
int settingsKey) {
|
||||
if (_history && _toForward.options != newOptions) {
|
||||
_menu->addAction(ktr(langKey), [=] {
|
||||
const auto error = GetErrorTextForSending(
|
||||
_history->peer,
|
||||
_toForward.items,
|
||||
true,
|
||||
newOptions != Options::PreserveInfo);
|
||||
if (!error.isEmpty()) {
|
||||
Ui::ShowMultilineToast({
|
||||
.text = error
|
||||
});
|
||||
return;
|
||||
}
|
||||
_toForward.options = newOptions;
|
||||
_history->setForwardDraft({
|
||||
.ids = session().data().itemsToIds(_toForward.items),
|
||||
|
|
|
|||
|
|
@ -489,7 +489,8 @@ bool MainWidget::setForwardDraft(PeerId peerId, Data::ForwardDraft &&draft) {
|
|||
const auto error = GetErrorTextForSending(
|
||||
peer,
|
||||
session().data().idsToItems(draft.ids),
|
||||
true);
|
||||
true,
|
||||
draft.options != Data::ForwardOptions::PreserveInfo);
|
||||
if (!error.isEmpty()) {
|
||||
Ui::show(Box<Ui::InformBox>(error), Ui::LayerOption::KeepOther);
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -1249,7 +1249,9 @@ QPointer<Ui::RpWidget> ShowForwardMessagesBox(
|
|||
const auto error = GetErrorTextForSending(
|
||||
peer,
|
||||
items,
|
||||
comment);
|
||||
comment,
|
||||
false, /* ignoreSlowmodeCountdown */
|
||||
newDraft.options != Data::ForwardOptions::PreserveInfo);
|
||||
if (!error.isEmpty()) {
|
||||
return std::make_pair(error, peer);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue