mirror of
https://we.phorge.it/source/phorge.git
synced 2025-02-17 09:18:44 +01:00
Drafts are saved as inline comments for images when user comments mock
Summary: Drafts are saved as inline comments for images when user comments mock. Test Plan: Verified that drafts receive transactionphid when user comments mock. Reviewers: epriestley Reviewed By: epriestley CC: aran, Korvin Maniphest Tasks: T2446 Differential Revision: https://secure.phabricator.com/D4850
This commit is contained in:
parent
431e2bee6e
commit
3ce3f5d368
4 changed files with 32 additions and 2 deletions
|
@ -4,5 +4,6 @@ final class PholioTransactionType extends PholioConstants {
|
|||
|
||||
const TYPE_NAME = 'name';
|
||||
const TYPE_DESCRIPTION = 'description';
|
||||
const TYPE_INLINE = 'inline';
|
||||
|
||||
}
|
||||
|
|
|
@ -22,6 +22,7 @@ final class PholioMockCommentController extends PholioController {
|
|||
$mock = id(new PholioMockQuery())
|
||||
->setViewer($user)
|
||||
->withIDs(array($this->id))
|
||||
->needImages(true)
|
||||
->executeOne();
|
||||
|
||||
if (!$mock) {
|
||||
|
@ -49,6 +50,18 @@ final class PholioMockCommentController extends PholioController {
|
|||
id(new PholioTransactionComment())
|
||||
->setContent($comment));
|
||||
|
||||
$inlineComments = id(new PholioTransactionComment())->loadAllWhere(
|
||||
'authorphid = %s AND transactionphid IS NULL AND imageid IN (%Ld)',
|
||||
$user->getPHID(),
|
||||
mpull($mock->getImages(), 'getID')
|
||||
);
|
||||
|
||||
foreach ($inlineComments as $inlineComment) {
|
||||
$xactions[] = id(new PholioTransaction())
|
||||
->setTransactionType(PholioTransactionType::TYPE_INLINE)
|
||||
->attachComment($inlineComment);
|
||||
}
|
||||
|
||||
$editor = id(new PholioMockEditor())
|
||||
->setActor($user)
|
||||
->setContentSource($content_source)
|
||||
|
|
|
@ -14,6 +14,7 @@ final class PholioMockEditor extends PhabricatorApplicationTransactionEditor {
|
|||
|
||||
$types[] = PholioTransactionType::TYPE_NAME;
|
||||
$types[] = PholioTransactionType::TYPE_DESCRIPTION;
|
||||
$types[] = PholioTransactionType::TYPE_INLINE;
|
||||
return $types;
|
||||
}
|
||||
|
||||
|
@ -40,6 +41,18 @@ final class PholioMockEditor extends PhabricatorApplicationTransactionEditor {
|
|||
}
|
||||
}
|
||||
|
||||
protected function transactionHasEffect(
|
||||
PhabricatorLiskDAO $object,
|
||||
PhabricatorApplicationTransaction $xaction) {
|
||||
|
||||
switch ($xaction->getTransactionType()) {
|
||||
case PholioTransactionType::TYPE_INLINE:
|
||||
return true;
|
||||
}
|
||||
|
||||
return parent::transactionHasEffect($object, $xaction);
|
||||
}
|
||||
|
||||
protected function applyCustomInternalTransaction(
|
||||
PhabricatorLiskDAO $object,
|
||||
PhabricatorApplicationTransaction $xaction) {
|
||||
|
|
|
@ -75,9 +75,12 @@ final class PhabricatorApplicationTransactionCommentEditor
|
|||
"Transaction must have a PHID before calling applyEdit()!");
|
||||
}
|
||||
|
||||
if ($comment->getPHID()) {
|
||||
throw new Exception(
|
||||
$type_comment = PhabricatorTransactions::TYPE_COMMENT;
|
||||
if ($xaction->getTransactionType() == $type_comment) {
|
||||
if ($comment->getPHID()) {
|
||||
throw new Exception(
|
||||
"Transaction comment must not yet have a PHID!");
|
||||
}
|
||||
}
|
||||
|
||||
if (!$this->getContentSource()) {
|
||||
|
|
Loading…
Add table
Reference in a new issue