Politeia Users will receive notification through the GUI of relevant events regarding paywall confirmations and admin actions on their proposals. The mapped events so far are:
- Proposal published
- Proposal censored
- Signup Paywal payment confirmed
- Proposal paywall payment confirmed
-
Storage: when the backend successfully process the mapped actions mentioned above, it creates a new notification stored in the user database. The database will store a maximum of 10 notificatinos per time.
-
API: The notification types are mapped in
www/v1.go
as follows:
NotificationInvalid NotificationT = 0
NotificationSignupPaywallPaymentConfirmed NotificationT = 1
NotificationPropPaywallPaymentConfirmed NotificationT = 2
NotificationProposalCensored NotificationT = 3
NotificationProposalPublished NotificationT = 4
NotificationProposalStartedVoting NotificationT = 5
NotificationIdentifier = map[NotificationT]string{
NotificationInvalid: "notification type invalid",
NotificationSignupPaywallPaymentConfirmed: "paywall payment for Politeia access confirmed",
NotificationPropPaywallPaymentConfirmed: "paywall payment for proposal submission confirmed",
NotificationProposalCensored: "user proposal censored",
NotificationProposalPublished: "user proposal published",
NotificationProposalStartedVoting: "user proposal voting has started",
}
Two new commands are exposed to http clients:
- Notifications: for fetching all user notifications
- CheckNotifications: to mark one or multiple notifications as viewed
type NotificationsReply struct {
Notifications []Notification `json:"notifications"`
}
type CheckNotifications struct {
NotificationIDs []uint64 `json:"notificationids"`
}
- The Notification Type:
type Notification struct {
NotificationID uint64 `json:"notificationid"`
NotificationType NotificationT `json:"notificationtype"`
Timestamp int64 `json:"timestamp"`
ContextInfo []string `json:"contextinfo,omitempty"`
Viewed bool `json:"viewed"`
}
- Notification ID: unique Id generated once the notification is created in the database.
- NotifcationType: is the indentifier which specify what is being actually notificated (proposal censored, paywall paid, etc).
- Timestamp: when the notification was created
- Viewed: either the notification was marked as seen by the user or not.
- ContextInfo: can contain one or multiple information about the notification context. The table bellow maps the notification type to its contextinfo value:
Notification type | Context info value |
---|---|
5 - proposal voting started | ["censorshiptoken"] |
4 - proposal published | ["censorshiptoken"] |
3 - proposal censored | ["censorhiptoken"] |
2 - proposal paywall paid | ["amount_of_credits"] |
1 - signup paywall paid | none |
0 - invalid | none |
All the backend logic has been done already, it has been reviewed multiple times by @sndurkin and @tiagoalvesdulce. The work can be better tracked from the PR description here: decred/politeia#393
Tiago is implementing the corresponding GUI work: