Closed bafplus closed 6 years ago
If i replace the webhook with a slack webhook everything works fine. So there is something of in the mattermost code in this plugin or at mattermost code.
I myself are no coder so have no clue where to look for a fix.
Strange, it's the same commit that went into both branches. @secustor would you mind validating that the latest master
works with Mattermost for you?
Only the 1.2 branch was merged
Here's the commit on master: https://github.com/infojunkie/MantisBT-Slack/commit/8aa67a830ca791936c05eede149d240d95579bcb - or is there another one I missed?
Probably because the slack.php in main branch was last updated 2 months ago?
Not saying its the root of my issue, but looks related.
The commit I point to above was made 6 days ago on master. Please make sure you are pulling the latest code, and from the correct repo: https://github.com/infojunkie/MantisBT-Slack or https://github.com/mantisbt-plugins/Slack
So...why is it 2 months there? Or am i missing something?
I see.. the patch was submitted two months ago. I merged the PR 6 days ago.
So that should be ok then?
Yes, the patch is in there. I doubt I will have time to test Mattermost myself, so I hope @secustor can confirm.
I wil test the master
I just tested current master and stil get that error.
@bafplus try to add the following line to Slack.php at line 268 (1.2.x branch) right before the post fields.
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type:application/json'));
It then should look like this:
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type:application/json'));
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($payload));
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
curl_setopt($ch, CURLOPT_TIMEOUT, 5);
$result = curl_exec($ch);
if ($result !== 'ok') {
trigger_error(curl_errno($ch) . ': ' . curl_error($ch), E_USER_WARNING);
plugin_error('ERROR_CURL', E_USER_ERROR);
}
curl_close($ch);
This will tell mattermost how to exactly handle the request, this shouldn't be necessary, but its worth a try.
but i use mantis 2.x?
For 2.x that would be line 295.
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type:application/json'));
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($payload));
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
curl_setopt($ch, CURLOPT_TIMEOUT, 5);
last fix for 2.x is working for me.
Thank you.
confirmed, @secustor that worked
Sorry, I closed too soon - I will add the relevant lines to both branches.
I can't make it work on mattermost, I may configured mantis wrong, I don't know but I need some help here, can you guys give me a hand?
Here's my current settings, oh by the way the webhook url is not for slack it is for my private mattermost
@dimitriacosta Your default channel is not valid. For mattermost you have to use the channel name as provided in the URL and without the hashtag e.g. 'town-square' for the Vanilla default channel
Hi @secustor thanks for your quick answer.
I did what you said and here's my new settings
It's still not working because every time I create a new issue I got this error
APPLICATION ERROR #plugin_Slack_ERROR_CURL
The request to Slack didn't go through. Check your webhook URL. Also make sure there are no unusual characters in your bot name or bot icon settings. Further details may be printed below this box.
Please use the "Back" button in your web browser to return to the previous page. There you can correct whatever problems were identified in this error or select another action. You can also click an option from the menu bar to go directly to a new section.
@dimitriacosta You have forgoten to mask the webhook on your second screenshot.
Activate the debug mode for webhooks in Mattermost and check what it is receiving.
@secustor I got something like this
[2017/11/14 20:09:33 UTC] [EROR] /hooks/<key>:IncomingWebhookRequestFromJson code=400 rid=3gjnzmnrxb8qfkof7p5ncae36o uid= ip=187.189.17.225 Unable to parse incoming data [details: EOF]
Hey @secustor I found this in my mattermost instance
I guess that's from you 😅 but I just can't make it work 😔
I am running mantis from a docker image so maybe there is something wrong with it, to be hones I have no idea.
It works perfectly fine with slack but not in mattermost.
By the way, notifications are sent only if the issue is created as public, if I make an issue as private I don't get anythinng
Do you have added the line above to the plugin? If yes, please share the ticket which you try to open, so I can try to reproduce the error on my local system.
That private issues are not sent is normal behaviour.
Oh I didn't noticed that line was removed when I recreated the docker image, I've just aded that line and its working fine now.
But now I have another question, what if I want mantis to send notifications even if issues are private? Considering that I have a private channel for the development team
In that case you have to modify the source code. Line 266 of Slack.php is a hot hint ;) . This will ignore the privacy setting of all issues and notes. BE WARNED!
On the mattermost side you need to create a webhook specific to the private channel and then let the plugin write on it too.
Great it worked, thank you very much for your help 👍
Thanks everyone. Will update the branches when I'm back at a computer one week from now.
The error: APPLICATION ERROR #plugin_Slack_ERROR_CURL The request to Slack didn’t go through. Check your webhook URL. Also make sure there are no unusual characters in your bot name or bot icon settings. Further details may be printed below this box. Please use the “Back” button in your web browser to return to the previous page. There you can correct whatever problems were identified in this error or select another action. You can also click an option from the menu bar to go directly to a new section.
I cant seem to find something wrong else then a empty UID in the string. There was a commit 6 days ago in the 1.2 branch that fixes a simular issue.