Skip to content

Commit b8d0187

Browse files
author
Theodore Li
committed
Add iam permissions needed for ses
1 parent 3a60107 commit b8d0187

2 files changed

Lines changed: 22 additions & 12 deletions

File tree

kotlin/lambda/transfer-event-handler/src/main/kotlin/com/zenobiapay/transfertableevent/logic/TransferTableEventLogic.kt

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -74,22 +74,27 @@ class TransferTableEventLogic @Inject constructor(
7474
newItem.data?.customer!!.name,
7575
)
7676

77+
try {
78+
val merchantItem = userDao.getUserItem(newItem.data?.merchant!!.id)
79+
merchantItem?.data?.merchantData?.notificationEmail?.let {
80+
logger.info { "Got notification email $it. Sending email" }
81+
emailUtil.sendEmail(
82+
it,
83+
merchantItem.data!!.merchantData!!.displayName!!,
84+
newItem.data!!.customer!!.name!!,
85+
newItem.requestId,
86+
newItem.outboundStatus,
87+
)
88+
}
89+
} catch (e: Exception) {
90+
logger.warn { "Failed to send email. Skipping" }
91+
metricsHelper.putMetric("EmailSendFailure", 1.0)
92+
}
93+
7794
if (!isWebhookStatusSuccessful) {
7895
metricsHelper.putMetric("WebhookSendFailure", 1.0)
7996
throw Exception("Failed to send webhook status.")
8097
}
81-
82-
val merchantItem = userDao.getUserItem(newItem.data?.merchant!!.id)
83-
merchantItem?.data?.merchantData?.notificationEmail?.let {
84-
logger.info { "Got notification email $it. Sending email"}
85-
emailUtil.sendEmail(
86-
it,
87-
merchantItem.data!!.merchantData!!.displayName!!,
88-
newItem.data!!.customer!!.name!!,
89-
newItem.requestId,
90-
newItem.outboundStatus,
91-
)
92-
}
9398
}
9499

95100
/**

sam/payout-stack.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,11 @@ Resources:
267267
Resource: !GetAtt WebhookSignatureKey.Arn
268268
- SQSSendMessagePolicy:
269269
QueueName: !GetAtt TransferTableNotificationsHandlerDLQ.QueueName
270+
- DynamoDBReadPolicy:
271+
TableName:
272+
Ref: UserTableName
273+
- SESCrudPolicy:
274+
IdentityName: !Ref SenderEmail
270275
Events:
271276
EventFromRedriveQueue:
272277
Type: SQS

0 commit comments

Comments
 (0)