Notification lifecycle
Brightspot invokes the following process when processing notifications.
An event occurs (e.g., a
ToolUser
publishes aContent
).Create a publisher with all the message context information for the event (content ID, user ID, etc.)
Invoke the publisher's
Publisher#publishNotification/Async
method, which performs all of the following steps.Publisher fetches a list of all possible receivers by invoking
Publisher#getReceivers
.For each receiver:
Fetch the set of subscriptions with
Receiver#getReceiverSubscriptions
.For each subscription:
Check if the following are true:
Subscription matches the publisher's generic type argument
<S>
inPublisher<S, C>
.Subscription#shouldDeliver(Receiver, C)
returns true.
If one of the tests fails, proceed to the next subscription.
Build the list of delivery options with
Subscription#getDeliveryOptions
.For each delivery option:
Fetch the delivery option's list of message formatters by calling
DeliveryOption#getMessageFormatters
.Find the message formatters that match the current subscription and delivery option.
For each message formatter:
Attempt to format the
MessageContext
into theDeliveryOption<M>
-specific message type<M>
by callingMessageFormatter#format(MessageContext<S, C>, D)
.If there are no valid message formatters, create a message from the subscription's default HTML or plain text format by calling
Subscription#to[Html/String]Format(Receiver, Context)
, passing the result to the current delivery option, and callingDeliveryOption#messageFrom[Html/String](MessageContext<S, C>, String result)
.Take the formatted message and deliver it by calling
DeliveryOption#deliverMessage(M)
.Capture the receiver ID, subscription ID, and any errors thrown as a
DeliveryException
during delivery of the message, and place into aDeliveryReference
receipt for that message.
Compile all delivery references for each receiver, subscription, and delivery option, along with the event message context and original publisher, into a notification object, and save it to the database.