Skip to content

Commit a7ebfc1

Browse files
author
Chad Little
committed
Modernize Conpherence with Modular Transactions
Summary: Begin converting Conpherence to ModularTransactions, this converts title, topic, and picture to use modular transactions. Participants seems hairy so I'll do that in another diff Test Plan: Create a room with a topic, change room name, topic. Add people, remove people. Set a room image. Unset topic. Reviewers: epriestley Reviewed By: epriestley Subscribers: Korvin Differential Revision: https://secure.phabricator.com/D17668
1 parent a9845b0 commit a7ebfc1

16 files changed

+248
-192
lines changed

resources/celerity/map.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
'names' => array(
1010
'conpherence.pkg.css' => 'b5ee2073',
1111
'conpherence.pkg.js' => '281b1a73',
12-
'core.pkg.css' => '476a4ec7',
12+
'core.pkg.css' => '30a64ed6',
1313
'core.pkg.js' => 'fbc1c380',
1414
'darkconsole.pkg.js' => 'e7393ebb',
1515
'differential.pkg.css' => '90b30783',
@@ -167,7 +167,7 @@
167167
'rsrc/css/phui/phui-spacing.css' => '042804d6',
168168
'rsrc/css/phui/phui-status.css' => 'd5263e49',
169169
'rsrc/css/phui/phui-tag-view.css' => '84d65f26',
170-
'rsrc/css/phui/phui-timeline-view.css' => 'bf45789e',
170+
'rsrc/css/phui/phui-timeline-view.css' => '1d7ef61d',
171171
'rsrc/css/phui/phui-two-column-view.css' => 'ce9fa0b7',
172172
'rsrc/css/phui/workboards/phui-workboard-color.css' => '783cdff5',
173173
'rsrc/css/phui/workboards/phui-workboard.css' => '3bc85455',
@@ -877,7 +877,7 @@
877877
'phui-status-list-view-css' => 'd5263e49',
878878
'phui-tag-view-css' => '84d65f26',
879879
'phui-theme-css' => '9f261c6b',
880-
'phui-timeline-view-css' => 'bf45789e',
880+
'phui-timeline-view-css' => '1d7ef61d',
881881
'phui-two-column-view-css' => 'ce9fa0b7',
882882
'phui-workboard-color-css' => '783cdff5',
883883
'phui-workboard-view-css' => '3bc85455',

src/__phutil_library_map__.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,11 +320,15 @@
320320
'ConpherenceThreadListView' => 'applications/conpherence/view/ConpherenceThreadListView.php',
321321
'ConpherenceThreadMailReceiver' => 'applications/conpherence/mail/ConpherenceThreadMailReceiver.php',
322322
'ConpherenceThreadMembersPolicyRule' => 'applications/conpherence/policyrule/ConpherenceThreadMembersPolicyRule.php',
323+
'ConpherenceThreadPictureTransaction' => 'applications/conpherence/xaction/ConpherenceThreadPictureTransaction.php',
323324
'ConpherenceThreadQuery' => 'applications/conpherence/query/ConpherenceThreadQuery.php',
324325
'ConpherenceThreadRemarkupRule' => 'applications/conpherence/remarkup/ConpherenceThreadRemarkupRule.php',
325326
'ConpherenceThreadSearchController' => 'applications/conpherence/controller/ConpherenceThreadSearchController.php',
326327
'ConpherenceThreadSearchEngine' => 'applications/conpherence/query/ConpherenceThreadSearchEngine.php',
327328
'ConpherenceThreadTitleNgrams' => 'applications/conpherence/storage/ConpherenceThreadTitleNgrams.php',
329+
'ConpherenceThreadTitleTransaction' => 'applications/conpherence/xaction/ConpherenceThreadTitleTransaction.php',
330+
'ConpherenceThreadTopicTransaction' => 'applications/conpherence/xaction/ConpherenceThreadTopicTransaction.php',
331+
'ConpherenceThreadTransactionType' => 'applications/conpherence/xaction/ConpherenceThreadTransactionType.php',
328332
'ConpherenceTransaction' => 'applications/conpherence/storage/ConpherenceTransaction.php',
329333
'ConpherenceTransactionComment' => 'applications/conpherence/storage/ConpherenceTransactionComment.php',
330334
'ConpherenceTransactionQuery' => 'applications/conpherence/query/ConpherenceTransactionQuery.php',
@@ -5099,12 +5103,16 @@
50995103
'ConpherenceThreadListView' => 'AphrontView',
51005104
'ConpherenceThreadMailReceiver' => 'PhabricatorObjectMailReceiver',
51015105
'ConpherenceThreadMembersPolicyRule' => 'PhabricatorPolicyRule',
5106+
'ConpherenceThreadPictureTransaction' => 'ConpherenceThreadTransactionType',
51025107
'ConpherenceThreadQuery' => 'PhabricatorCursorPagedPolicyAwareQuery',
51035108
'ConpherenceThreadRemarkupRule' => 'PhabricatorObjectRemarkupRule',
51045109
'ConpherenceThreadSearchController' => 'ConpherenceController',
51055110
'ConpherenceThreadSearchEngine' => 'PhabricatorApplicationSearchEngine',
51065111
'ConpherenceThreadTitleNgrams' => 'PhabricatorSearchNgrams',
5107-
'ConpherenceTransaction' => 'PhabricatorApplicationTransaction',
5112+
'ConpherenceThreadTitleTransaction' => 'ConpherenceThreadTransactionType',
5113+
'ConpherenceThreadTopicTransaction' => 'ConpherenceThreadTransactionType',
5114+
'ConpherenceThreadTransactionType' => 'PhabricatorModularTransactionType',
5115+
'ConpherenceTransaction' => 'PhabricatorModularTransaction',
51085116
'ConpherenceTransactionComment' => 'PhabricatorApplicationTransactionComment',
51095117
'ConpherenceTransactionQuery' => 'PhabricatorApplicationTransactionQuery',
51105118
'ConpherenceTransactionRenderer' => 'Phobject',

src/applications/conpherence/__tests__/ConpherenceRoomTestCase.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,8 @@ private function createRoom(
123123
->setTransactionType(ConpherenceTransaction::TYPE_PARTICIPANTS)
124124
->setNewValue(array('+' => $participant_phids));
125125
$xactions[] = id(new ConpherenceTransaction())
126-
->setTransactionType(ConpherenceTransaction::TYPE_TITLE)
126+
->setTransactionType(
127+
ConpherenceThreadTitleTransaction::TRANSACTIONTYPE)
127128
->setNewValue(pht('Test'));
128129

129130
id(new ConpherenceEditor())

src/applications/conpherence/conduit/ConpherenceUpdateThreadConduitAPIMethod.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,8 @@ protected function execute(ConduitAPIRequest $request) {
8383
}
8484
if ($title) {
8585
$xactions[] = id(new ConpherenceTransaction())
86-
->setTransactionType(ConpherenceTransaction::TYPE_TITLE)
86+
->setTransactionType(
87+
ConpherenceThreadTitleTransaction::TRANSACTIONTYPE)
8788
->setNewValue($title);
8889
}
8990
if ($message) {

src/applications/conpherence/controller/ConpherenceNewRoomController.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public function handleRequest(AphrontRequest $request) {
1616
$xactions = array();
1717

1818
$xactions[] = id(new ConpherenceTransaction())
19-
->setTransactionType(ConpherenceTransaction::TYPE_TITLE)
19+
->setTransactionType(ConpherenceThreadTitleTransaction::TRANSACTIONTYPE)
2020
->setNewValue($request->getStr('title'));
2121

2222
$participants = $request->getArr('participants');
@@ -26,7 +26,7 @@ public function handleRequest(AphrontRequest $request) {
2626
->setTransactionType(ConpherenceTransaction::TYPE_PARTICIPANTS)
2727
->setNewValue(array('+' => $participants));
2828
$xactions[] = id(new ConpherenceTransaction())
29-
->setTransactionType(ConpherenceTransaction::TYPE_TOPIC)
29+
->setTransactionType(ConpherenceThreadTopicTransaction::TRANSACTIONTYPE)
3030
->setNewValue($request->getStr('topic'));
3131
$xactions[] = id(new ConpherenceTransaction())
3232
->setTransactionType(PhabricatorTransactions::TYPE_VIEW_POLICY)
@@ -50,7 +50,8 @@ public function handleRequest(AphrontRequest $request) {
5050
} catch (PhabricatorApplicationTransactionValidationException $ex) {
5151
$validation_exception = $ex;
5252

53-
$e_title = $ex->getShortMessage(ConpherenceTransaction::TYPE_TITLE);
53+
$e_title = $ex->getShortMessage(
54+
ConpherenceThreadTitleTransaction::TRANSACTIONTYPE);
5455

5556
$conpherence->setViewPolicy($request->getStr('viewPolicy'));
5657
$conpherence->setEditPolicy($request->getStr('editPolicy'));

src/applications/conpherence/controller/ConpherenceRoomPictureController.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,8 @@ public function handleRequest(AphrontRequest $request) {
7676

7777
$xactions = array();
7878
$xactions[] = id(new ConpherenceTransaction())
79-
->setTransactionType(ConpherenceTransaction::TYPE_PICTURE)
79+
->setTransactionType(
80+
ConpherenceThreadPictureTransaction::TRANSACTIONTYPE)
8081
->setNewValue($new_value);
8182

8283
$editor = id(new ConpherenceEditor())

src/applications/conpherence/controller/ConpherenceUpdateController.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,10 +140,12 @@ public function handleRequest(AphrontRequest $request) {
140140
$title = $request->getStr('title');
141141
$topic = $request->getStr('topic');
142142
$xactions[] = id(new ConpherenceTransaction())
143-
->setTransactionType(ConpherenceTransaction::TYPE_TITLE)
143+
->setTransactionType(
144+
ConpherenceThreadTitleTransaction::TRANSACTIONTYPE)
144145
->setNewValue($title);
145146
$xactions[] = id(new ConpherenceTransaction())
146-
->setTransactionType(ConpherenceTransaction::TYPE_TOPIC)
147+
->setTransactionType(
148+
ConpherenceThreadTopicTransaction::TRANSACTIONTYPE)
147149
->setNewValue($topic);
148150
$xactions[] = id(new ConpherenceTransaction())
149151
->setTransactionType(PhabricatorTransactions::TYPE_VIEW_POLICY)

src/applications/conpherence/editor/ConpherenceEditor.php

Lines changed: 29 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,14 @@ public static function createThread(
4141
->setNewValue(array('+' => $participant_phids));
4242
if ($title) {
4343
$xactions[] = id(new ConpherenceTransaction())
44-
->setTransactionType(ConpherenceTransaction::TYPE_TITLE)
44+
->setTransactionType(
45+
ConpherenceThreadTitleTransaction::TRANSACTIONTYPE)
4546
->setNewValue($title);
4647
}
4748
if (strlen($topic)) {
4849
$xactions[] = id(new ConpherenceTransaction())
49-
->setTransactionType(ConpherenceTransaction::TYPE_TOPIC)
50+
->setTransactionType(
51+
ConpherenceThreadTopicTransaction::TRANSACTIONTYPE)
5052
->setNewValue($topic);
5153
}
5254

@@ -87,28 +89,42 @@ public function getTransactionTypes() {
8789

8890
$types[] = PhabricatorTransactions::TYPE_COMMENT;
8991

90-
$types[] = ConpherenceTransaction::TYPE_TITLE;
91-
$types[] = ConpherenceTransaction::TYPE_TOPIC;
9292
$types[] = ConpherenceTransaction::TYPE_PARTICIPANTS;
93-
$types[] = ConpherenceTransaction::TYPE_PICTURE;
9493
$types[] = PhabricatorTransactions::TYPE_VIEW_POLICY;
9594
$types[] = PhabricatorTransactions::TYPE_EDIT_POLICY;
9695
$types[] = PhabricatorTransactions::TYPE_JOIN_POLICY;
9796

9897
return $types;
9998
}
10099

100+
public function getCreateObjectTitle($author, $object) {
101+
return pht('%s created this room.', $author);
102+
}
103+
104+
protected function shouldPublishFeedStory(
105+
PhabricatorLiskDAO $object,
106+
array $xactions) {
107+
108+
foreach ($xactions as $xaction) {
109+
switch ($xaction->getTransactionType()) {
110+
case ConpherenceThreadTitleTransaction::TRANSACTIONTYPE:
111+
case ConpherenceThreadTopicTransaction::TRANSACTIONTYPE:
112+
case ConpherenceThreadPictureTransaction::TRANSACTIONTYPE:
113+
return true;
114+
default:
115+
return false;
116+
}
117+
}
118+
return true;
119+
}
120+
121+
122+
101123
protected function getCustomTransactionOldValue(
102124
PhabricatorLiskDAO $object,
103125
PhabricatorApplicationTransaction $xaction) {
104126

105127
switch ($xaction->getTransactionType()) {
106-
case ConpherenceTransaction::TYPE_TITLE:
107-
return $object->getTitle();
108-
case ConpherenceTransaction::TYPE_TOPIC:
109-
return $object->getTopic();
110-
case ConpherenceTransaction::TYPE_PICTURE:
111-
return $object->getProfileImagePHID();
112128
case ConpherenceTransaction::TYPE_PARTICIPANTS:
113129
if ($this->getIsNewObject()) {
114130
return array();
@@ -122,10 +138,6 @@ protected function getCustomTransactionNewValue(
122138
PhabricatorApplicationTransaction $xaction) {
123139

124140
switch ($xaction->getTransactionType()) {
125-
case ConpherenceTransaction::TYPE_TITLE:
126-
case ConpherenceTransaction::TYPE_TOPIC:
127-
case ConpherenceTransaction::TYPE_PICTURE:
128-
return $xaction->getNewValue();
129141
case ConpherenceTransaction::TYPE_PARTICIPANTS:
130142
return $this->getPHIDTransactionNewValue($xaction);
131143
}
@@ -211,15 +223,6 @@ protected function applyCustomInternalTransaction(
211223

212224
$make_author_recent_participant = true;
213225
switch ($xaction->getTransactionType()) {
214-
case ConpherenceTransaction::TYPE_TITLE:
215-
$object->setTitle($xaction->getNewValue());
216-
break;
217-
case ConpherenceTransaction::TYPE_TOPIC:
218-
$object->setTopic($xaction->getNewValue());
219-
break;
220-
case ConpherenceTransaction::TYPE_PICTURE:
221-
$object->setProfileImagePHID($xaction->getNewValue());
222-
break;
223226
case ConpherenceTransaction::TYPE_PARTICIPANTS:
224227
if (!$this->getIsNewObject()) {
225228
$old_map = array_fuse($xaction->getOldValue());
@@ -418,8 +421,8 @@ protected function requireCapabilities(
418421
PhabricatorPolicyCapability::CAN_EDIT);
419422
}
420423
break;
421-
case ConpherenceTransaction::TYPE_TITLE:
422-
case ConpherenceTransaction::TYPE_TOPIC:
424+
case ConpherenceThreadTitleTransaction::TRANSACTIONTYPE:
425+
case ConpherenceThreadTopicTransaction::TRANSACTIONTYPE:
423426
PhabricatorPolicyFilter::requireCapability(
424427
$this->requireActor(),
425428
$object,
@@ -434,8 +437,6 @@ protected function mergeTransactions(
434437

435438
$type = $u->getTransactionType();
436439
switch ($type) {
437-
case ConpherenceTransaction::TYPE_TITLE:
438-
return $v;
439440
case ConpherenceTransaction::TYPE_PARTICIPANTS:
440441
return $this->mergePHIDOrEdgeTransactions($u, $v);
441442
}
@@ -541,23 +542,6 @@ protected function getMailSubjectPrefix() {
541542
return PhabricatorEnv::getEnvConfig('metamta.conpherence.subject-prefix');
542543
}
543544

544-
protected function shouldPublishFeedStory(
545-
PhabricatorLiskDAO $object,
546-
array $xactions) {
547-
548-
foreach ($xactions as $xaction) {
549-
switch ($xaction->getTransactionType()) {
550-
case ConpherenceTransaction::TYPE_TITLE:
551-
case ConpherenceTransaction::TYPE_TOPIC:
552-
case ConpherenceTransaction::TYPE_PICTURE:
553-
return true;
554-
default:
555-
return false;
556-
}
557-
}
558-
return false;
559-
}
560-
561545
protected function supportsSearch() {
562546
return true;
563547
}
@@ -570,26 +554,6 @@ protected function validateTransaction(
570554
$errors = parent::validateTransaction($object, $type, $xactions);
571555

572556
switch ($type) {
573-
case ConpherenceTransaction::TYPE_TITLE:
574-
if (empty($xactions)) {
575-
break;
576-
}
577-
$missing = $this->validateIsEmptyTextField(
578-
$object->getTitle(),
579-
$xactions);
580-
581-
if ($missing) {
582-
$detail = pht('Room title is required.');
583-
$error = new PhabricatorApplicationTransactionValidationError(
584-
$type,
585-
pht('Required'),
586-
$detail,
587-
last($xactions));
588-
589-
$error->setIsMissingFieldError(true);
590-
$errors[] = $error;
591-
}
592-
break;
593557
case ConpherenceTransaction::TYPE_PARTICIPANTS:
594558
foreach ($xactions as $xaction) {
595559
$new_phids = $this->getPHIDTransactionNewValue($xaction, array());

src/applications/conpherence/storage/ConpherenceThread.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -268,9 +268,9 @@ public function getDisplayData(PhabricatorUser $viewer) {
268268
case PhabricatorTransactions::TYPE_COMMENT:
269269
$message_transaction = $transaction;
270270
break;
271-
case ConpherenceTransaction::TYPE_TITLE:
272-
case ConpherenceTransaction::TYPE_TOPIC:
273-
case ConpherenceTransaction::TYPE_PICTURE:
271+
case ConpherenceThreadTitleTransaction::TRANSACTIONTYPE:
272+
case ConpherenceThreadTopicTransaction::TRANSACTIONTYPE:
273+
case ConpherenceThreadPictureTransaction::TRANSACTIONTYPE:
274274
case ConpherenceTransaction::TYPE_PARTICIPANTS:
275275
$action_transaction = $transaction;
276276
break;

0 commit comments

Comments
 (0)