infojunkie/MantisBT-Slack

Option to skip notifications for private issues and notes

clan-destina opened this issue · 21 comments

Hello, I have followed every step of the configuration and I can't make it work.
Any guideline on how to debug the plugin?

Thanks

To debug, you can turn on logging as per https://www.mantisbt.org/docs/master/en-US/Admin_Guide/html/admin.config.logging.html and then insert logging instructions in the file Slack.php.

But what does

and I can't make it work.

mean? Specifically, what is not working?

  • Does the plugin show up in the "Installed Plugins" section of /manage_plugin_page.php ?
  • Does the plugin settings page show up at /plugin.php?page=Slack/config_page ?

Yes the plugin show up in the installed plugins section, I have everything configured including

  • webhook url, slack channels, slack usernames
    I try to do anything like post a note or delete a note, there is no notification to my slack channel

OK great, then you should be able to insert some logs at https://github.com/infojunkie/MantisBT-Slack/blob/master/Slack.php#L265 for example, to ensure that the execution reaches the right place. If not, go up the call chain until you reach bug_report, bug_update, etc.

What Mantis version are you using?

Wrong button :-)

I'm using the latest stable version 2.11.1
can you send me the lines to insert for the log? tnks!

Assuming you have turned on logging in Mantis config settings as per the link I sent above, you should be able to use the function plugin_log_event() to send messages to your log.

Note that I haven't tested the plugin with Mantis > 2.5, and I don't expect to do so in the short term - so I am grateful for your help here!

I put plugin_log_event($msg);
plugin_log_event($channel);
plugin_log_event($webhook);
right after line 265 and in the log every parameter is correct
any idea?

No idea, but I would continue debugging at https://github.com/infojunkie/MantisBT-Slack/blob/master/Slack.php#L299 and log the result there. If all else fails, try a manual curl invocation of your Slack webhook to make sure it does work.

Ok so I commented line 266
function notify($msg, $webhook, $channel, $attachment = FALSE) {
//if ($this->skip) return;
if (empty($channel)) return;
if (empty($webhook)) return;

and everything is working now, I'm getting the messages in slack =)

Nice! Can you find out which assignment of $this->skip causes this? There must be a difference in the sequence of events between Mantis 2.5.x and 2.11.x

ok, so further analysis, all my problems were due to the visibility of the bug and notes.
reviewing the conditions for the $this->skip if anything is private then the notification is skipped
since I want notification on all the bugs I removed the verification on every action

Thanks a lot for the analysis - feel free to convert this to a feature request to make optional the skipping of private content.

I created 2 new options, works great!

2018-02-27_0-17-37

Woooo plz PR !

I'm trying to do a push of the changes but I get permission denied (using sourcetree)

Please note that I will merge the two checkboxes into a single "Skip notification on private content" to a) avoid too many settings, and b) be symmetrical with the bulk actions option.

I'm trying to publish a branch and keep getting "Authentication failed. You may not have permission to access the repository or the repository may have been archived"

You are problably trying to push to my repository. You need to 1) fork the repo, 2) push fixes to your master or other branch, then 3) submit a PR to my repo. But don't worry about it too much I can make a commit like what you're doing above... the analysis was the important part.

Merged your PR after some changes - thanks!