-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Dynamic notification / action data #88
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is all solid and makes sense but I think we can do a little better on the notification data sanitisation - I've made a suggestion for a sanitize_notification_data()
function that takes the whole array rather than something applied to each item.
@shadyvb @roborourke I wonder if we should be able to add arbitrary data to the notification itself, instead of passing it on the action (or maybe in addition to the action?) As an example - we have a 'like article' feature, a notification is fired when this action happens. We want to group the 'like' notifications for a single article together so need some data to use for this. We don't need any actions for this functionality. @shadyvb Do you think if we could pass the data on the notification itself in a very similar way to what you are doing here for actions, then you could achieve your goals with that alone or do you also need to pass the data on the action too? |
Based on what you're saying @mattheu I agree that there's a use case for arbitrary meta data to be associated with a notification such as 'type' etc... I'm thinking there's a few things that are currently missing that would make this possible:
I was originally thinking you could wither use the
|
@mattheu We do need an action for the TBH it also complicates the grouping logic a bit! having to match at the action level instead of notification level. It made sense when I did it, but I think I’d have gone for notification-level data if the method was there. Happy for #90 to be merged and then our client PR can work off that. @roborourke Thanks for the insight, I guess @mattheu ‘s approach in #90 would bridge the gap we hit, along side changes in this PR. I’ll work on the sanitisation enhancements you proposed and push back for review. |
Add data to notification
For the |
…objects after sanitisation
# Conflicts: # package-lock.json # package.json # plugin.php
…action-data # Conflicts: # CHANGELOG.md
This adds two enhancements:
Enhancement: Allow action data attribute to be a callback receiving action arguments and returning data to be stored, to allow dynamic on-execution data storage.
Enhancement: Add a new filter to allow manipulating notification object before output, allows for further highly-dynamic data gathering on-output, or data that shouldn't be stored in DB.
Enhancement: Allow overriding the action data sanitisation callback to permit more flexible schemas.
Updated changelog
Updated version number in
package.json
andplugin.php
file with appropriate MAJOR.MINOR.PATCH change