From 593d93bfdf1b542fbd6cf65cf0b4f8978c7718f1 Mon Sep 17 00:00:00 2001 From: Maxson Almeida Date: Thu, 30 Oct 2025 11:48:23 -0300 Subject: [PATCH 1/4] =?UTF-8?q?feat:=20Adiciona=20campos=20de=20valida?= =?UTF-8?q?=C3=A7=C3=A3o=20e=20URL=20de=20verifica=C3=A7=C3=A3o=20de=20aut?= =?UTF-8?q?enticidade=20no=20resultado=20do=20certificado?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lambda_function.py | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/lambda_function.py b/lambda_function.py index 9fc175d..99bfb4d 100644 --- a/lambda_function.py +++ b/lambda_function.py @@ -132,6 +132,8 @@ def lambda_handler(event, context): certificates_results_messagens.append({ "order_id": result.get('participant', {}).get('event', {}).get('order_id', ""), + "validation_code": result.get('participant', {}).get('validation_code', ""), + "authenticity_verification_url": result.get('participant', {}).get('authenticity_verification_url', ""), "product_id": result.get('participant', {}).get('event', {}).get('product_id', ""), "product_name": result.get('participant', {}).get('event', {}).get('product_name', ""), "email": result.get('participant', {}).get('email', ""), @@ -169,3 +171,34 @@ def lambda_handler(event, context): 'message': 'Erro ao gerar certificados' }) } + + +if __name__ == "__main__": + # Test event for local execution + test_event = { + "Records": [ + { + "body": [ + { + "order_id": 2266, + "first_name": "Maxson", + "last_name": "Almeida Ferovante", + "email": "maxsonferovante@gmail.com", + "phone": "(48) 99223-8206", + "cpf": "", + "city": "Florianópolis", + "product_id": 316, + "product_name": "Evento de Teste", + "certificate_details": "In recognition of their participation in the 90st edition of the Python Floripa Community Meeting, held on Sep 27, 2025, in Florianópolis, Brazil, with a total duration of 5 hours.", + "certificate_logo": "https://tech.floripa.br/wp-content/uploads/2025/03/logo-certificado.png", + "certificate_background": "https://tech.floripa.br/wp-content/uploads/2025/03/certificado-python-floripa.png", + "order_date": "2025-08-28 02:44:54", + "checkin_latitude": "-27.5460492", + "checkin_longitude": "-48.6227075", + "time_checkin": "2025-03-26 20:55:44" + }, + ] + } + ] + } + lambda_handler(test_event, None) \ No newline at end of file From b09fec2864b3b84c99eaadfdb92f614ed92aeef1 Mon Sep 17 00:00:00 2001 From: Maxson Almeida Date: Thu, 30 Oct 2025 11:52:18 -0300 Subject: [PATCH 2/4] =?UTF-8?q?refactor:=20Remove=20c=C3=B3digo=20de=20tes?= =?UTF-8?q?te=20local=20do=20manipulador=20lambda?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lambda_function.py | 30 ------------------------------ 1 file changed, 30 deletions(-) diff --git a/lambda_function.py b/lambda_function.py index 99bfb4d..cc4099a 100644 --- a/lambda_function.py +++ b/lambda_function.py @@ -172,33 +172,3 @@ def lambda_handler(event, context): }) } - -if __name__ == "__main__": - # Test event for local execution - test_event = { - "Records": [ - { - "body": [ - { - "order_id": 2266, - "first_name": "Maxson", - "last_name": "Almeida Ferovante", - "email": "maxsonferovante@gmail.com", - "phone": "(48) 99223-8206", - "cpf": "", - "city": "Florianópolis", - "product_id": 316, - "product_name": "Evento de Teste", - "certificate_details": "In recognition of their participation in the 90st edition of the Python Floripa Community Meeting, held on Sep 27, 2025, in Florianópolis, Brazil, with a total duration of 5 hours.", - "certificate_logo": "https://tech.floripa.br/wp-content/uploads/2025/03/logo-certificado.png", - "certificate_background": "https://tech.floripa.br/wp-content/uploads/2025/03/certificado-python-floripa.png", - "order_date": "2025-08-28 02:44:54", - "checkin_latitude": "-27.5460492", - "checkin_longitude": "-48.6227075", - "time_checkin": "2025-03-26 20:55:44" - }, - ] - } - ] - } - lambda_handler(test_event, None) \ No newline at end of file From dbb6846330c2f89280a1b9994df2ecf900016a16 Mon Sep 17 00:00:00 2001 From: Maxson Almeida Date: Thu, 30 Oct 2025 13:16:46 -0300 Subject: [PATCH 3/4] =?UTF-8?q?feat:=20Adiciona=20campo=20TECH=5FFLORIPA?= =?UTF-8?q?=5FCERTIFICATE=5FVALIDATE=5FURL=20na=20configura=C3=A7=C3=A3o?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/config.py b/config.py index 5279d3f..39bfb47 100644 --- a/config.py +++ b/config.py @@ -9,7 +9,8 @@ class Config(BaseSettings): QUEUE_URL: str SERVICE_URL_REGISTRATION_API_SOLANA: str SERVICE_API_KEY_REGISTRATION_API_SOLANA: str - + TECH_FLORIPA_CERTIFICATE_VALIDATE_URL: str + class Config: env_file = ".env" env_file_encoding = "utf-8" From e74b2eca20ce83a9a0bdcc2782a24a8b5f483e59 Mon Sep 17 00:00:00 2001 From: Maxson Almeida Date: Thu, 30 Oct 2025 13:16:56 -0300 Subject: [PATCH 4/4] =?UTF-8?q?feat:=20Adiciona=20fun=C3=A7=C3=A3o=20para?= =?UTF-8?q?=20construir=20URL=20de=20valida=C3=A7=C3=A3o=20do=20certificad?= =?UTF-8?q?o=20Tech=20Floripa?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- certified_builder/build_url_tech_floripa.py | 9 +++++++++ certified_builder/certified_builder.py | 9 ++++++++- tests/conftest.py | 1 + 3 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 certified_builder/build_url_tech_floripa.py diff --git a/certified_builder/build_url_tech_floripa.py b/certified_builder/build_url_tech_floripa.py new file mode 100644 index 0000000..6ad600d --- /dev/null +++ b/certified_builder/build_url_tech_floripa.py @@ -0,0 +1,9 @@ +from config import config + +def build_url_tech_floripa(url_service_solona: str, validation_code: str, order_id: str) -> str: + try: + txid_solana = url_service_solona.split('/')[-1] + full_url = f"{config.TECH_FLORIPA_CERTIFICATE_VALIDATE_URL}?validate_code={validation_code}&hash={txid_solana}&order_id={order_id}" + return full_url + except Exception as e: + raise ValueError(f"Error building Tech Floripa URL: {str(e)}") \ No newline at end of file diff --git a/certified_builder/certified_builder.py b/certified_builder/certified_builder.py index 5aaa202..4cd0617 100644 --- a/certified_builder/certified_builder.py +++ b/certified_builder/certified_builder.py @@ -8,6 +8,7 @@ from certified_builder.utils.fetch_file_certificate import fetch_file_certificate from certified_builder.certificates_on_solana import CertificatesOnSolana from certified_builder.make_qrcode import MakeQRCode +from certified_builder.build_url_tech_floripa import build_url_tech_floripa FONT_NAME = os.path.join(os.path.dirname(__file__), "fonts/PinyonScript/PinyonScript-Regular.ttf") VALIDATION_CODE = os.path.join(os.path.dirname(__file__), "fonts/ChakraPetch/ChakraPetch-SemiBold.ttf") @@ -61,7 +62,13 @@ def build_certificates(self, participants: List[Participant]): # "verificacao_url": "https://www.google.com" # } # } - participant.authenticity_verification_url = solana_response.get("blockchain", {}).get("verificacao_url", "") + participant.validation_code = participant.formated_validation_code() + + participant.authenticity_verification_url = build_url_tech_floripa( + solana_response.get("blockchain", {}).get("verificacao_url", ""), + participant.validation_code, + participant.event.order_id + ) if not participant.authenticity_verification_url: raise RuntimeError("Failed to get authenticity verification URL from Solana response") diff --git a/tests/conftest.py b/tests/conftest.py index d7a4a7e..c1cd86c 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -20,6 +20,7 @@ class MockConfig: QUEUE_URL = "https://sqs.us-east-1.amazonaws.com/000000000000/test" SERVICE_URL_REGISTRATION_API_SOLANA = "https://example.test/solana/register" SERVICE_API_KEY_REGISTRATION_API_SOLANA = "test-api-key" + TECH_FLORIPA_CERTIFICATE_VALIDATE_URL = "https://example.test/validate/certificate" # comentário: expõe tanto a classe quanto a instância, como o módulo real faria mock_module.Config = MockConfig