1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2025-02-18 17:58:37 +01:00

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
This commit is contained in:
Chad Little 2016-09-17 21:23:54 +00:00 committed by chad
parent 28201bf2b5
commit a2a19e29aa
9 changed files with 2 additions and 157 deletions

View file

@ -112,25 +112,6 @@ final class ConpherenceRoomTestCase extends ConpherenceTestCase {
} }
} }
public function testAddMessageWithFileAttachments() {
$creator = $this->generateNewTestUser();
$friend_1 = $this->generateNewTestUser();
$participant_map = array(
$creator->getPHID() => $creator,
$friend_1->getPHID() => $friend_1,
);
$conpherence = $this->createRoom(
$creator,
array_keys($participant_map));
foreach ($participant_map as $phid => $user) {
$xactions = $this->addMessageWithFile($user, $conpherence);
$this->assertEqual(2, count($xactions));
}
}
private function createRoom( private function createRoom(
PhabricatorUser $creator, PhabricatorUser $creator,
array $participant_phids) { array $participant_phids) {

View file

@ -37,8 +37,7 @@ final class ConpherenceQueryThreadConduitAPIMethod
$query = id(new ConpherenceThreadQuery()) $query = id(new ConpherenceThreadQuery())
->setViewer($user) ->setViewer($user)
->needParticipantCache(true) ->needParticipantCache(true);
->needFilePHIDs(true);
if ($ids) { if ($ids) {
$conpherences = $query $conpherences = $query
@ -73,7 +72,6 @@ final class ConpherenceQueryThreadConduitAPIMethod
'conpherenceTitle' => $conpherence->getTitle(), 'conpherenceTitle' => $conpherence->getTitle(),
'messageCount' => $conpherence->getMessageCount(), 'messageCount' => $conpherence->getMessageCount(),
'recentParticipantPHIDs' => $conpherence->getRecentParticipantPHIDs(), 'recentParticipantPHIDs' => $conpherence->getRecentParticipantPHIDs(),
'filePHIDs' => $conpherence->getFilePHIDs(),
'conpherenceURI' => $this->getConpherenceURI($conpherence), 'conpherenceURI' => $this->getConpherenceURI($conpherence),
); );
} }

View file

