2
0
mirror of https://github.com/kotatogram/kotatogram-desktop synced 2025-08-31 22:55:11 +00:00

Use 48 bit [User/Chat/Channel]Id, 56 bit PeerId.

This commit is contained in:
John Preston
2021-04-02 01:04:10 +04:00
parent 61d0cc38b0
commit 1342077dcb
83 changed files with 904 additions and 475 deletions

View File

@@ -607,7 +607,7 @@ UserData *ParticipantsAdditionalData::applyCreator(
UserData *ParticipantsAdditionalData::applyAdmin(
const MTPDchannelParticipantAdmin &data) {
const auto user = _peer->owner().userLoaded(data.vuser_id().v);
const auto user = _peer->owner().userLoaded(UserId(data.vuser_id().v));
if (!user) {
return nullptr;
} else if (const auto chat = _peer->asChat()) {
@@ -631,7 +631,7 @@ UserData *ParticipantsAdditionalData::applyAdmin(
} else {
_adminRanks.remove(user);
}
if (const auto by = _peer->owner().userLoaded(data.vpromoted_by().v)) {
if (const auto by = _peer->owner().userLoaded(data.vpromoted_by())) {
const auto i = _adminPromotedBy.find(user);
if (i == _adminPromotedBy.end()) {
_adminPromotedBy.emplace(user, by);
@@ -646,7 +646,7 @@ UserData *ParticipantsAdditionalData::applyAdmin(
}
UserData *ParticipantsAdditionalData::applyRegular(MTPint userId) {
const auto user = _peer->owner().userLoaded(userId.v);
const auto user = _peer->owner().userLoaded(userId);
if (!user) {
return nullptr;
} else if (const auto chat = _peer->asChat()) {
@@ -685,7 +685,7 @@ PeerData *ParticipantsAdditionalData::applyBanned(
_kicked.erase(participant);
}
_restrictedRights[participant] = data.vbanned_rights();
if (const auto by = _peer->owner().userLoaded(data.vkicked_by().v)) {
if (const auto by = _peer->owner().userLoaded(data.vkicked_by())) {
const auto i = _restrictedBy.find(participant);
if (i == _restrictedBy.end()) {
_restrictedBy.emplace(participant, by);
@@ -725,7 +725,7 @@ ParticipantsOnlineSorter::ParticipantsOnlineSorter(
Data::PeerUpdate::Flag::OnlineStatus
) | rpl::start_with_next([=](const Data::PeerUpdate &update) {
const auto peerId = update.peer->id;
if (const auto row = _delegate->peerListFindRow(peerId)) {
if (const auto row = _delegate->peerListFindRow(peerId.value)) {
row->refreshStatus();
sortDelayed();
}
@@ -827,7 +827,7 @@ void ParticipantsBoxController::setupListChangeViewers() {
return;
}
}
if (const auto row = delegate()->peerListFindRow(user->id)) {
if (const auto row = delegate()->peerListFindRow(user->id.value)) {
delegate()->peerListPartitionRows([&](const PeerListRow &row) {
return (row.peer() == user);
});
@@ -843,7 +843,7 @@ void ParticipantsBoxController::setupListChangeViewers() {
channel->owner().megagroupParticipantRemoved(
channel
) | rpl::start_with_next([=](not_null<UserData*> user) {
if (const auto row = delegate()->peerListFindRow(user->id)) {
if (const auto row = delegate()->peerListFindRow(user->id.value)) {
delegate()->peerListRemoveRow(row);
}
delegate()->peerListRefreshRows();
@@ -1561,12 +1561,12 @@ void ParticipantsBoxController::editAdminDone(
using Flag = MTPDchannelParticipantCreator::Flag;
_additional.applyParticipant(MTP_channelParticipantCreator(
MTP_flags(rank.isEmpty() ? Flag(0) : Flag::f_rank),
MTP_int(user->bareId()),
peerToBareMTPInt(user->id),
rights,
MTP_string(rank)));
} else if (rights.c_chatAdminRights().vflags().v == 0) {
_additional.applyParticipant(MTP_channelParticipant(
MTP_int(user->bareId()),
peerToBareMTPInt(user->id),
MTP_int(date)));
if (_role == Role::Admins) {
removeRow(user);
@@ -1577,11 +1577,11 @@ void ParticipantsBoxController::editAdminDone(
_additional.applyParticipant(MTP_channelParticipantAdmin(
MTP_flags(Flag::f_can_edit
| (rank.isEmpty() ? Flag(0) : Flag::f_rank)),
MTP_int(user->bareId()),
peerToBareMTPInt(user->id),
MTPint(), // inviter_id
MTP_int(alreadyPromotedBy
? alreadyPromotedBy->bareId()
: user->session().userId()),
peerToBareMTPInt(alreadyPromotedBy
? alreadyPromotedBy->id
: user->session().userPeerId()),
MTP_int(date),
rights,
MTP_string(rank)));
@@ -1637,7 +1637,7 @@ void ParticipantsBoxController::editRestrictedDone(
if (Data::ChatBannedRightsFlags(rights) == 0) {
if (user) {
_additional.applyParticipant(MTP_channelParticipant(
MTP_int(user->bareId()),
peerToBareMTPInt(user->id),
MTP_int(date)));
} else {
_additional.setExternal(participant);
@@ -1654,14 +1654,10 @@ void ParticipantsBoxController::editRestrictedDone(
MTP_flags(kicked
? MTPDchannelParticipantBanned::Flag::f_left
: MTPDchannelParticipantBanned::Flag(0)),
(participant->isUser()
? MTP_peerUser(MTP_int(participant->bareId()))
: participant->isChat()
? MTP_peerChat(MTP_int(participant->bareId()))
: MTP_peerChannel(MTP_int(participant->bareId()))),
MTP_int(alreadyRestrictedBy
? alreadyRestrictedBy->bareId()
: participant->session().userId()),
peerToMTP(participant->id),
peerToBareMTPInt(alreadyRestrictedBy
? alreadyRestrictedBy->id
: participant->session().userPeerId()),
MTP_int(date),
rights));
if (kicked) {
@@ -1704,7 +1700,7 @@ void ParticipantsBoxController::kickParticipant(not_null<PeerData*> participant)
void ParticipantsBoxController::unkickParticipant(not_null<UserData*> user) {
_editBox = nullptr;
if (const auto row = delegate()->peerListFindRow(user->id)) {
if (const auto row = delegate()->peerListFindRow(user->id.value)) {
delegate()->peerListRemoveRow(row);
delegate()->peerListRefreshRows();
}
@@ -1720,7 +1716,7 @@ void ParticipantsBoxController::kickParticipantSure(
? *restrictedRights
: ChannelData::EmptyRestrictedRights(participant);
if (const auto row = delegate()->peerListFindRow(participant->id)) {
if (const auto row = delegate()->peerListFindRow(participant->id.value)) {
delegate()->peerListRemoveRow(row);
delegate()->peerListRefreshRows();
}
@@ -1770,7 +1766,7 @@ void ParticipantsBoxController::removeAdminSure(not_null<UserData*> user) {
void ParticipantsBoxController::removeKickedWithRow(
not_null<PeerData*> participant) {
if (const auto row = delegate()->peerListFindRow(participant->id)) {
if (const auto row = delegate()->peerListFindRow(participant->id.value)) {
removeKicked(row, participant);
} else {
removeKicked(participant);
@@ -1796,7 +1792,7 @@ void ParticipantsBoxController::removeKicked(
}
bool ParticipantsBoxController::appendRow(not_null<PeerData*> participant) {
if (delegate()->peerListFindRow(participant->id)) {
if (delegate()->peerListFindRow(participant->id.value)) {
recomputeTypeFor(participant);
return false;
} else if (auto row = createRow(participant)) {
@@ -1810,7 +1806,7 @@ bool ParticipantsBoxController::appendRow(not_null<PeerData*> participant) {
}
bool ParticipantsBoxController::prependRow(not_null<PeerData*> participant) {
if (const auto row = delegate()->peerListFindRow(participant->id)) {
if (const auto row = delegate()->peerListFindRow(participant->id.value)) {
recomputeTypeFor(participant);
refreshCustomStatus(row);
if (_role == Role::Admins) {
@@ -1829,7 +1825,7 @@ bool ParticipantsBoxController::prependRow(not_null<PeerData*> participant) {
}
bool ParticipantsBoxController::removeRow(not_null<PeerData*> participant) {
if (auto row = delegate()->peerListFindRow(participant->id)) {
if (auto row = delegate()->peerListFindRow(participant->id.value)) {
if (_role == Role::Admins) {
// Perhaps we are removing an admin from search results.
row->setCustomStatus(tr::lng_channel_admin_status_not_admin(tr::now));
@@ -1903,7 +1899,7 @@ void ParticipantsBoxController::recomputeTypeFor(
if (_role != Role::Profile) {
return;
}
if (const auto row = delegate()->peerListFindRow(participant->id)) {
if (const auto row = delegate()->peerListFindRow(participant->id.value)) {
static_cast<Row*>(row)->setType(computeType(participant));
}
}