Skip to content

Commit a2a19e2

Browse files
Chad Littlechad
authored andcommitted
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
1 parent 28201bf commit a2a19e2

9 files changed

+2
-157
lines changed

src/applications/conpherence/__tests__/ConpherenceRoomTestCase.php

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -112,25 +112,6 @@ public function testRoomParticipantDeletion() {
112112
}
113113
}
114114

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-
134115
private function createRoom(
135116
PhabricatorUser $creator,
136117
array $participant_phids) {

src/applications/conpherence/conduit/ConpherenceQueryThreadConduitAPIMethod.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,7 @@ protected function execute(ConduitAPIRequest $request) {
3737

3838
$query = id(new ConpherenceThreadQuery())
3939
->setViewer($user)
40-
->needParticipantCache(true)
41-
->needFilePHIDs(true);
40+
->needParticipantCache(true);
4241

4342
if ($ids) {
4443
$conpherences = $query
@@ -73,7 +72,6 @@ protected function execute(ConduitAPIRequest $request) {
7372
'conpherenceTitle' => $conpherence->getTitle(),
7473
'messageCount' => $conpherence->getMessageCount(),
7574
'recentParticipantPHIDs' => $conpherence->getRecentParticipantPHIDs(),
76-
'filePHIDs' => $conpherence->getFilePHIDs(),
7775
'conpherenceURI' => $this->getConpherenceURI($conpherence),
7876
);
7977
}

src/applications/conpherence/conduit/ConpherenceUpdateThreadConduitAPIMethod.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,7 @@ protected function execute(ConduitAPIRequest $request) {
4444
$id = $request->getValue('id');
4545
$phid = $request->getValue('phid');
4646
$query = id(new ConpherenceThreadQuery())
47-
->setViewer($user)
48-
->needFilePHIDs(true);
47+
->setViewer($user);
4948
if ($id) {
5049
$query->withIDs(array($id));
5150
} else if ($phid) {

src/applications/conpherence/controller/ConpherenceUpdateController.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ public function handleRequest(AphrontRequest $request) {
3636
$conpherence = id(new ConpherenceThreadQuery())
3737
->setViewer($user)
3838
->withIDs(array($conpherence_id))
39-
->needFilePHIDs(true)
4039
->needOrigPics(true)
4140
->needCropPics(true)
4241
->needParticipants($need_participants)

src/applications/conpherence/editor/ConpherenceEditor.php

Lines changed: 0 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ public static function createThread(
2222
$topic) {
2323

2424
$conpherence = ConpherenceThread::initializeNewRoom($creator);
25-
$files = array();
2625
$errors = array();
2726
if (empty($participant_phids)) {
2827
$errors[] = self::ERROR_EMPTY_PARTICIPANTS;
@@ -35,26 +34,11 @@ public static function createThread(
3534
$errors[] = self::ERROR_EMPTY_MESSAGE;
3635
}
3736

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-
4837
if (!$errors) {
4938
$xactions = array();
5039
$xactions[] = id(new ConpherenceTransaction())
5140
->setTransactionType(ConpherenceTransaction::TYPE_PARTICIPANTS)
5241
->setNewValue(array('+' => $participant_phids));
53-
if ($files) {
54-
$xactions[] = id(new ConpherenceTransaction())
55-
->setTransactionType(ConpherenceTransaction::TYPE_FILES)
56-
->setNewValue(array('+' => mpull($files, 'getPHID')));
57-
}
5842
if ($title) {
5943
$xactions[] = id(new ConpherenceTransaction())
6044
->setTransactionType(ConpherenceTransaction::TYPE_TITLE)
@@ -88,27 +72,7 @@ public function generateTransactionsFromText(
8872
ConpherenceThread $conpherence,
8973
$text) {
9074

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-
}
10675
$xactions = array();
107-
if ($files) {
108-
$xactions[] = id(new ConpherenceTransaction())
109-
->setTransactionType(ConpherenceTransaction::TYPE_FILES)
110-
->setNewValue(array('+' => mpull($files, 'getPHID')));
111-
}
11276
$xactions[] = id(new ConpherenceTransaction())
11377
->setTransactionType(PhabricatorTransactions::TYPE_COMMENT)
11478
->attachComment(
@@ -126,7 +90,6 @@ public function getTransactionTypes() {
12690
$types[] = ConpherenceTransaction::TYPE_TITLE;
12791
$types[] = ConpherenceTransaction::TYPE_TOPIC;
12892
$types[] = ConpherenceTransaction::TYPE_PARTICIPANTS;
129-
$types[] = ConpherenceTransaction::TYPE_FILES;
13093
$types[] = ConpherenceTransaction::TYPE_PICTURE;
13194
$types[] = ConpherenceTransaction::TYPE_PICTURE_CROP;
13295
$types[] = PhabricatorTransactions::TYPE_VIEW_POLICY;
@@ -154,8 +117,6 @@ protected function getCustomTransactionOldValue(
154117
return array();
155118
}
156119
return $object->getParticipantPHIDs();
157-
case ConpherenceTransaction::TYPE_FILES:
158-
return $object->getFilePHIDs();
159120
}
160121
}
161122

@@ -172,7 +133,6 @@ protected function getCustomTransactionNewValue(
172133
$file = $xaction->getNewValue();
173134
return $file->getPHID();
174135
case ConpherenceTransaction::TYPE_PARTICIPANTS:
175-
case ConpherenceTransaction::TYPE_FILES:
176136
return $this->getPHIDTransactionNewValue($xaction);
177137
}
178138
}
@@ -335,27 +295,6 @@ protected function applyCustomExternalTransaction(
335295
PhabricatorApplicationTransaction $xaction) {
336296

337297
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;
359298
case ConpherenceTransaction::TYPE_PARTICIPANTS:
360299
if ($this->getIsNewObject()) {
361300
continue;
@@ -488,14 +427,6 @@ protected function requireCapabilities(
488427
PhabricatorPolicyCapability::CAN_EDIT);
489428
}
490429
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;
499430
case ConpherenceTransaction::TYPE_TITLE:
500431
case ConpherenceTransaction::TYPE_TOPIC:
501432
PhabricatorPolicyFilter::requireCapability(
@@ -514,7 +445,6 @@ protected function mergeTransactions(
514445
switch ($type) {
515446
case ConpherenceTransaction::TYPE_TITLE:
516447
return $v;
517-
case ConpherenceTransaction::TYPE_FILES:
518448
case ConpherenceTransaction::TYPE_PARTICIPANTS:
519449
return $this->mergePHIDOrEdgeTransactions($u, $v);
520450
}

src/applications/conpherence/query/ConpherenceThreadQuery.php

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,11 @@ final class ConpherenceThreadQuery
1313
private $needOrigPics;
1414
private $needTransactions;
1515
private $needParticipantCache;
16-
private $needFilePHIDs;
1716
private $afterTransactionID;
1817
private $beforeTransactionID;
1918
private $transactionLimit;
2019
private $fulltext;
2120

22-
public function needFilePHIDs($need_file_phids) {
23-
$this->needFilePHIDs = $need_file_phids;
24-
return $this;
25-
}
26-
2721
public function needParticipantCache($participant_cache) {
2822
$this->needParticipantCache = $participant_cache;
2923
return $this;
@@ -116,9 +110,6 @@ protected function loadPage() {
116110
if ($this->needTransactions) {
117111
$this->loadTransactionsAndHandles($conpherences);
118112
}
119-
if ($this->needFilePHIDs) {
120-
$this->loadFilePHIDs($conpherences);
121-
}
122113
if ($this->needOrigPics || $this->needCropPics) {
123114
$this->initImages($conpherences);
124115
}
@@ -275,19 +266,6 @@ private function loadTransactionsAndHandles(array $conpherences) {
275266
return $this;
276267
}
277268

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-
}
288-
return $this;
289-
}
290-
291269
private function loadOrigPics(array $conpherences) {
292270
return $this->loadPics(
293271
$conpherences,

src/applications/conpherence/storage/ConpherenceThread.php

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ final class ConpherenceThread extends ConpherenceDAO
2020
private $participants = self::ATTACHABLE;
2121
private $transactions = self::ATTACHABLE;
2222
private $handles = self::ATTACHABLE;
23-
private $filePHIDs = self::ATTACHABLE;
2423
private $images = self::ATTACHABLE;
2524

2625
public static function initializeNewRoom(PhabricatorUser $sender) {
@@ -31,7 +30,6 @@ public static function initializeNewRoom(PhabricatorUser $sender) {
3130
->setTitle('')
3231
->setTopic('')
3332
->attachParticipants(array())
34-
->attachFilePHIDs(array())
3533
->attachImages(array())
3634
->setViewPolicy($default_policy)
3735
->setEditPolicy($default_policy)
@@ -158,14 +156,6 @@ public function getTransactionsFrom($begin = 0, $amount = null) {
158156
$amount);
159157
}
160158

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-
}
168-
169159
public function loadImageURI($size) {
170160
$file = $this->getImage($size);
171161

src/applications/conpherence/storage/ConpherenceTransaction.php

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
final class ConpherenceTransaction extends PhabricatorApplicationTransaction {
44

5-
const TYPE_FILES = 'files';
65
const TYPE_TITLE = 'title';
76
const TYPE_TOPIC = 'topic';
87
const TYPE_PARTICIPANTS = 'participants';
@@ -44,8 +43,6 @@ public function shouldHide() {
4443
case self::TYPE_PICTURE:
4544
case self::TYPE_DATE_MARKER:
4645
return false;
47-
case self::TYPE_FILES:
48-
return true;
4946
case self::TYPE_PICTURE_CROP:
5047
return true;
5148
}
@@ -68,29 +65,6 @@ public function getTitle() {
6865
case self::TYPE_PICTURE:
6966
return $this->getRoomTitle();
7067
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-
break;
9468
case self::TYPE_PARTICIPANTS:
9569
$add = array_diff($new, $old);
9670
$rem = array_diff($old, $new);
@@ -252,7 +226,6 @@ public function getRequiredHandlePHIDs() {
252226
switch ($this->getTransactionType()) {
253227
case self::TYPE_TITLE:
254228
case self::TYPE_PICTURE:
255-
case self::TYPE_FILES:
256229
case self::TYPE_DATE_MARKER:
257230
break;
258231
case self::TYPE_PARTICIPANTS:

src/applications/conpherence/view/ConpherenceTransactionView.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -227,9 +227,6 @@ private function renderTransactionContent() {
227227
$content = null;
228228
$handles = $this->getHandles();
229229
switch ($transaction->getTransactionType()) {
230-
case ConpherenceTransaction::TYPE_FILES:
231-
$content = $transaction->getTitle();
232-
break;
233230
case ConpherenceTransaction::TYPE_TITLE:
234231
case ConpherenceTransaction::TYPE_TOPIC:
235232
case ConpherenceTransaction::TYPE_PICTURE:

0 commit comments

Comments
 (0)