mirror of
https://we.phorge.it/source/phorge.git
synced 2025-02-21 11:09:02 +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_NAME = 'name';
|
||||||
const TYPE_DESCRIPTION = 'description';
|
const TYPE_DESCRIPTION = 'description';
|
||||||
|
const TYPE_INLINE = 'inline';
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,6 +22,7 @@ final class PholioMockCommentController extends PholioController {
|
||||||
$mock = id(new PholioMockQuery())
|
$mock = id(new PholioMockQuery())
|
||||||
->setViewer($user)
|
->setViewer($user)
|
||||||
->withIDs(array($this->id))
|
->withIDs(array($this->id))
|
||||||
|
->needImages(true)
|
||||||
->executeOne();
|
->executeOne();
|
||||||
|
|
||||||
if (!$mock) {
|
if (!$mock) {
|
||||||
|
@ -49,6 +50,18 @@ final class PholioMockCommentController extends PholioController {
|
||||||
id(new PholioTransactionComment())
|
id(new PholioTransactionComment())
|
||||||
->setContent($comment));
|
->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())
|
$editor = id(new PholioMockEditor())
|
||||||
->setActor($user)
|
->setActor($user)
|
||||||
->setContentSource($content_source)
|
->setContentSource($content_source)
|
||||||
|
|
|
@ -14,6 +14,7 @@ final class PholioMockEditor extends PhabricatorApplicationTransactionEditor {
|
||||||
|
|
||||||
$types[] = PholioTransactionType::TYPE_NAME;
|
$types[] = PholioTransactionType::TYPE_NAME;
|
||||||
$types[] = PholioTransactionType::TYPE_DESCRIPTION;
|
$types[] = PholioTransactionType::TYPE_DESCRIPTION;
|
||||||
|
$types[] = PholioTransactionType::TYPE_INLINE;
|
||||||
return $types;
|
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(
|
protected function applyCustomInternalTransaction(
|
||||||
PhabricatorLiskDAO $object,
|
PhabricatorLiskDAO $object,
|
||||||
PhabricatorApplicationTransaction $xaction) {
|
PhabricatorApplicationTransaction $xaction) {
|
||||||
|
|
|
@ -75,10 +75,13 @@ final class PhabricatorApplicationTransactionCommentEditor
|
||||||
"Transaction must have a PHID before calling applyEdit()!");
|
"Transaction must have a PHID before calling applyEdit()!");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$type_comment = PhabricatorTransactions::TYPE_COMMENT;
|
||||||
|
if ($xaction->getTransactionType() == $type_comment) {
|
||||||
if ($comment->getPHID()) {
|
if ($comment->getPHID()) {
|
||||||
throw new Exception(
|
throw new Exception(
|
||||||
"Transaction comment must not yet have a PHID!");
|
"Transaction comment must not yet have a PHID!");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!$this->getContentSource()) {
|
if (!$this->getContentSource()) {
|
||||||
throw new Exception(
|
throw new Exception(
|
||||||
|
|
Loading…
Add table
Reference in a new issue