@@ -55,10 +55,9 @@ def to_e164_br(phone_number):
5555 except phonenumbers .NumberParseException :
5656 return None
5757
58- def timestamp_formatado (timestamp ) :
58+ def timestamp_formatado (dt : datetime ) -> str :
5959 try :
60- data = datetime .fromisoformat (timestamp )
61- timestamp_formatado = data .isoformat ()
60+ return dt .replace (microsecond = 0 ).isoformat ()
6261 except ValueError :
6362 raise HTTPException (status_code = 400 , detail = "Formato de timestamp inválido. Use ISO 8601 (ex: '2025-06-27T14:00:00')" )
6463
@@ -293,7 +292,8 @@ async def criar_uma_agenda(nome_agenda: str, uid_do_responsavel: str, api_key: s
293292 agenda_ref .update ({
294293 uid_da_agenda : {
295294 'nome_agenda' : nome_agenda ,
296- 'chave_de_convite' : generate_random_invite_key ()
295+ 'chave_de_convite' : generate_random_invite_key (),
296+ 'firstCreated' : timestamp_formatado (datetime .now ())
297297 }
298298 })
299299
@@ -349,7 +349,7 @@ async def criar_uma_materia_na_agenda_já_criada(uid_da_agenda: str, nome_da_mat
349349 return {"message" : f'A matéria { nome_da_matéria } com o UID { uid } foi criada com sucesso' }
350350
351351@app .post ("/add/agenda/tarefa" , tags = ["Agenda" ], responses = STANDARD_RESPONSES )
352- async def criar_uma_tarefa_na_agenda_já_criada (uid_da_agenda : str , nome_da_tarefa : str , timestamp : str , api_key : str = Depends (get_api_key )):
352+ async def criar_uma_tarefa_na_agenda_já_criada (uid_da_agenda : str , nome_da_tarefa : str , api_key : str = Depends (get_api_key )):
353353 agenda_node = agenda_ref .child (uid_da_agenda )
354354 agenda_data = agenda_node .get ()
355355 if not agenda_data :
@@ -360,14 +360,14 @@ async def criar_uma_tarefa_na_agenda_já_criada(uid_da_agenda: str, nome_da_tare
360360 tarefa_criada .update ({
361361 uid : {
362362 'nome_da_tarefa' : nome_da_tarefa ,
363- 'timestamp' : timestamp_formatado (timestamp )
363+ 'timestamp' : timestamp_formatado (datetime . now () )
364364 }
365365 })
366366
367367 return {"message" : f'A tarefa com o UID { uid } foi criada com sucesso.' }
368368
369369@app .post ("/add/agenda/evento" , tags = ["Agenda" ], responses = STANDARD_RESPONSES )
370- async def criar_um_evento_na_agenda_já_criada (uid_da_agenda : str , nome_do_evento : str , timestamp : str , api_key : str = Depends (get_api_key )):
370+ async def criar_um_evento_na_agenda_já_criada (uid_da_agenda : str , nome_do_evento : str , api_key : str = Depends (get_api_key )):
371371 agenda_node = agenda_ref .child (uid_da_agenda )
372372 agenda_data = agenda_node .get ()
373373 if not agenda_data :
@@ -378,7 +378,7 @@ async def criar_um_evento_na_agenda_já_criada(uid_da_agenda: str, nome_do_event
378378 evento_criado .update ({
379379 uid : {
380380 'nome_do_evento' : nome_do_evento ,
381- 'timestamp' : timestamp_formatado (timestamp )
381+ 'timestamp' : timestamp_formatado (datetime . now () )
382382 }
383383 })
384384
@@ -484,13 +484,13 @@ async def atualizar_os_dados_da_agenda(uid_da_agenda: str = Query(...), uid_da_m
484484 return {"message" : "Agenda atualizada com sucesso" , "dados" : update_data }
485485
486486@app .patch ("/update/agenda/tarefa" , tags = ["Agenda" ], responses = STANDARD_RESPONSES )
487- async def atualizar_os_dados_da_agenda (uid_da_agenda : str = Query (...), uid_da_tarefa : str = Query (...), nome_da_tarefa : str = Query (None ), timestamp : str = Query ( None ), api_key : str = Depends (get_api_key )):
487+ async def atualizar_os_dados_da_agenda (uid_da_agenda : str = Query (...), uid_da_tarefa : str = Query (...), nome_da_tarefa : str = Query (None ), api_key : str = Depends (get_api_key )):
488488 agenda_node = agenda_ref .child (uid_da_agenda ).child ("tarefas" ).child (uid_da_tarefa )
489489 agenda_data = agenda_node .get ()
490490 if not matéria_data :
491491 raise HTTPException (status_code = 404 , detail = f"A tarefa com o UID { uid_da_tarefa } na agenda { uid_da_agenda } não existe" )
492492
493- timestamp_definido = timestamp_formatado (timestamp )
493+ timestamp_definido = timestamp_formatado (datetime . now () )
494494
495495 update_data = {}
496496 if nome_da_tarefa is not None :
@@ -506,13 +506,13 @@ async def atualizar_os_dados_da_agenda(uid_da_agenda: str = Query(...), uid_da_t
506506 return {"message" : "Agenda atualizada com sucesso" , "dados" : update_data }
507507
508508@app .patch ("/update/agenda/evento" , tags = ["Agenda" ], responses = STANDARD_RESPONSES )
509- async def atualizar_os_dados_da_agenda (uid_da_agenda : str = Query (...), uid_do_evento : str = Query (...), nome_do_evento : str = Query (None ), timestamp : str = Query ( None ), api_key : str = Depends (get_api_key )):
509+ async def atualizar_os_dados_da_agenda (uid_da_agenda : str = Query (...), uid_do_evento : str = Query (...), nome_do_evento : str = Query (None ), api_key : str = Depends (get_api_key )):
510510 agenda_node = agenda_ref .child (uid_da_agenda ).child ("eventos" ).child (uid_do_evento )
511511 agenda_data = agenda_node .get ()
512512 if not matéria_data :
513513 raise HTTPException (status_code = 404 , detail = f"O evento com o UID { uid_do_evento } na agenda { uid_da_agenda } não existe" )
514514
515- timestamp_definido = timestamp_formatado (timestamp )
515+ timestamp_definido = timestamp_formatado (datetime . now () )
516516
517517 update_data = {}
518518 if nome_da_tarefa is not None :
0 commit comments