mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-25 16:22:43 +01:00
Allow bugs@ addresses to blanket-accept tasks
Summary: Allow configuration of a default author for bugs@ emails which don't correspond to a known system user. Test Plan: Configured a default author, sent some mails from nonsense addresses, tasks were created. Reviewers: davidreuss, jungejason, nh, tuomaspelkonen, aran Reviewed By: aran CC: aran, epriestley, ide Differential Revision: 1013
This commit is contained in:
parent
0cb9f3dcf5
commit
9a4bb3901e
5 changed files with 50 additions and 8 deletions
|
@ -268,6 +268,17 @@ return array(
|
|||
// still **COMPLETELY INSECURE**.
|
||||
'metamta.insecure-auth-with-reply-to' => false,
|
||||
|
||||
// If you enable 'metamta.maniphest.public-create-email' and create an
|
||||
// email address like "bugs@phabricator.example.com", it will default to
|
||||
// rejecting mail which doesn't come from a known user. However, you might
|
||||
// want to let anyone send email to this address; to do so, set a default
|
||||
// author here (a Phabricator username). A typical use of this might be to
|
||||
// create a "System Agent" user called "bugs" and use that name here. If you
|
||||
// specify a valid username, mail will always be accepted and used to create
|
||||
// a task, even if the sender is not a system user. The original email
|
||||
// address will be stored in an 'From Email' field on the task.
|
||||
'metamta.maniphest.default-public-author' => null,
|
||||
|
||||
|
||||
// -- Auth ------------------------------------------------------------------ //
|
||||
|
||||
|
|
2
resources/sql/patches/077.originalemail.sql
Normal file
2
resources/sql/patches/077.originalemail.sql
Normal file
|
@ -0,0 +1,2 @@
|
|||
ALTER TABLE phabricator_maniphest.maniphest_task
|
||||
ADD originalEmailSource VARCHAR(255);
|
|
@ -115,6 +115,17 @@ class ManiphestTaskDetailController extends ManiphestController {
|
|||
|
||||
$dict['Author'] = $handles[$task->getAuthorPHID()]->renderLink();
|
||||
|
||||
$source = $task->getOriginalEmailSource();
|
||||
if ($source) {
|
||||
$subject = '[T'.$task->getID().'] '.$task->getTitle();
|
||||
$dict['From Email'] = phutil_render_tag(
|
||||
'a',
|
||||
array(
|
||||
'href' => 'mailto:'.$source.'?subject='.$subject
|
||||
),
|
||||
phutil_escape_html($source));
|
||||
}
|
||||
|
||||
$projects = $task->getProjectPHIDs();
|
||||
if ($projects) {
|
||||
$project_links = array();
|
||||
|
|
|
@ -31,7 +31,7 @@ class ManiphestTask extends ManiphestDAO {
|
|||
|
||||
protected $title;
|
||||
protected $description;
|
||||
|
||||
protected $originalEmailSource;
|
||||
protected $mailKey;
|
||||
|
||||
protected $attached = array();
|
||||
|
|
|
@ -64,16 +64,34 @@ class PhabricatorMetaMTAReceivedMail extends PhabricatorMetaMTADAO {
|
|||
'metamta.maniphest.public-create-email');
|
||||
|
||||
if ($create_task && $to == $create_task) {
|
||||
$receiver = new ManiphestTask();
|
||||
|
||||
$user = $this->lookupPublicUser();
|
||||
if (!$user) {
|
||||
// TODO: We should probably bounce these since from the user's
|
||||
// perspective their email vanishes into a black hole.
|
||||
return $this->setMessage("Invalid public user '{$from}'.")->save();
|
||||
if ($user) {
|
||||
$this->setAuthorPHID($user->getPHID());
|
||||
} else {
|
||||
$default_author = PhabricatorEnv::getEnvConfig(
|
||||
'metamta.manipest.default-public-author');
|
||||
|
||||
if ($default_author) {
|
||||
$user = id(new PhabricatorUser())->loadOneWhere(
|
||||
'username = %s',
|
||||
$default_author);
|
||||
if ($user) {
|
||||
$receiver->setOriginalEmailSource($from);
|
||||
} else {
|
||||
throw new Exception(
|
||||
"Phabricator is misconfigured, the configuration key ".
|
||||
"'metamta.manipest.default-public-author' is set to user ".
|
||||
"'{$default_author}' but that user does not exist.");
|
||||
}
|
||||
} else {
|
||||
// TODO: We should probably bounce these since from the user's
|
||||
// perspective their email vanishes into a black hole.
|
||||
return $this->setMessage("Invalid public user '{$from}'.")->save();
|
||||
}
|
||||
}
|
||||
|
||||
$this->setAuthorPHID($user->getPHID());
|
||||
|
||||
$receiver = new ManiphestTask();
|
||||
$receiver->setAuthorPHID($user->getPHID());
|
||||
$receiver->setPriority(ManiphestTaskPriority::PRIORITY_TRIAGE);
|
||||
|
||||
|
|
Loading…
Reference in a new issue