mirror of https://github.com/procxx/kepka.git
Fix user and chat flags handling.
This commit is contained in:
parent
48548e9303
commit
75db59a8bb
|
@ -867,20 +867,23 @@ void ApiWrap::gotChatFull(PeerData *peer, const MTPmessages_ChatFull &result, mt
|
||||||
}
|
}
|
||||||
auto &f = d.vfull_chat.c_chatFull();
|
auto &f = d.vfull_chat.c_chatFull();
|
||||||
App::feedParticipants(f.vparticipants, false);
|
App::feedParticipants(f.vparticipants, false);
|
||||||
auto &v = f.vbot_info.v;
|
if (f.has_bot_info()) {
|
||||||
for_const (auto &item, v) {
|
for (const auto &item : f.vbot_info.v) {
|
||||||
switch (item.type()) {
|
item.match([&](const MTPDbotInfo &data) {
|
||||||
case mtpc_botInfo: {
|
if (const auto bot = App::userLoaded(data.vuser_id.v)) {
|
||||||
auto &b = item.c_botInfo();
|
bot->setBotInfo(item);
|
||||||
if (auto user = App::userLoaded(b.vuser_id.v)) {
|
fullPeerUpdated().notify(bot);
|
||||||
user->setBotInfo(item);
|
|
||||||
fullPeerUpdated().notify(user);
|
|
||||||
}
|
}
|
||||||
} break;
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
chat->setUserpicPhoto(f.vchat_photo);
|
chat->setUserpicPhoto(f.has_chat_photo()
|
||||||
chat->setInviteLink((f.vexported_invite.type() == mtpc_chatInviteExported) ? qs(f.vexported_invite.c_chatInviteExported().vlink) : QString());
|
? f.vchat_photo
|
||||||
|
: MTPPhoto(MTP_photoEmpty(MTP_long(0))));
|
||||||
|
chat->setInviteLink(
|
||||||
|
(f.vexported_invite.type() == mtpc_chatInviteExported
|
||||||
|
? qs(f.vexported_invite.c_chatInviteExported().vlink)
|
||||||
|
: QString()));
|
||||||
if (f.has_pinned_msg_id()) {
|
if (f.has_pinned_msg_id()) {
|
||||||
chat->setPinnedMessageId(f.vpinned_msg_id.v);
|
chat->setPinnedMessageId(f.vpinned_msg_id.v);
|
||||||
} else {
|
} else {
|
||||||
|
@ -1029,6 +1032,7 @@ void ApiWrap::gotUserFull(UserData *user, const MTPUserFull &result, mtpRequestI
|
||||||
} else {
|
} else {
|
||||||
user->clearPinnedMessage();
|
user->clearPinnedMessage();
|
||||||
}
|
}
|
||||||
|
user->setFullFlags(d.vflags.v);
|
||||||
user->setBlockStatus(d.is_blocked() ? UserData::BlockStatus::Blocked : UserData::BlockStatus::NotBlocked);
|
user->setBlockStatus(d.is_blocked() ? UserData::BlockStatus::Blocked : UserData::BlockStatus::NotBlocked);
|
||||||
user->setCallsStatus(d.is_phone_calls_private() ? UserData::CallsStatus::Private : d.is_phone_calls_available() ? UserData::CallsStatus::Enabled : UserData::CallsStatus::Disabled);
|
user->setCallsStatus(d.is_phone_calls_private() ? UserData::CallsStatus::Private : d.is_phone_calls_available() ? UserData::CallsStatus::Enabled : UserData::CallsStatus::Disabled);
|
||||||
user->setAbout(d.has_about() ? qs(d.vabout) : QString());
|
user->setAbout(d.has_about() ? qs(d.vabout) : QString());
|
||||||
|
|
|
@ -172,13 +172,13 @@ void PeerData::setUserpic(
|
||||||
}
|
}
|
||||||
|
|
||||||
void PeerData::setUserpicPhoto(const MTPPhoto &data) {
|
void PeerData::setUserpicPhoto(const MTPPhoto &data) {
|
||||||
auto photoId = [&]() -> PhotoId {
|
const auto photoId = data.match([&](const MTPDphoto &data) {
|
||||||
if (const auto photo = Auth().data().photo(data)) {
|
const auto photo = Auth().data().photo(data);
|
||||||
photo->peer = this;
|
photo->peer = this;
|
||||||
return photo->id;
|
return photo->id;
|
||||||
}
|
}, [](const MTPDphotoEmpty &data) {
|
||||||
return 0;
|
return PhotoId(0);
|
||||||
}();
|
});
|
||||||
if (_userpicPhotoId != photoId) {
|
if (_userpicPhotoId != photoId) {
|
||||||
_userpicPhotoId = photoId;
|
_userpicPhotoId = photoId;
|
||||||
Notify::peerUpdatedDelayed(this, UpdateFlag::PhotoChanged);
|
Notify::peerUpdatedDelayed(this, UpdateFlag::PhotoChanged);
|
||||||
|
@ -332,7 +332,7 @@ void PeerData::setUserpicChecked(
|
||||||
|
|
||||||
bool PeerData::canPinMessages() const {
|
bool PeerData::canPinMessages() const {
|
||||||
if (const auto user = asUser()) {
|
if (const auto user = asUser()) {
|
||||||
return user->isSelf();
|
return user->fullFlags() & MTPDuserFull::Flag::f_can_pin_message;
|
||||||
} else if (const auto chat = asChat()) {
|
} else if (const auto chat = asChat()) {
|
||||||
return chat->adminsEnabled() ? chat->amAdmin() : chat->amIn();
|
return chat->adminsEnabled() ? chat->amAdmin() : chat->amIn();
|
||||||
} else if (const auto channel = asChannel()) {
|
} else if (const auto channel = asChannel()) {
|
||||||
|
|
Loading…
Reference in New Issue