1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-22 14:52:41 +01:00

When an email reply to a task includes files, attach them to the task

Summary:
Allow files to be attached to a task by attaching them to an email reply to the
task.

Test Plan:
Applied this patch live since I haven't managed to get inbound email configured
locally, then attached files to a task via email.

Reviewed By: jungejason
Reviewers: tuomaspelkonen, jungejason, aran
CC: anjali, aran, jungejason
Differential Revision: 369
This commit is contained in:
epriestley 2011-05-29 03:19:06 -07:00
parent 77a86dfe61
commit 0238f260df
3 changed files with 23 additions and 2 deletions

View file

@ -44,7 +44,7 @@ $received->setBodies(array(
));
$attachments = array();
foreach ($received->getAttachments() as $attachment) {
foreach ($parser->getAttachments() as $attachment) {
$file = PhabricatorFile::newFromFileData(
$attachment->getContent(),
array(

View file

@ -64,6 +64,24 @@ class ManiphestReplyHandler extends PhabricatorMailReplyHandler {
$command = $matches[1];
}
$xactions = array();
$files = $mail->getAttachments();
if ($files) {
$file_xaction = new ManiphestTransaction();
$file_xaction->setAuthorPHID($user->getPHID());
$file_xaction->setTransactionType(ManiphestTransactionType::TYPE_ATTACH);
$phid_type = PhabricatorPHIDConstants::PHID_TYPE_FILE;
$new = $task->getAttached();
foreach ($files as $file_phid) {
$new[$phid_type][$file_phid] = array();
}
$file_xaction->setNewValue($new);
$xactions[] = $file_xaction;
}
$ttype = ManiphestTransactionType::TYPE_NONE;
$new_value = null;
switch ($command) {
@ -93,8 +111,10 @@ class ManiphestReplyHandler extends PhabricatorMailReplyHandler {
$xaction->setNewValue($new_value);
$xaction->setComments($body);
$xactions[] = $xaction;
$editor = new ManiphestTransactionEditor();
$editor->applyTransactions($task, array($xaction));
$editor->applyTransactions($task, $xactions);
}

View file

@ -11,6 +11,7 @@ phutil_require_module('phabricator', 'applications/maniphest/constants/transacti
phutil_require_module('phabricator', 'applications/maniphest/editor/transaction');
phutil_require_module('phabricator', 'applications/maniphest/storage/transaction');
phutil_require_module('phabricator', 'applications/metamta/replyhandler/base');
phutil_require_module('phabricator', 'applications/phid/constants');
phutil_require_module('phabricator', 'infrastructure/env');
phutil_require_module('phutil', 'utils');