WIP: Notification Service API
The Notification Service api stores consent corresponding to user, creates and saves message, send all waiting message to external provider.
There are two scenarios for using the Notification service:
-
Entering/query of consents The user wants to give his consent for at least one module (e.g. for the PensionCompass in german VorsorgeKompass). For this the MicroService is called with the parameters UserID, DeviceID and ModuleName. The MS enters this combination into the database. If another user has already given a consent on the same device (regardless of which module), an error is thrown because a unique key is in the device column in the Database. So only one user per device can activate the push messages. To keep it simple, the first user wins and there is no way to manage it.
-
Sending push messages In the first step, push messages are sent only from the backend. Each module of NAVIDA that uses a backend can send push messages to the MS PushNotification. For example, the backend PensionCompass has a cron job that checks every night if users have birthdays and therefore new examinations are possible for them. If a user is found, the MS PensionCompass sends to the MS PushNotification via API an object with UserID, ModuleName, Message and scheduled sending time. The MS PushNotification checks on the basis of the UserID whether a device is registered for this user and whether this device has a valid consent for the module. If so, the MS PushNotification stores the message and sends it to WonderPush at the scheduled time.
Database schema (ER diagram)
Process diagram
REST endpoints
Description | HTTP METHOD | HEADER | URL(for root /api/v1) | PAYLOAD | RESPONSE (SUCCESS) | RESPONSE (ERROR) |
---|---|---|---|---|---|---|
Create message | POST | /pushnotification/user/UserID/notification | Object<Message> | Object<Message> (with updated messageID) | Object<Error> | |
Send all waiting messages | GET | WITHOUT BEARER TOKEN | private/pushnotification/cronjob/sendwaitingmessages | 200 OK | none | |
Cleanup wonderpush | GET | WITHOUT BEARER TOKEN | private/pushnotification/cronjob/cleanup-wonderpush | 200 OK | none |
Class Diagram
Error handling
Error {
"statusCode": <ERROR CODE>,
"message":String
}
Case | HTTP Code | Error Code | Error Message |
---|---|---|---|
No user consent existing in DB | 404 | 102 | Consent for User ID: < UserID > Not Found |
Authentification error | 401 | ||
No message with MessageID existing for User with UserID in DB | 404 | 104 | Message with ID: < MessageID > Not Found for User with ID: < UserID > |
No messages existing for User with UserID in DB | 404 | 105 | Messages Not Found for User with ID: < UserID > |
No device content existing in DB | 404 | 106 | Consent for Device ID: < DeviceID > Not Found |
No module exists with this name | 404 | 107 | Module name does not exists |
An other user is registered with same device already | 409 | 108 | An other user is registered with same device: < DeviceID > |