Add very basic scaffolding for Pholio
Summary:
I'm not going to land this until it's a bit more fleshed out since it would just confuse users, but this is probably more reviewable as a few diffs adding a couple features than one ULTRA-diff adding everything. Implement application basics for Pholio. This does more or less nothing, but adds storage, subscribe, flag, markup, indexing, query basics, PHIDs, handle loads, a couple of realy really basic controllers, etc.
Basic hierarchy is:
- **Moleskine**: Top-level object like a Differential Revision, like "Ponder Feed Ideas".
- **Image**: Each Moleskine has one or more images, like the unexpanded / expanded / mobile / empty states of feed.
- **Transaction**: Comment or edit, like Maniphest. I generally want to move most apps to a transaction model so we can log edits.
- **PixelComment**: Equivalent of an inline comment.
Test Plan: Created a fake object and viewed it.
Reviewers: btrahan, chad
Reviewed By: btrahan
CC: aran, davidreuss
Maniphest Tasks: T2097
Differential Revision: https://secure.phabricator.com/D3817
2012-11-22 02:22:36 +01:00
|
|
|
<?php
|
|
|
|
|
2012-12-11 22:59:20 +01:00
|
|
|
final class PholioMockEditor extends PhabricatorApplicationTransactionEditor {
|
Add very basic scaffolding for Pholio
Summary:
I'm not going to land this until it's a bit more fleshed out since it would just confuse users, but this is probably more reviewable as a few diffs adding a couple features than one ULTRA-diff adding everything. Implement application basics for Pholio. This does more or less nothing, but adds storage, subscribe, flag, markup, indexing, query basics, PHIDs, handle loads, a couple of realy really basic controllers, etc.
Basic hierarchy is:
- **Moleskine**: Top-level object like a Differential Revision, like "Ponder Feed Ideas".
- **Image**: Each Moleskine has one or more images, like the unexpanded / expanded / mobile / empty states of feed.
- **Transaction**: Comment or edit, like Maniphest. I generally want to move most apps to a transaction model so we can log edits.
- **PixelComment**: Equivalent of an inline comment.
Test Plan: Created a fake object and viewed it.
Reviewers: btrahan, chad
Reviewed By: btrahan
CC: aran, davidreuss
Maniphest Tasks: T2097
Differential Revision: https://secure.phabricator.com/D3817
2012-11-22 02:22:36 +01:00
|
|
|
|
2013-07-16 22:31:20 +02:00
|
|
|
private $newImages = array();
|
2014-08-12 21:28:41 +02:00
|
|
|
|
|
|
|
public function getEditorApplicationClass() {
|
|
|
|
return 'PhabricatorPholioApplication';
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getEditorObjectsDescription() {
|
|
|
|
return pht('Pholio Mocks');
|
|
|
|
}
|
|
|
|
|
2013-07-16 22:31:20 +02:00
|
|
|
private function setNewImages(array $new_images) {
|
|
|
|
assert_instances_of($new_images, 'PholioImage');
|
|
|
|
$this->newImages = $new_images;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
private function getNewImages() {
|
|
|
|
return $this->newImages;
|
|
|
|
}
|
|
|
|
|
2012-12-11 22:59:20 +01:00
|
|
|
public function getTransactionTypes() {
|
|
|
|
$types = parent::getTransactionTypes();
|
Add very basic scaffolding for Pholio
Summary:
I'm not going to land this until it's a bit more fleshed out since it would just confuse users, but this is probably more reviewable as a few diffs adding a couple features than one ULTRA-diff adding everything. Implement application basics for Pholio. This does more or less nothing, but adds storage, subscribe, flag, markup, indexing, query basics, PHIDs, handle loads, a couple of realy really basic controllers, etc.
Basic hierarchy is:
- **Moleskine**: Top-level object like a Differential Revision, like "Ponder Feed Ideas".
- **Image**: Each Moleskine has one or more images, like the unexpanded / expanded / mobile / empty states of feed.
- **Transaction**: Comment or edit, like Maniphest. I generally want to move most apps to a transaction model so we can log edits.
- **PixelComment**: Equivalent of an inline comment.
Test Plan: Created a fake object and viewed it.
Reviewers: btrahan, chad
Reviewed By: btrahan
CC: aran, davidreuss
Maniphest Tasks: T2097
Differential Revision: https://secure.phabricator.com/D3817
2012-11-22 02:22:36 +01:00
|
|
|
|
2013-07-20 00:59:29 +02:00
|
|
|
$types[] = PhabricatorTransactions::TYPE_EDGE;
|
2013-01-02 03:14:41 +01:00
|
|
|
$types[] = PhabricatorTransactions::TYPE_COMMENT;
|
2012-12-11 22:59:20 +01:00
|
|
|
$types[] = PhabricatorTransactions::TYPE_VIEW_POLICY;
|
|
|
|
$types[] = PhabricatorTransactions::TYPE_EDIT_POLICY;
|
2012-11-22 02:27:44 +01:00
|
|
|
|
2015-06-08 01:54:53 +02:00
|
|
|
$types[] = PholioTransaction::TYPE_INLINE;
|
2013-07-16 22:31:20 +02:00
|
|
|
|
2015-06-08 01:54:53 +02:00
|
|
|
$types[] = PholioTransaction::TYPE_IMAGE_FILE;
|
|
|
|
$types[] = PholioTransaction::TYPE_IMAGE_REPLACE;
|
|
|
|
$types[] = PholioTransaction::TYPE_IMAGE_SEQUENCE;
|
2013-07-16 22:31:20 +02:00
|
|
|
|
2012-12-11 22:59:20 +01:00
|
|
|
return $types;
|
2012-11-22 02:27:44 +01:00
|
|
|
}
|
|
|
|
|
2012-12-11 22:59:20 +01:00
|
|
|
protected function getCustomTransactionOldValue(
|
|
|
|
PhabricatorLiskDAO $object,
|
|
|
|
PhabricatorApplicationTransaction $xaction) {
|
2012-11-22 02:38:57 +01:00
|
|
|
|
2012-12-11 22:59:20 +01:00
|
|
|
switch ($xaction->getTransactionType()) {
|
2015-06-08 01:54:53 +02:00
|
|
|
case PholioTransaction::TYPE_IMAGE_FILE:
|
2013-07-16 22:31:20 +02:00
|
|
|
$images = $object->getImages();
|
|
|
|
return mpull($images, 'getPHID');
|
2015-06-08 01:54:53 +02:00
|
|
|
case PholioTransaction::TYPE_IMAGE_REPLACE:
|
2013-07-26 01:59:25 +02:00
|
|
|
$raw = $xaction->getNewValue();
|
|
|
|
return $raw->getReplacesImagePHID();
|
2015-06-08 01:54:53 +02:00
|
|
|
case PholioTransaction::TYPE_IMAGE_SEQUENCE:
|
2013-08-12 22:09:07 +02:00
|
|
|
$sequence = null;
|
|
|
|
$phid = null;
|
|
|
|
$image = $this->getImageForXaction($object, $xaction);
|
|
|
|
if ($image) {
|
|
|
|
$sequence = $image->getSequence();
|
|
|
|
$phid = $image->getPHID();
|
|
|
|
}
|
|
|
|
return array($phid => $sequence);
|
2012-11-22 02:38:57 +01:00
|
|
|
}
|
2012-12-11 22:59:20 +01:00
|
|
|
}
|
2012-11-22 02:38:57 +01:00
|
|
|
|
2012-12-11 22:59:20 +01:00
|
|
|
protected function getCustomTransactionNewValue(
|
|
|
|
PhabricatorLiskDAO $object,
|
|
|
|
PhabricatorApplicationTransaction $xaction) {
|
2012-11-22 02:27:44 +01:00
|
|
|
|
2012-12-11 22:59:20 +01:00
|
|
|
switch ($xaction->getTransactionType()) {
|
2015-06-08 01:54:53 +02:00
|
|
|
case PholioTransaction::TYPE_IMAGE_SEQUENCE:
|
2012-12-11 22:59:20 +01:00
|
|
|
return $xaction->getNewValue();
|
2015-06-08 01:54:53 +02:00
|
|
|
case PholioTransaction::TYPE_IMAGE_REPLACE:
|
2013-07-26 01:59:25 +02:00
|
|
|
$raw = $xaction->getNewValue();
|
|
|
|
return $raw->getPHID();
|
2015-06-08 01:54:53 +02:00
|
|
|
case PholioTransaction::TYPE_IMAGE_FILE:
|
2013-07-16 22:31:20 +02:00
|
|
|
$raw_new_value = $xaction->getNewValue();
|
|
|
|
$new_value = array();
|
|
|
|
foreach ($raw_new_value as $key => $images) {
|
|
|
|
$new_value[$key] = mpull($images, 'getPHID');
|
|
|
|
}
|
|
|
|
$xaction->setNewValue($new_value);
|
|
|
|
return $this->getPHIDTransactionNewValue($xaction);
|
2012-11-22 02:27:44 +01:00
|
|
|
}
|
2012-12-11 22:59:20 +01:00
|
|
|
}
|
2012-11-22 02:27:44 +01:00
|
|
|
|
2013-10-07 02:07:55 +02:00
|
|
|
protected function extractFilePHIDsFromCustomTransaction(
|
|
|
|
PhabricatorLiskDAO $object,
|
|
|
|
PhabricatorApplicationTransaction $xaction) {
|
|
|
|
|
Extract PHIDs from transactions later, fixing Paste extraction/attachment
Summary:
Fixes T9787. Currently, file PHID extraction logic happens very early, before we normalize/merge/etc the transactions.
In D14390, I changed how the CONTENT transaction works: before, callers would pass in a file PHID. Afterward, they just pass in the content.
Passing in the content is generaly easier and feels more correct, but inadvertenly broke PHID extraction because converting the content into a file PHID now happened after we extracted the PHID. So we'd extract the entire text of the paste as a "file PHID", which wouldn't work.
Instead, extract file PHIDs later. This impacts a couple of other applications (Conpherence, Pholio) which receive an object or have an unusual file-oriented transaction.
Test Plan:
- Made a new paste, verified the raw file attached to it properly.
- Made and updated a mock, verified all the files attached properly.
- Updated a Conpherence room image, verified the files attached properly.
Reviewers: chad
Reviewed By: chad
Maniphest Tasks: T9787
Differential Revision: https://secure.phabricator.com/D14494
2015-11-16 18:53:08 +01:00
|
|
|
$images = $this->getNewImages();
|
|
|
|
$images = mpull($images, null, 'getPHID');
|
|
|
|
|
2013-10-07 02:07:55 +02:00
|
|
|
switch ($xaction->getTransactionType()) {
|
2015-06-08 01:54:53 +02:00
|
|
|
case PholioTransaction::TYPE_IMAGE_FILE:
|
Extract PHIDs from transactions later, fixing Paste extraction/attachment
Summary:
Fixes T9787. Currently, file PHID extraction logic happens very early, before we normalize/merge/etc the transactions.
In D14390, I changed how the CONTENT transaction works: before, callers would pass in a file PHID. Afterward, they just pass in the content.
Passing in the content is generaly easier and feels more correct, but inadvertenly broke PHID extraction because converting the content into a file PHID now happened after we extracted the PHID. So we'd extract the entire text of the paste as a "file PHID", which wouldn't work.
Instead, extract file PHIDs later. This impacts a couple of other applications (Conpherence, Pholio) which receive an object or have an unusual file-oriented transaction.
Test Plan:
- Made a new paste, verified the raw file attached to it properly.
- Made and updated a mock, verified all the files attached properly.
- Updated a Conpherence room image, verified the files attached properly.
Reviewers: chad
Reviewed By: chad
Maniphest Tasks: T9787
Differential Revision: https://secure.phabricator.com/D14494
2015-11-16 18:53:08 +01:00
|
|
|
$file_phids = array();
|
|
|
|
foreach ($xaction->getNewValue() as $image_phid) {
|
|
|
|
$image = idx($images, $image_phid);
|
|
|
|
if (!$image) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
$file_phids[] = $image->getFilePHID();
|
2013-10-07 02:07:55 +02:00
|
|
|
}
|
Extract PHIDs from transactions later, fixing Paste extraction/attachment
Summary:
Fixes T9787. Currently, file PHID extraction logic happens very early, before we normalize/merge/etc the transactions.
In D14390, I changed how the CONTENT transaction works: before, callers would pass in a file PHID. Afterward, they just pass in the content.
Passing in the content is generaly easier and feels more correct, but inadvertenly broke PHID extraction because converting the content into a file PHID now happened after we extracted the PHID. So we'd extract the entire text of the paste as a "file PHID", which wouldn't work.
Instead, extract file PHIDs later. This impacts a couple of other applications (Conpherence, Pholio) which receive an object or have an unusual file-oriented transaction.
Test Plan:
- Made a new paste, verified the raw file attached to it properly.
- Made and updated a mock, verified all the files attached properly.
- Updated a Conpherence room image, verified the files attached properly.
Reviewers: chad
Reviewed By: chad
Maniphest Tasks: T9787
Differential Revision: https://secure.phabricator.com/D14494
2015-11-16 18:53:08 +01:00
|
|
|
return $file_phids;
|
2015-06-08 01:54:53 +02:00
|
|
|
case PholioTransaction::TYPE_IMAGE_REPLACE:
|
Extract PHIDs from transactions later, fixing Paste extraction/attachment
Summary:
Fixes T9787. Currently, file PHID extraction logic happens very early, before we normalize/merge/etc the transactions.
In D14390, I changed how the CONTENT transaction works: before, callers would pass in a file PHID. Afterward, they just pass in the content.
Passing in the content is generaly easier and feels more correct, but inadvertenly broke PHID extraction because converting the content into a file PHID now happened after we extracted the PHID. So we'd extract the entire text of the paste as a "file PHID", which wouldn't work.
Instead, extract file PHIDs later. This impacts a couple of other applications (Conpherence, Pholio) which receive an object or have an unusual file-oriented transaction.
Test Plan:
- Made a new paste, verified the raw file attached to it properly.
- Made and updated a mock, verified all the files attached properly.
- Updated a Conpherence room image, verified the files attached properly.
Reviewers: chad
Reviewed By: chad
Maniphest Tasks: T9787
Differential Revision: https://secure.phabricator.com/D14494
2015-11-16 18:53:08 +01:00
|
|
|
$image_phid = $xaction->getNewValue();
|
|
|
|
$image = idx($images, $image_phid);
|
|
|
|
|
|
|
|
if ($image) {
|
|
|
|
return array($image->getFilePHID());
|
|
|
|
}
|
|
|
|
break;
|
2013-10-07 02:07:55 +02:00
|
|
|
}
|
|
|
|
|
Extract PHIDs from transactions later, fixing Paste extraction/attachment
Summary:
Fixes T9787. Currently, file PHID extraction logic happens very early, before we normalize/merge/etc the transactions.
In D14390, I changed how the CONTENT transaction works: before, callers would pass in a file PHID. Afterward, they just pass in the content.
Passing in the content is generaly easier and feels more correct, but inadvertenly broke PHID extraction because converting the content into a file PHID now happened after we extracted the PHID. So we'd extract the entire text of the paste as a "file PHID", which wouldn't work.
Instead, extract file PHIDs later. This impacts a couple of other applications (Conpherence, Pholio) which receive an object or have an unusual file-oriented transaction.
Test Plan:
- Made a new paste, verified the raw file attached to it properly.
- Made and updated a mock, verified all the files attached properly.
- Updated a Conpherence room image, verified the files attached properly.
Reviewers: chad
Reviewed By: chad
Maniphest Tasks: T9787
Differential Revision: https://secure.phabricator.com/D14494
2015-11-16 18:53:08 +01:00
|
|
|
return parent::extractFilePHIDsFromCustomTransaction($object, $xaction);
|
2013-10-07 02:07:55 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-02-07 17:02:52 +01:00
|
|
|
protected function transactionHasEffect(
|
|
|
|
PhabricatorLiskDAO $object,
|
|
|
|
PhabricatorApplicationTransaction $xaction) {
|
|
|
|
|
|
|
|
switch ($xaction->getTransactionType()) {
|
2015-06-08 01:54:53 +02:00
|
|
|
case PholioTransaction::TYPE_INLINE:
|
2013-02-07 17:02:52 +01:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return parent::transactionHasEffect($object, $xaction);
|
|
|
|
}
|
|
|
|
|
2013-07-16 22:31:20 +02:00
|
|
|
protected function shouldApplyInitialEffects(
|
|
|
|
PhabricatorLiskDAO $object,
|
|
|
|
array $xactions) {
|
|
|
|
|
|
|
|
foreach ($xactions as $xaction) {
|
|
|
|
switch ($xaction->getTransactionType()) {
|
2015-06-08 01:54:53 +02:00
|
|
|
case PholioTransaction::TYPE_IMAGE_FILE:
|
|
|
|
case PholioTransaction::TYPE_IMAGE_REPLACE:
|
2013-07-16 22:31:20 +02:00
|
|
|
return true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
protected function applyInitialEffects(
|
|
|
|
PhabricatorLiskDAO $object,
|
|
|
|
array $xactions) {
|
|
|
|
|
|
|
|
$new_images = array();
|
|
|
|
foreach ($xactions as $xaction) {
|
|
|
|
switch ($xaction->getTransactionType()) {
|
2015-06-08 01:54:53 +02:00
|
|
|
case PholioTransaction::TYPE_IMAGE_FILE:
|
2013-07-16 22:31:20 +02:00
|
|
|
$new_value = $xaction->getNewValue();
|
|
|
|
foreach ($new_value as $key => $txn_images) {
|
|
|
|
if ($key != '+') {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
foreach ($txn_images as $image) {
|
|
|
|
$image->save();
|
|
|
|
$new_images[] = $image;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
2015-06-08 01:54:53 +02:00
|
|
|
case PholioTransaction::TYPE_IMAGE_REPLACE:
|
2013-07-26 01:59:25 +02:00
|
|
|
$image = $xaction->getNewValue();
|
|
|
|
$image->save();
|
|
|
|
$new_images[] = $image;
|
|
|
|
break;
|
2013-07-16 22:31:20 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
$this->setNewImages($new_images);
|
|
|
|
}
|
|
|
|
|
|
|
|
private function getImageForXaction(
|
|
|
|
PholioMock $mock,
|
|
|
|
PhabricatorApplicationTransaction $xaction) {
|
|
|
|
$raw_new_value = $xaction->getNewValue();
|
|
|
|
$image_phid = key($raw_new_value);
|
|
|
|
$images = $mock->getImages();
|
|
|
|
foreach ($images as $image) {
|
|
|
|
if ($image->getPHID() == $image_phid) {
|
|
|
|
return $image;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2017-05-15 22:22:05 +02:00
|
|
|
protected function applyCustomInternalTransaction(
|
|
|
|
PhabricatorLiskDAO $object,
|
|
|
|
PhabricatorApplicationTransaction $xaction) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-12-11 22:59:20 +01:00
|
|
|
protected function applyCustomExternalTransaction(
|
|
|
|
PhabricatorLiskDAO $object,
|
|
|
|
PhabricatorApplicationTransaction $xaction) {
|
2013-07-16 22:31:20 +02:00
|
|
|
|
|
|
|
switch ($xaction->getTransactionType()) {
|
2015-06-08 01:54:53 +02:00
|
|
|
case PholioTransaction::TYPE_IMAGE_FILE:
|
2013-07-16 22:31:20 +02:00
|
|
|
$old_map = array_fuse($xaction->getOldValue());
|
|
|
|
$new_map = array_fuse($xaction->getNewValue());
|
|
|
|
|
|
|
|
$obsolete_map = array_diff_key($old_map, $new_map);
|
|
|
|
$images = $object->getImages();
|
|
|
|
foreach ($images as $seq => $image) {
|
|
|
|
if (isset($obsolete_map[$image->getPHID()])) {
|
|
|
|
$image->setIsObsolete(1);
|
|
|
|
$image->save();
|
|
|
|
unset($images[$seq]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$object->attachImages($images);
|
|
|
|
break;
|
2015-06-08 01:54:53 +02:00
|
|
|
case PholioTransaction::TYPE_IMAGE_REPLACE:
|
2013-07-26 01:59:25 +02:00
|
|
|
$old = $xaction->getOldValue();
|
|
|
|
$images = $object->getImages();
|
|
|
|
foreach ($images as $seq => $image) {
|
|
|
|
if ($image->getPHID() == $old) {
|
|
|
|
$image->setIsObsolete(1);
|
|
|
|
$image->save();
|
|
|
|
unset($images[$seq]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$object->attachImages($images);
|
|
|
|
break;
|
2015-06-08 01:54:53 +02:00
|
|
|
case PholioTransaction::TYPE_IMAGE_SEQUENCE:
|
2013-08-12 22:09:07 +02:00
|
|
|
$image = $this->getImageForXaction($object, $xaction);
|
2015-05-19 23:06:07 +02:00
|
|
|
$value = (int)head($xaction->getNewValue());
|
2013-08-12 22:09:07 +02:00
|
|
|
$image->setSequence($value);
|
|
|
|
$image->save();
|
|
|
|
break;
|
2013-07-16 22:31:20 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
protected function applyFinalEffects(
|
|
|
|
PhabricatorLiskDAO $object,
|
|
|
|
array $xactions) {
|
|
|
|
|
|
|
|
$images = $this->getNewImages();
|
|
|
|
foreach ($images as $image) {
|
|
|
|
$image->setMockID($object->getID());
|
|
|
|
$image->save();
|
|
|
|
}
|
Update overall revision status after reviewers change
Summary:
Ref T2222. This doesn't feel super clean, but doesn't feel too bad either.
Basically, Differential transactions can have secondary state-based effects (changing the overall revision status) when reviewers resign, are removed, accept, or reject revisions.
To deal with this in ApplicationTransactions, I did this:
- `applyFinalEffects()` can now alter the transaction set (notably, add new ones). This mostly matters for email, notifications and feed.
- In Differential, check for an overall revision state transition in `applyFinalEffects()` (e.g., your reject moving the revision to a rejected state).
- I'm only writing the transaction if the transition is implied and indirect.
- For example, if you "Plan Changes", that action changes the state on its own so there's no implicit state change transaction added.
The transactions themselves are kind of fluff, but it seems useful to keep a record of when state changes occurred in the transaction log. If people complain we can hide/remove them.
Test Plan: {F118143}
Reviewers: btrahan
Reviewed By: btrahan
CC: aran
Maniphest Tasks: T2222
Differential Revision: https://secure.phabricator.com/D8339
2014-02-25 21:36:49 +01:00
|
|
|
|
|
|
|
return $xactions;
|
2012-12-11 22:59:20 +01:00
|
|
|
}
|
2012-11-22 02:27:44 +01:00
|
|
|
|
2012-12-11 22:59:20 +01:00
|
|
|
protected function mergeTransactions(
|
|
|
|
PhabricatorApplicationTransaction $u,
|
|
|
|
PhabricatorApplicationTransaction $v) {
|
2012-11-22 02:39:46 +01:00
|
|
|
|
2012-12-11 22:59:20 +01:00
|
|
|
$type = $u->getTransactionType();
|
|
|
|
switch ($type) {
|
2015-06-08 01:54:53 +02:00
|
|
|
case PholioTransaction::TYPE_IMAGE_REPLACE:
|
2013-11-09 02:13:36 +01:00
|
|
|
$u_img = $u->getNewValue();
|
|
|
|
$v_img = $v->getNewValue();
|
|
|
|
if ($u_img->getReplacesImagePHID() == $v_img->getReplacesImagePHID()) {
|
2013-07-26 01:59:25 +02:00
|
|
|
return $v;
|
|
|
|
}
|
2013-11-09 02:13:36 +01:00
|
|
|
break;
|
2015-06-08 01:54:53 +02:00
|
|
|
case PholioTransaction::TYPE_IMAGE_FILE:
|
2013-07-16 22:31:20 +02:00
|
|
|
return $this->mergePHIDOrEdgeTransactions($u, $v);
|
2015-06-08 01:54:53 +02:00
|
|
|
case PholioTransaction::TYPE_IMAGE_SEQUENCE:
|
2013-07-16 22:31:20 +02:00
|
|
|
$raw_new_value_u = $u->getNewValue();
|
|
|
|
$raw_new_value_v = $v->getNewValue();
|
|
|
|
$phid_u = key($raw_new_value_u);
|
|
|
|
$phid_v = key($raw_new_value_v);
|
|
|
|
if ($phid_u == $phid_v) {
|
|
|
|
return $v;
|
|
|
|
}
|
|
|
|
break;
|
2012-12-11 22:59:20 +01:00
|
|
|
}
|
2012-11-22 02:27:44 +01:00
|
|
|
|
2012-12-11 22:59:20 +01:00
|
|
|
return parent::mergeTransactions($u, $v);
|
2012-11-22 02:27:44 +01:00
|
|
|
}
|
|
|
|
|
2013-09-14 00:08:17 +02:00
|
|
|
protected function shouldSendMail(
|
|
|
|
PhabricatorLiskDAO $object,
|
|
|
|
array $xactions) {
|
2012-12-11 23:00:07 +01:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
protected function buildReplyHandler(PhabricatorLiskDAO $object) {
|
|
|
|
return id(new PholioReplyHandler())
|
|
|
|
->setMailReceiver($object);
|
|
|
|
}
|
2012-12-11 22:59:20 +01:00
|
|
|
|
2012-12-11 23:00:07 +01:00
|
|
|
protected function buildMailTemplate(PhabricatorLiskDAO $object) {
|
|
|
|
$id = $object->getID();
|
|
|
|
$name = $object->getName();
|
|
|
|
$original_name = $object->getOriginalName();
|
2012-11-22 02:39:46 +01:00
|
|
|
|
2012-12-11 23:00:07 +01:00
|
|
|
return id(new PhabricatorMetaMTAMail())
|
|
|
|
->setSubject("M{$id}: {$name}")
|
|
|
|
->addHeader('Thread-Topic', "M{$id}: {$original_name}");
|
|
|
|
}
|
2012-11-22 02:39:46 +01:00
|
|
|
|
2012-12-11 23:00:07 +01:00
|
|
|
protected function getMailTo(PhabricatorLiskDAO $object) {
|
|
|
|
return array(
|
|
|
|
$object->getAuthorPHID(),
|
2012-11-22 02:39:46 +01:00
|
|
|
$this->requireActor()->getPHID(),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2012-12-11 23:00:07 +01:00
|
|
|
protected function buildMailBody(
|
|
|
|
PhabricatorLiskDAO $object,
|
|
|
|
array $xactions) {
|
2012-11-22 02:39:46 +01:00
|
|
|
|
2013-06-21 02:13:48 +02:00
|
|
|
$body = new PhabricatorMetaMTAMailBody();
|
|
|
|
$headers = array();
|
|
|
|
$comments = array();
|
|
|
|
$inline_comments = array();
|
|
|
|
|
|
|
|
foreach ($xactions as $xaction) {
|
2013-07-16 22:31:20 +02:00
|
|
|
if ($xaction->shouldHide()) {
|
|
|
|
continue;
|
|
|
|
}
|
2013-06-21 02:13:48 +02:00
|
|
|
$comment = $xaction->getComment();
|
|
|
|
switch ($xaction->getTransactionType()) {
|
2015-06-08 01:54:53 +02:00
|
|
|
case PholioTransaction::TYPE_INLINE:
|
2013-06-21 02:13:48 +02:00
|
|
|
if ($comment && strlen($comment->getContent())) {
|
|
|
|
$inline_comments[] = $comment;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case PhabricatorTransactions::TYPE_COMMENT:
|
|
|
|
if ($comment && strlen($comment->getContent())) {
|
|
|
|
$comments[] = $comment->getContent();
|
|
|
|
}
|
|
|
|
// fallthrough
|
|
|
|
default:
|
|
|
|
$headers[] = id(clone $xaction)
|
|
|
|
->setRenderingTarget('text')
|
|
|
|
->getTitle();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
$body->addRawSection(implode("\n", $headers));
|
|
|
|
|
|
|
|
foreach ($comments as $comment) {
|
|
|
|
$body->addRawSection($comment);
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($inline_comments) {
|
|
|
|
$body->addRawSection(pht('INLINE COMMENTS'));
|
|
|
|
foreach ($inline_comments as $comment) {
|
|
|
|
$text = pht(
|
|
|
|
'Image %d: %s',
|
|
|
|
$comment->getImageID(),
|
|
|
|
$comment->getContent());
|
|
|
|
$body->addRawSection($text);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-10-30 23:24:10 +01:00
|
|
|
$body->addLinkSection(
|
2012-12-11 23:00:07 +01:00
|
|
|
pht('MOCK DETAIL'),
|
|
|
|
PhabricatorEnv::getProductionURI('/M'.$object->getID()));
|
2012-11-22 02:39:46 +01:00
|
|
|
|
2012-12-11 23:00:07 +01:00
|
|
|
return $body;
|
2012-11-22 02:39:46 +01:00
|
|
|
}
|
|
|
|
|
2012-12-11 23:00:07 +01:00
|
|
|
protected function getMailSubjectPrefix() {
|
2012-11-22 02:39:46 +01:00
|
|
|
return PhabricatorEnv::getEnvConfig('metamta.pholio.subject-prefix');
|
|
|
|
}
|
|
|
|
|
2014-08-12 21:28:41 +02:00
|
|
|
public function getMailTagsMap() {
|
|
|
|
return array(
|
2015-06-08 01:54:53 +02:00
|
|
|
PholioTransaction::MAILTAG_STATUS =>
|
2014-08-12 21:28:41 +02:00
|
|
|
pht("A mock's status changes."),
|
2015-06-08 01:54:53 +02:00
|
|
|
PholioTransaction::MAILTAG_COMMENT =>
|
2014-08-12 21:28:41 +02:00
|
|
|
pht('Someone comments on a mock.'),
|
2015-06-08 01:54:53 +02:00
|
|
|
PholioTransaction::MAILTAG_UPDATED =>
|
2014-08-12 21:28:41 +02:00
|
|
|
pht('Mock images or descriptions change.'),
|
2015-06-08 01:54:53 +02:00
|
|
|
PholioTransaction::MAILTAG_OTHER =>
|
2014-08-12 21:28:41 +02:00
|
|
|
pht('Other mock activity not listed above occurs.'),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2014-03-05 02:01:33 +01:00
|
|
|
protected function shouldPublishFeedStory(
|
|
|
|
PhabricatorLiskDAO $object,
|
|
|
|
array $xactions) {
|
2012-12-11 23:00:21 +01:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2012-12-21 23:21:50 +01:00
|
|
|
protected function supportsSearch() {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2014-03-05 21:06:59 +01:00
|
|
|
protected function shouldApplyHeraldRules(
|
|
|
|
PhabricatorLiskDAO $object,
|
|
|
|
array $xactions) {
|
2013-08-15 22:10:45 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
protected function buildHeraldAdapter(
|
|
|
|
PhabricatorLiskDAO $object,
|
|
|
|
array $xactions) {
|
|
|
|
|
|
|
|
return id(new HeraldPholioMockAdapter())
|
|
|
|
->setMock($object);
|
|
|
|
}
|
|
|
|
|
2013-02-25 15:19:03 +01:00
|
|
|
protected function sortTransactions(array $xactions) {
|
|
|
|
$head = array();
|
|
|
|
$tail = array();
|
|
|
|
|
2013-06-05 00:28:24 +02:00
|
|
|
// Move inline comments to the end, so the comments precede them.
|
2013-02-25 15:19:03 +01:00
|
|
|
foreach ($xactions as $xaction) {
|
|
|
|
$type = $xaction->getTransactionType();
|
2015-06-08 01:54:53 +02:00
|
|
|
if ($type == PholioTransaction::TYPE_INLINE) {
|
2013-02-25 15:19:03 +01:00
|
|
|
$tail[] = $xaction;
|
|
|
|
} else {
|
|
|
|
$head[] = $xaction;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return array_values(array_merge($head, $tail));
|
|
|
|
}
|
|
|
|
|
2013-03-10 02:55:14 +01:00
|
|
|
protected function shouldImplyCC(
|
|
|
|
PhabricatorLiskDAO $object,
|
|
|
|
PhabricatorApplicationTransaction $xaction) {
|
|
|
|
|
|
|
|
switch ($xaction->getTransactionType()) {
|
2015-06-08 01:54:53 +02:00
|
|
|
case PholioTransaction::TYPE_INLINE:
|
2013-03-10 02:55:14 +01:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return parent::shouldImplyCC($object, $xaction);
|
|
|
|
}
|
|
|
|
|
Add very basic scaffolding for Pholio
Summary:
I'm not going to land this until it's a bit more fleshed out since it would just confuse users, but this is probably more reviewable as a few diffs adding a couple features than one ULTRA-diff adding everything. Implement application basics for Pholio. This does more or less nothing, but adds storage, subscribe, flag, markup, indexing, query basics, PHIDs, handle loads, a couple of realy really basic controllers, etc.
Basic hierarchy is:
- **Moleskine**: Top-level object like a Differential Revision, like "Ponder Feed Ideas".
- **Image**: Each Moleskine has one or more images, like the unexpanded / expanded / mobile / empty states of feed.
- **Transaction**: Comment or edit, like Maniphest. I generally want to move most apps to a transaction model so we can log edits.
- **PixelComment**: Equivalent of an inline comment.
Test Plan: Created a fake object and viewed it.
Reviewers: btrahan, chad
Reviewed By: btrahan
CC: aran, davidreuss
Maniphest Tasks: T2097
Differential Revision: https://secure.phabricator.com/D3817
2012-11-22 02:22:36 +01:00
|
|
|
}
|