Skip to main content

Notification Offline Requests

Summary

This worker subscribes to the notifications-notification-offline-requested Pub/Sub topic and publishes these notification requests to the notifications-notification-requested Pub/Sub topic

Service TypeWorker
Pub/Sub Topicnotifications-notification-offline-requested
Pub/Sub Subscriptionnotifications-notification-offline-requested-notification-offline-requests-worker

Testing

./scripts/start-with-monolith-db.sh 
# rails c
data = {
"notification_name" => "unread_inbox_message_daily_digest",
"notification_version" => "1",
"user_id" => "125",
"created_at" => "2024-08-08T14:03:20.027551+00:00",
"attributes" => {
"unread_messages" => [{
"sender_id" => "1",
"sender_institution_id" => "1",
"internal_message_id" => "123",
}]
}
}.to_json
pubsub = Rails.configuration.pubsub
topic = pubsub.topic("notifications-notification-offline-requested")
topic.publish_async(data)

Pub/Sub Message Schema

This worker expects Pub/Sub messages to be JSON-formatted with the following schema:

FieldDescription
Notification NameRequiredThe name of the requested notification. This should match an existing notification config in the Notifications Service. If it does not, a Bugsnag will be raised and the message will not be retried.
Notification VersionRequiredThe version of the requested notification. This should match an existing notification config in the Notifications Service. If it does not, a Bugsnag will be raised and the message will not be retried.
User IdRequiredThe monolith user id of the notification recipient.
Email AddressOptionalThe email address of the notification recipient. If not provided, the primary email of the recipient will be used.
AttributesOptionalData required to build the requested notification.
MetadataOptionalData to be included for data analytics.
Created AtRequiredTime at which the offline notification data was gathered.

Example

{
"notification_name": "unread_inbox_message_daily_digest",
"notification_version": "1",
"user_id": "125",
"created_at": "2024-08-08T14:03:20.027551+00:00",
"attributes": {
"unread_messages": [
{
"internal_message_id": "123",
"sender_id": "1",
"sender_institution_id": "1"
}
]
}
}

Monitoring

TODO

Resources