mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-15 13:47:05 +02:00
Added api support to toggle and reorder bot usernames.
This commit is contained in:
parent
bbeefaed9c
commit
896bbb7c56
1 changed files with 20 additions and 0 deletions
|
@ -24,6 +24,14 @@ namespace {
|
|||
};
|
||||
}
|
||||
|
||||
[[nodiscard]] std::optional<MTPInputUser> BotUserInput(
|
||||
not_null<PeerData*> peer) {
|
||||
const auto user = peer->asUser();
|
||||
return (user && user->botInfo && user->botInfo->canEditInformation)
|
||||
? std::make_optional<MTPInputUser>(user->inputUser)
|
||||
: std::nullopt;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
Usernames::Usernames(not_null<ApiWrap*> api)
|
||||
|
@ -157,6 +165,12 @@ rpl::producer<rpl::no_value, Usernames::Error> Usernames::toggle(
|
|||
MTP_string(username),
|
||||
MTP_bool(active)
|
||||
)).done(done).fail(fail).send();
|
||||
} else if (const auto botUserInput = BotUserInput(peer)) {
|
||||
_api.request(MTPbots_ToggleUsername(
|
||||
*botUserInput,
|
||||
MTP_string(username),
|
||||
MTP_bool(active)
|
||||
)).done(done).fail(fail).send();
|
||||
} else {
|
||||
return rpl::never<rpl::no_value, Error>();
|
||||
}
|
||||
|
@ -204,6 +218,12 @@ rpl::producer<> Usernames::reorder(
|
|||
MTP_vector<MTPstring>(std::move(tlUsernames))
|
||||
)).done(finish).fail(finish).send();
|
||||
_reorderRequests.emplace(peerId, requestId);
|
||||
} else if (const auto botUserInput = BotUserInput(peer)) {
|
||||
const auto requestId = _api.request(MTPbots_ReorderUsernames(
|
||||
*botUserInput,
|
||||
MTP_vector<MTPstring>(std::move(tlUsernames))
|
||||
)).done(finish).fail(finish).send();
|
||||
_reorderRequests.emplace(peerId, requestId);
|
||||
}
|
||||
return lifetime;
|
||||
};
|
||||
|
|
Loading…
Add table
Reference in a new issue