aboutsummaryrefslogtreecommitdiff
path: root/services/docker/mail-server/aws-lambda.js
blob: d240c1a4cde768c433bfbd26460c1cf4a667232a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
export const handler = async (event, context, callback) => {
  const sesNotification = event.Records[0].ses;
  console.log("SES Notification:\n", JSON.stringify(sesNotification, null, 2));

  const res = await fetch(
    `https://mail.crupest.life/${process.env.CRUPEST_MAIL_SERVER_AWS_INBOUND_PATH}`,
    {
      method: "POST",
      headers: {
        "content-type": "application/json",
        "Authorization": process.env.CRUPEST_MAIL_SERVER_AWS_INBOUND_KEY,
      },
      body: JSON.stringify({
        key: sesNotification.mail.messageId,
        recipients: sesNotification.receipt.recipients,
      }),
    },
  );
  console.log(res);
  console.log(res.text());

  callback(null, { "disposition": "CONTINUE" });
};