2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-08-31 06:26:18 +00:00

Use user phrases for support accounts.

This commit is contained in:
John Preston
2019-03-12 14:36:33 +04:00
parent b798654ca7
commit 13a9b967e9
21 changed files with 98 additions and 79 deletions

View File

@@ -313,11 +313,12 @@ not_null<UserData*> Session::processUser(const MTPUser &data) {
const auto nameChanged = (result->firstName != fname)
|| (result->lastName != lname);
auto showPhone = !isServiceUser(result->id)
auto showPhone = !result->isServiceUser()
&& !data.is_support()
&& !data.is_self()
&& !data.is_contact()
&& !data.is_mutual_contact();
auto showPhoneChanged = !isServiceUser(result->id)
auto showPhoneChanged = !result->isServiceUser()
&& !data.is_self()
&& ((showPhone
&& result->contactStatus() == UserData::ContactStatus::Contact)
@@ -325,7 +326,7 @@ not_null<UserData*> Session::processUser(const MTPUser &data) {
&& result->contactStatus() == UserData::ContactStatus::CanAdd));
if (minimal) {
showPhoneChanged = false;
showPhone = !isServiceUser(result->id)
showPhone = !result->isServiceUser()
&& (result->id != _session->userPeerId())
&& (result->contactStatus() == UserData::ContactStatus::CanAdd);
}
@@ -2959,14 +2960,14 @@ void Session::serviceNotification(
const TextWithEntities &message,
const MTPMessageMedia &media) {
const auto date = unixtime();
if (!userLoaded(ServiceUserId)) {
if (!peerLoaded(PeerData::kServiceNotificationsId)) {
processUser(MTP_user(
MTP_flags(
MTPDuser::Flag::f_first_name
| MTPDuser::Flag::f_phone
| MTPDuser::Flag::f_status
| MTPDuser::Flag::f_verified),
MTP_int(ServiceUserId),
MTP_int(peerToUser(PeerData::kServiceNotificationsId)),
MTPlong(),
MTP_string("Telegram"),
MTPstring(),
@@ -2979,7 +2980,7 @@ void Session::serviceNotification(
MTPstring(),
MTPstring()));
}
const auto history = this->history(peerFromUser(ServiceUserId));
const auto history = this->history(PeerData::kServiceNotificationsId);
if (!history->lastMessageKnown()) {
_session->api().requestDialogEntry(history, [=] {
insertCheckedServiceNotification(message, media, date);
@@ -3001,7 +3002,7 @@ void Session::insertCheckedServiceNotification(
const TextWithEntities &message,
const MTPMessageMedia &media,
TimeId date) {
const auto history = this->history(peerFromUser(ServiceUserId));
const auto history = this->history(PeerData::kServiceNotificationsId);
if (!history->isReadyFor(ShowAtUnreadMsgId)) {
history->setUnreadCount(0);
history->getReadyFor(ShowAtTheEndMsgId);
@@ -3016,7 +3017,7 @@ void Session::insertCheckedServiceNotification(
MTP_message(
MTP_flags(flags),
MTP_int(clientMsgId()),
MTP_int(ServiceUserId),
MTP_int(peerToUser(PeerData::kServiceNotificationsId)),
MTP_peerUser(MTP_int(_session->userId())),
MTPnullFwdHeader,
MTPint(),