Skip to content
This repository has been archived by the owner on Jan 13, 2022. It is now read-only.

Commit

Permalink
Initial commit that includes JIRAMailListener.
Browse files Browse the repository at this point in the history
  • Loading branch information
mareksapota-fb committed Nov 9, 2011
0 parents commit 1010837
Show file tree
Hide file tree
Showing 7 changed files with 134 additions and 0 deletions.
9 changes: 9 additions & 0 deletions .arcconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"project_id" : "arcjira",
"conduit_uri" : "https://reviews.facebook.net/",
"copyright_holder" : "Facebook",
"lint_engine" : "PhutilLintEngine",
"phutil_libraries" : {
"phabricator" : "../phabricator/src/"
}
}
1 change: 1 addition & 0 deletions .phutil_module_cache
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"src":{"signature":"68bb41a0f7b4f90e6568bdc6989c3db8","spec":{"declares":{"class":{"JIRAMailListener":"JIRAMailListener.php:604"},"interface":[],"function":[],"source":{"JIRAMailListener.php":true}},"requires":{"class":{"PhabricatorEventListener":["JIRAMailListener.php:629"],"PhabricatorEventType":["JIRAMailListener.php:705"]},"interface":[],"function":[],"source":{"JIRAMailListener.php":["__init__.php:255"]},"module":{"phabricator:infrastructure\/events\/listener":["__init__.php:104"],"phabricator:infrastructure\/events\/constant\/type":["__init__.php:176"]}},"chain":{"class":{"JIRAMailListener":"PhabricatorEventListener"}},"messages":[]}}}
24 changes: 24 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
========================
About Phabricator-JIRA
========================

This package provides Phabricator extensions that allows integration between
Differential code review tool and JIRA issue tracker.

This extensions should be used along with Arc-JIRA on the client side.

==============
Installation
==============

You should put `phabricator-jira` directory in the same place where you put
`arcanist`, `phabricator` and `libphutil` directories.

cd where/I/put/phabricator
git clone git://github.com/facebook/phabricator-jira.git

Edit your Phabricator config file, add `phabricator-jira` to Phabricator load
path, and tell it to use provided event listeners.

'load-libraries' => array('phabricator-jira'),
'event.listeners' => array('JIRAMailListener'),
19 changes: 19 additions & 0 deletions __phutil_library_init__.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php

/*
* Copyright 2011 Facebook
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

phutil_register_library('phabricatorjira', __FILE__);
23 changes: 23 additions & 0 deletions __phutil_library_map__.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php

/**
* This file is automatically generated. Use 'phutil_mapper.php' to rebuild it.
* @generated
*/

phutil_register_library_map(array(
'class' =>
array(
'JIRAMailListener' => 'src',
),
'function' =>
array(
),
'requires_class' =>
array(
'JIRAMailListener' => 'PhabricatorEventListener',
),
'requires_interface' =>
array(
),
));
45 changes: 45 additions & 0 deletions src/JIRAMailListener.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<?php

/*
* Copyright 2011 Facebook
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

class JIRAMailListener extends PhabricatorEventListener {
public function register() {
$this->listen(PhabricatorEventType::TYPE_DIFFERENTIAL_WILLSENDMAIL);
}

public function handleEvent(PhabricatorEvent $event) {
$mail = $event->getValue('mail');
$subject = $mail->getSubject();
$match = null;
preg_match(
'/([[:alnum:]]+-[[:digit:]]+)\s+\[jira\]/',
$subject,
$match
);
if (!$match) {
// Not a JIRA mail, ignore it.
return;
}
$jira_id = $match[1];
$attachments = $mail->getAttachments();
foreach ($attachments as $attachment) {
$attachment->setFileName(
$jira_id.'.'.$attachment->getFileName()
);
}
}
}
13 changes: 13 additions & 0 deletions src/__init__.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php
/**
* This file is automatically generated. Lint this module to rebuild it.
* @generated
*/



phutil_require_module('phabricator', 'infrastructure/events/listener');
phutil_require_module('phabricator', 'infrastructure/events/constant/type');


phutil_require_source('JIRAMailListener.php');

0 comments on commit 1010837

Please sign in to comment.