| 546 | } |
| 547 | |
| 548 | not_null<UserData*> Session::processUser(const MTPUser &data) { |
| 549 | const auto result = user(data.match([](const auto &data) { |
| 550 | return data.vid().v; |
| 551 | })); |
| 552 | auto minimal = false; |
| 553 | const MTPUserStatus *status = nullptr; |
| 554 | const MTPUserStatus emptyStatus = MTP_userStatusEmpty(); |
| 555 | |
| 556 | using UpdateFlag = PeerUpdate::Flag; |
| 557 | auto flags = UpdateFlag::None | UpdateFlag::None; |
| 558 | data.match([&](const MTPDuserEmpty &data) { |
| 559 | const auto canShareThisContact = result->canShareThisContactFast(); |
| 560 | |
| 561 | result->setName(tr::lng_deleted(tr::now), QString(), QString(), QString()); |
| 562 | result->setPhoto(MTP_userProfilePhotoEmpty()); |
| 563 | result->setFlags(UserDataFlag::Deleted); |
| 564 | if (!result->phone().isEmpty()) { |
| 565 | result->setPhone(QString()); |
| 566 | flags |= UpdateFlag::PhoneNumber; |
| 567 | } |
| 568 | result->setBotInfoVersion(-1); |
| 569 | status = &emptyStatus; |
| 570 | result->setIsContact(false); |
| 571 | if (canShareThisContact != result->canShareThisContactFast()) { |
| 572 | flags |= UpdateFlag::CanShareContact; |
| 573 | } |
| 574 | }, [&](const MTPDuser &data) { |
| 575 | minimal = data.is_min(); |
| 576 | |
| 577 | const auto canShareThisContact = result->canShareThisContactFast(); |
| 578 | |
| 579 | const auto hasRequirePremiumToWrite |
| 580 | = data.is_contact_require_premium(); |
| 581 | const auto hasStarsPerMessage |
| 582 | = data.vsend_paid_messages_stars().has_value(); |
| 583 | if (!hasStarsPerMessage) { |
| 584 | result->setStarsPerMessage(0); |
| 585 | } |
| 586 | result->setBotInfoVersion(data.vbot_info_version().value_or(-1)); |
| 587 | |
| 588 | if (!minimal) { |
| 589 | if (const auto info = result->botInfo.get()) { |
| 590 | info->readsAllHistory = data.is_bot_chat_history(); |
| 591 | if (info->cantJoinGroups != data.is_bot_nochats()) { |
| 592 | info->cantJoinGroups = data.is_bot_nochats(); |
| 593 | flags |= UpdateFlag::BotCanBeInvited; |
| 594 | } |
| 595 | if (const auto value = data.vbot_inline_placeholder()) { |
| 596 | info->inlinePlaceholder = '_' + qs(*value); |
| 597 | } else { |
| 598 | info->inlinePlaceholder = QString(); |
| 599 | } |
| 600 | info->supportsAttachMenu = data.is_bot_attach_menu(); |
| 601 | info->supportsBusiness = data.is_bot_business(); |
| 602 | const auto canEditInformation = data.is_bot_can_edit(); |
| 603 | if (info->canEditInformation != canEditInformation) { |
| 604 | info->canEditInformation = canEditInformation; |
| 605 | flags |= UpdateFlag::ManagedBot; |
no test coverage detected