This repository has been archived by the owner on Apr 5, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit c6a5552
Showing
29 changed files
with
384 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
The MIT License (MIT) | ||
|
||
Copyright (c) 2015 Frédéric Guillot | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in | ||
all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<?php | ||
|
||
return array( | ||
'Help on Mattermost integration' => 'Nápověda pro Mattermost integraci.', | ||
'Channel/Group/User (Optional)' => 'Kanál/Skupina/Uživatel (volitelně)', | ||
); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<?php | ||
|
||
return array( | ||
// 'Help on Mattermost integration' => '', | ||
// 'Channel/Group/User (Optional)' => '', | ||
); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<?php | ||
|
||
return array( | ||
'Help on Mattermost integration' => 'Hilfe für Mattermost-Integration.', | ||
'Channel/Group/User (Optional)' => 'Kanal/Gruppe/Benutzer (optional)', | ||
); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<?php | ||
|
||
return array( | ||
'Help on Mattermost integration' => 'Ayuda sobre integración Desatendida', | ||
'Channel/Group/User (Optional)' => 'Canal/Grupo/Usuario (Opcional)', | ||
); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<?php | ||
|
||
return array( | ||
// 'Help on Mattermost integration' => '', | ||
// 'Channel/Group/User (Optional)' => '', | ||
); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<?php | ||
|
||
return array( | ||
'Help on Mattermost integration' => 'Aide sur l\'intégration avec Mattermost', | ||
'Channel/Group/User (Optional)' => 'Canal/Groupe/Utilisateur (Optionnel)', | ||
); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<?php | ||
|
||
return array( | ||
// 'Help on Mattermost integration' => '', | ||
// 'Channel/Group/User (Optional)' => '', | ||
); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<?php | ||
|
||
return array( | ||
'Help on Mattermost integration' => 'Bantuan pada integrasi Mattermost', | ||
'Channel/Group/User (Optional)' => 'Kanal/Grup/Pengguna (pilihan)', | ||
); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<?php | ||
|
||
return array( | ||
'Help on Mattermost integration' => 'Guida all\'integrazione con Mattermost', | ||
// 'Channel/Group/User (Optional)' => '', | ||
); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<?php | ||
|
||
return array( | ||
'Help on Mattermost integration' => 'Mattermost 連携のヘルプ', | ||
// 'Channel/Group/User (Optional)' => '', | ||
); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<?php | ||
|
||
return array( | ||
// 'Help on Mattermost integration' => '', | ||
// 'Channel/Group/User (Optional)' => '', | ||
); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<?php | ||
|
||
return array( | ||
// 'Help on Mattermost integration' => '', | ||
// 'Channel/Group/User (Optional)' => '', | ||
); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<?php | ||
|
||
return array( | ||
// 'Help on Mattermost integration' => '', | ||
// 'Channel/Group/User (Optional)' => '', | ||
); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<?php | ||
|
||
return array( | ||
'Help on Mattermost integration' => 'Ajuda sobre integração com o Mattermost', | ||
'Channel/Group/User (Optional)' => 'Canal/Grupo/Utilizador (Opcional)', | ||
); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<?php | ||
|
||
return array( | ||
'Help on Mattermost integration' => 'Ajuda na integração com o Mattermost', | ||
'Channel/Group/User (Optional)' => 'Canal/Grupo/Utilizador (Opcional)', | ||
); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<?php | ||
|
||
return array( | ||
'Help on Mattermost integration' => 'Помощь по интеграции Mattermost', | ||
'Channel/Group/User (Optional)' => 'Канал/Группа/Пользователь (опционально)', | ||
); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<?php | ||
|
||
return array( | ||
// 'Help on Mattermost integration' => '', | ||
// 'Channel/Group/User (Optional)' => '', | ||
); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<?php | ||
|
||
return array( | ||
'Help on Mattermost integration' => 'Hjälp för Mattermost integration', | ||
'Channel/Group/User (Optional)' => 'Kanal/Grupp/Användare (valfri)', | ||
); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<?php | ||
|
||
return array( | ||
// 'Help on Mattermost integration' => '', | ||
// 'Channel/Group/User (Optional)' => '', | ||
); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<?php | ||
|
||
return array( | ||
// 'Help on Mattermost integration' => '', | ||
// 'Channel/Group/User (Optional)' => '', | ||
); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<?php | ||
|
||
return array( | ||
'Help on Mattermost integration' => 'Mattermost 整合帮助', | ||
// 'Channel/Group/User (Optional)' => '', | ||
); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
all: | ||
@ echo "Build archive for plugin ${plugin} version=${version}" | ||
@ git archive HEAD --prefix=${plugin}/ --format=zip -o ${plugin}-${version}.zip |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
<?php | ||
|
||
namespace Kanboard\Plugin\Mattermost\Notification; | ||
|
||
use Kanboard\Core\Base; | ||
use Kanboard\Notification\NotificationInterface; | ||
|
||
/** | ||
* Mattermost Notification | ||
* | ||
* @package notification | ||
* @author Frederic Guillot | ||
*/ | ||
class Mattermost extends Base implements NotificationInterface | ||
{ | ||
/** | ||
* Send notification to a user | ||
* | ||
* @access public | ||
* @param array $user | ||
* @param string $event_name | ||
* @param array $event_data | ||
*/ | ||
public function notifyUser(array $user, $event_name, array $event_data) | ||
{ | ||
} | ||
|
||
/** | ||
* Send notification to a project | ||
* | ||
* @access public | ||
* @param array $project | ||
* @param string $event_name | ||
* @param array $event_data | ||
*/ | ||
public function notifyProject(array $project, $event_name, array $event_data) | ||
{ | ||
$webhook = $this->projectMetadata->get($project['id'], 'mattermost_webhook_url', $this->config->get('mattermost_webhook_url')); | ||
$channel = $this->projectMetadata->get($project['id'], 'mattermost_webhook_channel'); | ||
|
||
if (! empty($webhook)) { | ||
$this->sendMessage($webhook, $channel, $project, $event_name, $event_data); | ||
} | ||
} | ||
|
||
/** | ||
* Get message to send | ||
* | ||
* @access public | ||
* @param array $project | ||
* @param string $event_name | ||
* @param array $event_data | ||
*/ | ||
public function getMessage(array $project, $event_name, array $event_data) | ||
{ | ||
if ($this->userSession->isLogged()) { | ||
$author = $this->helper->user->getFullname(); | ||
$title = $this->notification->getTitleWithAuthor($author, $event_name, $event_data); | ||
} else { | ||
$title = $this->notification->getTitleWithoutAuthor($event_name, $event_data); | ||
} | ||
|
||
$message = '**['.$project['name']."]** "; | ||
$message .= '_'.$event_data['task']['title']."_\n"; | ||
$message .= $title."\n"; | ||
|
||
if ($this->config->get('application_url') !== '') { | ||
$message .= '['.t('View the task on Kanboard').']'; | ||
$message .= '('; | ||
$message .= $this->helper->url->to('task', 'show', array('task_id' => $event_data['task']['id'], 'project_id' => $project['id']), '', true); | ||
$message .= ')'; | ||
} | ||
|
||
return array( | ||
'text' => $message, | ||
'username' => 'Kanboard', | ||
'icon_url' => 'http://kanboard.net/assets/img/favicon.png', | ||
); | ||
} | ||
|
||
/** | ||
* Send message to Mattermost | ||
* | ||
* @access private | ||
* @param srting $webhook | ||
* @param string $channel | ||
* @param array $project | ||
* @param string $event_name | ||
* @param array $event_data | ||
*/ | ||
private function sendMessage($webhook, $channel, array $project, $event_name, array $event_data) | ||
{ | ||
$payload = $this->getMessage($project, $event_name, $event_data); | ||
|
||
if (! empty($channel)) { | ||
$payload['channel'] = $channel; | ||
} | ||
|
||
$this->httpClient->postJson($webhook, $payload); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
<?php | ||
|
||
namespace Kanboard\Plugin\Mattermost; | ||
|
||
use Kanboard\Core\Translator; | ||
use Kanboard\Core\Plugin\Base; | ||
|
||
/** | ||
* Mattermost Plugin | ||
* | ||
* @package mattermost | ||
* @author Frederic Guillot | ||
*/ | ||
class Plugin extends Base | ||
{ | ||
public function initialize() | ||
{ | ||
$this->template->hook->attach('template:config:integrations', 'mattermost:config/integration'); | ||
$this->template->hook->attach('template:project:integrations', 'mattermost:project/integration'); | ||
|
||
$this->projectNotificationType->setType('mattermost', t('Mattermost'), '\Kanboard\Plugin\Mattermost\Notification\Mattermost'); | ||
|
||
$this->on('session.bootstrap', function($container) { | ||
Translator::load($container['config']->getCurrentLanguage(), __DIR__.'/Locale'); | ||
}); | ||
} | ||
|
||
public function getPluginDescription() | ||
{ | ||
return 'Receive notifications on Mattermost'; | ||
} | ||
|
||
public function getPluginAuthor() | ||
{ | ||
return 'Frédéric Guillot'; | ||
} | ||
|
||
public function getPluginVersion() | ||
{ | ||
return '1.0.0'; | ||
} | ||
|
||
public function getPluginHomepage() | ||
{ | ||
return 'https://github.com/kanboard/plugin-mattermost'; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
Mattermost plugin for Kanboard | ||
============================== | ||
|
||
Receive Kanboard notifications on Mattermost. | ||
|
||
Author | ||
------ | ||
|
||
- Frederic Guillot | ||
- License MIT | ||
|
||
Installation | ||
------------ | ||
|
||
- Create a folder **plugins/Mattermost** or uncompress the latest archive in the folder **plugins** | ||
- Copy all files under this directory | ||
|
||
Configuration | ||
------------- | ||
|
||
Firstly, you have to generate a new webhook url in Mattermost (**Integration Settings > Incoming Webhooks**). | ||
|
||
### Receive project notifications to a room | ||
|
||
- Go to the project settings then choose **Integrations > Mattermost** | ||
- Copy and paste the webhook url from Mattermost or leave it blank if you want to use the global webhook url | ||
- Use `channel` to override the webhook channel, example: **off-topic** | ||
- Enable Mattermost in your project notifications **Notifications > Mattermost** | ||
|
||
You can also define the webhook URL globally in the **Application settings > Integrations > Mattermost**. | ||
|
||
### Mattermost configuration | ||
|
||
- Change the config option `EnablePostUsernameOverride` to `true` to have Kanboard as username | ||
- Change `EnablePostIconOverride` to `true` to see Kanboard icon | ||
|
||
## Troubleshooting | ||
|
||
- Enable the debug mode | ||
- All connection errors with the Mattermost API are recorded in the log files `data/debug.log` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<h3><img src="<?= $this->url->dir() ?>plugins/Mattermost/mattermost-icon.png"/> Mattermost</h3> | ||
<div class="listing"> | ||
<?= $this->form->label(t('Webhook URL'), 'mattermost_webhook_url') ?> | ||
<?= $this->form->text('mattermost_webhook_url', $values) ?> | ||
|
||
<p class="form-help"><a href="https://github.com/kanboard/plugin-mattermost" target="_blank"><?= t('Help on Mattermost integration') ?></a></p> | ||
|
||
<div class="form-actions"> | ||
<input type="submit" value="<?= t('Save') ?>" class="btn btn-blue"/> | ||
</div> | ||
</div> |
Oops, something went wrong.