@@ -446,6 +446,33 @@ public function register(Request $request, Response $response, array $args = [])
446446 return $ response ;
447447 }
448448
449+
450+ /**
451+ * returns details about a list of registered users
452+ *
453+ * @param Request $request
454+ * @param Response $response
455+ * @param array $args
456+ *
457+ * @return Response
458+ */
459+ public function batchDetails (Request $ request , Response $ response , array $ args = []): Response {
460+ $ body = json_decode ($ request ->getBody (), true );
461+
462+ if ($ body === null || !isset ($ body ['authKey ' ]) || !isset ($ body ['users ' ])) {
463+ return $ response ->withStatus (400 );
464+ }
465+
466+ if ($ body ['authKey ' ] !== $ this ->authKey ) {
467+ return $ response ->withStatus (403 );
468+ }
469+
470+ $ response ->getBody ()->write (json_encode ($ this ->selectDetails ($ body ['users ' ])));
471+
472+ return $ response ;
473+ }
474+
475+
449476 /**
450477 * let Nextcloud servers auto register users, used in the global scale scenario
451478 *
@@ -472,7 +499,6 @@ public function batchRegister(Request $request, Response $response, array $args
472499 }
473500
474501 return $ response ;
475-
476502 }
477503
478504 /**
@@ -582,6 +608,33 @@ public function verify(
582608 return $ response ;
583609 }
584610
611+
612+ private function selectDetails (array $ userIds ): array {
613+ $ stmt = $ this ->db ->prepare ('SELECT
614+ `u`.`federationId`,
615+ `s`.`v` AS `displayName`
616+ FROM
617+ `store` AS `s`,
618+ `users` AS `u`
619+ WHERE
620+ `u`.`id` = `s`.`userId` AND `s`.`k` = \'name \'
621+ AND `u`.`federationId`
622+ IN ( ' . implode (', ' , array_fill (0 , count ($ userIds ), '? ' )) . ') '
623+ );
624+
625+ $ stmt ->execute ($ userIds );
626+
627+ $ details = [];
628+ while ($ data = $ stmt ->fetch ()) {
629+ $ details [$ data ['federationId ' ]] = $ data ['displayName ' ];
630+ }
631+
632+ $ stmt ->closeCursor ();
633+
634+ return $ details ;
635+ }
636+
637+
585638 /**
586639 * increase number of max tries to verify account data
587640 *
0 commit comments