Autowatch on Time Logged

I was never a fan of the autowatch on comments. It's a good idea, but creates a bit too much noise for our users. But what I would like is something very similar in that anyone who logs time to an issue is auto-added as a watcher. Without writing custom code, does anyone know a solution?

3 answers

1 accepted

This widget could not be displayed.

I crafted this today that adds anyone logging time to the watch list.

package com.custom

import com.atlassian.jira.event.issue.AbstractIssueEventListener
import com.atlassian.jira.event.issue.IssueEvent
import org.apache.log4j.Category
import com.atlassian.jira.ComponentManager
import com.atlassian.jira.issue.watchers.WatcherManager
import com.atlassian.jira.security.JiraAuthenticationContext

class WorkLoggedListener extends AbstractIssueEventListener {
    Category log = Category.getInstance(WorkLoggedListener.class)
 
    @Override
    void issueWorkLogged (IssueEvent event) {
    	log.setLevel(org.apache.log4j.Level.WARN)
    	log.debug ("----------- begin WorkLoggedListener --------------")
    	
    	ComponentManager componentManager = ComponentManager.getInstance()
    	WatcherManager watcherManager = componentManager.getWatcherManager()
    	JiraAuthenticationContext jiraAuthenticationContext = componentManager.getJiraAuthenticationContext()
    	watcherManager.startWatching(jiraAuthenticationContext.getLoggedInUser(), event.issue)
    	
    	log.debug ("----------- end WorkLoggedListener ----------------")
    }
}

Upvoted, but I think you are over-complicating this. You can get a WatcherService via:

ComponentAccessor.getComponent(WatcherService.class)

Then you don't need to create one yourself along with all its dependencies. Furthermore I think I would just use

watcherManager.startWatching(watcher, issue)

watcherManager.startWatching was a *much* cleaner way of doing this so I edited the code above to reflect my changes. Thanks for the tip, Jamie.

(i didn't use ComponentAccessor as you suggested above though. Instead, I stuck with ComponentManager.)

No worries. CA and CM do the same thing under the covers, but CA is @PublicApi, CM is not. One day... probably a very long time in the future, CM might be removed...

This widget could not be displayed.
Ivan Tse Atlassian Team Mar 14, 2013

That is odd. I would have assumed that the auto watch would have captured that action and added the user who logged time against the ticket to have been added as a watcher. I've made an improvement request for now to review consistency for what actions automatically add a watcher.

https://jira.atlassian.com/browse/JRA-32119

If logging time againast a ticket is one of the actions which adds a user as a watcher then your want to add users once they logged work will fall under the default auto-watch feature.

thanks, ivan. i voted up the issue, and i'm going to add a few of my thoughts.

This widget could not be displayed.

Without custom code, it is not possible.

how many times do i have to tell you to stop giving me bad news, jobin? ;)

lol........

Suggest an answer

Log in or Sign up to answer
Atlassian Summit 2018

Meet the community IRL

Atlassian Summit is an excellent opportunity for in-person support, training, and networking.

Learn more
Community showcase
Posted Wednesday in New to Jira

Are you planning to trial, or are currently trialling Jira Software? - We want to talk to you!

Hello! I'm Rayen, a product manager at Atlassian. My team and I are working hard to improve the trial experience for Jira Software Cloud. We are interested in   talking to 20 people planning t...

175 views 2 0
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you