steemit / yo

Modular event-driven notification service
https://github.com/steemit/yo/issues/113
MIT License
7 stars 9 forks source link

Yotifications - settings api #13

Open relativityboy opened 7 years ago

relativityboy commented 7 years ago

Create a per-user settings api that allows users to enable/disable transports and enable/disable notification types within those transports

GwenNelson commented 7 years ago

As discussed on slack, this already exists in the form of the enable_transports API call, but that doesn't use "one big object" that represents the whole state (it enables transports passed to it in params).

The plan is to replace it with that one big object consisting of a dictionary mapping transports to notification types handled by that transport like this:

{'email':{'notification_types':['VOTE','TRANSFER',...],
              'sub_data':'test@example.com'},
 'wwwpoll':{'notification_types':[...],
                     'sub_data':{}}

So for each transport we have a list of notification types that go over that transport and a sub_data field that can contain any valid JSON object (in the email example, it's a string with the email address).

The "wwwpoll" transport is what condenser will use, it is not currently in place yet, but for this transport it is assumed that no special sub_data is needed, so we have a simple empty dictionary.

GwenNelson commented 7 years ago

Oh, and of course the above object will be passed to the API as so:

set_transports(username,transports) to set a new config get_transports(username) to return the current config

relativityboy commented 7 years ago

@GarethNelson as an https api user, I'm primarily interested in the shape of that api. when you wrote set_transports(username,transports) to set a new config did you mean the https jsonrpc request body should look like

{
  "jsonrpc": "2.0", 
  "method": "set_transports", 
  "params": {
    "email": {
      "notification_types": ["VOTE", "TRANSFER", ...],
      "sub_data": "test@example.com"
    },
    "wwwpoll": {
      "notification_types": [...],
      "sub_data": {}
    }
  }, 
  "id": "an id unique to the client"
}

It's unclear as to where username should go. Or will that be derived from an authentication?

GwenNelson commented 7 years ago

Everything is JSON-RPC

GwenNelson commented 7 years ago

However, it should look like this:

{
  "jsonrpc": "2.0", 
  "method": "set_transports", 
  "params": {
   "username":"testuser",
   "transports":{
     "email": {
      "notification_types": ["VOTE", "TRANSFER", ...],
      "sub_data": "test@example.com"
    },
    "wwwpoll": {
      "notification_types": [...],
      "sub_data": {}
    }
   }
  }, 
  "id": "an id unique to the client"}
GwenNelson commented 7 years ago

This is now in place in latest commit, requires integration testing with condenser UI

GwenNelson commented 7 years ago

@bnchdrff @relativityboy

Once this PR is merged, someone should check it's all working with condenser: https://github.com/steemit/yo/pull/57

Once it is, this issue can be closed unless the API for settings is missing something.

john-g-g commented 6 years ago

@relativityboy can you confirm this is working so we can close it