From f14b822b0b9d4bb3aaf75619a8ed6732a429c88b Mon Sep 17 00:00:00 2001 From: Dakshi Date: Fri, 13 Oct 2023 22:00:33 +0530 Subject: [PATCH] added aws sns adapter --- .github/workflows/tests.yml | 1 + docker-compose.yml | 1 + src/Utopia/Messaging/Adapters/Push/AWSSNS.php | 62 +++++++++++++++++++ tests/e2e/Push/AWSSNSTest.php | 26 ++++++++ 4 files changed, 90 insertions(+) create mode 100644 src/Utopia/Messaging/Adapters/Push/AWSSNS.php create mode 100644 tests/e2e/Push/AWSSNSTest.php diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 552b207d..f2ab9d0e 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -25,6 +25,7 @@ jobs: TWILIO_FROM: ${{ secrets.TWILIO_FROM }} TELNYX_API_KEY: ${{ secrets.TELNYX_API_KEY }} TELNYX_PUBLIC_KEY: ${{ secrets.TELNYX_PUBLIC_KEY }} + AWSSNS_API_GATEWAY_URL: ${{ secrets.AWSSNS_API_GATEWAY_URL }} APNS_AUTHKEY_8KVVCLA3HL: ${{ secrets.APNS_AUTHKEY_8KVVCLA3HL }} APNS_AUTH_ID: ${{ secrets.APNS_AUTH_ID }} APNS_TEAM_ID: ${{ secrets.APNS_TEAM_ID }} diff --git a/docker-compose.yml b/docker-compose.yml index 80d626d9..492d6a50 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -14,6 +14,7 @@ services: - TWILIO_FROM - TELNYX_API_KEY - TELNYX_PUBLIC_KEY + - AWSSNS_API_GATEWAY_URL - APNS_AUTHKEY_8KVVCLA3HL - APNS_AUTH_ID - APNS_TEAM_ID diff --git a/src/Utopia/Messaging/Adapters/Push/AWSSNS.php b/src/Utopia/Messaging/Adapters/Push/AWSSNS.php new file mode 100644 index 00000000..1326c873 --- /dev/null +++ b/src/Utopia/Messaging/Adapters/Push/AWSSNS.php @@ -0,0 +1,62 @@ + $message->getData() + ]; + + // Make the HTTP request + $response = $this->request( + method: 'POST', + url: $this->apiGatewayUrl, + headers: [ + 'Content-Type: application/json', + ], + body: json_encode($payload) + ); + + return $response; + } +} diff --git a/tests/e2e/Push/AWSSNSTest.php b/tests/e2e/Push/AWSSNSTest.php new file mode 100644 index 00000000..cabde95a --- /dev/null +++ b/tests/e2e/Push/AWSSNSTest.php @@ -0,0 +1,26 @@ +send($message), true); + + $this->assertNotEmpty($response); + $this->assertEquals('success', $response['status'] ?? null); + $this->assertNotEmpty($response['MessageId'] ?? null); + } +}