Skip to content
Snippets Groups Projects

Notification: the Workspaces Notification Service

The notification service is based on a few very simple ideas:

  • Notification content should be configuration, not code
  • Notification senders shouldn't worry about formatting
  • Notification senders probably have lots of information that would be useful to include in the message content

Since Mustache and JSON are pervasive concepts in Workspaces, the design here is intentionally kept very simple. Notification senders simply make a POST call:

POST /notify/<name>

The POST will include a JSON object. The parameters of that JSON object are fed to the Mustache rendering process. There is one mandatory field in the JSON: destination_email, which is who receives the message.

Example

Here's an example of a message template for when a capability is submitted:

Subject: NRAO Workspaces Request #{{request_id}}: Submitted


Dear User,

Your {{capability_name}} request has been submitted.

You will be notified when it is complete.

The status of your request can be tracked here:

{{{status_link}}}

Best regards,

NRAO Workspaces

The notification is stored under the name "submitted_email". When the capability system wants to send this notification, it submits the following POST request:

POST /notify/submitted_email

The body of the notification might look like:

{
    "capability_name": "download",
    "status_link": "http://ws-dev.nrao.edu/capability/download/requests/23",
    "destination_email": "dlyons@nrao.edu",
    "request_id": 23,
}

The rendered message (shown below) will be emailed to dlyons@nrao.edu:

Subject: NRAO Workspaces Request #23: Submitted


Dear User,

Your download request has been submitted.

You will be notified when it is complete.

The status of your request can be tracked here:

http://ws-dev.nrao.edu/capability/download/requests/23

Best regards,

NRAO Workspaces