Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Base architecture #7

Merged
merged 46 commits into from
Sep 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
4b4e10d
Add adapter base
abnegate Sep 27, 2022
c496b02
Add email base adapter
abnegate Sep 27, 2022
5534b91
Add email message type
abnegate Sep 27, 2022
13f82ef
Add mailgun adapter
abnegate Sep 27, 2022
e4b1c41
Add SMS base adapter
abnegate Sep 27, 2022
cb69920
Add SMS message type
abnegate Sep 27, 2022
c86af93
Add Twilio adapter
abnegate Sep 27, 2022
405fa2c
Add ignore
abnegate Sep 27, 2022
490437d
Add push base adapter
abnegate Sep 27, 2022
76d6515
Add push message type
abnegate Sep 27, 2022
0190b2f
Add FCM adapter
abnegate Sep 27, 2022
3351fd7
Allow mixed body for base request
abnegate Sep 27, 2022
995eaed
Add composer
abnegate Sep 27, 2022
2c545f3
Add mock SMS adapter
abnegate Sep 27, 2022
5a2a8dc
Add composer
abnegate Sep 27, 2022
597a216
Add docker
abnegate Sep 27, 2022
69544d3
Add mock SMS test
abnegate Sep 27, 2022
6c0b334
Add mock email adapter
abnegate Sep 27, 2022
a08c446
Add mock email test
abnegate Sep 27, 2022
bb15edb
Move max message per request function to adapter base
abnegate Sep 27, 2022
915a5f6
Add github workflows + linter
abnegate Sep 27, 2022
d837af7
Lint
abnegate Sep 27, 2022
a60c759
Install deps instead of update
abnegate Sep 27, 2022
604cd24
Fix compose volume mounts
abnegate Sep 27, 2022
5b28933
Fix contributing refs
abnegate Sep 27, 2022
c3a27fb
Keep unit test folder
abnegate Sep 27, 2022
2711fe1
Sleep before tests
abnegate Sep 27, 2022
1f2f407
Structure updates
abnegate Sep 28, 2022
37a693c
Add Msg91 SMS adapter
abnegate Sep 28, 2022
d933a43
Add Telesign SMS adapter
abnegate Sep 28, 2022
93552df
Add Vonage SMS adapter
abnegate Sep 28, 2022
6bbcfe6
Refactor constructor params for clarity
abnegate Sep 28, 2022
1792c51
Add TextMagic SMS adapter
abnegate Sep 28, 2022
2d92286
Update structure
abnegate Sep 28, 2022
1bc7726
Lint
abnegate Sep 28, 2022
bcb67ae
Add Sendgrid email adapter
abnegate Sep 28, 2022
52bc710
Add + to twilio requests
abnegate Sep 28, 2022
3e5eb89
Add curl ext dependency
abnegate Sep 28, 2022
1c91ea8
Update structure
abnegate Sep 28, 2022
a5f707a
Add get message type function
abnegate Sep 28, 2022
cbad65e
Import aliases
abnegate Sep 28, 2022
3d04104
Strip '+' where required
abnegate Sep 28, 2022
e85775a
Update structure
abnegate Sep 28, 2022
68a9c16
Add Twilio Notify SMS adapter
abnegate Sep 28, 2022
249faf9
Add readme
abnegate Sep 29, 2022
b68972f
Add adding new adapter guide
abnegate Sep 29, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
75 changes: 75 additions & 0 deletions .github/ISSUE_TEMPLATE/bug.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
name: "🐛 Bug Report"
description: "Submit a bug report to help us improve"
title: "🐛 Bug Report: "
labels: [bug]
body:
- type: markdown
attributes:
value: |
Thanks for taking the time to fill out our bug report form 🙏
- type: textarea
id: steps-to-reproduce
validations:
required: true
attributes:
label: "👟 Reproduction steps"
description: "How do you trigger this bug? Please walk us through it step by step."
placeholder: "When I ..."
- type: textarea
id: expected-behavior
validations:
required: true
attributes:
label: "👍 Expected behavior"
description: "What did you think would happen?"
placeholder: "It should ..."
- type: textarea
id: actual-behavior
validations:
required: true
attributes:
label: "👎 Actual Behavior"
description: "What did actually happen? Add screenshots, if applicable."
placeholder: "It actually ..."
- type: textarea
id: version
attributes:
label: "🎲 Version"
description: "What version of are you running?"
validations:
required: true
- type: dropdown
id: operating-system
attributes:
label: "💻 Operating system"
description: "What OS is your server / device running on?"
options:
- Linux
- MacOS
- Windows
- Something else
validations:
required: true
- type: textarea
id: environment
validations:
required: false
attributes:
label: "🧱 Your Environment"
description: "Is your environment customized in any way?"
placeholder: "I use Cloudflare for ..."
- type: checkboxes
id: no-duplicate-issues
attributes:
label: "👀 Have you spent some time to check if this issue has been raised before?"
description: "Have you Googled for a similar issue or checked our older issues for a similar bug?"
options:
- label: "I checked and didn't find similar issue"
required: true
- type: checkboxes
id: read-code-of-conduct
attributes:
label: "🏢 Have you read the Code of Conduct?"
options:
- label: "I have read the [Code of Conduct](https://github.com/utopia-php/messaging/blob/HEAD/CODE_OF_CONDUCT.md)"
required: true
32 changes: 32 additions & 0 deletions .github/ISSUE_TEMPLATE/documentation.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: "📚 Documentation"
description: "Report an issue related to documentation"
title: "📚 Documentation: "
labels: [documentation]
body:
- type: markdown
attributes:
value: |
Thanks for taking the time to make our documentation better 🙏
- type: textarea
id: issue-description
validations:
required: true
attributes:
label: "💭 Description"
description: "A clear and concise description of what the issue is."
placeholder: "Documentation should not ..."
- type: checkboxes
id: no-duplicate-issues
attributes:
label: "👀 Have you spent some time to check if this issue has been raised before?"
description: "Have you Googled for a similar issue or checked our older issues for a similar bug?"
options:
- label: "I checked and didn't find similar issue"
required: true
- type: checkboxes
id: read-code-of-conduct
attributes:
label: "🏢 Have you read the Code of Conduct?"
options:
- label: "I have read the [Code of Conduct](https://github.com/utopia-php/messaging/blob/HEAD/CODE_OF_CONDUCT.md)"
required: true
40 changes: 40 additions & 0 deletions .github/ISSUE_TEMPLATE/feature.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: 🚀 Feature
description: "Submit a proposal for a new feature"
title: "🚀 Feature: "
labels: [feature]
body:
- type: markdown
attributes:
value: |
Thanks for taking the time to fill out our feature request form 🙏
- type: textarea
id: feature-description
validations:
required: true
attributes:
label: "🔖 Feature description"
description: "A clear and concise description of what the feature is."
placeholder: "You should add ..."
- type: textarea
id: pitch
validations:
required: true
attributes:
label: "🎤 Pitch"
description: "Please explain why this feature should be implemented and how it would be used. Add examples, if applicable."
placeholder: "In my use-case, ..."
- type: checkboxes
id: no-duplicate-issues
attributes:
label: "👀 Have you spent some time to check if this issue has been raised before?"
description: "Have you Googled for a similar issue or checked our older issues for a similar bug?"
options:
- label: "I checked and didn't find similar issue"
required: true
- type: checkboxes
id: read-code-of-conduct
attributes:
label: "🏢 Have you read the Code of Conduct?"
options:
- label: "I have read the [Code of Conduct](https://github.com/utopia-php/messaging/blob/HEAD/CODE_OF_CONDUCT.md)"
required: true
26 changes: 26 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<!--
Thank you for sending the PR! We appreciate you spending the time to work on these changes.

Help us understand your motivation by explaining why you decided to make this change.

You can learn more about contributing to appwrite here: https://github.com/utopia-php/messaging/blob/master/CONTRIBUTING.md

Happy contributing!

-->

## What does this PR do?

(Provide a description of what this PR does.)

## Test Plan

(Write your test plan here. If you changed any code, please provide us with clear instructions on how you verified your changes work.)

## Related PRs and Issues

(If this PR is related to any other PR or resolves any issue or related to any issue link all related PR and issues here.)

### Have you read the [Contributing Guidelines on issues](https://github.com/utopia-php/messaging/blob/master/CONTRIBUTING.md)?

(Write your answer here.)
18 changes: 18 additions & 0 deletions .github/workflows/linter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: "Linter"

on: [pull_request]
jobs:
lint:
name: Linter
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
fetch-depth: 2
- run: git checkout HEAD^2
- name: Run Linter
run: |
docker run --rm -v $PWD:/app composer sh -c \
"composer install --profile --ignore-platform-reqs && composer lint"
19 changes: 19 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: "Tests"

on: [pull_request]
jobs:
tests:
name: Unit & E2E
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v2
with:
fetch-depth: 2
- run: git checkout HEAD^2
- name: Run Tests
run: |
docker compose up -d --build
sleep 5
docker compose exec tests vendor/bin/phpunit
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.idea
vendor
.phpunit.result.cache
25 changes: 25 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
FROM composer:2.0 as composer

ARG TESTING=false
ENV TESTING=$TESTING

WORKDIR /usr/local/src/

COPY composer.lock /usr/local/src/
COPY composer.json /usr/local/src/

RUN composer install \
--ignore-platform-reqs \
--optimize-autoloader \
--no-plugins \
--no-scripts \
--prefer-dist

FROM php:8.0-cli-alpine

WORKDIR /usr/local/src/

COPY --from=composer /usr/local/src/vendor /usr/local/src/vendor
COPY . /usr/local/src/

CMD [ "tail", "-f", "/dev/null" ]
147 changes: 147 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
# Utopia Messaging

