Open-event-server: Notification response needs further details for FE regarding actions

Created on 3 Jun 2018  路  11Comments  路  Source: fossasia/open-event-server

Is your feature request related to a problem? Please describe.

Current action data is notification response is not enough.

Describe the solution you'd like

The response should be something like this,

{
    "title": "New session proposal for abc",
    "message": "abc event",
    "actions": [
      {
        "type": "view",
        "subject": "session",
        "id": 1324
      },
      {
        "type": "delete",
        "subject": "session",
        "id": 1324
      }
    ],
    "is-read": false,
    "received-at": "2018-05-19T18:13:43.500342+00:00"
}

Where actions is an array contain all the actions a user should be able to perform in the order of priority. (i.e. the first action element of the array is to be considered the primary action and so on - FE should display/behave accordingly.)

enhancement has-PR parent issue

Most helpful comment

@srv-twry
Yes, the server returns a full HTML button in the actions. But that really shouldn鈥檛 be the way. Server is meant to be consumed ny more than just frontend and even the frontend鈥檚 html May change over time. Rather the server should return the concrete data of the actions which are possible with a notification. The frontend can use the actions array to generate appropriate buttons.

All 11 comments

Working on it.

@schedutron can i work on it with you ?

@bhavybarca sure, but how should we split this up?

Currently, action is a string column in the notification database model. To implement a list of actions, there should be a separate actions table with a one-to-many relationship between notifications and actions? Thoughts @iamareebjamal @bhaveshAn @srv-twry @mayank8318?

Why not a comma separated value ? @schedutron

@srv-twry Something like "type, subject, id, view, session, 1324, delete, session, 1324"?

Will the above format work?

@schedutron Sorry about the delay. Saw it just now. I think a separate table should be used here. Ignore my previous suggestion.

@niranjan94 @CosmicCoder96
Need your help. I noticed this just now.
The response for a new session proposal from server is something like this:

NEW_SESSION: {
        'title': u'New session proposal for {event_name}',
        'message': u"The event <strong>{event_name}</strong> has received" +
                   u"a new session proposal.<br><br>" +
                   u"<a href='{link}' class='btn btn-info btn-sm'>View Session</a>",
        'recipient': 'Organizer',
    },

It already has the link added in the button. Similarly proper links are already added in the buttons for other notifications also. I don't see the point of adding actions. The FE can simply render this in the frontend and add some styling and it should automatically work.

@srv-twry
Yes, the server returns a full HTML button in the actions. But that really shouldn鈥檛 be the way. Server is meant to be consumed ny more than just frontend and even the frontend鈥檚 html May change over time. Rather the server should return the concrete data of the actions which are possible with a notification. The frontend can use the actions array to generate appropriate buttons.

@CosmicCoder96 Agreed. This was also my concern over sending event description as HTML

Was this page helpful?
0 / 5 - 0 ratings

Related issues

CosmicCoder96 picture CosmicCoder96  路  4Comments

SaptakS picture SaptakS  路  3Comments

iamareebjamal picture iamareebjamal  路  4Comments

schedutron picture schedutron  路  4Comments

mariobehling picture mariobehling  路  4Comments