I've downloaded a MantisBT/Discord webhook plugin (https://github.com/TechGuard/MantisBT-Discord) which is heavily based on the Slack plugin (viewtopic.php?f=15&t=25349). I'm hacking it up a little; I've removed the URL embed, but I'd also like to make it so that if a project's view_state is set to private, the webhook skips printing out the change. It already does this if the issue itself has a view_state of VS_PRIVATE, but I'm having problems getting the project's overall view_state. I've been digging through the SOAP API docs and I haven't found an easy way of doing this. Keep in mind that I'm a PHP beginner; I'm also on shared hosting so I don't have access to logs to figure out what's wrong with my code.
Here's one of the functions as it's originally written:
Code: Select all
function bug_report_update($event, $bug, $bug_id)
{
lang_push( plugin_config_get('language') );
$this->skip = $this->skip || gpc_get_bool('slack_skip') || $bug->view_state == VS_PRIVATE;
$project = project_get_name($bug->project_id);
$url = string_get_bug_view_url_with_fqdn($bug_id);
$summary = $this->format_summary($bug);
$reporter = $this->get_user_name(auth_get_current_user_id());
$handler = $this->format_value($bug, 'handler_id');
$msg = sprintf(plugin_lang_get($event === 'EVENT_REPORT_BUG' ? 'bug_created' : 'bug_updated'),
$project, $reporter, $url, $summary, $handler
);
$this->notify($msg, $this->get_webhook($project), $this->get_attachment($bug));
lang_pop();
}
Code: Select all
lang_push( plugin_config_get('language') );
$project = project_get_name($bug->project_id);
$p_id = $bug->project_id;
$projdata = mci_project_get($p_id, "english", true);
$p_viewst = $projdata['view_state']
$this->skip = $this->skip || gpc_get_bool('slack_skip') || $bug->view_state == VS_PRIVATE || $p_viewst == VS_PRIVATE;