From 65a36e49bda1ef8145edec56ed3d78a7b677bfb7 Mon Sep 17 00:00:00 2001
From: John Preston <johnprestonmail@gmail.com>
Date: Mon, 27 May 2019 15:26:12 +0200
Subject: [PATCH] Support custom forwarded text in url auth button.

---
 Telegram/SourceFiles/history/history_item_components.cpp | 9 ++++++++-
 Telegram/SourceFiles/history/history_item_components.h   | 3 ++-
 2 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/Telegram/SourceFiles/history/history_item_components.cpp b/Telegram/SourceFiles/history/history_item_components.cpp
index b6c167586..dfcbfc6df 100644
--- a/Telegram/SourceFiles/history/history_item_components.cpp
+++ b/Telegram/SourceFiles/history/history_item_components.cpp
@@ -733,9 +733,11 @@ HistoryMessageMarkupButton::HistoryMessageMarkupButton(
 	Type type,
 	const QString &text,
 	const QByteArray &data,
+	const QString &forwardText,
 	int32 buttonId)
 : type(type)
 , text(text)
+, forwardText(forwardText)
 , data(data)
 , buttonId(buttonId) {
 }
@@ -806,6 +808,7 @@ void HistoryMessageReplyMarkup::createFromButtonRows(
 						Type::Auth,
 						qs(data.vtext),
 						qba(data.vurl),
+						data.has_fwd_text() ? qs(data.vfwd_text) : QString(),
 						data.vbutton_id.v);
 				}, [&](const MTPDinputKeyboardButtonUrlAuth &data) {
 					LOG(("API Error: inputKeyboardButtonUrlAuth received."));
@@ -866,10 +869,14 @@ void HistoryMessageReplyMarkup::create(
 			const auto newType = (button.type != Type::SwitchInlineSame)
 				? button.type
 				: Type::SwitchInline;
+			const auto text = button.forwardText.isEmpty()
+				? button.text
+				: button.forwardText;
 			row.emplace_back(
 				newType,
-				button.text,
+				text,
 				button.data,
+				QString(),
 				button.buttonId);
 		}
 		if (!row.empty()) {
diff --git a/Telegram/SourceFiles/history/history_item_components.h b/Telegram/SourceFiles/history/history_item_components.h
index 2b5edfb8e..1cd5bd9b7 100644
--- a/Telegram/SourceFiles/history/history_item_components.h
+++ b/Telegram/SourceFiles/history/history_item_components.h
@@ -171,6 +171,7 @@ struct HistoryMessageMarkupButton {
 		Type type,
 		const QString &text,
 		const QByteArray &data = QByteArray(),
+		const QString &forwardText = QString(),
 		int32 buttonId = 0);
 
 	static HistoryMessageMarkupButton *Get(
@@ -179,7 +180,7 @@ struct HistoryMessageMarkupButton {
 		int column);
 
 	Type type;
-	QString text;
+	QString text, forwardText;
 	QByteArray data;
 	int32 buttonId = 0;
 	mutable mtpRequestId requestId = 0;