1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-22 23:02:42 +01:00

When creating a Phriction document, mark initial transactions as "create" transactions to fix weird email

Summary:
Ref T13289. When you create a Phriction document, you currently get an email with the whole new content as a "diff".

You also get extra transactions in the email and on the page.

This is because Phriction isn't on EditEngine and doesn't mark "create" transactions in a modern way. Get them marked properly to fix these obviously-broken behaviors. This can all go away once Phriction switches to EditEngine, although I don't have any particular plans to do that in the immediate future.

Test Plan:
  - Created a new document, viewed email, no longer saw redundant "edited content" transaction or "CHANGES TO CONTENT" diff.
  - Updated a document, viewed email, got interdiff.

Reviewers: amckinley

Reviewed By: amckinley

Maniphest Tasks: T13289

Differential Revision: https://secure.phabricator.com/D20548
This commit is contained in:
epriestley 2019-05-22 15:10:19 -07:00
parent b95bf722d5
commit f6af1c4374
2 changed files with 19 additions and 4 deletions

View file

@ -97,6 +97,10 @@ final class PhrictionEditController
$content_text = $content->getContent(); $content_text = $content->getContent();
$is_draft_mode = ($document->getContent()->getVersion() != $max_version); $is_draft_mode = ($document->getContent()->getVersion() != $max_version);
$default_view = $document->getViewPolicy();
$default_edit = $document->getEditPolicy();
$default_space = $document->getSpacePHID();
if ($request->isFormPost()) { if ($request->isFormPost()) {
if ($is_new) { if ($is_new) {
$save_as_draft = false; $save_as_draft = false;
@ -122,6 +126,11 @@ final class PhrictionEditController
$xactions = array(); $xactions = array();
if ($is_new) {
$xactions[] = id(new PhrictionTransaction())
->setTransactionType(PhabricatorTransactions::TYPE_CREATE);
}
$xactions[] = id(new PhrictionTransaction()) $xactions[] = id(new PhrictionTransaction())
->setTransactionType(PhrictionDocumentTitleTransaction::TRANSACTIONTYPE) ->setTransactionType(PhrictionDocumentTitleTransaction::TRANSACTIONTYPE)
->setNewValue($title); ->setNewValue($title);
@ -130,13 +139,16 @@ final class PhrictionEditController
->setNewValue($content_text); ->setNewValue($content_text);
$xactions[] = id(new PhrictionTransaction()) $xactions[] = id(new PhrictionTransaction())
->setTransactionType(PhabricatorTransactions::TYPE_VIEW_POLICY) ->setTransactionType(PhabricatorTransactions::TYPE_VIEW_POLICY)
->setNewValue($v_view); ->setNewValue($v_view)
->setIsDefaultTransaction($is_new && ($v_view === $default_view));
$xactions[] = id(new PhrictionTransaction()) $xactions[] = id(new PhrictionTransaction())
->setTransactionType(PhabricatorTransactions::TYPE_EDIT_POLICY) ->setTransactionType(PhabricatorTransactions::TYPE_EDIT_POLICY)
->setNewValue($v_edit); ->setNewValue($v_edit)
->setIsDefaultTransaction($is_new && ($v_edit === $default_edit));
$xactions[] = id(new PhrictionTransaction()) $xactions[] = id(new PhrictionTransaction())
->setTransactionType(PhabricatorTransactions::TYPE_SPACE) ->setTransactionType(PhabricatorTransactions::TYPE_SPACE)
->setNewValue($v_space); ->setNewValue($v_space)
->setIsDefaultTransaction($is_new && ($v_space === $default_space));
$xactions[] = id(new PhrictionTransaction()) $xactions[] = id(new PhrictionTransaction())
->setTransactionType(PhabricatorTransactions::TYPE_SUBSCRIBERS) ->setTransactionType(PhabricatorTransactions::TYPE_SUBSCRIBERS)
->setNewValue(array('=' => $v_cc)); ->setNewValue(array('=' => $v_cc));

View file

@ -78,10 +78,13 @@ final class PhrictionDocument extends PhrictionDAO
} }
if ($parent_doc) { if ($parent_doc) {
$space_phid = PhabricatorSpacesNamespaceQuery::getObjectSpacePHID(
$parent_doc);
$document $document
->setViewPolicy($parent_doc->getViewPolicy()) ->setViewPolicy($parent_doc->getViewPolicy())
->setEditPolicy($parent_doc->getEditPolicy()) ->setEditPolicy($parent_doc->getEditPolicy())
->setSpacePHID($parent_doc->getSpacePHID()); ->setSpacePHID($space_phid);
} else { } else {
$default_view_policy = PhabricatorPolicies::getMostOpenPolicy(); $default_view_policy = PhabricatorPolicies::getMostOpenPolicy();
$document $document