mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-22 23:02:42 +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:
parent
77a86dfe61
commit
0238f260df
3 changed files with 23 additions and 2 deletions
|
@ -44,7 +44,7 @@ $received->setBodies(array(
|
||||||
));
|
));
|
||||||
|
|
||||||
$attachments = array();
|
$attachments = array();
|
||||||
foreach ($received->getAttachments() as $attachment) {
|
foreach ($parser->getAttachments() as $attachment) {
|
||||||
$file = PhabricatorFile::newFromFileData(
|
$file = PhabricatorFile::newFromFileData(
|
||||||
$attachment->getContent(),
|
$attachment->getContent(),
|
||||||
array(
|
array(
|
||||||
|
|
|
@ -64,6 +64,24 @@ class ManiphestReplyHandler extends PhabricatorMailReplyHandler {
|
||||||
$command = $matches[1];
|
$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;
|
$ttype = ManiphestTransactionType::TYPE_NONE;
|
||||||
$new_value = null;
|
$new_value = null;
|
||||||
switch ($command) {
|
switch ($command) {
|
||||||
|
@ -93,8 +111,10 @@ class ManiphestReplyHandler extends PhabricatorMailReplyHandler {
|
||||||
$xaction->setNewValue($new_value);
|
$xaction->setNewValue($new_value);
|
||||||
$xaction->setComments($body);
|
$xaction->setComments($body);
|
||||||
|
|
||||||
|
$xactions[] = $xaction;
|
||||||
|
|
||||||
$editor = new ManiphestTransactionEditor();
|
$editor = new ManiphestTransactionEditor();
|
||||||
$editor->applyTransactions($task, array($xaction));
|
$editor->applyTransactions($task, $xactions);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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/editor/transaction');
|
||||||
phutil_require_module('phabricator', 'applications/maniphest/storage/transaction');
|
phutil_require_module('phabricator', 'applications/maniphest/storage/transaction');
|
||||||
phutil_require_module('phabricator', 'applications/metamta/replyhandler/base');
|
phutil_require_module('phabricator', 'applications/metamta/replyhandler/base');
|
||||||
|
phutil_require_module('phabricator', 'applications/phid/constants');
|
||||||
phutil_require_module('phabricator', 'infrastructure/env');
|
phutil_require_module('phabricator', 'infrastructure/env');
|
||||||
|
|
||||||
phutil_require_module('phutil', 'utils');
|
phutil_require_module('phutil', 'utils');
|
||||||
|
|
Loading…
Reference in a new issue