Notification filter preferences remover

Last modified by Anca Luca on 2022/08/18 13:23

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

slauriere

Rating
0 Votes
LicenseGNU 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}}
     

Get Connected