@@ -179,6 +179,19 @@ public function edit(Request $request, Response $response, Session $session, Ker
179179 $ this ->succeed ($ response );
180180 }
181181
182+ protected static function _extractProfile (User $ user ): array
183+ {
184+ return array_change_key_case (
185+ array_filter (
186+ $ user ->attributes ()->toArray (),
187+ function (string $ key ): bool {
188+ return strtolower ($ key ) != "password " ;
189+ },
190+ ARRAY_FILTER_USE_KEY
191+ ), CASE_LOWER
192+ );
193+ }
194+
182195 /**
183196 * Get Threads
184197 *
@@ -209,34 +222,18 @@ public function getThreads(Request $request, Response $response, Kernel $kernel)
209222 continue ;
210223 }
211224 $ contributors_x = [];
212- $ contributors_x [$ author ->id ()->toString ()] = $ author ;
225+ $ contributors_x [$ author ->id ()->toString ()] = static :: _extractProfile ( $ author) ;
213226 $ contributors = array_map (
214- function (User $ u ) : array
215- {
216- return [
217- $ u ->id ()->toString () =>
218- array_change_key_case (
219- array_filter (
220- $ u ->attributes ()->toArray (),
221- function (string $ key ): bool {
222- return strtolower ($ key ) != "password " ;
223- },
224- ARRAY_FILTER_USE_KEY
225- ), CASE_LOWER
226- )
227- ];
228- },array_map ( function (Reply $ r ): User {
229- return $ r ->tail ()->node ();
230- }, $ thing ->getReplies ()));
231- $ contributors [] = array_change_key_case (
232- array_filter (
233- $ author ->attributes ()->toArray (),
234- function (string $ key ): bool {
235- return strtolower ($ key ) != "password " ;
236- },
237- ARRAY_FILTER_USE_KEY
238- ), CASE_LOWER
227+ function (User $ u ) : array {
228+ return [ $ u ->id ()->toString () => static ::_extractProfile ($ u ) ];
229+ }, array_map (
230+ function (Reply $ r ): User {
231+ return $ r ->tail ()->node ();
232+ },
233+ $ thing ->getReplies ()
234+ )
239235 );
236+ $ contributors [] = static ::_extractProfile ($ author );
240237 foreach ($ contributors as $ contributor ) {
241238 foreach ($ contributor as $ k =>$ v ) {
242239 if (!isset ($ contributors_x [$ k ]))
0 commit comments