@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Remove TYPE_FILES from Conpherence

Summary: I believe these are left over from widgets, when we added a "Files" widget that kept track of everything added to the window.

Test Plan: Added files to a Conpherece, Set an image when editing. Anything else?

Reviewers: epriestley

Reviewed By: epriestley

Subscribers: Korvin

Differential Revision: https://secure.phabricator.com/D16567

authored by

Chad Little and committed by
chad
a2a19e29 28201bf2

+2 -157
-19
src/applications/conpherence/__tests__/ConpherenceRoomTestCase.php
··· 112 112 } 113 113 } 114 114 115 - public function testAddMessageWithFileAttachments() { 116 - $creator = $this->generateNewTestUser(); 117 - $friend_1 = $this->generateNewTestUser(); 118 - 119 - $participant_map = array( 120 - $creator->getPHID() => $creator, 121 - $friend_1->getPHID() => $friend_1, 122 - ); 123 - 124 - $conpherence = $this->createRoom( 125 - $creator, 126 - array_keys($participant_map)); 127 - 128 - foreach ($participant_map as $phid => $user) { 129 - $xactions = $this->addMessageWithFile($user, $conpherence); 130 - $this->assertEqual(2, count($xactions)); 131 - } 132 - } 133 - 134 115 private function createRoom( 135 116 PhabricatorUser $creator, 136 117 array $participant_phids) {
+1 -3
src/applications/conpherence/conduit/ConpherenceQueryThreadConduitAPIMethod.php
··· 37 37 38 38 $query = id(new ConpherenceThreadQuery()) 39 39 ->setViewer($user) 40 - ->needParticipantCache(true) 41 - ->needFilePHIDs(true); 40 + ->needParticipantCache(true); 42 41 43 42 if ($ids) { 44 43 $conpherences = $query ··· 73 72 'conpherenceTitle' => $conpherence->getTitle(), 74 73 'messageCount' => $conpherence->getMessageCount(), 75 74 'recentParticipantPHIDs' => $conpherence->getRecentParticipantPHIDs(), 76 - 'filePHIDs' => $conpherence->getFilePHIDs(), 77 75 'conpherenceURI' => $this->getConpherenceURI($conpherence), 78 76 ); 79 77 }
+1 -2
src/applications/conpherence/conduit/ConpherenceUpdateThreadConduitAPIMethod.php
··· 44 44 $id = $request->getValue('id'); 45 45 $phid = $request->getValue('phid'); 46 46 $query = id(new ConpherenceThreadQuery()) 47 - ->setViewer($user) 48 - ->needFilePHIDs(true); 47 + ->setViewer($user); 49 48 if ($id) { 50 49 $query->withIDs(array($id)); 51 50 } else if ($phid) {
-1
src/applications/conpherence/controller/ConpherenceUpdateController.php
··· 36 36 $conpherence = id(new ConpherenceThreadQuery()) 37 37 ->setViewer($user) 38 38 ->withIDs(array($conpherence_id)) 39 - ->needFilePHIDs(true) 40 39 ->needOrigPics(true) 41 40 ->needCropPics(true) 42 41 ->needParticipants($need_participants)
-70
src/applications/conpherence/editor/ConpherenceEditor.php
··· 22 22 $topic) { 23 23 24 24 $conpherence = ConpherenceThread::initializeNewRoom($creator); 25 - $files = array(); 26 25 $errors = array(); 27 26 if (empty($participant_phids)) { 28 27 $errors[] = self::ERROR_EMPTY_PARTICIPANTS; ··· 35 34 $errors[] = self::ERROR_EMPTY_MESSAGE; 36 35 } 37 36 38 - $file_phids = PhabricatorMarkupEngine::extractFilePHIDsFromEmbeddedFiles( 39 - $creator, 40 - array($message)); 41 - if ($file_phids) { 42 - $files = id(new PhabricatorFileQuery()) 43 - ->setViewer($creator) 44 - ->withPHIDs($file_phids) 45 - ->execute(); 46 - } 47 - 48 37 if (!$errors) { 49 38 $xactions = array(); 50 39 $xactions[] = id(new ConpherenceTransaction()) 51 40 ->setTransactionType(ConpherenceTransaction::TYPE_PARTICIPANTS) 52 41 ->setNewValue(array('+' => $participant_phids)); 53 - if ($files) { 54 - $xactions[] = id(new ConpherenceTransaction()) 55 - ->setTransactionType(ConpherenceTransaction::TYPE_FILES) 56 - ->setNewValue(array('+' => mpull($files, 'getPHID'))); 57 - } 58 42 if ($title) { 59 43 $xactions[] = id(new ConpherenceTransaction()) 60 44 ->setTransactionType(ConpherenceTransaction::TYPE_TITLE) ··· 88 72 ConpherenceThread $conpherence, 89 73 $text) { 90 74 91 - $files = array(); 92 - $file_phids = PhabricatorMarkupEngine::extractFilePHIDsFromEmbeddedFiles( 93 - $viewer, 94 - array($text)); 95 - // Since these are extracted from text, we might be re-including the 96 - // same file -- e.g. a mock under discussion. Filter files we 97 - // already have. 98 - $existing_file_phids = $conpherence->getFilePHIDs(); 99 - $file_phids = array_diff($file_phids, $existing_file_phids); 100 - if ($file_phids) { 101 - $files = id(new PhabricatorFileQuery()) 102 - ->setViewer($this->getActor()) 103 - ->withPHIDs($file_phids) 104 - ->execute(); 105 - } 106 75 $xactions = array(); 107 - if ($files) { 108 - $xactions[] = id(new ConpherenceTransaction()) 109 - ->setTransactionType(ConpherenceTransaction::TYPE_FILES) 110 - ->setNewValue(array('+' => mpull($files, 'getPHID'))); 111 - } 112 76 $xactions[] = id(new ConpherenceTransaction()) 113 77 ->setTransactionType(PhabricatorTransactions::TYPE_COMMENT) 114 78 ->attachComment( ··· 126 90 $types[] = ConpherenceTransaction::TYPE_TITLE; 127 91 $types[] = ConpherenceTransaction::TYPE_TOPIC; 128 92 $types[] = ConpherenceTransaction::TYPE_PARTICIPANTS; 129 - $types[] = ConpherenceTransaction::TYPE_FILES; 130 93 $types[] = ConpherenceTransaction::TYPE_PICTURE; 131 94 $types[] = ConpherenceTransaction::TYPE_PICTURE_CROP; 132 95 $types[] = PhabricatorTransactions::TYPE_VIEW_POLICY; ··· 154 117 return array(); 155 118 } 156 119 return $object->getParticipantPHIDs(); 157 - case ConpherenceTransaction::TYPE_FILES: 158 - return $object->getFilePHIDs(); 159 120 } 160 121 } 161 122 ··· 172 133 $file = $xaction->getNewValue(); 173 134 return $file->getPHID(); 174 135 case ConpherenceTransaction::TYPE_PARTICIPANTS: 175 - case ConpherenceTransaction::TYPE_FILES: 176 136 return $this->getPHIDTransactionNewValue($xaction); 177 137 } 178 138 } ··· 335 295 PhabricatorApplicationTransaction $xaction) { 336 296 337 297 switch ($xaction->getTransactionType()) { 338 - case ConpherenceTransaction::TYPE_FILES: 339 - $editor = new PhabricatorEdgeEditor(); 340 - $edge_type = PhabricatorObjectHasFileEdgeType::EDGECONST; 341 - $old = array_fill_keys($xaction->getOldValue(), true); 342 - $new = array_fill_keys($xaction->getNewValue(), true); 343 - $add_edges = array_keys(array_diff_key($new, $old)); 344 - $remove_edges = array_keys(array_diff_key($old, $new)); 345 - foreach ($add_edges as $file_phid) { 346 - $editor->addEdge( 347 - $object->getPHID(), 348 - $edge_type, 349 - $file_phid); 350 - } 351 - foreach ($remove_edges as $file_phid) { 352 - $editor->removeEdge( 353 - $object->getPHID(), 354 - $edge_type, 355 - $file_phid); 356 - } 357 - $editor->save(); 358 - break; 359 298 case ConpherenceTransaction::TYPE_PARTICIPANTS: 360 299 if ($this->getIsNewObject()) { 361 300 continue; ··· 488 427 PhabricatorPolicyCapability::CAN_EDIT); 489 428 } 490 429 break; 491 - // This is similar to PhabricatorTransactions::TYPE_COMMENT so 492 - // use CAN_VIEW 493 - case ConpherenceTransaction::TYPE_FILES: 494 - PhabricatorPolicyFilter::requireCapability( 495 - $this->requireActor(), 496 - $object, 497 - PhabricatorPolicyCapability::CAN_VIEW); 498 - break; 499 430 case ConpherenceTransaction::TYPE_TITLE: 500 431 case ConpherenceTransaction::TYPE_TOPIC: 501 432 PhabricatorPolicyFilter::requireCapability( ··· 514 445 switch ($type) { 515 446 case ConpherenceTransaction::TYPE_TITLE: 516 447 return $v; 517 - case ConpherenceTransaction::TYPE_FILES: 518 448 case ConpherenceTransaction::TYPE_PARTICIPANTS: 519 449 return $this->mergePHIDOrEdgeTransactions($u, $v); 520 450 }
-22
src/applications/conpherence/query/ConpherenceThreadQuery.php
··· 13 13 private $needOrigPics; 14 14 private $needTransactions; 15 15 private $needParticipantCache; 16 - private $needFilePHIDs; 17 16 private $afterTransactionID; 18 17 private $beforeTransactionID; 19 18 private $transactionLimit; 20 19 private $fulltext; 21 - 22 - public function needFilePHIDs($need_file_phids) { 23 - $this->needFilePHIDs = $need_file_phids; 24 - return $this; 25 - } 26 20 27 21 public function needParticipantCache($participant_cache) { 28 22 $this->needParticipantCache = $participant_cache; ··· 115 109 } 116 110 if ($this->needTransactions) { 117 111 $this->loadTransactionsAndHandles($conpherences); 118 - } 119 - if ($this->needFilePHIDs) { 120 - $this->loadFilePHIDs($conpherences); 121 112 } 122 113 if ($this->needOrigPics || $this->needCropPics) { 123 114 $this->initImages($conpherences); ··· 271 262 } 272 263 $conpherence->attachHandles($conpherence->getHandles() + $handles); 273 264 $conpherence->attachTransactions($current_transactions); 274 - } 275 - return $this; 276 - } 277 - 278 - private function loadFilePHIDs(array $conpherences) { 279 - $edge_type = PhabricatorObjectHasFileEdgeType::EDGECONST; 280 - $file_edges = id(new PhabricatorEdgeQuery()) 281 - ->withSourcePHIDs(array_keys($conpherences)) 282 - ->withEdgeTypes(array($edge_type)) 283 - ->execute(); 284 - foreach ($file_edges as $conpherence_phid => $data) { 285 - $conpherence = $conpherences[$conpherence_phid]; 286 - $conpherence->attachFilePHIDs(array_keys($data[$edge_type])); 287 265 } 288 266 return $this; 289 267 }
-10
src/applications/conpherence/storage/ConpherenceThread.php
··· 20 20 private $participants = self::ATTACHABLE; 21 21 private $transactions = self::ATTACHABLE; 22 22 private $handles = self::ATTACHABLE; 23 - private $filePHIDs = self::ATTACHABLE; 24 23 private $images = self::ATTACHABLE; 25 24 26 25 public static function initializeNewRoom(PhabricatorUser $sender) { ··· 31 30 ->setTitle('') 32 31 ->setTopic('') 33 32 ->attachParticipants(array()) 34 - ->attachFilePHIDs(array()) 35 33 ->attachImages(array()) 36 34 ->setViewPolicy($default_policy) 37 35 ->setEditPolicy($default_policy) ··· 156 154 $this->getTransactions(), 157 155 $length - $begin - $amount, 158 156 $amount); 159 - } 160 - 161 - public function attachFilePHIDs(array $file_phids) { 162 - $this->filePHIDs = $file_phids; 163 - return $this; 164 - } 165 - public function getFilePHIDs() { 166 - return $this->assertAttached($this->filePHIDs); 167 157 } 168 158 169 159 public function loadImageURI($size) {
-27
src/applications/conpherence/storage/ConpherenceTransaction.php
··· 2 2 3 3 final class ConpherenceTransaction extends PhabricatorApplicationTransaction { 4 4 5 - const TYPE_FILES = 'files'; 6 5 const TYPE_TITLE = 'title'; 7 6 const TYPE_TOPIC = 'topic'; 8 7 const TYPE_PARTICIPANTS = 'participants'; ··· 44 43 case self::TYPE_PICTURE: 45 44 case self::TYPE_DATE_MARKER: 46 45 return false; 47 - case self::TYPE_FILES: 48 - return true; 49 46 case self::TYPE_PICTURE_CROP: 50 47 return true; 51 48 } ··· 67 64 case PhabricatorTransactions::TYPE_JOIN_POLICY: 68 65 case self::TYPE_PICTURE: 69 66 return $this->getRoomTitle(); 70 - break; 71 - case self::TYPE_FILES: 72 - $add = array_diff($new, $old); 73 - $rem = array_diff($old, $new); 74 - 75 - if ($add && $rem) { 76 - $title = pht( 77 - '%s edited files(s), added %d and removed %d.', 78 - $this->renderHandleLink($author_phid), 79 - count($add), 80 - count($rem)); 81 - } else if ($add) { 82 - $title = pht( 83 - '%s added %s files(s).', 84 - $this->renderHandleLink($author_phid), 85 - phutil_count($add)); 86 - } else { 87 - $title = pht( 88 - '%s removed %s file(s).', 89 - $this->renderHandleLink($author_phid), 90 - phutil_count($rem)); 91 - } 92 - return $title; 93 67 break; 94 68 case self::TYPE_PARTICIPANTS: 95 69 $add = array_diff($new, $old); ··· 252 226 switch ($this->getTransactionType()) { 253 227 case self::TYPE_TITLE: 254 228 case self::TYPE_PICTURE: 255 - case self::TYPE_FILES: 256 229 case self::TYPE_DATE_MARKER: 257 230 break; 258 231 case self::TYPE_PARTICIPANTS:
-3
src/applications/conpherence/view/ConpherenceTransactionView.php
··· 227 227 $content = null; 228 228 $handles = $this->getHandles(); 229 229 switch ($transaction->getTransactionType()) { 230 - case ConpherenceTransaction::TYPE_FILES: 231 - $content = $transaction->getTitle(); 232 - break; 233 230 case ConpherenceTransaction::TYPE_TITLE: 234 231 case ConpherenceTransaction::TYPE_TOPIC: 235 232 case ConpherenceTransaction::TYPE_PICTURE: