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

[RW-90] Use AWS SES api for subscriptions #478

Open
wants to merge 18 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
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
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
],
"require": {
"php": ">=8.2",
"aws/aws-sdk-php": "^3.281.6",
"composer/installers": "^1.12",
"cweagans/composer-patches": "^1.7",
"drupal/admin_denied": "^2.0",
Expand Down
219 changes: 217 additions & 2 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions config/reliefweb_subscriptions.settings.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
method: smtp
aws_ses_api_version: latest
aws_ses_api_region: null
aws_ses_api_endpoint: null
aws_ses_api_bulk_batch_size: 50
aws_ses_api_key: null
aws_ses_api_secret: null
aws_ses_api_token: null
aws_ses_api_scheme: null
aws_ses_api_identity: null
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# How to send the emails: smtp or AWS SES API (aws_ses_api_bulk).
method: smtp
# Version of the AWS SES API.
aws_ses_api_version: latest
# Region to use for the AWS SES API.
aws_ses_api_region:
# Endpoint of the AWS SES API, leave empty to use the default endpoint.
aws_ses_api_endpoint:
# Scheme of the AWS SES API endpoint, leave empty to use the default scheme.
aws_ses_api_scheme:
# Maximum number of recipients when using the bulk endpoint.
aws_ses_api_bulk_batch_size: 50
# AWS SES API key.
aws_ses_api_key:
# AWS SES API secret.
aws_ses_api_secret:
# AWS SES API token.
aws_ses_api_token:
# AWS SES API identity.
aws_ses_api_identity:
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
reliefweb_subscriptions.settings:
type: config_object
label: 'Reliefweb Subscriptions settings'
mapping:
method:
type: string
label: 'How to send the emails: smtp or AWS SES API (aws_ses_api_bulk)'
aws_ses_api_version:
type: string
label: 'Version of the AWS SES API'
aws_ses_api_region:
type: string
label: 'Region to use for the AWS SES API'
aws_ses_api_endpoint:
type: string
label: 'Endpoint of the AWS SES API, leave empty to use the default endpoint'
aws_ses_api_schema:
type: string
label: 'Scheme of the AWS SES API endpoint, leave empty to use the default scheme'
aws_ses_api_bulk_batch_size:
type: integer
label: 'Maximum number of recipients when using the bulk endpoint'
aws_ses_api_key:
type: string
label: 'AWS SES API key'
aws_ses_api_secret:
type: string
label: 'AWS SES API secret'
aws_ses_api_token:
type: string
label: 'AWS SES API token'
aws_ses_api_identity:
type: string
label: 'AWS SES API identity'
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ function reliefweb_subscriptions_subscriptions() {
'id' => 'headlines',
'name' => t('ReliefWeb Headlines'),
'description' => t('ReliefWeb Headlines (daily)'),
'aws_ses_template_name' => 'reliefweb_subscriptions_headlines',
// Sengrid category.
'category' => 'Headlines',
'type' => 'scheduled',
Expand Down Expand Up @@ -66,6 +67,7 @@ function reliefweb_subscriptions_subscriptions() {
'id' => 'appeals',
'name' => t('All Appeals'),
'description' => t('Latest Appeals (weekly)'),
'aws_ses_template_name' => 'reliefweb_subscriptions_appeals',
// Sengrid cateogry.
'category' => 'Appeals',
'type' => 'scheduled',
Expand Down Expand Up @@ -104,6 +106,7 @@ function reliefweb_subscriptions_subscriptions() {
'id' => 'jobs',
'name' => t('All Jobs'),
'description' => t('All Jobs (bi-weekly: Monday, Thursday)'),
'aws_ses_template_name' => 'reliefweb_subscriptions_jobs',
'group' => 'global',
// Sengrid cateogry.
'category' => 'Jobs digest',
Expand Down Expand Up @@ -138,6 +141,7 @@ function reliefweb_subscriptions_subscriptions() {
'id' => 'training',
'name' => t('All Training Programs'),
'description' => t('All Training Programs (weekly: Wednesday)'),
'aws_ses_template_name' => 'reliefweb_subscriptions_training',
'group' => 'global',
// Sengrid cateogry.
'category' => 'Training programs digest',
Expand Down Expand Up @@ -174,6 +178,7 @@ function reliefweb_subscriptions_subscriptions() {
'id' => 'disaster',
'name' => t('New alert or ongoing disaster'),
'description' => t('New alert or ongoing disaster (when published)'),
'aws_ses_template_name' => 'reliefweb_subscriptions_disasters',
'group' => 'global',
// Sengrid cateogry.
'category' => 'New Disasters',
Expand Down Expand Up @@ -208,6 +213,7 @@ function reliefweb_subscriptions_subscriptions() {
'id' => 'ocha_sitrep',
'name' => t('New OCHA situation report'),
'description' => t('New OCHA situation report'),
'aws_ses_template_name' => 'reliefweb_subscriptions_ocha_sitrep',
'group' => 'global',
// Sengrid cateogry.
'category' => 'OCHA Sitreps',
Expand Down Expand Up @@ -262,6 +268,7 @@ function reliefweb_subscriptions_subscriptions() {
'id' => $sid,
'name' => t('Updates on @country', ['@country' => $name]),
'description' => t('Updates on @country (daily)', ['@country' => $name]),
'aws_ses_template_name' => 'reliefweb_subscriptions_' . $sid,
'group' => 'country_updates',
// This is just for convenience for the `My subscriptions` page and the
// template preprocess function.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,14 @@ reliefweb_subscriptions.subscription_form.current_user:
requirements:
_user_is_logged_in: 'TRUE'
reliefweb_subscriptions.unsubscribe:
path: '/notifications/unsubscribe/user/{user}/{timestamp}/{signature}'
defaults:
_controller: '\Drupal\reliefweb_subscriptions\Controller\UnsubscribeController::unsubscribe'
_title: 'Unsubscribe'
requirements:
_access: 'TRUE'
user: \d+
reliefweb_subscriptions.unsubscribe.parameters:
path: '/notifications/unsubscribe/user/{user}'
defaults:
_controller: '\Drupal\reliefweb_subscriptions\Controller\UnsubscribeController::unsubscribe'
Expand Down
Loading