Add get_simple_config_firebase_realtime.
GitOrigin-RevId: 04b3aedcbe9ec1985f69cced34b0d890eedcf934
This commit is contained in:
parent
d462e21d20
commit
4ce54818a3
@ -330,6 +330,22 @@ ActorOwn<> get_simple_config_firebase_remote_config(Promise<SimpleConfigResult>
|
|||||||
{}, prefer_ipv6, std::move(get_config), payload, "application/json");
|
{}, prefer_ipv6, std::move(get_config), payload, "application/json");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ActorOwn<> get_simple_config_firebase_realtime(Promise<SimpleConfigResult> promise, const ConfigShared *shared_config,
|
||||||
|
bool is_test, int32 scheduler_id) {
|
||||||
|
if (is_test) {
|
||||||
|
promise.set_error(Status::Error(400, "Test config is not supported"));
|
||||||
|
return ActorOwn<>();
|
||||||
|
}
|
||||||
|
|
||||||
|
string url = "https://reserve-5a846.firebaseio.com/ipconfigv3.json";
|
||||||
|
const bool prefer_ipv6 = shared_config == nullptr ? false : shared_config->get_option_boolean("prefer_ipv6");
|
||||||
|
auto get_config = [](HttpQuery &http_query) -> Result<string> {
|
||||||
|
return http_query.get_arg("content").str();
|
||||||
|
};
|
||||||
|
return get_simple_config_impl(std::move(promise), scheduler_id, std::move(url), "reserve-5a846.firebaseio.com", {},
|
||||||
|
prefer_ipv6, std::move(get_config));
|
||||||
|
}
|
||||||
|
|
||||||
ActorOwn<> get_full_config(DcOption option, Promise<FullConfig> promise, ActorShared<> parent) {
|
ActorOwn<> get_full_config(DcOption option, Promise<FullConfig> promise, ActorShared<> parent) {
|
||||||
class SessionCallback : public Session::Callback {
|
class SessionCallback : public Session::Callback {
|
||||||
public:
|
public:
|
||||||
@ -755,6 +771,8 @@ class ConfigRecoverer : public Actor {
|
|||||||
return get_simple_config_azure;
|
return get_simple_config_azure;
|
||||||
case 3:
|
case 3:
|
||||||
return get_simple_config_firebase_remote_config;
|
return get_simple_config_firebase_remote_config;
|
||||||
|
case 4:
|
||||||
|
return get_simple_config_firebase_realtime;
|
||||||
case 0:
|
case 0:
|
||||||
return get_simple_config_google_dns;
|
return get_simple_config_google_dns;
|
||||||
case 1:
|
case 1:
|
||||||
|
@ -48,6 +48,9 @@ ActorOwn<> get_simple_config_firebase_remote_config(Promise<SimpleConfigResult>
|
|||||||
const ConfigShared *shared_config, bool is_test,
|
const ConfigShared *shared_config, bool is_test,
|
||||||
int32 scheduler_id);
|
int32 scheduler_id);
|
||||||
|
|
||||||
|
ActorOwn<> get_simple_config_firebase_realtime(Promise<SimpleConfigResult> promise, const ConfigShared *shared_config,
|
||||||
|
bool is_test, int32 scheduler_id);
|
||||||
|
|
||||||
class HttpDate {
|
class HttpDate {
|
||||||
static bool is_leap(int32 year) {
|
static bool is_leap(int32 year) {
|
||||||
return year % 4 == 0 && (year % 100 != 0 || year % 400 == 0);
|
return year % 4 == 0 && (year % 100 != 0 || year % 400 == 0);
|
||||||
|
@ -590,6 +590,18 @@ Status HttpReader::parse_json_parameters(MutableSlice parameters) {
|
|||||||
|
|
||||||
Parser parser(parameters);
|
Parser parser(parameters);
|
||||||
parser.skip_whitespaces();
|
parser.skip_whitespaces();
|
||||||
|
if (parser.peek_char() == '"') {
|
||||||
|
auto r_value = json_string_decode(parser);
|
||||||
|
if (r_value.is_error()) {
|
||||||
|
return Status::Error(400, PSLICE() << "Bad Request: can't parse string content: " << r_value.error().message());
|
||||||
|
}
|
||||||
|
if (!parser.empty()) {
|
||||||
|
return Status::Error(400, "Bad Request: extra data after string");
|
||||||
|
}
|
||||||
|
query_->container_.emplace_back(BufferSlice("content"));
|
||||||
|
query_->args_.emplace_back(query_->container_.back().as_slice(), r_value.move_as_ok());
|
||||||
|
return Status::OK();
|
||||||
|
}
|
||||||
parser.skip('{');
|
parser.skip('{');
|
||||||
if (parser.status().is_error()) {
|
if (parser.status().is_error()) {
|
||||||
return Status::Error(400, "Bad Request: JSON object expected");
|
return Status::Error(400, "Bad Request: JSON object expected");
|
||||||
|
@ -171,6 +171,7 @@ TEST(Mtproto, config) {
|
|||||||
run(get_simple_config_google_dns, true);
|
run(get_simple_config_google_dns, true);
|
||||||
run(get_simple_config_mozilla_dns, true);
|
run(get_simple_config_mozilla_dns, true);
|
||||||
run(get_simple_config_firebase_remote_config, false);
|
run(get_simple_config_firebase_remote_config, false);
|
||||||
|
run(get_simple_config_firebase_realtime, false);
|
||||||
}
|
}
|
||||||
cnt--;
|
cnt--;
|
||||||
sched.start();
|
sched.start();
|
||||||
|
Reference in New Issue
Block a user