Add schema migration for Slack channel

This commit is contained in:
Frederic Guillot 2015-07-05 13:14:00 -04:00
parent aa2ca3342d
commit afab68b130
5 changed files with 30 additions and 13 deletions

View File

@ -38,7 +38,7 @@ class SlackWebhook extends \Core\Base
$options = $this->projectIntegration->getParameters($project_id);
return $options['slack_webhook_url'];
}
/**
* Get optional Slack channel
*
@ -48,10 +48,10 @@ class SlackWebhook extends \Core\Base
*/
public function getChannel($project_id)
{
if (!empty($this->config->get('integration_slack_webhook_channel'))) {
if (! empty($this->config->get('integration_slack_webhook_channel'))) {
return $this->config->get('integration_slack_webhook_channel');
}
$options = $this->projectIntegration->getParameters($project_id);
return $options['slack_webhook_channel'];
}
@ -85,9 +85,9 @@ class SlackWebhook extends \Core\Base
$payload['text'] .= $this->helper->url->href('task', 'show', array('task_id' => $task_id, 'project_id' => $project_id));
$payload['text'] .= '|'.t('view the task on Kanboard').'>';
}
$channel = $this->getChannel($project_id);
if (!empty($channel)) {
if (! empty($channel)) {
$payload['channel'] = $channel;
}

View File

@ -6,7 +6,13 @@ use PDO;
use Core\Security;
use Model\Link;
const VERSION = 77;
const VERSION = 78;
function version_78($pdo)
{
$pdo->exec("ALTER TABLE project_integrations ADD COLUMN slack_webhook_channel VARCHAR(255) DEFAULT ''");
$pdo->exec("INSERT INTO settings VALUES ('integration_slack_webhook_channel', '')");
}
function version_77($pdo)
{

View File

@ -6,7 +6,13 @@ use PDO;
use Core\Security;
use Model\Link;
const VERSION = 57;
const VERSION = 58;
function version_58($pdo)
{
$pdo->exec("ALTER TABLE project_integrations ADD COLUMN slack_webhook_channel VARCHAR(255) DEFAULT ''");
$pdo->exec("INSERT INTO settings VALUES ('integration_slack_webhook_channel', '')");
}
function version_57($pdo)
{

View File

@ -6,7 +6,13 @@ use Core\Security;
use PDO;
use Model\Link;
const VERSION = 73;
const VERSION = 74;
function version_74($pdo)
{
$pdo->exec("ALTER TABLE project_integrations ADD COLUMN slack_webhook_channel TEXT DEFAULT ''");
$pdo->exec("INSERT INTO settings VALUES ('integration_slack_webhook_channel', '')");
}
function version_73($pdo)
{

View File

@ -29,11 +29,10 @@ Now, Kanboard events will be sent to the Slack channel.
### Overriding Channel (Optional)
Optnally you can override the channel, private group or send direct messages by filling up **Channel/Group/User** textbox. Leaving it empty will post to the channel configured during webhook configuration.
Optionally you can override the channel, private group or send direct messages by filling up **Channel/Group/User** text box. Leaving it empty will post to the channel configured during webhook configuration.
Examples:
- #mychannel1 - Send message to channel 'mychannel1'
- #myprivategroup1 - Send message to private group 'myprivategroup1'
- @anotheruser1 - Send message to user 'anotheruser1'
- Send messages to another channel: **#mychannel1**
- Send messages to a private group: **#myprivategroup1**
- Send messages directly to someone: **@anotheruser1**