diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 552b207d..bc7dc67e 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -7,40 +7,41 @@ jobs: runs-on: ubuntu-latest steps: - - name: Checkout repository - uses: actions/checkout@v2 - with: - fetch-depth: 2 - - run: git checkout HEAD^2 - - name: Run Tests - env: - MAILGUN_API_KEY: ${{ secrets.MAILGUN_API_KEY }} - MAILGUN_DOMAIN: ${{ secrets.MAILGUN_DOMAIN }} - SENDGRID_API_KEY: ${{ secrets.SENDGRID_API_KEY }} - FCM_SERVER_KEY: ${{ secrets.FCM_SERVER_KEY }} - FCM_SERVER_TO: ${{ secrets.FCM_SERVER_TO }} - TWILIO_ACCOUNT_SID: ${{ secrets.TWILIO_ACCOUNT_SID }} - TWILIO_AUTH_TOKEN: ${{ secrets.TWILIO_AUTH_TOKEN }} - TWILIO_TO: ${{ secrets.TWILIO_TO }} - TWILIO_FROM: ${{ secrets.TWILIO_FROM }} - TELNYX_API_KEY: ${{ secrets.TELNYX_API_KEY }} - TELNYX_PUBLIC_KEY: ${{ secrets.TELNYX_PUBLIC_KEY }} - APNS_AUTHKEY_8KVVCLA3HL: ${{ secrets.APNS_AUTHKEY_8KVVCLA3HL }} - APNS_AUTH_ID: ${{ secrets.APNS_AUTH_ID }} - APNS_TEAM_ID: ${{ secrets.APNS_TEAM_ID }} - APNS_BUNDLE_ID: ${{ secrets.APNS_BUNDLE_ID }} - APNS_TO: ${{ secrets.APNS_TO }} - MSG_91_SENDER_ID: ${{ secrets.MSG_91_SENDER_ID }} - MSG_91_AUTH_KEY: ${{ secrets.MSG_91_AUTH_KEY }} - MSG_91_TO: ${{ secrets.MSG_91_TO }} - MSG_91_FROM: ${{ secrets.MSG_91_FROM }} - TEST_EMAIL: ${{ secrets.TEST_EMAIL }} - TEST_FROM_EMAIL: ${{ secrets.TEST_FROM_EMAIL }} - VONAGE_API_KEY: ${{ secrets.VONAGE_API_KEY }} - VONAGE_API_SECRET: ${{ secrets.VONAGE_API_SECRET }} - VONAGE_TO: ${{ secrets.VONAGE_TO }} - VONAGE_FROM: ${{ secrets.VONAGE_FROM }} - run: | - docker compose up -d --build - sleep 5 - docker compose exec tests vendor/bin/phpunit \ No newline at end of file + - name: Checkout repository + uses: actions/checkout@v2 + with: + fetch-depth: 2 + - run: git checkout HEAD^2 + - name: Run Tests + env: + MAILGUN_API_KEY: ${{ secrets.MAILGUN_API_KEY }} + MAILGUN_DOMAIN: ${{ secrets.MAILGUN_DOMAIN }} + SENDGRID_API_KEY: ${{ secrets.SENDGRID_API_KEY }} + FCM_SERVER_KEY: ${{ secrets.FCM_SERVER_KEY }} + FCM_SERVER_TO: ${{ secrets.FCM_SERVER_TO }} + TWILIO_ACCOUNT_SID: ${{ secrets.TWILIO_ACCOUNT_SID }} + TWILIO_AUTH_TOKEN: ${{ secrets.TWILIO_AUTH_TOKEN }} + TWILIO_TO: ${{ secrets.TWILIO_TO }} + TWILIO_FROM: ${{ secrets.TWILIO_FROM }} + TELNYX_API_KEY: ${{ secrets.TELNYX_API_KEY }} + TELNYX_PUBLIC_KEY: ${{ secrets.TELNYX_PUBLIC_KEY }} + APNS_AUTHKEY_8KVVCLA3HL: ${{ secrets.APNS_AUTHKEY_8KVVCLA3HL }} + APNS_AUTH_ID: ${{ secrets.APNS_AUTH_ID }} + APNS_TEAM_ID: ${{ secrets.APNS_TEAM_ID }} + APNS_BUNDLE_ID: ${{ secrets.APNS_BUNDLE_ID }} + APNS_TO: ${{ secrets.APNS_TO }} + MSG_91_SENDER_ID: ${{ secrets.MSG_91_SENDER_ID }} + MSG_91_AUTH_KEY: ${{ secrets.MSG_91_AUTH_KEY }} + MSG_91_TO: ${{ secrets.MSG_91_TO }} + MSG_91_FROM: ${{ secrets.MSG_91_FROM }} + TEST_EMAIL: ${{ secrets.TEST_EMAIL }} + TEST_FROM_EMAIL: ${{ secrets.TEST_FROM_EMAIL }} + VONAGE_API_KEY: ${{ secrets.VONAGE_API_KEY }} + VONAGE_API_SECRET: ${{ secrets.VONAGE_API_SECRET }} + VONAGE_TO: ${{ secrets.VONAGE_TO }} + VONAGE_FROM: ${{ secrets.VONAGE_FROM }} + PUSHBULLET_API_KEY: ${{ secrets.PUSHBULLET_API_KEY }} + run: | + docker compose up -d --build + sleep 5 + docker compose exec tests vendor/bin/phpunit diff --git a/docker-compose.yml b/docker-compose.yml index 80d626d9..e9c5267e 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,47 +1,48 @@ -version: '3.9' +version: "3.9" services: tests: environment: - - MAILGUN_API_KEY - - MAILGUN_DOMAIN - - SENDGRID_API_KEY - - FCM_SERVER_KEY - - FCM_SERVER_TO - - TWILIO_ACCOUNT_SID - - TWILIO_AUTH_TOKEN - - TWILIO_TO - - TWILIO_FROM - - TELNYX_API_KEY - - TELNYX_PUBLIC_KEY - - APNS_AUTHKEY_8KVVCLA3HL - - APNS_AUTH_ID - - APNS_TEAM_ID - - APNS_BUNDLE_ID - - APNS_TO - - MSG_91_SENDER_ID - - MSG_91_AUTH_KEY - - MSG_91_TO - - MSG_91_FROM - - TEST_EMAIL - - TEST_FROM_EMAIL - - VONAGE_API_KEY - - VONAGE_API_SECRET - - VONAGE_TO - - VONAGE_FROM + - MAILGUN_API_KEY + - MAILGUN_DOMAIN + - SENDGRID_API_KEY + - FCM_SERVER_KEY + - FCM_SERVER_TO + - TWILIO_ACCOUNT_SID + - TWILIO_AUTH_TOKEN + - TWILIO_TO + - TWILIO_FROM + - TELNYX_API_KEY + - TELNYX_PUBLIC_KEY + - APNS_AUTHKEY_8KVVCLA3HL + - APNS_AUTH_ID + - APNS_TEAM_ID + - APNS_BUNDLE_ID + - APNS_TO + - MSG_91_SENDER_ID + - MSG_91_AUTH_KEY + - MSG_91_TO + - MSG_91_FROM + - TEST_EMAIL + - TEST_FROM_EMAIL + - VONAGE_API_KEY + - VONAGE_API_SECRET + - VONAGE_TO + - VONAGE_FROM + - PUSHBULLET_API_KEY build: context: . volumes: - ./src:/usr/local/src/src - ./tests:/usr/local/src/tests - ./phpunit.xml:/usr/local/src/phpunit.xml - + maildev: image: appwrite/mailcatcher:1.0.0 ports: - - '10000:1080' + - "10000:1080" request-catcher: image: appwrite/requestcatcher:1.0.0 ports: - - '10001:5000' \ No newline at end of file + - "10001:5000" diff --git a/src/Utopia/Messaging/Adapters/Push/Pushbullet.php b/src/Utopia/Messaging/Adapters/Push/Pushbullet.php new file mode 100644 index 00000000..2eef5260 --- /dev/null +++ b/src/Utopia/Messaging/Adapters/Push/Pushbullet.php @@ -0,0 +1,64 @@ + 'note', + 'title' => $message->getTitle(), + 'body' => $message->getBody(), + ]; + + try { + $client = new Client(); + $response = $client->request('POST', 'https://api.pushbullet.com/v2/pushes', [ + 'headers' => [ + 'Access-Token' => $this->apiKey, + 'Content-Type' => 'application/json', + ], + 'json' => $payload, + ]); + + return $response; + } catch (Exception $e) { + return false; + } + } +} diff --git a/tests/e2e/Push/PushBulletTest.php b/tests/e2e/Push/PushBulletTest.php new file mode 100644 index 00000000..38a597b8 --- /dev/null +++ b/tests/e2e/Push/PushBulletTest.php @@ -0,0 +1,34 @@ +process($message)); + + $this->assertNotEmpty($response); + $this->assertEquals('success', $response->status); + } +}