diff --git a/Telegram/SourceFiles/api/api_bot.cpp b/Telegram/SourceFiles/api/api_bot.cpp index 19ef1c06a..43f0fd1b3 100644 --- a/Telegram/SourceFiles/api/api_bot.cpp +++ b/Telegram/SourceFiles/api/api_bot.cpp @@ -418,7 +418,7 @@ void ActivateBotCommand(ClickHandlerContext context, int row, int column) { }(); if (!fastSwitchDone) { controller->content()->inlineSwitchLayer('@' - + bot->username + + bot->username() + ' ' + QString::fromUtf8(button->data)); } diff --git a/Telegram/SourceFiles/api/api_updates.cpp b/Telegram/SourceFiles/api/api_updates.cpp index 07e3ce501..5ef4ba3ea 100644 --- a/Telegram/SourceFiles/api/api_updates.cpp +++ b/Telegram/SourceFiles/api/api_updates.cpp @@ -1953,7 +1953,7 @@ void Updates::feedUpdate(const MTPUpdate &update) { || user->phone().isEmpty()) ? QString() : Ui::FormatPhone(user->phone())), - user->username); + user->username()); session().changes().peerUpdated( user, diff --git a/Telegram/SourceFiles/apiwrap.cpp b/Telegram/SourceFiles/apiwrap.cpp index bc9b46747..82e7752d7 100644 --- a/Telegram/SourceFiles/apiwrap.cpp +++ b/Telegram/SourceFiles/apiwrap.cpp @@ -3559,7 +3559,7 @@ void ApiWrap::sendBotStart( : bot.get()))); message.textWithTags = { u"/start"_q, TextWithTags::Tags() }; if (chat) { - message.textWithTags.text += '@' + bot->username; + message.textWithTags.text += '@' + bot->username(); } sendMessage(std::move(message)); return; diff --git a/Telegram/SourceFiles/boxes/add_contact_box.cpp b/Telegram/SourceFiles/boxes/add_contact_box.cpp index f33798de0..64c4169c0 100644 --- a/Telegram/SourceFiles/boxes/add_contact_box.cpp +++ b/Telegram/SourceFiles/boxes/add_contact_box.cpp @@ -1446,7 +1446,7 @@ void EditNameBox::saveSelfFail(const QString &error) { TextUtilities::SingleLine(_first->getLastText().trimmed()), TextUtilities::SingleLine(_last->getLastText().trimmed()), QString(), - TextUtilities::SingleLine(_user->username)); + TextUtilities::SingleLine(_user->username())); closeBox(); } else if (error == "FIRSTNAME_INVALID") { _first->setFocus(); diff --git a/Telegram/SourceFiles/boxes/peers/edit_contact_box.cpp b/Telegram/SourceFiles/boxes/peers/edit_contact_box.cpp index 14ddbe7bb..f2351f292 100644 --- a/Telegram/SourceFiles/boxes/peers/edit_contact_box.cpp +++ b/Telegram/SourceFiles/boxes/peers/edit_contact_box.cpp @@ -57,7 +57,7 @@ void SendRequest( first, last, user->nameOrPhone, - user->username); + user->username()); user->session().api().applyUpdates(result); if (const auto settings = user->settings()) { const auto flags = PeerSetting::AddContact diff --git a/Telegram/SourceFiles/boxes/share_box.cpp b/Telegram/SourceFiles/boxes/share_box.cpp index 3bdc09720..505ed363b 100644 --- a/Telegram/SourceFiles/boxes/share_box.cpp +++ b/Telegram/SourceFiles/boxes/share_box.cpp @@ -1266,7 +1266,7 @@ void FastShareMessage( if (const auto media = item->media()) { if (const auto game = media->game()) { const auto link = session->createInternalLinkFull( - bot->username + qsl("?game=") + game->shortName); + bot->username() + qsl("?game=") + game->shortName); QGuiApplication::clipboard()->setText(link); diff --git a/Telegram/SourceFiles/boxes/username_box.cpp b/Telegram/SourceFiles/boxes/username_box.cpp index e61f0bc37..82042702e 100644 --- a/Telegram/SourceFiles/boxes/username_box.cpp +++ b/Telegram/SourceFiles/boxes/username_box.cpp @@ -34,7 +34,7 @@ UsernameBox::UsernameBox(QWidget*, not_null session) this, st::defaultInputField, rpl::single(qsl("@username")), - session->user()->username, + session->user()->username(), QString()) , _about( this, @@ -45,7 +45,7 @@ UsernameBox::UsernameBox(QWidget*, not_null session) } void UsernameBox::prepare() { - _goodText = _session->user()->username.isEmpty() + _goodText = _session->user()->username().isEmpty() ? QString() : tr::lng_username_available(tr::now); @@ -196,7 +196,7 @@ void UsernameBox::check() { _checkRequestId = 0; _errorText = (mtpIsTrue(result) - || _checkUsername == _session->user()->username) + || _checkUsername == _session->user()->username()) ? QString() : tr::lng_username_occupied(tr::now); _goodText = _errorText.isEmpty() @@ -263,7 +263,7 @@ void UsernameBox::linkClick() { void UsernameBox::updateFail(const QString &error) { const auto self = _session->user(); if ((error == qstr("USERNAME_NOT_MODIFIED")) - || (_sentUsername == self->username)) { + || (_sentUsername == self->username())) { self->setName( TextUtilities::SingleLine(self->firstName), TextUtilities::SingleLine(self->lastName), @@ -291,7 +291,7 @@ void UsernameBox::checkFail(const QString &error) { _errorText = tr::lng_username_invalid(tr::now); update(); } else if ((error == qstr("USERNAME_OCCUPIED")) - && (_checkUsername != _session->user()->username)) { + && (_checkUsername != _session->user()->username())) { _errorText = tr::lng_username_occupied(tr::now); update(); } else { diff --git a/Telegram/SourceFiles/chat_helpers/bot_command.cpp b/Telegram/SourceFiles/chat_helpers/bot_command.cpp index 64be1e4b8..e82742602 100644 --- a/Telegram/SourceFiles/chat_helpers/bot_command.cpp +++ b/Telegram/SourceFiles/chat_helpers/bot_command.cpp @@ -33,7 +33,7 @@ QString WrapCommandInChat( not_null peer, const QString &command, not_null bot) { - if (!bot->isBot() || bot->username.isEmpty()) { + if (!bot->isBot() || bot->username().isEmpty()) { return command; } const auto botStatus = peer->isChat() @@ -42,7 +42,7 @@ QString WrapCommandInChat( ? peer->asChannel()->mgInfo->botStatus : -1; return ((command.indexOf('@') < 2) && (botStatus == 0 || botStatus == 2)) - ? command + '@' + bot->username + ? command + '@' + bot->username() : command; } diff --git a/Telegram/SourceFiles/chat_helpers/field_autocomplete.cpp b/Telegram/SourceFiles/chat_helpers/field_autocomplete.cpp index 57c394993..b72e2ed36 100644 --- a/Telegram/SourceFiles/chat_helpers/field_autocomplete.cpp +++ b/Telegram/SourceFiles/chat_helpers/field_autocomplete.cpp @@ -396,8 +396,9 @@ void FieldAutocomplete::updateFiltered(bool resetScroll) { } auto filterNotPassedByUsername = [this](UserData *user) -> bool { - if (user->username.startsWith(_filter, Qt::CaseInsensitive)) { - bool exactUsername = (user->username.size() == _filter.size()); + if (user->username().startsWith(_filter, Qt::CaseInsensitive)) { + const auto exactUsername = + (user->username().size() == _filter.size()); return exactUsername; } return true; @@ -405,7 +406,8 @@ void FieldAutocomplete::updateFiltered(bool resetScroll) { auto filterNotPassedByName = [&](UserData *user) -> bool { for (const auto &nameWord : user->nameWords()) { if (nameWord.startsWith(_filter, Qt::CaseInsensitive)) { - auto exactUsername = (user->username.compare(_filter, Qt::CaseInsensitive) == 0); + const auto exactUsername = + (user->username().compare(_filter, Qt::CaseInsensitive) == 0); return exactUsername; } } @@ -554,7 +556,7 @@ void FieldAutocomplete::updateFiltered(bool resetScroll) { for (const auto &command : *i->second) { if (!listAllSuggestions) { auto toFilter = (hasUsername || botStatus == 0 || botStatus == 2) - ? command.command + '@' + user->username + ? command.command + '@' + user->username() : command.command; if (!toFilter.startsWith(_filter, Qt::CaseInsensitive)/* || toFilter.size() == _filter.size()*/) { continue; @@ -570,7 +572,11 @@ void FieldAutocomplete::updateFiltered(bool resetScroll) { const auto user = i->first; for (const auto &command : *i->second) { if (!listAllSuggestions) { - QString toFilter = (hasUsername || botStatus == 0 || botStatus == 2) ? command.command + '@' + user->username : command.command; + const auto toFilter = (hasUsername + || botStatus == 0 + || botStatus == 2) + ? command.command + '@' + user->username() + : command.command; if (!toFilter.startsWith(_filter, Qt::CaseInsensitive)/* || toFilter.size() == _filter.size()*/) continue; } brows.push_back(make(user, command)); @@ -934,8 +940,17 @@ void FieldAutocomplete::Inner::paintEvent(QPaintEvent *e) { if (!_mrows->empty()) { auto &row = _mrows->at(i); const auto user = row.user; - auto first = (!filterIsEmpty && user->username.startsWith(filter, Qt::CaseInsensitive)) ? ('@' + user->username.mid(0, filterSize)) : QString(); - auto second = first.isEmpty() ? (user->username.isEmpty() ? QString() : ('@' + user->username)) : user->username.mid(filterSize); + auto first = (!filterIsEmpty + && user->username().startsWith( + filter, + Qt::CaseInsensitive)) + ? ('@' + user->username().mid(0, filterSize)) + : QString(); + auto second = first.isEmpty() + ? (user->username().isEmpty() + ? QString() + : ('@' + user->username())) + : user->username().mid(filterSize); auto firstwidth = st::mentionFont->width(first); auto secondwidth = st::mentionFont->width(second); auto unamewidth = firstwidth + secondwidth; @@ -1000,7 +1015,7 @@ void FieldAutocomplete::Inner::paintEvent(QPaintEvent *e) { auto toHighlight = row.command; int32 botStatus = _parent->chat() ? _parent->chat()->botStatus : ((_parent->channel() && _parent->channel()->isMegagroup()) ? _parent->channel()->mgInfo->botStatus : -1); if (hasUsername || botStatus == 0 || botStatus == 2) { - toHighlight += '@' + user->username; + toHighlight += '@' + user->username(); } user->loadUserpic(); user->paintUserpicLeft(p, row.userpic, st::mentionPadding.left(), i * st::mentionHeight + st::mentionPadding.top(), width(), st::mentionPhotoSize); @@ -1157,7 +1172,7 @@ bool FieldAutocomplete::Inner::chooseAtIndex( || _parent->filter().indexOf('@') > 0); const auto commandString = QString("/%1%2").arg( command, - insertUsername ? ('@' + user->username) : QString()); + insertUsername ? ('@' + user->username()) : QString()); _botCommandChosen.fire({ commandString, method }); return true; diff --git a/Telegram/SourceFiles/data/data_peer.cpp b/Telegram/SourceFiles/data/data_peer.cpp index ae3794ad4..da2e9f5c2 100644 --- a/Telegram/SourceFiles/data/data_peer.cpp +++ b/Telegram/SourceFiles/data/data_peer.cpp @@ -198,7 +198,7 @@ void PeerData::updateNameDelayed( if (_name == newName && _nameVersion > 1) { if (isUser()) { if (asUser()->nameOrPhone == newNameOrPhone - && asUser()->username == newUsername) { + && asUser()->username() == newUsername) { return; } } else if (isChannel()) { @@ -220,8 +220,8 @@ void PeerData::updateNameDelayed( flags |= UpdateFlag::Name; } if (isUser()) { - if (asUser()->username != newUsername) { - asUser()->username = newUsername; + if (asUser()->username() != newUsername) { + asUser()->setUsername(newUsername); flags |= UpdateFlag::Username; } asUser()->setNameOrPhone(newNameOrPhone); @@ -631,7 +631,7 @@ void PeerData::fillNames() { if (user->nameOrPhone != name()) { appendToIndex(user->nameOrPhone); } - appendToIndex(user->username); + appendToIndex(user->username()); if (isSelf()) { const auto english = qsl("Saved messages"); const auto localized = tr::lng_saved_messages(tr::now); @@ -820,7 +820,7 @@ const QString &PeerData::shortName() const { QString PeerData::userName() const { if (const auto user = asUser()) { - return user->username; + return user->username(); } else if (const auto channel = asChannel()) { return channel->username(); } diff --git a/Telegram/SourceFiles/data/data_session.cpp b/Telegram/SourceFiles/data/data_session.cpp index d1fd7b983..1b4979ea1 100644 --- a/Telegram/SourceFiles/data/data_session.cpp +++ b/Telegram/SourceFiles/data/data_session.cpp @@ -517,12 +517,24 @@ not_null Session::processUser(const MTPUser &data) { } else { // apply first_name and last_name from minimal user only if we don't have // local values for first name and last name already, otherwise skip - bool noLocalName = result->firstName.isEmpty() && result->lastName.isEmpty(); - QString fname = (!minimal || noLocalName) ? TextUtilities::SingleLine(qs(data.vfirst_name().value_or_empty())) : result->firstName; - QString lname = (!minimal || noLocalName) ? TextUtilities::SingleLine(qs(data.vlast_name().value_or_empty())) : result->lastName; + const auto noLocalName = result->firstName.isEmpty() + && result->lastName.isEmpty(); + const auto fname = (!minimal || noLocalName) + ? TextUtilities::SingleLine( + qs(data.vfirst_name().value_or_empty())) + : result->firstName; + const auto lname = (!minimal || noLocalName) + ? TextUtilities::SingleLine( + qs(data.vlast_name().value_or_empty())) + : result->lastName; - QString phone = minimal ? result->phone() : qs(data.vphone().value_or_empty()); - QString uname = minimal ? result->username : TextUtilities::SingleLine(qs(data.vusername().value_or_empty())); + const auto phone = minimal + ? result->phone() + : qs(data.vphone().value_or_empty()); + const auto uname = minimal + ? result->username() + : TextUtilities::SingleLine( + qs(data.vusername().value_or_empty())); const auto phoneChanged = (result->phone() != phone); if (phoneChanged) { diff --git a/Telegram/SourceFiles/data/data_user.cpp b/Telegram/SourceFiles/data/data_user.cpp index f3a2f1c47..d3a0d6a1d 100644 --- a/Telegram/SourceFiles/data/data_user.cpp +++ b/Telegram/SourceFiles/data/data_user.cpp @@ -119,6 +119,12 @@ void UserData::setName(const QString &newFirstName, const QString &newLastName, updateNameDelayed(newFullName, newPhoneName, newUsername); } +void UserData::setUsername(const QString &username) { + if (_username != username) { + _username = username; + } +} + void UserData::setPhone(const QString &newPhone) { if (_phone != newPhone) { _phone = newPhone; @@ -281,6 +287,10 @@ bool UserData::canShareThisContactFast() const { return !_phone.isEmpty(); } +const QString &UserData::username() const { + return _username; +} + const QString &UserData::phone() const { return _phone; } diff --git a/Telegram/SourceFiles/data/data_user.h b/Telegram/SourceFiles/data/data_user.h index 826883acc..c078f6061 100644 --- a/Telegram/SourceFiles/data/data_user.h +++ b/Telegram/SourceFiles/data/data_user.h @@ -77,6 +77,7 @@ public: void setEmojiStatus(DocumentId emojiStatusId, TimeId until = 0); [[nodiscard]] DocumentId emojiStatusId() const; + void setUsername(const QString &username); void setPhone(const QString &newPhone); void setBotInfoVersion(int version); void setBotInfo(const MTPBotInfo &info); @@ -126,8 +127,8 @@ public: QString firstName; QString lastName; - QString username; [[nodiscard]] const QString &phone() const; + [[nodiscard]] const QString &username() const; QString nameOrPhone; TimeId onlineTill = 0; @@ -165,6 +166,7 @@ private: Flags _flags; std::vector _unavailableReasons; + QString _username; QString _phone; ContactStatus _contactStatus = ContactStatus::Unknown; CallsStatus _callsStatus = CallsStatus::Unknown; diff --git a/Telegram/SourceFiles/history/history_inner_widget.cpp b/Telegram/SourceFiles/history/history_inner_widget.cpp index 24ca77c40..536311ede 100644 --- a/Telegram/SourceFiles/history/history_inner_widget.cpp +++ b/Telegram/SourceFiles/history/history_inner_widget.cpp @@ -3282,7 +3282,7 @@ void HistoryInner::elementSendBotCommand( } void HistoryInner::elementHandleViaClick(not_null bot) { - _widget->insertBotCommand('@' + bot->username); + _widget->insertBotCommand('@' + bot->username()); } bool HistoryInner::elementIsChatWide() { diff --git a/Telegram/SourceFiles/history/history_item_components.cpp b/Telegram/SourceFiles/history/history_item_components.cpp index 6a1e7d7d0..804fc7fc3 100644 --- a/Telegram/SourceFiles/history/history_item_components.cpp +++ b/Telegram/SourceFiles/history/history_item_components.cpp @@ -53,7 +53,10 @@ void HistoryMessageVia::create( UserId userId) { bot = owner->user(userId); maxWidth = st::msgServiceNameFont->width( - tr::lng_inline_bot_via(tr::now, lt_inline_bot, '@' + bot->username)); + tr::lng_inline_bot_via( + tr::now, + lt_inline_bot, + '@' + bot->username())); link = std::make_shared([bot = this->bot]( ClickContext context) { const auto my = context.other.value(); @@ -83,7 +86,10 @@ void HistoryMessageVia::resize(int32 availw) const { text = QString(); width = 0; } else { - text = tr::lng_inline_bot_via(tr::now, lt_inline_bot, '@' + bot->username); + text = tr::lng_inline_bot_via( + tr::now, + lt_inline_bot, + '@' + bot->username()); if (availw < maxWidth) { text = st::msgServiceNameFont->elided(text, availw); width = st::msgServiceNameFont->width(text); @@ -182,7 +188,7 @@ void HistoryMessageForwarded::create(const HistoryMessageVia *via) const { lt_channel, Ui::Text::Link(phrase.text, 1), // Link 1. lt_inline_bot, - Ui::Text::Link('@' + via->bot->username, 2), // Link 2. + Ui::Text::Link('@' + via->bot->username(), 2), // Link 2. Ui::Text::WithEntities); } else { phrase = tr::lng_forwarded_via( @@ -190,7 +196,7 @@ void HistoryMessageForwarded::create(const HistoryMessageVia *via) const { lt_user, Ui::Text::Link(phrase.text, 1), // Link 1. lt_inline_bot, - Ui::Text::Link('@' + via->bot->username, 2), // Link 2. + Ui::Text::Link('@' + via->bot->username(), 2), // Link 2. Ui::Text::WithEntities); } } else { diff --git a/Telegram/SourceFiles/history/history_widget.cpp b/Telegram/SourceFiles/history/history_widget.cpp index 0f80dc1ab..27c6c0142 100644 --- a/Telegram/SourceFiles/history/history_widget.cpp +++ b/Telegram/SourceFiles/history/history_widget.cpp @@ -1333,14 +1333,14 @@ void HistoryWidget::start() { void HistoryWidget::insertMention(UserData *user) { QString replacement, entityTag; - if (user->username.isEmpty()) { + if (user->username().isEmpty()) { replacement = user->firstName; if (replacement.isEmpty()) { replacement = user->name(); } entityTag = PrepareMentionTag(user); } else { - replacement = '@' + user->username; + replacement = '@' + user->username(); } _field->insertTag(replacement, entityTag); } @@ -1759,7 +1759,10 @@ void HistoryWidget::setInnerFocus() { bool HistoryWidget::notify_switchInlineBotButtonReceived(const QString &query, UserData *samePeerBot, MsgId samePeerReplyTo) { if (samePeerBot) { if (_history) { - TextWithTags textWithTags = { '@' + samePeerBot->username + ' ' + query, TextWithTags::Tags() }; + const auto textWithTags = TextWithTags{ + '@' + samePeerBot->username() + ' ' + query, + TextWithTags::Tags(), + }; MessageCursor cursor = { int(textWithTags.text.size()), int(textWithTags.text.size()), QFIXED_MAX }; _history->setLocalDraft(std::make_unique( textWithTags, @@ -1781,7 +1784,10 @@ bool HistoryWidget::notify_switchInlineBotButtonReceived(const QString &query, U bot->botInfo->inlineReturnTo = Dialogs::EntryState(); using Section = Dialogs::EntryState::Section; - TextWithTags textWithTags = { '@' + bot->username + ' ' + query, TextWithTags::Tags() }; + const auto textWithTags = TextWithTags{ + '@' + bot->username() + ' ' + query, + TextWithTags::Tags(), + }; MessageCursor cursor = { int(textWithTags.text.size()), int(textWithTags.text.size()), QFIXED_MAX }; auto draft = std::make_unique( textWithTags, @@ -4182,7 +4188,7 @@ bool HistoryWidget::insertBotCommand(const QString &cmd) { if (bot && (!bot->isUser() || !bot->asUser()->isBot())) { bot = nullptr; } - auto username = bot ? bot->asUser()->username : QString(); + auto username = bot ? bot->asUser()->username() : QString(); auto botStatus = _peer->isChat() ? _peer->asChat()->botStatus : (_peer->isMegagroup() ? _peer->asChannel()->mgInfo->botStatus : -1); if (toInsert.indexOf('@') < 0 && !username.isEmpty() && (botStatus == 0 || botStatus == 2)) { toInsert += '@' + username; @@ -4818,7 +4824,7 @@ void HistoryWidget::updateFieldPlaceholder() { if (!_editMsgId && _inlineBot && !_inlineLookingUpBot) { _field->setPlaceholder( rpl::single(_inlineBot->botInfo->inlinePlaceholder.mid(1)), - _inlineBot->username.size() + 2); + _inlineBot->username().size() + 2); return; } diff --git a/Telegram/SourceFiles/history/view/controls/history_view_compose_controls.cpp b/Telegram/SourceFiles/history/view/controls/history_view_compose_controls.cpp index bd1e22ded..3411eaab5 100644 --- a/Telegram/SourceFiles/history/view/controls/history_view_compose_controls.cpp +++ b/Telegram/SourceFiles/history/view/controls/history_view_compose_controls.cpp @@ -1497,12 +1497,12 @@ void ComposeControls::initAutocomplete() { } }; const auto insertMention = [=](not_null user) { - if (user->username.isEmpty()) { + if (user->username().isEmpty()) { _field->insertTag( user->firstName.isEmpty() ? user->name() : user->firstName, PrepareMentionTag(user)); } else { - _field->insertTag('@' + user->username); + _field->insertTag('@' + user->username()); } }; @@ -1604,7 +1604,7 @@ void ComposeControls::updateFieldPlaceholder() { if (!isEditingMessage() && _isInlineBot) { _field->setPlaceholder( rpl::single(_inlineBot->botInfo->inlinePlaceholder.mid(1)), - _inlineBot->username.size() + 2); + _inlineBot->username().size() + 2); return; } diff --git a/Telegram/SourceFiles/history/view/history_view_replies_section.cpp b/Telegram/SourceFiles/history/view/history_view_replies_section.cpp index b70c16332..7c7e97f27 100644 --- a/Telegram/SourceFiles/history/view/history_view_replies_section.cpp +++ b/Telegram/SourceFiles/history/view/history_view_replies_section.cpp @@ -1972,7 +1972,7 @@ void RepliesWidget::listSendBotCommand( } void RepliesWidget::listHandleViaClick(not_null bot) { - _composeControls->setText({ '@' + bot->username + ' ' }); + _composeControls->setText({ '@' + bot->username() + ' ' }); } not_null RepliesWidget::listChatTheme() { diff --git a/Telegram/SourceFiles/history/view/history_view_scheduled_section.cpp b/Telegram/SourceFiles/history/view/history_view_scheduled_section.cpp index 8338751a6..7d224e04b 100644 --- a/Telegram/SourceFiles/history/view/history_view_scheduled_section.cpp +++ b/Telegram/SourceFiles/history/view/history_view_scheduled_section.cpp @@ -1235,7 +1235,7 @@ void ScheduledWidget::listSendBotCommand( } void ScheduledWidget::listHandleViaClick(not_null bot) { - _composeControls->setText({ '@' + bot->username + ' ' }); + _composeControls->setText({ '@' + bot->username() + ' ' }); } not_null ScheduledWidget::listChatTheme() { diff --git a/Telegram/SourceFiles/inline_bots/bot_attach_web_view.cpp b/Telegram/SourceFiles/inline_bots/bot_attach_web_view.cpp index f71b84116..7126b925a 100644 --- a/Telegram/SourceFiles/inline_bots/bot_attach_web_view.cpp +++ b/Telegram/SourceFiles/inline_bots/bot_attach_web_view.cpp @@ -406,7 +406,7 @@ void AttachWebView::request( if (botUsername.isEmpty()) { return; } - const auto username = _bot ? _bot->username : _botUsername; + const auto username = _bot ? _bot->username() : _botUsername; if (_peer == peer && username.toLower() == botUsername.toLower() && _startCommand == startCommand) { @@ -879,7 +879,7 @@ void AttachWebView::show( .url = url, .userDataPath = _session->domain().local().webviewDataPath(), .title = std::move(title), - .bottom = rpl::single('@' + _bot->username), + .bottom = rpl::single('@' + _bot->username()), .handleLocalUri = handleLocalUri, .handleInvoice = handleInvoice, .sendData = sendData, diff --git a/Telegram/SourceFiles/passport/passport_panel_form.cpp b/Telegram/SourceFiles/passport/passport_panel_form.cpp index 3978e0763..985e729fa 100644 --- a/Telegram/SourceFiles/passport/passport_panel_form.cpp +++ b/Telegram/SourceFiles/passport/passport_panel_form.cpp @@ -148,7 +148,7 @@ not_null PanelForm::setupContent() { auto text = policyUrl.isEmpty() ? tr::lng_passport_allow( lt_bot, - rpl::single('@' + bot->username) + rpl::single('@' + bot->username()) ) | Ui::Text::ToWithEntities() : tr::lng_passport_accept_allow( lt_policy, @@ -157,7 +157,7 @@ not_null PanelForm::setupContent() { rpl::single(bot->name()) ) | Ui::Text::ToLink(policyUrl), lt_bot, - rpl::single('@' + bot->username) | Ui::Text::ToWithEntities(), + rpl::single('@' + bot->username()) | Ui::Text::ToWithEntities(), Ui::Text::WithEntities); const auto policy = inner->add( object_ptr( diff --git a/Telegram/SourceFiles/payments/payments_form.cpp b/Telegram/SourceFiles/payments/payments_form.cpp index 8dd8b2d42..fa423d8a0 100644 --- a/Telegram/SourceFiles/payments/payments_form.cpp +++ b/Telegram/SourceFiles/payments/payments_form.cpp @@ -421,7 +421,7 @@ void Form::processDetails(const MTPDpayments_paymentForm &data) { if (const auto botId = _details.botId) { if (const auto bot = _session->data().userLoaded(botId)) { _invoice.cover.seller = bot->name(); - _details.termsBotUsername = bot->username; + _details.termsBotUsername = bot->username(); } } if (const auto providerId = _details.providerId) { diff --git a/Telegram/SourceFiles/settings/settings_privacy_controllers.cpp b/Telegram/SourceFiles/settings/settings_privacy_controllers.cpp index 4fc3a7054..53d8e5974 100644 --- a/Telegram/SourceFiles/settings/settings_privacy_controllers.cpp +++ b/Telegram/SourceFiles/settings/settings_privacy_controllers.cpp @@ -439,8 +439,8 @@ std::unique_ptr BlockedBoxController::createRow( return tr::lng_group_status(tr::now); } else if (!user->phone().isEmpty()) { return Ui::FormatPhone(user->phone()); - } else if (!user->username.isEmpty()) { - return '@' + user->username; + } else if (!user->username().isEmpty()) { + return '@' + user->username(); } else if (user->isBot()) { return tr::lng_status_bot(tr::now); } diff --git a/Telegram/SourceFiles/storage/serialize_peer.cpp b/Telegram/SourceFiles/storage/serialize_peer.cpp index b1f9e0823..a9a4ee640 100644 --- a/Telegram/SourceFiles/storage/serialize_peer.cpp +++ b/Telegram/SourceFiles/storage/serialize_peer.cpp @@ -121,7 +121,7 @@ uint32 peerSize(not_null peer) { result += stringSize(user->firstName) + stringSize(user->lastName) + stringSize(user->phone()) - + stringSize(user->username) + + stringSize(user->username()) + sizeof(quint64) // access + sizeof(qint32) // flags + sizeof(qint32) // onlineTill @@ -164,7 +164,7 @@ void writePeer(QDataStream &stream, not_null peer) { << user->firstName << user->lastName << user->phone() - << user->username + << user->username() << quint64(user->accessHash()) << qint32(user->flags()) << botInlinePlaceholder diff --git a/Telegram/SourceFiles/storage/storage_account.cpp b/Telegram/SourceFiles/storage/storage_account.cpp index 578dcc348..3ae1efa8c 100644 --- a/Telegram/SourceFiles/storage/storage_account.cpp +++ b/Telegram/SourceFiles/storage/storage_account.cpp @@ -2537,7 +2537,7 @@ void Account::readRecentHashtagsAndBots() { } else if (peer->isUser() && peer->asUser()->isBot() && !peer->asUser()->botInfo->inlinePlaceholder.isEmpty() - && !peer->asUser()->username.isEmpty()) { + && !peer->asUser()->username().isEmpty()) { bots.push_back(peer->asUser()); } } diff --git a/Telegram/SourceFiles/window/notifications_manager.cpp b/Telegram/SourceFiles/window/notifications_manager.cpp index 07e0b211d..f2acc5db3 100644 --- a/Telegram/SourceFiles/window/notifications_manager.cpp +++ b/Telegram/SourceFiles/window/notifications_manager.cpp @@ -957,9 +957,9 @@ QString Manager::addTargetAccountName( return add ? (title + accountNameSeparator() - + (session->user()->username.isEmpty() + + (session->user()->username().isEmpty() ? session->user()->name() - : session->user()->username)) + : session->user()->username())) : title; }