[![Build Status](https://travis-ci.org/utopia-php/abuse.svg?branch=master)](https://travis-ci.com/utopia-php/database)
![Total Downloads](https://img.shields.io/packagist/dt/utopia-php/messaging.svg)
[![Discord](https://img.shields.io/discord/564160730845151244?label=discord)](https://appwrite.io/discord)

Utopia Messaging library is simple and lite library for sending messages using multiple messaging adapters. This library is aiming to be as simple and easy to learn and use. This library is maintained by the [Appwrite team](https://appwrite.io).

Although this library is part of the [Utopia Framework](https://github.com/utopia-php/framework) project it is dependency free, and can be used as standalone with any other PHP project or framework.

## Getting Started

Install using composer:
```bash
composer require utopia-php/messaging
```

## Email

```php
<?php

use \Utopia\Messaging\Messages\Email;
use \Utopia\Messaging\Adapters\Email\SendGrid;
use \Utopia\Messaging\Adapters\Email\Mailgun;

$message = new Email(
to: ['[email protected]'],
subject: 'Hello World',
content: '<h1>Hello World</h1>'
);

$messaging = new Sendgrid('YOUR_API_KEY');
$messaging->send($message);

$messaging = new Mailgun('YOUR_API_KEY', 'YOUR_DOMAIN');
$messaging->send($message);
```

## SMS

```php
<?php

use \Utopia\Messaging\Messages\SMS;
use \Utopia\Messaging\Adapters\SMS\Twilio;
use \Utopia\Messaging\Adapters\SMS\Telesign;

$message = new SMS(
to: ['+12025550139'],
content: 'Hello World'
);

$messaging = new Twilio('YOUR_ACCOUNT_SID', 'YOUR_AUTH_TOKEN');
$messaging->send($message);

$messaging = new Telesign('YOUR_USERNAME', 'YOUR_PASSWORD');
$messaging->send($message);
```

## Push

```php
<?php

use \Utopia\Messaging\Messages\Push;
use \Utopia\Messaging\Adapters\Push\FCM;

$message = new Push(
to: ['eyJhGc...ssw5c'],
content: 'Hello World'
);

$messaging = new FCM('YOUR_SERVER_KEY');
$messaging->send($message);
```

## Adapters

> Want to implement any of the missing adapters or have an idea for another? We would love to hear from you! Please check out our [contribution guide](./CONTRIBUTING.md) and [new adapter guide](./docs/add-new-adapter.md) for more information.

### Email
- [x] [SendGrid](https://sendgrid.com/)
- [x] [Mailgun](https://www.mailgun.com/)
- [ ] [Mailjet](https://www.mailjet.com/)
- [ ] [Mailchimp](https://www.mailchimp.com/)
- [ ] [Postmark](https://postmarkapp.com/)
- [ ] [SparkPost](https://www.sparkpost.com/)
- [ ] [SendinBlue](https://www.sendinblue.com/)
- [ ] [MailSlurp](https://www.mailslurp.com/)
- [ ] [ElasticEmail](https://elasticemail.com/)
- [ ] [SES](https://aws.amazon.com/ses/)

### SMS
- [x] [Twilio](https://www.twilio.com/)
- [x] [Twilio Notify](https://www.twilio.com/notify)
- [x] [Telesign](https://www.telesign.com/)
- [x] [TextMagic](https://www.textmagic.com/)
- [x] [Msg91](https://msg91.com/)
- [x] [Vonage](https://www.vonage.com/)
- [ ] [Plivo](https://www.plivo.com/)
- [ ] [Infobip](https://www.infobip.com/)
- [ ] [Clickatell](https://www.clickatell.com/)
- [ ] [AfricasTalking](https://africastalking.com/)
- [ ] [Sinch](https://www.sinch.com/)
- [ ] [Sms77](https://www.sms77.io/)
- [ ] [SmsGlobal](https://www.smsglobal.com/)

### Push
- [x] [FCM](https://firebase.google.com/docs/cloud-messaging)
- [ ] [APNS](https://developer.apple.com/documentation/usernotifications)
- [ ] [OneSignal](https://onesignal.com/)
- [ ] [Pusher](https://pusher.com/)
- [ ] [WebPush](https://developer.mozilla.org/en-US/docs/Web/API/Push_API)
- [ ] [UrbanAirship](https://www.urbanairship.com/)
- [ ] [Pushwoosh](https://www.pushwoosh.com/)
- [ ] [PushBullet](https://www.pushbullet.com/)
- [ ] [Pushy](https://pushy.me/)

## System Requirements

Utopia Messaging requires PHP 8.0 or later. We recommend using the latest PHP version whenever possible.

## Tests

To run all unit tests, use the following Docker command:

```bash
composer test
```

To run static code analysis, use the following Psalm command:

```bash
composer lint
```

## Authors

**Jake Barnby**

+ [https://github.com/abnegate](https://github.com/abnegate)
+ [https://nz.linkedin.com/in/jakebarnby](https://nz.linkedin.com/in/jakebarnby)

## Copyright and license

The MIT License (MIT) [http://www.opensource.org/licenses/mit-license.php](http://www.opensource.org/licenses/mit-license.php)
Loading