Skip to content

Commit

Permalink
Fixed crash on restricting users from moderation box.
Browse files Browse the repository at this point in the history
  • Loading branch information
23rd authored and john-preston committed May 4, 2024
1 parent 129d356 commit a866ba8
Showing 1 changed file with 25 additions and 17 deletions.
42 changes: 25 additions & 17 deletions Telegram/SourceFiles/boxes/moderate_messages_box.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -678,24 +678,32 @@ void CreateModerateMessagesBox(
Ui::AddSkip(container);
container->add(std::move(checkboxes));

handleConfirmation(ban, controller, [=](
not_null<PeerData*> peer,
not_null<ChannelData*> channel) {
if (wrap->toggled()) {
Api::ChatParticipants::Restrict(
channel,
peer,
ChatRestrictionsInfo(), // Unused.
ChatRestrictionsInfo(getRestrictions(), 0),
nullptr,
nullptr);
} else {
channel->session().api().chatParticipants().kick(
channel,
peer,
{ channel->restrictions(), 0 });
// Handle confirmation manually.
confirms->events() | rpl::start_with_next([=] {
if (ban->checked() && controller->collectRequests) {
const auto kick = !wrap->toggled();
const auto restrictions = getRestrictions();
const auto request = [=](
not_null<PeerData*> peer,
not_null<ChannelData*> channel) {
if (!kick) {
Api::ChatParticipants::Restrict(
channel,
peer,
ChatRestrictionsInfo(), // Unused.
ChatRestrictionsInfo(restrictions, 0),
nullptr,
nullptr);
} else {
channel->session().api().chatParticipants().kick(
channel,
peer,
{ channel->restrictions(), 0 });
}
};
sequentiallyRequest(request, controller->collectRequests());
}
});
}, ban->lifetime());
}

const auto close = crl::guard(box, [=] { box->closeBox(); });
Expand Down

0 comments on commit a866ba8

Please sign in to comment.