mirror of
https://github.com/telegramdesktop/tdesktop
synced 2025-03-11 08:48:14 +00:00
Added usernames info to ChannelData.
This commit is contained in:
parent
ffa8a94180
commit
4f4d0bef25
@ -20,6 +20,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
#include "data/data_group_call.h"
|
||||
#include "data/data_message_reactions.h"
|
||||
#include "data/data_peer_bot_command.h"
|
||||
#include "data/data_user_names.h"
|
||||
#include "data/notify/data_notify_settings.h"
|
||||
#include "main/main_session.h"
|
||||
#include "main/session/send_as_peers.h"
|
||||
@ -107,10 +108,24 @@ void ChannelData::setUsername(const QString &username) {
|
||||
}
|
||||
}
|
||||
|
||||
void ChannelData::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;
|
||||
}
|
||||
|
||||
QString ChannelData::username() const {
|
||||
return _username;
|
||||
}
|
||||
|
||||
const std::vector<QString> &ChannelData::usernames() const {
|
||||
return _usernames;
|
||||
}
|
||||
|
||||
void ChannelData::setAccessHash(uint64 accessHash) {
|
||||
access = accessHash;
|
||||
input = MTP_inputPeerChannel(
|
||||
|
@ -13,6 +13,10 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
#include "data/data_chat_participant_status.h"
|
||||
#include "data/data_peer_bot_commands.h"
|
||||
|
||||
namespace Data {
|
||||
struct Username;
|
||||
} // namespace Data
|
||||
|
||||
struct ChannelLocation {
|
||||
QString address;
|
||||
Data::LocationPoint point;
|
||||
@ -147,6 +151,7 @@ public:
|
||||
|
||||
void setName(const QString &name, const QString &username);
|
||||
void setUsername(const QString &username);
|
||||
void setUsernames(const std::vector<Data::Username> &usernames);
|
||||
void setPhoto(const MTPChatPhoto &photo);
|
||||
void setAccessHash(uint64 accessHash);
|
||||
|
||||
@ -161,6 +166,7 @@ public:
|
||||
}
|
||||
|
||||
[[nodiscard]] QString username() const;
|
||||
[[nodiscard]] const std::vector<QString> &usernames() const;
|
||||
|
||||
[[nodiscard]] int membersCount() const {
|
||||
return std::max(_membersCount, 1);
|
||||
@ -461,6 +467,7 @@ private:
|
||||
PtsWaiter _ptsWaiter;
|
||||
|
||||
QString _username;
|
||||
std::vector<QString> _usernames;
|
||||
|
||||
int _membersCount = -1;
|
||||
int _adminsCount = 1;
|
||||
|
@ -798,6 +798,20 @@ not_null<PeerData*> Session::processChat(const MTPChat &data) {
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
const auto newUsername = qs(data.vusername().value_or_empty());
|
||||
const auto newUsernames = data.vusernames()
|
||||
? Api::Usernames::FromTL(*data.vusernames())
|
||||
: !newUsername.isEmpty()
|
||||
? Data::Usernames{ Data::Username{ newUsername, true, true } }
|
||||
: Data::Usernames();
|
||||
channel->setName(
|
||||
qs(data.vtitle()),
|
||||
TextUtilities::SingleLine(newUsername));
|
||||
channel->setUsernames(newUsernames);
|
||||
}
|
||||
const auto hasUsername = !channel->username().isEmpty();
|
||||
|
||||
using Flag = ChannelDataFlag;
|
||||
const auto flagsMask = Flag::Broadcast
|
||||
| Flag::Verified
|
||||
@ -823,7 +837,7 @@ not_null<PeerData*> Session::processChat(const MTPChat &data) {
|
||||
| (data.is_fake() ? Flag::Fake : Flag())
|
||||
| (data.is_megagroup() ? Flag::Megagroup : Flag())
|
||||
| (data.is_gigagroup() ? Flag::Gigagroup : Flag())
|
||||
| (data.vusername() ? Flag::Username : Flag())
|
||||
| (hasUsername ? Flag::Username : Flag())
|
||||
| (data.is_signatures() ? Flag::Signatures : Flag())
|
||||
| (data.is_has_link() ? Flag::HasLink : Flag())
|
||||
| (data.is_slowmode_enabled() ? Flag::SlowmodeEnabled : Flag())
|
||||
@ -845,10 +859,6 @@ not_null<PeerData*> Session::processChat(const MTPChat &data) {
|
||||
: Flag());
|
||||
channel->setFlags((channel->flags() & ~flagsMask) | flagsSet);
|
||||
|
||||
channel->setName(
|
||||
qs(data.vtitle()),
|
||||
TextUtilities::SingleLine(qs(data.vusername().value_or_empty())));
|
||||
|
||||
channel->setPhoto(data.vphoto());
|
||||
|
||||
if (wasInChannel != channel->amIn()) {
|
||||
|
@ -19,7 +19,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
#include "ui/widgets/buttons.h"
|
||||
#include "settings/settings_common.h"
|
||||
#include "window/window_session_controller.h"
|
||||
#include "data/data_channel.h"
|
||||
#include "data/data_user.h"
|
||||
#include "styles/style_info.h"
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user