1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-10 08:52:39 +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();
$is_draft_mode = ($document->getContent()->getVersion() != $max_version);
$default_view = $document->getViewPolicy();
$default_edit = $document->getEditPolicy();
$default_space = $document->getSpacePHID();
if ($request->isFormPost()) {
if ($is_new) {
$save_as_draft = false;
@ -122,6 +126,11 @@ final class PhrictionEditController
$xactions = array();
if ($is_new) {
$xactions[] = id(new PhrictionTransaction())
->setTransactionType(PhabricatorTransactions::TYPE_CREATE);
}
$xactions[] = id(new PhrictionTransaction())
->setTransactionType(PhrictionDocumentTitleTransaction::TRANSACTIONTYPE)
->setNewValue($title);
@ -130,13 +139,16 @@ final class PhrictionEditController
->setNewValue($content_text);
$xactions[] = id(new PhrictionTransaction())
->setTransactionType(PhabricatorTransactions::TYPE_VIEW_POLICY)
->setNewValue($v_view);
->setNewValue($v_view)
->setIsDefaultTransaction($is_new && ($v_view === $default_view));
$xactions[] = id(new PhrictionTransaction())
->setTransactionType(PhabricatorTransactions::TYPE_EDIT_POLICY)
->setNewValue($v_edit);
->setNewValue($v_edit)
->setIsDefaultTransaction($is_new && ($v_edit === $default_edit));
$xactions[] = id(new PhrictionTransaction())
->setTransactionType(PhabricatorTransactions::TYPE_SPACE)
->setNewValue($v_space);
->setNewValue($v_space)
->setIsDefaultTransaction($is_new && ($v_space === $default_space));
$xactions[] = id(new PhrictionTransaction())
->setTransactionType(PhabricatorTransactions::TYPE_SUBSCRIBERS)
->setNewValue(array('=' => $v_cc));

View file

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