Skip to content
This repository was archived by the owner on Apr 1, 2021. It is now read-only.

Commit 4d454ed

Browse files
authored
Merge pull request #1 from Jamie-Owen/override-channel
Added option to override the channel
2 parents 3d50677 + 05c5da5 commit 4d454ed

File tree

5 files changed

+33
-6
lines changed

5 files changed

+33
-6
lines changed

Notification/RocketChat.php

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,11 @@ class RocketChat extends Base implements NotificationInterface
2424
public function notifyUser(array $user, $event_name, array $event_data)
2525
{
2626
$webhook = $this->userMetadataModel->get($user['id'], 'rocketchat_webhook_url');
27+
$channel = $this->userMetadataModel->get($user['id'], 'rocketchat_webhook_channel');
2728

2829
if (! empty($webhook)) {
2930
$project = $this->projectModel->getById($event_data['task']['project_id']);
30-
$this->sendMessage($webhook, $project, $event_name, $event_data);
31+
$this->sendMessage($webhook, $channel, $project, $event_name, $event_data);
3132
}
3233
}
3334

@@ -42,9 +43,10 @@ public function notifyUser(array $user, $event_name, array $event_data)
4243
public function notifyProject(array $project, $event_name, array $event_data)
4344
{
4445
$webhook = $this->projectMetadataModel->get($project['id'], 'rocketchat_webhook_url');
46+
$channel = $this->projectMetadataModel->get($project['id'], 'rocketchat_webhook_channel');
4547

4648
if (! empty($webhook)) {
47-
$this->sendMessage($webhook, $project, $event_name, $event_data);
49+
$this->sendMessage($webhook, $channel, $project, $event_name, $event_data);
4850
}
4951
}
5052

@@ -88,13 +90,19 @@ public function getMessage(array $project, $event_name, array $event_data)
8890
*
8991
* @access private
9092
* @param string $webhook
93+
* @param string $channel
9194
* @param array $project
9295
* @param string $event_name
9396
* @param array $event_data
9497
*/
95-
private function sendMessage($webhook, array $project, $event_name, array $event_data)
98+
private function sendMessage($webhook, $channel, array $project, $event_name, array $event_data)
9699
{
97100
$payload = $this->getMessage($project, $event_name, $event_data);
101+
102+
if (! empty($channel)) {
103+
$payload['channel'] = $channel;
104+
}
105+
98106
$this->httpClient->postFormAsync($webhook, $payload);
99107
}
100108
}

Plugin.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
/**
99
* RocketChat Plugin
1010
*
11-
* @package slack
11+
* @package rocketchat
1212
* @author Frederic Guillot
1313
*/
1414
class Plugin extends Base
@@ -39,7 +39,7 @@ public function getPluginAuthor()
3939

4040
public function getPluginVersion()
4141
{
42-
return '1.0.2';
42+
return '1.0.3';
4343
}
4444

4545
public function getPluginHomepage()

README.md

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,21 @@ Configuration
3939

4040
- Generate a new webhook url
4141
- Go to **Administration > Integrations > New Integration > Incoming Webhook**
42+
- You can override the channel later if required
4243

4344
### Kanboard configuration
4445

45-
1. Copy and paste the webhook url in **Integrations > RocketChat** (user profile or project settings)
46+
#### Individual notifications
47+
48+
1. Copy and paste the webhook url into **Integrations > RocketChat** in your
49+
user profile
4650
2. Enable RocketChat notifications in your user profile or project settings
4751
3. Enjoy!
52+
53+
#### Project notification
54+
55+
1. Copy and paste the webhook url into **Integrations > RocketChat** in the
56+
project settings
57+
2. Add the channel name (Optional)
58+
3. Enable RocketChat notification in the project
59+
4. Enjoy!

Template/project/integration.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
<div class="listing">
33
<?= $this->form->label(t('Webhook URL'), 'rocketchat_webhook_url') ?>
44
<?= $this->form->text('rocketchat_webhook_url', $values) ?>
5+
6+
<?= $this->form->label(t('Channel (Optional)'), 'rocketchat_webhook_channel') ?>
7+
<?= $this->form->text('rocketchat_webhook_channel', $values, array(), array('placeholder="#channel"')) ?>
58
<p class="form-help"><a href="https://kanboard.net/plugin/rocketchat" target="_blank"><?= t('Help on RocketChat integration') ?></a></p>
69

710
<div class="form-actions">

Template/user/integration.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22
<div class="listing">
33
<?= $this->form->label(t('Webhook URL'), 'rocketchat_webhook_url') ?>
44
<?= $this->form->text('rocketchat_webhook_url', $values) ?>
5+
6+
<?= $this->form->label(t('User (Optional)'), 'rocketchat_webhook_channel') ?>
7+
<?= $this->form->text('rocketchat_webhook_channel', $values, array(), array('placeholder="@username"')) ?>
8+
59
<p class="form-help"><a href="https://kanboard.net/plugin/rocketchat" target="_blank"><?= t('Help on RocketChat integration') ?></a></p>
610

711
<div class="form-actions">

0 commit comments

Comments
 (0)