mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-07-26 07:23:02 +02:00
parent
1c41e01f0d
commit
a285c1abec
3 changed files with 53 additions and 14 deletions
|
@ -1167,8 +1167,15 @@ Chat ParseChat(const MTPChat &data) {
|
||||||
result.colorIndex = (color && color->data().vcolor())
|
result.colorIndex = (color && color->data().vcolor())
|
||||||
? color->data().vcolor()->v
|
? color->data().vcolor()->v
|
||||||
: PeerColorIndex(result.bareId);
|
: PeerColorIndex(result.bareId);
|
||||||
|
result.isMonoforum = data.is_monoforum();
|
||||||
result.isBroadcast = data.is_broadcast();
|
result.isBroadcast = data.is_broadcast();
|
||||||
result.isSupergroup = data.is_megagroup();
|
result.isSupergroup = data.is_megagroup();
|
||||||
|
result.hasMonoforumAdminRights = data.is_broadcast()
|
||||||
|
&& (data.is_creator()
|
||||||
|
|| (data.vadmin_rights()
|
||||||
|
&& data.vadmin_rights()->data().is_manage_direct_messages()));
|
||||||
|
result.monoforumLinkId
|
||||||
|
= data.vlinked_monoforum_id().value_or_empty();
|
||||||
result.title = ParseString(data.vtitle());
|
result.title = ParseString(data.vtitle());
|
||||||
if (const auto username = data.vusername()) {
|
if (const auto username = data.vusername()) {
|
||||||
result.username = ParseString(*username);
|
result.username = ParseString(*username);
|
||||||
|
@ -1188,15 +1195,6 @@ Chat ParseChat(const MTPChat &data) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::map<PeerId, Chat> ParseChatsList(const MTPVector<MTPChat> &data) {
|
|
||||||
auto result = std::map<PeerId, Chat>();
|
|
||||||
for (const auto &chat : data.v) {
|
|
||||||
auto parsed = ParseChat(chat);
|
|
||||||
result.emplace(parsed.id(), std::move(parsed));
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
Utf8String ContactInfo::name() const {
|
Utf8String ContactInfo::name() const {
|
||||||
return firstName.isEmpty()
|
return firstName.isEmpty()
|
||||||
? (lastName.isEmpty()
|
? (lastName.isEmpty()
|
||||||
|
@ -1273,6 +1271,20 @@ std::map<PeerId, Peer> ParsePeersLists(
|
||||||
auto parsed = ParseChat(chat);
|
auto parsed = ParseChat(chat);
|
||||||
result.emplace(parsed.id(), Peer{ std::move(parsed) });
|
result.emplace(parsed.id(), Peer{ std::move(parsed) });
|
||||||
}
|
}
|
||||||
|
for (auto &[peerId, parsed] : result) {
|
||||||
|
if (const auto chat = std::get_if<Chat>(&parsed.data)) {
|
||||||
|
if (chat->isMonoforum) {
|
||||||
|
const auto i = result.find(
|
||||||
|
PeerId(ChannelId(chat->monoforumLinkId)));
|
||||||
|
if (i != end(result)) {
|
||||||
|
chat->isMonoforumAdmin
|
||||||
|
= i->second.chat()->hasMonoforumAdminRights;
|
||||||
|
chat->isMonoforumOfPublicBroadcast
|
||||||
|
= !i->second.chat()->username.isEmpty();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2191,7 +2203,13 @@ const DialogInfo *DialogsInfo::item(int index) const {
|
||||||
|
|
||||||
DialogInfo::Type DialogTypeFromChat(const Chat &chat) {
|
DialogInfo::Type DialogTypeFromChat(const Chat &chat) {
|
||||||
using Type = DialogInfo::Type;
|
using Type = DialogInfo::Type;
|
||||||
return chat.username.isEmpty()
|
return (chat.isMonoforum && !chat.isMonoforumAdmin)
|
||||||
|
? Type::Personal
|
||||||
|
: (chat.isMonoforumAdmin && chat.isMonoforumOfPublicBroadcast)
|
||||||
|
? Type::PublicSupergroup
|
||||||
|
: chat.isMonoforumAdmin
|
||||||
|
? Type::PrivateSupergroup
|
||||||
|
: chat.username.isEmpty()
|
||||||
? (chat.isBroadcast
|
? (chat.isBroadcast
|
||||||
? Type::PrivateChannel
|
? Type::PrivateChannel
|
||||||
: chat.isSupergroup
|
: chat.isSupergroup
|
||||||
|
@ -2252,6 +2270,11 @@ DialogsInfo ParseDialogsInfo(const MTPmessages_Dialogs &data) {
|
||||||
info.migratedToChannelId = peer.chat()
|
info.migratedToChannelId = peer.chat()
|
||||||
? peer.chat()->migratedToChannelId
|
? peer.chat()->migratedToChannelId
|
||||||
: 0;
|
: 0;
|
||||||
|
info.isMonoforum = peer.chat()
|
||||||
|
&& peer.chat()->isMonoforum;
|
||||||
|
info.monoforumBroadcastInput = peer.chat()
|
||||||
|
? peer.chat()->monoforumBroadcastInput
|
||||||
|
: MTPInputPeer(MTP_inputPeerEmpty());
|
||||||
}
|
}
|
||||||
info.topMessageId = fields.vtop_message().v;
|
info.topMessageId = fields.vtop_message().v;
|
||||||
const auto messageIt = messages.find(MessageId{
|
const auto messageIt = messages.find(MessageId{
|
||||||
|
@ -2290,6 +2313,10 @@ DialogInfo DialogInfoFromChat(const Chat &data) {
|
||||||
result.topMessageId = 0;
|
result.topMessageId = 0;
|
||||||
result.type = DialogTypeFromChat(data);
|
result.type = DialogTypeFromChat(data);
|
||||||
result.migratedToChannelId = data.migratedToChannelId;
|
result.migratedToChannelId = data.migratedToChannelId;
|
||||||
|
result.isMonoforum = data.isMonoforum;
|
||||||
|
if (data.isMonoforumAdmin) {
|
||||||
|
result.monoforumBroadcastInput = data.monoforumBroadcastInput;
|
||||||
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2424,7 +2451,8 @@ void FinalizeDialogsInfo(DialogsInfo &info, const Settings &settings) {
|
||||||
}
|
}
|
||||||
Unexpected("Type in ApiWrap::onlyMyMessages.");
|
Unexpected("Type in ApiWrap::onlyMyMessages.");
|
||||||
}();
|
}();
|
||||||
dialog.onlyMyMessages = ((settings.fullChats & setting) != setting);
|
dialog.onlyMyMessages = (dialog.type != DialogType::Personal)
|
||||||
|
&& ((settings.fullChats & setting) != setting);
|
||||||
|
|
||||||
ranges::sort(dialog.splits);
|
ranges::sort(dialog.splits);
|
||||||
}
|
}
|
||||||
|
|
|
@ -319,14 +319,19 @@ struct Chat {
|
||||||
Utf8String title;
|
Utf8String title;
|
||||||
Utf8String username;
|
Utf8String username;
|
||||||
uint8 colorIndex = 0;
|
uint8 colorIndex = 0;
|
||||||
|
bool isMonoforum = false;
|
||||||
bool isBroadcast = false;
|
bool isBroadcast = false;
|
||||||
bool isSupergroup = false;
|
bool isSupergroup = false;
|
||||||
|
bool isMonoforumAdmin = false;
|
||||||
|
bool hasMonoforumAdminRights = false;
|
||||||
|
bool isMonoforumOfPublicBroadcast = false;
|
||||||
|
BareId monoforumLinkId = 0;
|
||||||
|
|
||||||
MTPInputPeer input = MTP_inputPeerEmpty();
|
MTPInputPeer input = MTP_inputPeerEmpty();
|
||||||
|
MTPInputPeer monoforumBroadcastInput = MTP_inputPeerEmpty();
|
||||||
};
|
};
|
||||||
|
|
||||||
Chat ParseChat(const MTPChat &data);
|
Chat ParseChat(const MTPChat &data);
|
||||||
std::map<PeerId, Chat> ParseChatsList(const MTPVector<MTPChat> &data);
|
|
||||||
|
|
||||||
struct Peer {
|
struct Peer {
|
||||||
PeerId id() const;
|
PeerId id() const;
|
||||||
|
@ -952,12 +957,15 @@ struct DialogInfo {
|
||||||
MTPInputPeer migratedFromInput = MTP_inputPeerEmpty();
|
MTPInputPeer migratedFromInput = MTP_inputPeerEmpty();
|
||||||
ChannelId migratedToChannelId = 0;
|
ChannelId migratedToChannelId = 0;
|
||||||
|
|
||||||
|
MTPInputPeer monoforumBroadcastInput = MTP_inputPeerEmpty();
|
||||||
|
|
||||||
// User messages splits which contained that dialog.
|
// User messages splits which contained that dialog.
|
||||||
std::vector<int> splits;
|
std::vector<int> splits;
|
||||||
|
|
||||||
// Filled after the whole dialogs list is accumulated.
|
// Filled after the whole dialogs list is accumulated.
|
||||||
bool onlyMyMessages = false;
|
bool onlyMyMessages = false;
|
||||||
bool isLeftChannel = false;
|
bool isLeftChannel = false;
|
||||||
|
bool isMonoforum = false;
|
||||||
QString relativePath;
|
QString relativePath;
|
||||||
|
|
||||||
// Filled when requesting dialog messages.
|
// Filled when requesting dialog messages.
|
||||||
|
|
|
@ -1370,7 +1370,7 @@ void ApiWrap::appendSinglePeerDialogs(Data::DialogsInfo &&info) {
|
||||||
if (isSupergroupType(info.type) && !migratedRequestId) {
|
if (isSupergroupType(info.type) && !migratedRequestId) {
|
||||||
migratedRequestId = requestSinglePeerMigrated(info);
|
migratedRequestId = requestSinglePeerMigrated(info);
|
||||||
continue;
|
continue;
|
||||||
} else if (isChannelType(info.type)) {
|
} else if (isChannelType(info.type) || info.isMonoforum) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
for (auto i = last; i != 0; --i) {
|
for (auto i = last; i != 0; --i) {
|
||||||
|
@ -1642,6 +1642,9 @@ void ApiWrap::requestChatMessages(
|
||||||
const auto realPeerInput = (splitIndex >= 0)
|
const auto realPeerInput = (splitIndex >= 0)
|
||||||
? _chatProcess->info.input
|
? _chatProcess->info.input
|
||||||
: _chatProcess->info.migratedFromInput;
|
: _chatProcess->info.migratedFromInput;
|
||||||
|
const auto outgoingInput = _chatProcess->info.isMonoforum
|
||||||
|
? _chatProcess->info.monoforumBroadcastInput
|
||||||
|
: MTP_inputPeerSelf();
|
||||||
const auto realSplitIndex = (splitIndex >= 0)
|
const auto realSplitIndex = (splitIndex >= 0)
|
||||||
? splitIndex
|
? splitIndex
|
||||||
: (splitsCount + splitIndex);
|
: (splitsCount + splitIndex);
|
||||||
|
@ -1650,7 +1653,7 @@ void ApiWrap::requestChatMessages(
|
||||||
MTP_flags(MTPmessages_Search::Flag::f_from_id),
|
MTP_flags(MTPmessages_Search::Flag::f_from_id),
|
||||||
realPeerInput,
|
realPeerInput,
|
||||||
MTP_string(), // query
|
MTP_string(), // query
|
||||||
MTP_inputPeerSelf(),
|
outgoingInput,
|
||||||
MTPInputPeer(), // saved_peer_id
|
MTPInputPeer(), // saved_peer_id
|
||||||
MTPVector<MTPReaction>(), // saved_reaction
|
MTPVector<MTPReaction>(), // saved_reaction
|
||||||
MTPint(), // top_msg_id
|
MTPint(), // top_msg_id
|
||||||
|
|
Loading…
Add table
Reference in a new issue