mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Added usernames info to UserData.
This commit is contained in:
parent
51cead1445
commit
ffa8a94180
3 changed files with 30 additions and 0 deletions
|
@ -15,6 +15,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "mainwidget.h"
|
#include "mainwidget.h"
|
||||||
#include "api/api_bot.h"
|
#include "api/api_bot.h"
|
||||||
#include "api/api_text_entities.h"
|
#include "api/api_text_entities.h"
|
||||||
|
#include "api/api_user_names.h"
|
||||||
#include "core/application.h"
|
#include "core/application.h"
|
||||||
#include "core/core_settings.h"
|
#include "core/core_settings.h"
|
||||||
#include "core/mime_type.h" // Core::IsMimeSticker
|
#include "core/mime_type.h" // Core::IsMimeSticker
|
||||||
|
@ -583,6 +584,15 @@ not_null<UserData*> Session::processUser(const MTPUser &data) {
|
||||||
result->setAccessHash(accessHash->v);
|
result->setAccessHash(accessHash->v);
|
||||||
}
|
}
|
||||||
status = data.vstatus();
|
status = data.vstatus();
|
||||||
|
{
|
||||||
|
const auto newUsername = uname;
|
||||||
|
const auto newUsernames = data.vusernames()
|
||||||
|
? Api::Usernames::FromTL(*data.vusernames())
|
||||||
|
: !newUsername.isEmpty()
|
||||||
|
? Data::Usernames{{ newUsername, true, true }}
|
||||||
|
: Data::Usernames();
|
||||||
|
result->setUsernames(newUsernames);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (const auto &status = data.vemoji_status()) {
|
if (const auto &status = data.vemoji_status()) {
|
||||||
result->setEmojiStatus(*status);
|
result->setEmojiStatus(*status);
|
||||||
|
|
|
@ -13,6 +13,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "data/data_changes.h"
|
#include "data/data_changes.h"
|
||||||
#include "data/data_peer_bot_command.h"
|
#include "data/data_peer_bot_command.h"
|
||||||
#include "data/data_emoji_statuses.h"
|
#include "data/data_emoji_statuses.h"
|
||||||
|
#include "data/data_user_names.h"
|
||||||
#include "data/notify/data_notify_settings.h"
|
#include "data/notify/data_notify_settings.h"
|
||||||
#include "ui/text/text_options.h"
|
#include "ui/text/text_options.h"
|
||||||
#include "lang/lang_keys.h"
|
#include "lang/lang_keys.h"
|
||||||
|
@ -119,6 +120,16 @@ void UserData::setName(const QString &newFirstName, const QString &newLastName,
|
||||||
updateNameDelayed(newFullName, newPhoneName, newUsername);
|
updateNameDelayed(newFullName, newPhoneName, newUsername);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void UserData::setUsernames(const Data::Usernames &usernames) {
|
||||||
|
_usernames = ranges::views::all(
|
||||||
|
usernames
|
||||||
|
) | ranges::views::filter([&](const Data::Username &username) {
|
||||||
|
return username.active;
|
||||||
|
}) | ranges::views::transform([&](const Data::Username &username) {
|
||||||
|
return username.username;
|
||||||
|
}) | ranges::to_vector;
|
||||||
|
}
|
||||||
|
|
||||||
void UserData::setUsername(const QString &username) {
|
void UserData::setUsername(const QString &username) {
|
||||||
if (_username != username) {
|
if (_username != username) {
|
||||||
_username = username;
|
_username = username;
|
||||||
|
@ -291,6 +302,10 @@ const QString &UserData::username() const {
|
||||||
return _username;
|
return _username;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const std::vector<QString> &UserData::usernames() const {
|
||||||
|
return _usernames;
|
||||||
|
}
|
||||||
|
|
||||||
const QString &UserData::phone() const {
|
const QString &UserData::phone() const {
|
||||||
return _phone;
|
return _phone;
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,6 +13,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
|
|
||||||
namespace Data {
|
namespace Data {
|
||||||
struct BotCommand;
|
struct BotCommand;
|
||||||
|
struct Username;
|
||||||
} // namespace Data
|
} // namespace Data
|
||||||
|
|
||||||
struct BotInfo {
|
struct BotInfo {
|
||||||
|
@ -73,6 +74,7 @@ public:
|
||||||
const QString &newLastName,
|
const QString &newLastName,
|
||||||
const QString &newPhoneName,
|
const QString &newPhoneName,
|
||||||
const QString &newUsername);
|
const QString &newUsername);
|
||||||
|
void setUsernames(const std::vector<Data::Username> &usernames);
|
||||||
|
|
||||||
void setEmojiStatus(DocumentId emojiStatusId, TimeId until = 0);
|
void setEmojiStatus(DocumentId emojiStatusId, TimeId until = 0);
|
||||||
[[nodiscard]] DocumentId emojiStatusId() const;
|
[[nodiscard]] DocumentId emojiStatusId() const;
|
||||||
|
@ -129,6 +131,7 @@ public:
|
||||||
QString lastName;
|
QString lastName;
|
||||||
[[nodiscard]] const QString &phone() const;
|
[[nodiscard]] const QString &phone() const;
|
||||||
[[nodiscard]] const QString &username() const;
|
[[nodiscard]] const QString &username() const;
|
||||||
|
[[nodiscard]] const std::vector<QString> &usernames() const;
|
||||||
QString nameOrPhone;
|
QString nameOrPhone;
|
||||||
TimeId onlineTill = 0;
|
TimeId onlineTill = 0;
|
||||||
|
|
||||||
|
@ -172,6 +175,8 @@ private:
|
||||||
CallsStatus _callsStatus = CallsStatus::Unknown;
|
CallsStatus _callsStatus = CallsStatus::Unknown;
|
||||||
int _commonChatsCount = 0;
|
int _commonChatsCount = 0;
|
||||||
|
|
||||||
|
std::vector<QString> _usernames;
|
||||||
|
|
||||||
uint64 _accessHash = 0;
|
uint64 _accessHash = 0;
|
||||||
static constexpr auto kInaccessibleAccessHashOld
|
static constexpr auto kInaccessibleAccessHashOld
|
||||||
= 0xFFFFFFFFFFFFFFFFULL;
|
= 0xFFFFFFFFFFFFFFFFULL;
|
||||||
|
|
Loading…
Add table
Reference in a new issue