@@ -290,7 +290,7 @@ async def mostrar_todas_as_agendas_que_o_usuário_faz_parte(uid_do_responsavel:
290290 return agendas
291291
292292@app .get ("/getAllTarefasFromOneAgenda" , tags = ["Agenda" ], responses = STANDARD_RESPONSES )
293- async def get_all_tarefas_from_agenda (uid_da_agenda : str , api_key : str = Depends (get_api_key )):
293+ async def mostrar_todas_as_tarefas_dentro_de_uma_agenda (uid_da_agenda : str , api_key : str = Depends (get_api_key )):
294294 agenda_node = agenda_ref .child (uid_da_agenda ).get ()
295295
296296 if not agenda_node :
@@ -303,6 +303,50 @@ async def get_all_tarefas_from_agenda(uid_da_agenda: str, api_key: str = Depends
303303
304304 return {"tarefas" : tarefas }
305305
306+ @app .get ("/getAllMembrosFromOneAgenda" , tags = ["Agenda" ], responses = STANDARD_RESPONSES )
307+ async def mostrar_todos_os_membros_dentro_de_uma_agenda (uid_da_agenda : str , api_key : str = Depends (get_api_key )):
308+ membros_geral = agenda_membros_ref .get ()
309+ if not membros_geral :
310+ raise HTTPException (status_code = 404 , detail = "Não há membros vinculados a nenhuma agenda." )
311+
312+ membros_da_agenda = {}
313+
314+ for uid_usuario , agendas in membros_geral .items ():
315+ if uid_da_agenda in agendas :
316+ role = agendas [uid_da_agenda ].get ("role" , "Desconhecido" )
317+ membros_da_agenda [uid_usuario ] = role
318+
319+ if not membros_da_agenda :
320+ raise HTTPException (status_code = 404 , detail = f"Nenhum membro encontrado para a agenda '{ uid_da_agenda } '." )
321+
322+ todos_usuarios = {}
323+ page = auth .list_users ()
324+ while page :
325+ for user in page .users :
326+ todos_usuarios [user .uid ] = {
327+ "uid" : user .uid ,
328+ "email" : user .email ,
329+ "display_name" : user .display_name ,
330+ "phone_number" : user .phone_number or "" ,
331+ "photo_url" : user .photo_url or ""
332+ }
333+ page = page .get_next_page ()
334+
335+ resultado = []
336+ for uid , role in membros_da_agenda .items ():
337+ usuario_info = todos_usuarios .get (uid )
338+ if usuario_info :
339+ usuario_info ["role" ] = role
340+ resultado .append (usuario_info )
341+ else :
342+ resultado .append ({
343+ "uid" : uid ,
344+ "role" : role ,
345+ "info" : "Usuário não encontrado no Firebase Auth"
346+ })
347+
348+ return {"membros" : resultado }
349+
306350@app .post ("/add/agenda" , tags = ["Agenda" ], responses = STANDARD_RESPONSES )
307351async def criar_uma_agenda (nome_agenda : str , uid_do_responsavel : str , api_key : str = Depends (get_api_key )):
308352 if not check_uid_exists (uid_do_responsavel ):
0 commit comments