Support custom forwarded text in url auth button.

This commit is contained in:
John Preston 2019-05-27 15:26:12 +02:00
parent db66e93258
commit 65a36e49bd
2 changed files with 10 additions and 2 deletions

View File

@ -733,9 +733,11 @@ HistoryMessageMarkupButton::HistoryMessageMarkupButton(
Type type, Type type,
const QString &text, const QString &text,
const QByteArray &data, const QByteArray &data,
const QString &forwardText,
int32 buttonId) int32 buttonId)
: type(type) : type(type)
, text(text) , text(text)
, forwardText(forwardText)
, data(data) , data(data)
, buttonId(buttonId) { , buttonId(buttonId) {
} }
@ -806,6 +808,7 @@ void HistoryMessageReplyMarkup::createFromButtonRows(
Type::Auth, Type::Auth,
qs(data.vtext), qs(data.vtext),
qba(data.vurl), qba(data.vurl),
data.has_fwd_text() ? qs(data.vfwd_text) : QString(),
data.vbutton_id.v); data.vbutton_id.v);
}, [&](const MTPDinputKeyboardButtonUrlAuth &data) { }, [&](const MTPDinputKeyboardButtonUrlAuth &data) {
LOG(("API Error: inputKeyboardButtonUrlAuth received.")); LOG(("API Error: inputKeyboardButtonUrlAuth received."));
@ -866,10 +869,14 @@ void HistoryMessageReplyMarkup::create(
const auto newType = (button.type != Type::SwitchInlineSame) const auto newType = (button.type != Type::SwitchInlineSame)
? button.type ? button.type
: Type::SwitchInline; : Type::SwitchInline;
const auto text = button.forwardText.isEmpty()
? button.text
: button.forwardText;
row.emplace_back( row.emplace_back(
newType, newType,
button.text, text,
button.data, button.data,
QString(),
button.buttonId); button.buttonId);
} }
if (!row.empty()) { if (!row.empty()) {

View File

@ -171,6 +171,7 @@ struct HistoryMessageMarkupButton {
Type type, Type type,
const QString &text, const QString &text,
const QByteArray &data = QByteArray(), const QByteArray &data = QByteArray(),
const QString &forwardText = QString(),
int32 buttonId = 0); int32 buttonId = 0);
static HistoryMessageMarkupButton *Get( static HistoryMessageMarkupButton *Get(
@ -179,7 +180,7 @@ struct HistoryMessageMarkupButton {
int column); int column);
Type type; Type type;
QString text; QString text, forwardText;
QByteArray data; QByteArray data;
int32 buttonId = 0; int32 buttonId = 0;
mutable mtpRequestId requestId = 0; mutable mtpRequestId requestId = 0;