Added api support to toggle and reorder bot usernames.
This commit is contained in:
parent
bbeefaed9c
commit
896bbb7c56
|
@ -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
|
} // namespace
|
||||||
|
|
||||||
Usernames::Usernames(not_null<ApiWrap*> api)
|
Usernames::Usernames(not_null<ApiWrap*> api)
|
||||||
|
@ -157,6 +165,12 @@ rpl::producer<rpl::no_value, Usernames::Error> Usernames::toggle(
|
||||||
MTP_string(username),
|
MTP_string(username),
|
||||||
MTP_bool(active)
|
MTP_bool(active)
|
||||||
)).done(done).fail(fail).send();
|
)).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 {
|
} else {
|
||||||
return rpl::never<rpl::no_value, Error>();
|
return rpl::never<rpl::no_value, Error>();
|
||||||
}
|
}
|
||||||
|
@ -204,6 +218,12 @@ rpl::producer<> Usernames::reorder(
|
||||||
MTP_vector<MTPstring>(std::move(tlUsernames))
|
MTP_vector<MTPstring>(std::move(tlUsernames))
|
||||||
)).done(finish).fail(finish).send();
|
)).done(finish).fail(finish).send();
|
||||||
_reorderRequests.emplace(peerId, requestId);
|
_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;
|
return lifetime;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue
Block a user