Skip to main content

Data Service Mailgun Ingestor

service type: worker

Summary

This worker subscribes to the mailgun-events Pub/Sub topic and updates email records in the email_notifications table of the notifications data service.

Events Ingested

| Event | Column Updated | Notes | |:-------------|:-----------------|:---------------------------------------| | clicked | first_clicked_at | will only update if the column is nil | | delivered | sent_at | | | failed | failed_at | | | opened | first_opened_at | will only update if the columnis nil | | unsubscribed | unsubscribed_at | |

Testing

Development

Be sure handshake is running on localhost:3000

start all notifications

./scripts/start-all.sh

create an email notification

curl -s \
-H 'Content-Type: application/json' \
-H "Authorization: Bearer apitoken" \
-X POST \
-d '{"notification_name": "job_application_reminder", "notification_version": "v1", "user_id": 125, "user_email_address": "user125@joinhandshake.com", "attributes": { "jobs": [{ "id": 1 }] }}' \
localhost:5550/v1/notifications | jq

look for the email_notification_id in the notification request worker window

email_notification_id

check that the sent_at timestamp is not there

curl -s -H "Authorization: Bearer apitoken" localhost:5551/v1/notifications/email/4d2f72d2-b953-434d-8896-eb135df4731c | jq

send test message

PUBSUB_EMULATOR_HOST=0.0.0.0:3032 go run workers/mailgun-events-nds-ingestor/main.go dev pte -e delivered -u 4d2f72d2-b953-434d-8896-eb135df4731c

check that the sent_at timestamp is there

curl -s -H "Authorization: Bearer apitoken" localhost:5551/v1/notifications/email/4d2f72d2-b953-434d-8896-eb135df4731c | jq

With Mailgun Ingestor

You can check if the mailgun events ingestor is correctly sending the data to pubsub.

  • start all services
./scripts/start-all.sh
  • Use the instructions here to start the mailgun ingestor and send a webhook event.

Resources