How to cancel all watches?

Richard Boult December 19, 2016

My role has changed. Hundreds of pages I was watching are now no longer relevant for me. I want to be able to do mass unwatch, rather than one by one. Or simply wipe the slate clean and unwatch all. 

An alternative would be to unwatch all pages in a particular space, thus I could go through the spaces more quickly than through all the separate pages.

Any suggestions?  Do I need to raise a suggestion?

 

Confluence 5.8 

2 answers

0 votes
Anton Kulikov April 15, 2021

this code help me 

import com.atlassian.confluence.mail.notification.NotificationManager
import com.atlassian.spring.container.ContainerManager
import com.atlassian.sal.api.component.ComponentLocator
import com.atlassian.confluence.pages.PageManager
import com.atlassian.confluence.search.service.ContentTypeEnum
import org.slf4j.Logger
import org.slf4j.LoggerFactory
import com.atlassian.confluence.user.UserAccessor
import com.atlassian.confluence.spaces.SpaceManager
import com.atlassian.user.UserManager 
Logger log = LoggerFactory.getLogger("console") 

def userManager = ComponentLocator.getComponent(UserManager)

NotificationManager nm = ( NotificationManager) ContainerManager.getComponent(
"notificationManager")
PageManager pageManager = ComponentLocator.getComponent(PageManager)
ContentTypeEnum ctp = ComponentLocator.getComponent(ContentTypeEnum)
UserAccessor userAccessor = ComponentLocator.getComponent(UserAccessor)
def spaceManager = ComponentLocator.getComponent(SpaceManager)
def users = userManager.users.find{it.getName() == "username"} 
def nfu = nm.getNotificationsByUser(userAccessor.getUserByName(users?.getName()))
nm.removeAllNotificationsForUser(userAccessor.getUserByName(users.getName()))
return  nm.getNotificationsByUser(userAccessor.getUserByName(users.getName()))
0 votes
Dave Bosman
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
December 20, 2016

Hi Richard,

 

Check out this question and answers. 

https://answers.atlassian.com/questions/33993

 

Regards,

Dave

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events