3939use OCP \Http \Client \IClient ;
4040use OCP \Http \Client \IClientService ;
4141use OCP \Http \Client \IResponse ;
42- use OCP \ILogger ;
4342use OCP \IURLGenerator ;
4443use OCP \OCS \IDiscoveryService ;
4544use Psr \Log \LoggerInterface ;
@@ -60,7 +59,6 @@ class GetSharedSecret extends Job {
6059 private LoggerInterface $ logger ;
6160 protected bool $ retainJob = false ;
6261 private string $ defaultEndPoint = '/ocs/v2.php/apps/federation/api/v1/shared-secret ' ;
63-
6462 /** 30 day = 2592000sec */
6563 private int $ maxLifespan = 2592000 ;
6664
@@ -83,16 +81,13 @@ public function __construct(
8381 }
8482
8583 /**
86- * run the job, then remove it from the joblist
87- *
88- * @param IJobList $jobList
89- * @param ILogger|null $logger
84+ * Run the job, then remove it from the joblist
9085 */
91- public function execute (IJobList $ jobList, ILogger $ logger = null ) {
86+ public function start (IJobList $ jobList): void {
9287 $ target = $ this ->argument ['url ' ];
9388 // only execute if target is still in the list of trusted domains
9489 if ($ this ->trustedServers ->isTrustedServer ($ target )) {
95- $ this -> parentExecute ($ jobList, $ logger );
90+ parentStart ($ jobList );
9691 }
9792
9893 $ jobList ->remove ($ this , $ this ->argument );
@@ -102,14 +97,8 @@ public function execute(IJobList $jobList, ILogger $logger = null) {
10297 }
10398 }
10499
105- /**
106- * Call execute() method of parent
107- *
108- * @param IJobList $jobList
109- * @param ILogger $logger
110- */
111- protected function parentExecute ($ jobList , $ logger = null ) {
112- parent ::execute ($ jobList , $ logger );
100+ protected function parentStart (IJobList $ jobList ): void {
101+ parent ::start ($ jobList );
113102 }
114103
115104 protected function run ($ argument ) {
@@ -162,12 +151,10 @@ protected function run($argument) {
162151 $ status = -1 ; // There is no status code if we could not connect
163152 $ this ->logger ->info ('Could not connect to ' . $ target , [
164153 'exception ' => $ e ,
165- 'app ' => 'federation ' ,
166154 ]);
167155 } catch (\Throwable $ e ) {
168156 $ status = Http::STATUS_INTERNAL_SERVER_ERROR ;
169157 $ this ->logger ->error ($ e ->getMessage (), [
170- 'app ' => 'federation ' ,
171158 'exception ' => $ e ,
172159 ]);
173160 }
@@ -190,22 +177,22 @@ protected function run($argument) {
190177 );
191178 } else {
192179 $ this ->logger ->error (
193- 'remote server " ' . $ target . '"" does not return a valid shared secret. Received data: ' . $ body ,
194- ['app ' => 'federation ' ]
180+ 'remote server " ' . $ target . '"" does not return a valid shared secret. Received data: ' . $ body ,
181+ ['app ' => 'federation ' ]
195182 );
196183 $ this ->trustedServers ->setServerStatus ($ target , TrustedServers::STATUS_FAILURE );
197184 }
198185 }
199186 }
200187
201188 /**
202- * re -add background job
189+ * Re -add background job
203190 *
204191 * @param array $argument
205192 */
206193 protected function reAddJob (array $ argument ): void {
207194 $ url = $ argument ['url ' ];
208- $ created = isset ( $ argument ['created ' ]) ? ( int ) $ argument [ ' created ' ] : $ this ->time ->getTime ();
195+ $ created = $ argument ['created ' ] ?? $ this ->time ->getTime ();
209196 $ token = $ argument ['token ' ];
210197 $ this ->jobList ->add (
211198 GetSharedSecret::class,
0 commit comments