mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-25 16:22:43 +01:00
162f34b8c8
Summary: add email reply handler so that the user can reply to a differential email to act on the revision. It generates the reply-to email address, creates email body text with supported commands list, and handle the action request on the differential revision. Right now the reply-to handing is disabled in the config file. But a site using Phabricator can enable it and implement a class inheriting from DifferentialReplyHandler to enable customized email handing. Later we will need to add code to DifferentialMail.php to support sending separate email to each email recipient to achieve better security (see D226). The reply-to will be something like D<revision_id>+<user_id>+<hash>@domain.com. We will create separate task for it. Test Plan: tried comment on a revision from web UI and the email was sent out as before without any change. When a subclass of DifferentialReplyHandler is implemented and enabled, email's reply-to is set and email text is added. Reply to the email with valid command did create action to the revision. Reviewed By: epriestley Reviewers: tuomaspelkonen, epriestley, slawekbiel, dpepper CC: aran, epriestley, jungejason Differential Revision: 224
62 lines
1.5 KiB
PHP
62 lines
1.5 KiB
PHP
<?php
|
|
|
|
/*
|
|
* Copyright 2011 Facebook, Inc.
|
|
*
|
|
* 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 DifferentialExceptionMail extends DifferentialMail {
|
|
|
|
public function __construct(
|
|
DifferentialRevision $revision,
|
|
Exception $exception,
|
|
$original_body) {
|
|
|
|
$this->revision = $revision;
|
|
$this->exception = $exception;
|
|
$this->originalBody = $original_body;
|
|
}
|
|
|
|
protected function renderBody() {
|
|
// Never called since buildBody() is overridden.
|
|
}
|
|
|
|
protected function renderSubject() {
|
|
return "Exception: unable to process your mail request.";
|
|
}
|
|
|
|
protected function buildBody() {
|
|
$exception = $this->exception;
|
|
$original_body = $this->originalBody;
|
|
|
|
$message = $exception->getMessage();
|
|
$trace = $exception->getTraceAsString();
|
|
|
|
return <<<EOBODY
|
|
Your request failed because an exception was encoutered while processing it:
|
|
|
|
EXCEPTION: {$message}
|
|
|
|
{$trace}
|
|
|
|
-- Original Body --------------------------
|
|
|
|
{$original_body}
|
|
|
|
EOBODY;
|
|
}
|
|
|
|
}
|
|
|
|
|