while debugging https://jira.xwiki.org/browse/XWIKI-17783 we discovered that the way we handle Targetable events and filters might be a bit weird.
To be clear, Targetable Events are events that targets specific users or groups, so basically for those events we know in advance to whom we should send them. Right now any event is filtered by the ScopeNotificationFilter: this component ensures that the various filters we can put on page, spaces or wiki are honored. And it’s possible to create such filters to exclude or specifically include a page/space/wiki and to specify exactly which type of events the filter is dedicated to.
This filter mechanism is quite performant but I don’t think it has been designed to handle Targetable events. For example, if I create an extension that sends SharePageEvent to share pages of a wiki to a specific user. Right now I couldn’t use my extension because users would only receive notifications about the pages they already watch even if the events are targeted to those people.
That’s currently exactly the problem we have with Mentions: only the mentions that comes from pages already watches by the user are received, while we should always receive any mention targeting the user.
So I propose that we change the way filters are handling Targetable events. I see two solutions:
- we never filter Targetable events with ScopeNotificationFilter. Which also mean that we shouldn’t be able to create custom filters for those type of events.
- we only allow to specify exclude filters for Targetable events and the UI should only allow exclude filters for them
Solution 2 is a bit more elegant IMO since it might allow users to stop being spam on some places: we could imagine some usecases where a user would want to stop receiving mentions from a specific space or page. Now it’s also more difficult to implement I think, especially on the UI part.