This repository has been archived by the owner on Dec 8, 2017. It is now read-only.
forked from DanKottke/midas
-
Notifications
You must be signed in to change notification settings - Fork 4
Notifications
Roger Steve Ruiz edited this page Nov 27, 2015
·
6 revisions
The notification process works like this:
- Create a notification model with an action and a model. The action is a
string name for the notification, and the model is a model associated with the
notification, for instance, the user for a user welcome email notification. By
convention, I'm naming actions as
model
.method
.name
, likeuser.create.welcome
. - When a new notification is created, it triggers a notification email, which builds the data object for the email and constructs the email header and body from templates compiled with the data object.
- Triggering a notification automatically renders and sends it;
trigger
,render
andsend
are all model methods now instead of a separate service.
Adding / editing an email template is much easier. Email templates now consist of two files in a folder named after the action:
api/notifications/
|- user.create.welcome/
|- notification.js
|- template.html
|- layout.html
-
notification.js
exports template strings for header fieldsto
,cc
,bcc
, andsubject
as well as adata
function that takes the notification's associated model and a callback and returns adata
object used to build the templates -
template.html
is an html underscore template file for the body -
layout.html
is a global layout template that all notification body content gets rendered into before sending
We rely on our our mailing API to inline CSS and convert HTML templates to plain-text.
Welcome to the Open Opportunities Wiki
- Getting Started