Notification filter preferences remover
Last modified by slauriere on 2026/06/02 17:54
| Removes the page only notification filter preferences for a given user |
| Type | |
| Category | |
| Developed by | |
| Rating | |
| License | GNU Lesser General Public License 2.1 |
Table of contents
Description
This snippet removes all the notification filters of a given user whose scope is "page only". It can be handy when a user has many page notification filters, which can slow down the wiki in some cases.
{{groovy}}
def notificationFilterPreferenceService = services.component.componentManager.getInstance(org.xwiki.notifications.filters.NotificationFilterPreferenceManager.class)
def userReference = services.model.createDocumentReference("xwiki", "XWiki", "jdoe")
def filters = notificationFilterPreferenceService.getFilterPreferences(userReference)
filters.eachWithIndex() {
it, index ->
if (it.pageOnly != null) {
println "* #${index}: ${it.id}"
notificationFilterPreferenceService.deleteFilterPreference(userReference, it.getId())
}
}
{{/groovy}}