mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2026-08-14 07:23:46 +00:00
Preserve rich pages when rescheduling messages.
Task: 2026/07/23/preserve-rich-page-on-reschedule
This commit is contained in:
@@ -11,6 +11,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
#include "api/api_media.h"
|
||||
#include "api/api_text_entities.h"
|
||||
#include "base/random.h"
|
||||
#include "core/application.h"
|
||||
#include "ui/boxes/confirm_box.h"
|
||||
#include "data/business/data_shortcut_messages.h"
|
||||
#include "data/components/scheduled_messages.h"
|
||||
@@ -23,6 +24,9 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
#include "history/view/controls/history_view_compose_media_edit_manager.h"
|
||||
#include "history/history.h"
|
||||
#include "history/history_item_components.h"
|
||||
#include "iv/iv_instance.h"
|
||||
#include "iv/iv_rich_message_serializer.h"
|
||||
#include "iv/iv_rich_page.h"
|
||||
#include "lang/lang_keys.h"
|
||||
#include "main/main_session.h"
|
||||
#include "mtproto/mtproto_response.h"
|
||||
@@ -436,6 +440,45 @@ void EditMessageWithUploadedMedia(
|
||||
void RescheduleMessage(
|
||||
not_null<HistoryItem*> item,
|
||||
SendOptions options) {
|
||||
if (item->richPage()) {
|
||||
const auto session = &item->history()->session();
|
||||
const auto itemId = item->fullId();
|
||||
const auto edit = [=] {
|
||||
const auto item = session->data().message(itemId);
|
||||
if (!item || !item->isScheduled() || !item->richPage()) {
|
||||
return;
|
||||
}
|
||||
const auto serialize = [=]()
|
||||
-> std::optional<MTPInputRichMessage> {
|
||||
const auto fullPage = item->fullRichPage();
|
||||
const auto page = fullPage ? fullPage : item->richPage();
|
||||
if (!page) {
|
||||
return std::nullopt;
|
||||
}
|
||||
auto serialized = Iv::SerializeInputRichMessage(
|
||||
session,
|
||||
*page,
|
||||
Iv::SerializeInputRichMessageMode::FinalSubmit);
|
||||
using Status = Iv::SerializeInputRichMessageStatus;
|
||||
return (serialized.status == Status::Success)
|
||||
&& serialized.value
|
||||
? std::make_optional(std::move(*serialized.value))
|
||||
: std::nullopt;
|
||||
};
|
||||
EditRichMessage(item, serialize, options, nullptr, nullptr);
|
||||
};
|
||||
if (item->fullRichPage() || !item->richPage()->part) {
|
||||
edit();
|
||||
} else {
|
||||
Core::App().iv().resolveRichMessage(session, item, [=](
|
||||
std::shared_ptr<const Iv::RichPage> page) {
|
||||
if (page) {
|
||||
edit();
|
||||
}
|
||||
});
|
||||
}
|
||||
return;
|
||||
}
|
||||
const auto empty = [] {};
|
||||
options.invertCaption = item->invertMedia();
|
||||
EditMessage(item, options, empty, empty);
|
||||
|
||||
Reference in New Issue
Block a user