mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Allow editing caption of forwarded audio file.
Fixes https://bugs.telegram.org/c/3025
This commit is contained in:
parent
8e0b9b685c
commit
c5c94276c2
9 changed files with 42 additions and 19 deletions
|
@ -244,6 +244,14 @@ bool Media::forwardedBecomesUnread() const {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Media::dropForwardedInfo() const {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Media::forceForwardedInfo() const {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
QString Media::errorTextForForward(not_null<PeerData*> peer) const {
|
QString Media::errorTextForForward(not_null<PeerData*> peer) const {
|
||||||
return QString();
|
return QString();
|
||||||
}
|
}
|
||||||
|
@ -625,6 +633,10 @@ bool MediaFile::forwardedBecomesUnread() const {
|
||||||
|| _document->isVideoMessage();
|
|| _document->isVideoMessage();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool MediaFile::dropForwardedInfo() const {
|
||||||
|
return _document->isSong();
|
||||||
|
}
|
||||||
|
|
||||||
QString MediaFile::errorTextForForward(not_null<PeerData*> peer) const {
|
QString MediaFile::errorTextForForward(not_null<PeerData*> peer) const {
|
||||||
if (const auto sticker = _document->sticker()) {
|
if (const auto sticker = _document->sticker()) {
|
||||||
if (const auto error = Data::RestrictionError(
|
if (const auto error = Data::RestrictionError(
|
||||||
|
@ -1140,6 +1152,10 @@ QString MediaGame::errorTextForForward(not_null<PeerData*> peer) const {
|
||||||
).value_or(QString());
|
).value_or(QString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool MediaGame::dropForwardedInfo() const {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
bool MediaGame::consumeMessageText(const TextWithEntities &text) {
|
bool MediaGame::consumeMessageText(const TextWithEntities &text) {
|
||||||
_consumedText = text;
|
_consumedText = text;
|
||||||
return true;
|
return true;
|
||||||
|
@ -1347,6 +1363,10 @@ TextForMimeData MediaDice::clipboardText() const {
|
||||||
return { notificationText() };
|
return { notificationText() };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool MediaDice::forceForwardedInfo() const {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
bool MediaDice::updateInlineResultMedia(const MTPMessageMedia &media) {
|
bool MediaDice::updateInlineResultMedia(const MTPMessageMedia &media) {
|
||||||
return updateSentMedia(media);
|
return updateSentMedia(media);
|
||||||
}
|
}
|
||||||
|
|
|
@ -102,6 +102,8 @@ public:
|
||||||
virtual bool allowsEditMedia() const;
|
virtual bool allowsEditMedia() const;
|
||||||
virtual bool allowsRevoke(TimeId now) const;
|
virtual bool allowsRevoke(TimeId now) const;
|
||||||
virtual bool forwardedBecomesUnread() const;
|
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) const;
|
||||||
|
|
||||||
[[nodiscard]] virtual bool consumeMessageText(
|
[[nodiscard]] virtual bool consumeMessageText(
|
||||||
|
@ -191,6 +193,7 @@ public:
|
||||||
bool allowsEditCaption() const override;
|
bool allowsEditCaption() const override;
|
||||||
bool allowsEditMedia() const override;
|
bool allowsEditMedia() const override;
|
||||||
bool forwardedBecomesUnread() const override;
|
bool forwardedBecomesUnread() const override;
|
||||||
|
bool dropForwardedInfo() const override;
|
||||||
QString errorTextForForward(not_null<PeerData*> peer) const override;
|
QString errorTextForForward(not_null<PeerData*> peer) const override;
|
||||||
|
|
||||||
bool updateInlineResultMedia(const MTPMessageMedia &media) override;
|
bool updateInlineResultMedia(const MTPMessageMedia &media) override;
|
||||||
|
@ -352,6 +355,7 @@ public:
|
||||||
QString pinnedTextSubstring() const override;
|
QString pinnedTextSubstring() const override;
|
||||||
TextForMimeData clipboardText() const override;
|
TextForMimeData clipboardText() const override;
|
||||||
QString errorTextForForward(not_null<PeerData*> peer) const override;
|
QString errorTextForForward(not_null<PeerData*> peer) const override;
|
||||||
|
bool dropForwardedInfo() const override;
|
||||||
|
|
||||||
bool consumeMessageText(const TextWithEntities &text) override;
|
bool consumeMessageText(const TextWithEntities &text) override;
|
||||||
TextWithEntities consumedMessageText() const override;
|
TextWithEntities consumedMessageText() const override;
|
||||||
|
@ -442,6 +446,8 @@ public:
|
||||||
QString notificationText() const override;
|
QString notificationText() const override;
|
||||||
QString pinnedTextSubstring() const override;
|
QString pinnedTextSubstring() const override;
|
||||||
TextForMimeData clipboardText() const override;
|
TextForMimeData clipboardText() const override;
|
||||||
|
bool forceForwardedInfo() const override;
|
||||||
|
|
||||||
bool updateInlineResultMedia(const MTPMessageMedia &media) override;
|
bool updateInlineResultMedia(const MTPMessageMedia &media) override;
|
||||||
bool updateSentMedia(const MTPMessageMedia &media) override;
|
bool updateSentMedia(const MTPMessageMedia &media) override;
|
||||||
std::unique_ptr<HistoryView::Media> createView(
|
std::unique_ptr<HistoryView::Media> createView(
|
||||||
|
|
|
@ -562,8 +562,14 @@ HistoryMessage::HistoryMessage(
|
||||||
|
|
||||||
auto config = CreateConfig();
|
auto config = CreateConfig();
|
||||||
|
|
||||||
if (original->Has<HistoryMessageForwarded>() || !original->history()->peer->isSelf()) {
|
const auto originalMedia = original->media();
|
||||||
// Server doesn't add "fwd_from" to non-forwarded messages from chat with yourself.
|
const auto dropForwardInfo = (originalMedia
|
||||||
|
&& originalMedia->dropForwardedInfo())
|
||||||
|
|| (original->history()->peer->isSelf()
|
||||||
|
&& !history->peer->isSelf()
|
||||||
|
&& !original->Has<HistoryMessageForwarded>()
|
||||||
|
&& (!originalMedia || !originalMedia->forceForwardedInfo()));
|
||||||
|
if (!dropForwardInfo) {
|
||||||
config.originalDate = original->dateOriginal();
|
config.originalDate = original->dateOriginal();
|
||||||
if (const auto info = original->hiddenForwardedInfo()) {
|
if (const auto info = original->hiddenForwardedInfo()) {
|
||||||
config.senderNameOriginal = info->name;
|
config.senderNameOriginal = info->name;
|
||||||
|
@ -595,6 +601,12 @@ HistoryMessage::HistoryMessage(
|
||||||
}
|
}
|
||||||
if (const auto fwdViaBot = original->viaBot()) {
|
if (const auto fwdViaBot = original->viaBot()) {
|
||||||
config.viaBotId = peerToUser(fwdViaBot->id);
|
config.viaBotId = peerToUser(fwdViaBot->id);
|
||||||
|
} else if (originalMedia && originalMedia->game()) {
|
||||||
|
if (const auto user = original->history()->peer->asUser()) {
|
||||||
|
if (user->isBot()) {
|
||||||
|
config.viaBotId = peerToUser(user->id);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
const auto fwdViewsCount = original->viewsCount();
|
const auto fwdViewsCount = original->viewsCount();
|
||||||
if (fwdViewsCount > 0) {
|
if (fwdViewsCount > 0) {
|
||||||
|
|
|
@ -2128,10 +2128,8 @@ bool Message::displayForwardedFrom() const {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const auto media = this->media();
|
const auto media = item->media();
|
||||||
return !media
|
return !media || !media->dropForwardedInfo();
|
||||||
|| !media->isDisplayed()
|
|
||||||
|| !media->hideForwardedFrom();
|
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -950,10 +950,6 @@ QMargins Document::bubbleMargins() const {
|
||||||
return QMargins(padding.left(), padding.top(), padding.left(), padding.bottom());
|
return QMargins(padding.left(), padding.top(), padding.left(), padding.bottom());
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Document::hideForwardedFrom() const {
|
|
||||||
return _data->isSong();
|
|
||||||
}
|
|
||||||
|
|
||||||
QSize Document::sizeForGroupingOptimal(int maxWidth) const {
|
QSize Document::sizeForGroupingOptimal(int maxWidth) const {
|
||||||
const auto thumbed = Get<HistoryDocumentThumbed>();
|
const auto thumbed = Get<HistoryDocumentThumbed>();
|
||||||
const auto &st = (thumbed ? st::msgFileThumbLayoutGrouped : st::msgFileLayoutGrouped);
|
const auto &st = (thumbed ? st::msgFileThumbLayoutGrouped : st::msgFileLayoutGrouped);
|
||||||
|
|
|
@ -60,7 +60,6 @@ public:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
QMargins bubbleMargins() const override;
|
QMargins bubbleMargins() const override;
|
||||||
bool hideForwardedFrom() const override;
|
|
||||||
|
|
||||||
QSize sizeForGroupingOptimal(int maxWidth) const override;
|
QSize sizeForGroupingOptimal(int maxWidth) const override;
|
||||||
QSize sizeForGrouping(int width) const override;
|
QSize sizeForGrouping(int width) const override;
|
||||||
|
|
|
@ -202,9 +202,6 @@ public:
|
||||||
[[nodiscard]] virtual QMargins bubbleMargins() const {
|
[[nodiscard]] virtual QMargins bubbleMargins() const {
|
||||||
return QMargins();
|
return QMargins();
|
||||||
}
|
}
|
||||||
[[nodiscard]] virtual bool hideForwardedFrom() const {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
[[nodiscard]] virtual bool overrideEditedDate() const {
|
[[nodiscard]] virtual bool overrideEditedDate() const {
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -695,10 +695,6 @@ bool GroupedMedia::needsBubble() const {
|
||||||
return _needBubble;
|
return _needBubble;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GroupedMedia::hideForwardedFrom() const {
|
|
||||||
return main()->hideForwardedFrom();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool GroupedMedia::computeNeedBubble() const {
|
bool GroupedMedia::computeNeedBubble() const {
|
||||||
if (!_caption.isEmpty() || _mode == Mode::Column) {
|
if (!_caption.isEmpty() || _mode == Mode::Column) {
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -91,7 +91,6 @@ public:
|
||||||
bool customHighlight() const override {
|
bool customHighlight() const override {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
bool hideForwardedFrom() const override;
|
|
||||||
|
|
||||||
void stopAnimation() override;
|
void stopAnimation() override;
|
||||||
void checkAnimation() override;
|
void checkAnimation() override;
|
||||||
|
|
Loading…
Add table
Reference in a new issue