cogRemoves the page only notification filter preferences for a given user
Developed by

slauriere

Rating
Rate!
0 Votes
LicenseGNU Lesser General Public License 2.1

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}}

Prerequisites & Installation Instructions

Copy the code snippet to a page and save it.

Tags:
Created by slauriere on 2019/07/05 11:05
     

Get Connected