Skip to content

Instantly share code, notes, and snippets.

@fernandoabolafio
Last active August 13, 2018 18:03
Show Gist options
  • Save fernandoabolafio/0d13902f05294eb83480b1dab11e92c6 to your computer and use it in GitHub Desktop.
Save fernandoabolafio/0d13902f05294eb83480b1dab11e92c6 to your computer and use it in GitHub Desktop.
This Gist attempts to show the current status of the notification system implementation

Politeia notification system

How it works:

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

Design:

  • 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

Current status: Done

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:

  • Notifications signal appears at th top right of the screen along with the username: screen shot 2018-08-09 at 10 12 58 am

  • By clicking on it the user is redirected to the notificatinos page: screen shot 2018-08-09 at 10 15 23 am

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment