Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hipchat notifier #137

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions config/ProjectConfiguration.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ public function setup()
$this->enablePlugins('sfGuardPlugin');
$this->enablePlugins('crewLessPlugin');
require_once sfConfig::get('sf_root_dir') . '/lib/vendor/XMPPHP/XMPP.php';
require_once sfConfig::get('sf_root_dir') . '/lib/vendor/HipChat/HipChat.php';

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ligne superflue ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sans elle la lib n'est pas incluse.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Je parlais juste de la ligne vide 😄

$this->dispatcher->connect('context.load_factories', array($this, 'listenLoadFactoriesEvent'));
}
Expand Down
19 changes: 19 additions & 0 deletions config/notifiers.yml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,23 @@ XmppNotifier:
server: jabber.yourdomain.com
to: [email protected]
type: groupchat
HipchatNotifier:
review-request:
enabled: 0
message: "New review request for branch %branch%"
add-links: 1
notify: 0
color: "purple"
comment:
enabled: 0
branch_message: "%branch% - %author% : %message%"
file_message: "%branch% - %author% : %message%"
line_message: "%branch% - %author% : %message%"
add-links: 1
notify: 0
projects:
2:
token: "2718a778gavde59a8fa51aa7aze"
room: "developers"
user: "Crew"

46 changes: 46 additions & 0 deletions lib/notifiers/HipchatNotifier.class.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<?php

class HipchatNotifier extends SimpleNotifier
{

/**
* @param int $statusId
*
* @return string
*/
protected function getLabelStatus($statusId)
{
return BranchPeer::getLabelStatus($statusId);
}

/**
* @param $message
*
* @return $this
*/
protected function send($message)
{
$configCurrentProject = $this->getCurrentProjectConfig();

$token = $configCurrentProject['token'];
$room = $configCurrentProject['room'];
$user = $configCurrentProject['user'];

list(,$eventName) = explode('.', $this->name);
$eventConfig = $this->getEventConfig($eventName);

$notify = isset($eventConfig['notify']) && $eventConfig['notify'] == '1';

$color = Hipchat::COLOR_YELLOW;
if (isset($eventConfig['color']))
{
$color = $eventConfig['color'];
}

$hipChat = new HipChat($token);
$hipChat->message_room($room, $user, $message, $notify, $color, Hipchat::FORMAT_TEXT);

return $this;
}

}
Loading