@ -44,8 +44,7 @@ final class ConpherenceUpdateThreadConduitAPIMethod
$id = $request->getValue('id'); $id = $request->getValue('id');
$phid = $request->getValue('phid'); $phid = $request->getValue('phid');
$query = id(new ConpherenceThreadQuery()) $query = id(new ConpherenceThreadQuery())
->setViewer($user) ->setViewer($user);
->needFilePHIDs(true);
if ($id) { if ($id) {
$query->withIDs(array($id)); $query->withIDs(array($id));
} else if ($phid) { } else if ($phid) {

View file

@ -36,7 +36,6 @@ final class ConpherenceUpdateController
$conpherence = id(new ConpherenceThreadQuery()) $conpherence = id(new ConpherenceThreadQuery())
->setViewer($user) ->setViewer($user)
->withIDs(array($conpherence_id)) ->withIDs(array($conpherence_id))
->needFilePHIDs(true)
->needOrigPics(true) ->needOrigPics(true)
->needCropPics(true) ->needCropPics(true)
->needParticipants($need_participants) ->needParticipants($need_participants)

View file

@ -22,7 +22,6 @@ final class ConpherenceEditor extends PhabricatorApplicationTransactionEditor {
$topic) { $topic) {
$conpherence = ConpherenceThread::initializeNewRoom($creator); $conpherence = ConpherenceThread::initializeNewRoom($creator);
$files = array();
$errors = array(); $errors = array();
if (empty($participant_phids)) { if (empty($participant_phids)) {
$errors[] = self::ERROR_EMPTY_PARTICIPANTS; $errors[] = self::ERROR_EMPTY_PARTICIPANTS;
@ -35,26 +34,11 @@ final class ConpherenceEditor extends PhabricatorApplicationTransactionEditor {
$errors[] = self::ERROR_EMPTY_MESSAGE; $errors[] = self::ERROR_EMPTY_MESSAGE;
} }
$file_phids = PhabricatorMarkupEngine::extractFilePHIDsFromEmbeddedFiles(
$creator,
array($message));
if ($file_phids) {
$files = id(new PhabricatorFileQuery())
->setViewer($creator)
->withPHIDs($file_phids)
->execute();
}
if (!$errors) { if (!$errors) {
$xactions = array(); $xactions = array();
$xactions[] = id(new ConpherenceTransaction()) $xactions[] = id(new ConpherenceTransaction())
->setTransactionType(ConpherenceTransaction::TYPE_PARTICIPANTS) ->setTransactionType(ConpherenceTransaction::TYPE_PARTICIPANTS)
->setNewValue(array('+' => $participant_phids)); ->setNewValue(array('+' => $participant_phids));
if ($files) {
$xactions[] = id(new ConpherenceTransaction())
->setTransactionType(ConpherenceTransaction::TYPE_FILES)
->setNewValue(array('+' => mpull($files, 'getPHID')));
}
if ($title) { if ($title) {
$xactions[] = id(new ConpherenceTransaction()) $xactions[] = id(new ConpherenceTransaction())
->setTransactionType(ConpherenceTransaction::TYPE_TITLE) ->setTransactionType(ConpherenceTransaction::TYPE_TITLE)
@ -88,27 +72,7 @@ final class ConpherenceEditor extends PhabricatorApplicationTransactionEditor {
ConpherenceThread $conpherence, ConpherenceThread $conpherence,
$text) { $text) {
$files = array();
$file_phids = PhabricatorMarkupEngine::extractFilePHIDsFromEmbeddedFiles(
$viewer,
array($text));
// Since these are extracted from text, we might be re-including the
// same file -- e.g. a mock under discussion. Filter files we
// already have.
$existing_file_phids = $conpherence->getFilePHIDs();
$file_phids = array_diff($file_phids, $existing_file_phids);
if ($file_phids) {
$files = id(new PhabricatorFileQuery())
->setViewer($this->getActor())
->withPHIDs($file_phids)
->execute();
}
$xactions = array(); $xactions = array();
if ($files) {
$xactions[] = id(new ConpherenceTransaction())
->setTransactionType(ConpherenceTransaction::TYPE_FILES)
->setNewValue(array('+' => mpull($files, 'getPHID')));
}
$xactions[] = id(new ConpherenceTransaction()) $xactions[] = id(new ConpherenceTransaction())
->setTransactionType(PhabricatorTransactions::TYPE_COMMENT) ->setTransactionType(PhabricatorTransactions::TYPE_COMMENT)
->attachComment( ->attachComment(
@ -126,7 +90,6 @@ final class ConpherenceEditor extends PhabricatorApplicationTransactionEditor {
$types[] = ConpherenceTransaction::TYPE_TITLE; $types[] = ConpherenceTransaction::TYPE_TITLE;
$types[] = ConpherenceTransaction::TYPE_TOPIC; $types[] = ConpherenceTransaction::TYPE_TOPIC;
$types[] = ConpherenceTransaction::TYPE_PARTICIPANTS; $types[] = ConpherenceTransaction::TYPE_PARTICIPANTS;
$types[] = ConpherenceTransaction::TYPE_FILES;
$types[] = ConpherenceTransaction::TYPE_PICTURE; $types[] = ConpherenceTransaction::TYPE_PICTURE;
$types[] = ConpherenceTransaction::TYPE_PICTURE_CROP; $types[] = ConpherenceTransaction::TYPE_PICTURE_CROP;
$types[] = PhabricatorTransactions::TYPE_VIEW_POLICY; $types[] = PhabricatorTransactions::TYPE_VIEW_POLICY;
@ -154,8 +117,6 @@ final class ConpherenceEditor extends PhabricatorApplicationTransactionEditor {
return array(); return array();
} }
return $object->getParticipantPHIDs(); return $object->getParticipantPHIDs();
case ConpherenceTransaction::TYPE_FILES:
return $object->getFilePHIDs();
} }
} }
@ -172,7 +133,6 @@ final class ConpherenceEditor extends PhabricatorApplicationTransactionEditor {
$file = $xaction->getNewValue(); $file = $xaction->getNewValue();
return $file->getPHID(); return $file->getPHID();
case ConpherenceTransaction::TYPE_PARTICIPANTS: case ConpherenceTransaction::TYPE_PARTICIPANTS:
case ConpherenceTransaction::TYPE_FILES:
return $this->getPHIDTransactionNewValue($xaction); return $this->getPHIDTransactionNewValue($xaction);
} }
} }
@ -335,27 +295,6 @@ final class ConpherenceEditor extends PhabricatorApplicationTransactionEditor {
PhabricatorApplicationTransaction $xaction) { PhabricatorApplicationTransaction $xaction) {
switch ($xaction->getTransactionType()) { switch ($xaction->getTransactionType()) {
case ConpherenceTransaction::TYPE_FILES:
$editor = new PhabricatorEdgeEditor();
$edge_type = PhabricatorObjectHasFileEdgeType::EDGECONST;
$old = array_fill_keys($xaction->getOldValue(), true);
$new = array_fill_keys($xaction->getNewValue(), true);
$add_edges = array_keys(array_diff_key($new, $old));
$remove_edges = array_keys(array_diff_key($old, $new));
foreach ($add_edges as $file_phid) {
$editor->addEdge(
$object->getPHID(),
$edge_type,
$file_phid);
}
foreach ($remove_edges as $file_phid) {
$editor->removeEdge(
$object->getPHID(),
$edge_type,
$file_phid);
}
$editor->save();
break;
case ConpherenceTransaction::TYPE_PARTICIPANTS: case ConpherenceTransaction::TYPE_PARTICIPANTS:
if ($this->getIsNewObject()) { if ($this->getIsNewObject()) {
continue; continue;
@ -488,14 +427,6 @@ final class ConpherenceEditor extends PhabricatorApplicationTransactionEditor {
PhabricatorPolicyCapability::CAN_EDIT); PhabricatorPolicyCapability::CAN_EDIT);
} }
break; break;
// This is similar to PhabricatorTransactions::TYPE_COMMENT so
// use CAN_VIEW
case ConpherenceTransaction::TYPE_FILES:
PhabricatorPolicyFilter::requireCapability(
$this->requireActor(),
$object,
PhabricatorPolicyCapability::CAN_VIEW);
break;
case ConpherenceTransaction::TYPE_TITLE: case ConpherenceTransaction::TYPE_TITLE:
case ConpherenceTransaction::TYPE_TOPIC: case ConpherenceTransaction::TYPE_TOPIC:
PhabricatorPolicyFilter::requireCapability( PhabricatorPolicyFilter::requireCapability(
@ -514,7 +445,6 @@ final class ConpherenceEditor extends PhabricatorApplicationTransactionEditor {
switch ($type) { switch ($type) {
case ConpherenceTransaction::TYPE_TITLE: case ConpherenceTransaction::TYPE_TITLE:
return $v; return $v;
case ConpherenceTransaction::TYPE_FILES:
case ConpherenceTransaction::TYPE_PARTICIPANTS: case ConpherenceTransaction::TYPE_PARTICIPANTS:
return $this->mergePHIDOrEdgeTransactions($u, $v); return $this->mergePHIDOrEdgeTransactions($u, $v);
} }

View file

@ -13,17 +13,11 @@ final class ConpherenceThreadQuery
private $needOrigPics; private $needOrigPics;
private $needTransactions; private $needTransactions;
private $needParticipantCache; private $needParticipantCache;
private $needFilePHIDs;
private $afterTransactionID; private $afterTransactionID;
private $beforeTransactionID; private $beforeTransactionID;
private $transactionLimit; private $transactionLimit;
private $fulltext; private $fulltext;
public function needFilePHIDs($need_file_phids) {
$this->needFilePHIDs = $need_file_phids;
return $this;
}
public function needParticipantCache($participant_cache) { public function needParticipantCache($participant_cache) {
$this->needParticipantCache = $participant_cache; $this->needParticipantCache = $participant_cache;
return $this; return $this;
@ -116,9 +110,6 @@ final class ConpherenceThreadQuery
if ($this->needTransactions) { if ($this->needTransactions) {
$this->loadTransactionsAndHandles($conpherences); $this->loadTransactionsAndHandles($conpherences);
} }
if ($this->needFilePHIDs) {
$this->loadFilePHIDs($conpherences);
}
if ($this->needOrigPics || $this->needCropPics) { if ($this->needOrigPics || $this->needCropPics) {
$this->initImages($conpherences); $this->initImages($conpherences);
} }
@ -275,19 +266,6 @@ final class ConpherenceThreadQuery
return $this; return $this;
} }
private function loadFilePHIDs(array $conpherences) {
$edge_type = PhabricatorObjectHasFileEdgeType::EDGECONST;
$file_edges = id(new PhabricatorEdgeQuery())
->withSourcePHIDs(array_keys($conpherences))
->withEdgeTypes(array($edge_type))
->execute();
foreach ($file_edges as $conpherence_phid => $data) {
$conpherence = $conpherences[$conpherence_phid];
$conpherence->attachFilePHIDs(array_keys($data[$edge_type]));
}
return $this;
}
private function loadOrigPics(array $conpherences) { private function loadOrigPics(array $conpherences) {
return $this->loadPics( return $this->loadPics(
$conpherences, $conpherences,

View file

@ -20,7 +20,6 @@ final class ConpherenceThread extends ConpherenceDAO
private $participants = self::ATTACHABLE; private $participants = self::ATTACHABLE;
private $transactions = self::ATTACHABLE; private $transactions = self::ATTACHABLE;
private $handles = self::ATTACHABLE; private $handles = self::ATTACHABLE;
private $filePHIDs = self::ATTACHABLE;
private $images = self::ATTACHABLE; private $images = self::ATTACHABLE;
public static function initializeNewRoom(PhabricatorUser $sender) { public static function initializeNewRoom(PhabricatorUser $sender) {
@ -31,7 +30,6 @@ final class ConpherenceThread extends ConpherenceDAO
->setTitle('') ->setTitle('')
->setTopic('') ->setTopic('')
->attachParticipants(array()) ->attachParticipants(array())
->attachFilePHIDs(array())
->attachImages(array()) ->attachImages(array())
->setViewPolicy($default_policy) ->setViewPolicy($default_policy)
->setEditPolicy($default_policy) ->setEditPolicy($default_policy)
@ -158,14 +156,6 @@ final class ConpherenceThread extends ConpherenceDAO
$amount); $amount);
} }
public function attachFilePHIDs(array $file_phids) {
$this->filePHIDs = $file_phids;
return $this;
}
public function getFilePHIDs() {
return $this->assertAttached($this->filePHIDs);
}
public function loadImageURI($size) { public function loadImageURI($size) {
$file = $this->getImage($size); $file = $this->getImage($size);

View file

@ -2,7 +2,6 @@
final class ConpherenceTransaction extends PhabricatorApplicationTransaction { final class ConpherenceTransaction extends PhabricatorApplicationTransaction {
const TYPE_FILES = 'files';
const TYPE_TITLE = 'title'; const TYPE_TITLE = 'title';
const TYPE_TOPIC = 'topic'; const TYPE_TOPIC = 'topic';
const TYPE_PARTICIPANTS = 'participants'; const TYPE_PARTICIPANTS = 'participants';
@ -44,8 +43,6 @@ final class ConpherenceTransaction extends PhabricatorApplicationTransaction {
case self::TYPE_PICTURE: case self::TYPE_PICTURE:
case self::TYPE_DATE_MARKER: case self::TYPE_DATE_MARKER:
return false; return false;
case self::TYPE_FILES:
return true;
case self::TYPE_PICTURE_CROP: case self::TYPE_PICTURE_CROP:
return true; return true;
} }
@ -68,29 +65,6 @@ final class ConpherenceTransaction extends PhabricatorApplicationTransaction {
case self::TYPE_PICTURE: case self::TYPE_PICTURE:
return $this->getRoomTitle(); return $this->getRoomTitle();
break; break;
case self::TYPE_FILES:
$add = array_diff($new, $old);
$rem = array_diff($old, $new);
if ($add && $rem) {
$title = pht(
'%s edited files(s), added %d and removed %d.',
$this->renderHandleLink($author_phid),
count($add),
count($rem));
} else if ($add) {
$title = pht(
'%s added %s files(s).',
$this->renderHandleLink($author_phid),
phutil_count($add));
} else {
$title = pht(
'%s removed %s file(s).',
$this->renderHandleLink($author_phid),
phutil_count($rem));
}
return $title;
break;
case self::TYPE_PARTICIPANTS: case self::TYPE_PARTICIPANTS:
$add = array_diff($new, $old); $add = array_diff($new, $old);
$rem = array_diff($old, $new); $rem = array_diff($old, $new);
@ -252,7 +226,6 @@ final class ConpherenceTransaction extends PhabricatorApplicationTransaction {
switch ($this->getTransactionType()) { switch ($this->getTransactionType()) {
case self::TYPE_TITLE: case self::TYPE_TITLE:
case self::TYPE_PICTURE: case self::TYPE_PICTURE:
case self::TYPE_FILES:
case self::TYPE_DATE_MARKER: case self::TYPE_DATE_MARKER:
break; break;
case self::TYPE_PARTICIPANTS: case self::TYPE_PARTICIPANTS:

View file

@ -227,9 +227,6 @@ final class ConpherenceTransactionView extends AphrontView {
$content = null; $content = null;
$handles = $this->getHandles(); $handles = $this->getHandles();
switch ($transaction->getTransactionType()) { switch ($transaction->getTransactionType()) {
case ConpherenceTransaction::TYPE_FILES:
$content = $transaction->getTitle();
break;
case ConpherenceTransaction::TYPE_TITLE: case ConpherenceTransaction::TYPE_TITLE:
case ConpherenceTransaction::TYPE_TOPIC: case ConpherenceTransaction::TYPE_TOPIC:
case ConpherenceTransaction::TYPE_PICTURE: case ConpherenceTransaction::TYPE_PICTURE: