1010use OC \Server ;
1111
1212use OCA \Solid \Service \UserService ;
13+ use OCA \Solid \Service \SolidWebhookService ;
14+ use OCA \Solid \Db \SolidWebhookMapper ;
1315use OCA \Solid \WellKnown \OpenIdConfigurationHandler ;
1416use OCA \Solid \WellKnown \SolidHandler ;
1517use OCA \Solid \Middleware \SolidCorsMiddleware ;
2325use OCP \IServerContainer ;
2426use OCP \Settings \IManager ;
2527use OCP \Util ;
28+ use OCP \IDBConnection ;
2629
2730class Application extends App implements IBootstrap {
2831 public const APP_ID = 'solid ' ;
@@ -32,34 +35,12 @@ class Application extends App implements IBootstrap {
3235 */
3336 public function __construct (array $ urlParams = []) {
3437 parent ::__construct (self ::APP_ID , $ urlParams );
35-
36- $ container = $ this ->getContainer ();
37-
38- $ container ->registerService (SolidCorsMiddleware::class, function ($ c ): SolidCorsMiddleware {
39- return new SolidCorsMiddleware (
40- $ c ->get (IRequest::class)
41- );
42- });
43-
44- // executed in the order that it is registered
45- $ container ->registerMiddleware (SolidCorsMiddleware::class);
46-
47- $ container ->registerService (SolidWebhookService::class, function ($ c ): SolidWebhookService {
48- return new SolidWebhookService (
49- $ c ->query (SolidWebhookMapper::class)
50- );
51- });
52-
53- $ container ->registerService (SolidWebhookMapper::class, function ($ c ): SolidWebhookMapper {
54- return new SolidWebhookMapper (
55- $ c ->get (IDBConnection::class)
56- );
57- });
5838 }
5939
6040 public function register (IRegistrationContext $ context ): void {
6141 $ context ->registerWellKnownHandler (\OCA \Solid \WellKnown \OpenIdConfigurationHandler::class);
6242 $ context ->registerWellKnownHandler (\OCA \Solid \WellKnown \SolidHandler::class);
43+ $ context ->registerMiddleware (SolidCorsMiddleware::class);
6344
6445 /**
6546 * Core class wrappers
@@ -79,6 +60,19 @@ public function register(IRegistrationContext $context): void {
7960 $ context ->registerService ('User ' , function ($ c ) {
8061 return $ c ->query ('UserSession ' )->getUser ();
8162 });
63+
64+ /* webhook DB services */
65+ $ context ->registerService (SolidWebhookService::class, function ($ c ): SolidWebhookService {
66+ return new SolidWebhookService (
67+ $ c ->query (SolidWebhookMapper::class)
68+ );
69+ });
70+
71+ $ context ->registerService (SolidWebhookMapper::class, function ($ c ): SolidWebhookMapper {
72+ return new SolidWebhookMapper (
73+ $ c ->get (\OCP \IDBConnection::class)
74+ );
75+ });
8276 }
8377
8478 public function boot (IBootContext $ context ): void {
0 commit comments