ndaversa / hubot-jira-bot

Lets you search for JIRA tickets, open them, transition them thru different states, comment on them, rank them up or down, start or stop watching them or change who is assigned to a ticket. Also, notifications for assignments, mentions and watched tickets.
https://www.npmjs.com/package/hubot-jira-bot
MIT License
61 stars 43 forks source link

Filter out notifications on Jira issues where comment author is watcher/assignee #43

Open vwbusguy opened 7 years ago

vwbusguy commented 7 years ago

Currently, a user receives a notification if they comment on a ticket that they are assigned on or watching. This is unnecessary noise, so I forked and modified the code so that users don't get notified for their own comments.

This code is currently working for us with slack+hubot.

ndaversa commented 7 years ago

@vwbusguy also thanks for taking the time to make this PR

vwbusguy commented 7 years ago

That makes sense to have it in a common place in the DM context, however, it looks like that was added for 7.1 and as of 7.3.2 we were still getting notifications for comments. I see that comment.author is being passed https://github.com/ndaversa/hubot-jira-bot/blob/master/src/index.coffee#L165 and https://github.com/ndaversa/hubot-jira-bot/blob/master/src/index.coffee#L182 but I wonder if the validation is failing to equate the author object with the email address.

The schema given for the author by the Jira API doesn't include an email address: https://docs.atlassian.com/jira/REST/server/#api/2/issue-getComments

            "author": {
                "self": "http://www.example.com/jira/rest/api/2/user?username=fred",
                "name": "fred",
                "displayName": "Fred F. User",
                "active": false
            },

This is why I ended up doing the condition check on name in the comment context.

ndaversa commented 7 years ago

@vwbusguy

how about if here...

https://github.com/ndaversa/hubot-jira-bot/blob/356f50c441a5275e199ee38725329ed60e8e08d3/src/adapters/generic.coffee#L70-L71

we did something like this?

else if message.author?
  if user.profile?.email is message.author.emailAddress or message.author.name is user.name

In both cases you are passing the user object you want to check the name against, either watchers or assignee.

I haven't run the code to verify, but I think it should work?

vwbusguy commented 6 years ago

Sorry it took so long to respond. I pulled 7.4.0 and I'm still seeing notifications when I comment on an issue. I do not see the same behavior with my submitted PR.