captcha-queries.php: refactor NativeCaptchaQuery to use DI

This commit is contained in:
Zankaria
2024-08-15 15:17:54 +02:00
parent 933594194c
commit a275d04efa
3 changed files with 18 additions and 6 deletions

View File

@@ -4,6 +4,7 @@ namespace Vichan;
use RuntimeException;
use Vichan\Driver\{HttpDriver, HttpDrivers, Log, LogDrivers};
use Vichan\Service\HCaptchaQuery;
use Vichan\Service\NativeCaptchaQuery;
use Vichan\Service\ReCaptchaQuery;
use Vichan\Service\RemoteCaptchaQuery;
@@ -67,6 +68,15 @@ function build_context(array $config): Context {
} else {
throw new RuntimeException('No remote captcha service available');
}
},
NativeCaptchaQuery::class => function($c) {
$http = $c->get(HttpDriver::class);
$config = $c->get('config');
return new NativeCaptchaQuery($http,
$config['domain'],
$config['captcha']['provider_check'],
$config['captcha']['extra']
);
}
]);
}