fix enroll and reenroll relationship
This commit is contained in:
@@ -56,6 +56,9 @@ def lambda_handler(event: EventBridgeEvent, context: LambdaContext) -> bool:
|
||||
)
|
||||
|
||||
try:
|
||||
if 's3_uri' not in cert:
|
||||
raise ValueError('Template URI is missing')
|
||||
|
||||
# Send template URI and data to Paperforge API to generate a PDF
|
||||
r = requests.post(
|
||||
PAPERFORGE_API,
|
||||
@@ -79,10 +82,11 @@ def lambda_handler(event: EventBridgeEvent, context: LambdaContext) -> bool:
|
||||
),
|
||||
},
|
||||
),
|
||||
timeout=5,
|
||||
)
|
||||
r.raise_for_status()
|
||||
|
||||
object_key = f'issuedcerts/{enrollment_id}.pdf'
|
||||
object_key = f'certs/{enrollment_id}.pdf'
|
||||
s3_uri = f's3://{BUCKET_NAME}/{object_key}'
|
||||
|
||||
s3_client.put_object(
|
||||
@@ -93,10 +97,10 @@ def lambda_handler(event: EventBridgeEvent, context: LambdaContext) -> bool:
|
||||
)
|
||||
|
||||
logger.debug(f'PDF uploaded successfully to {s3_uri}')
|
||||
except KeyError:
|
||||
except ValueError as exc:
|
||||
# PDF generation fails if template URI is missing
|
||||
s3_uri = None
|
||||
logger.debug('Template URI is missing')
|
||||
logger.exception(exc)
|
||||
except requests.exceptions.RequestException as exc:
|
||||
logger.exception(exc)
|
||||
raise
|
||||
|
||||
Reference in New Issue
Block a user