1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-18 19:40:55 +01:00

Remove "needWidgetData" from Conpherence

Summary: We no longer have widgets, don't need these calls for simplicity.

Test Plan: Add a user to a room, remove a user from a room. Grep for `needWidgetData`

Reviewers: epriestley

Reviewed By: epriestley

Subscribers: Korvin

Differential Revision: https://secure.phabricator.com/D16562
This commit is contained in:
Chad Little 2016-09-16 13:46:01 -07:00
parent f6023d17da
commit 5cffe9e5e5
4 changed files with 4 additions and 117 deletions

View file

@ -17,7 +17,7 @@ final class ConpherenceParticipantController extends ConpherenceController {
$conpherence = id(new ConpherenceThreadQuery())
->setViewer($viewer)
->withIDs(array($conpherence_id))
->needWidgetData(true)
->needParticipants(true)
->executeOne();
if (!$conpherence) {

View file

@ -597,7 +597,7 @@ final class ConpherenceUpdateController
->setAfterTransactionID($latest_transaction_id)
->needCropPics(true)
->needParticipantCache($need_participant_cache)
->needWidgetData($need_widget_data)
->needParticipants(true)
->needTransactions($need_transactions)
->withIDs(array($conpherence_id))
->executeOne();

View file

@ -9,7 +9,6 @@ final class ConpherenceThreadQuery
private $ids;
private $participantPHIDs;
private $needParticipants;
private $needWidgetData;
private $needCropPics;
private $needOrigPics;
private $needTransactions;
@ -35,11 +34,6 @@ final class ConpherenceThreadQuery
return $this;
}
public function needWidgetData($need_widget_data) {
$this->needWidgetData = $need_widget_data;
return $this;
}
public function needCropPics($need) {
$this->needCropPics = $need;
return $this;
@ -116,18 +110,15 @@ final class ConpherenceThreadQuery
if ($this->needParticipantCache) {
$this->loadCoreHandles($conpherences, 'getRecentParticipantPHIDs');
}
if ($this->needWidgetData || $this->needParticipants) {
if ($this->needParticipants) {
$this->loadCoreHandles($conpherences, 'getParticipantPHIDs');
}
if ($this->needTransactions) {
$this->loadTransactionsAndHandles($conpherences);
}
if ($this->needFilePHIDs || $this->needWidgetData) {
if ($this->needFilePHIDs) {
$this->loadFilePHIDs($conpherences);
}
if ($this->needWidgetData) {
$this->loadWidgetData($conpherences);
}
if ($this->needOrigPics || $this->needCropPics) {
$this->initImages($conpherences);
}
@ -297,101 +288,6 @@ final class ConpherenceThreadQuery
return $this;
}
private function loadWidgetData(array $conpherences) {
$participant_phids = array();
$file_phids = array();
foreach ($conpherences as $conpherence) {
$participant_phids[] = array_keys($conpherence->getParticipants());
$file_phids[] = $conpherence->getFilePHIDs();
}
$participant_phids = array_mergev($participant_phids);
$file_phids = array_mergev($file_phids);
$epochs = CalendarTimeUtil::getCalendarEventEpochs(
$this->getViewer());
$start_epoch = $epochs['start_epoch'];
$end_epoch = $epochs['end_epoch'];
$events = array();
if ($participant_phids) {
// TODO: All of this Calendar code is probably extra-broken, but none
// of it is currently reachable in the UI.
$events = id(new PhabricatorCalendarEventQuery())
->setViewer($this->getViewer())
->withInvitedPHIDs($participant_phids)
->withIsCancelled(false)
->withDateRange($start_epoch, $end_epoch)
->execute();
$events = mpull($events, null, 'getPHID');
}
$invitees = array();
foreach ($events as $event_phid => $event) {
foreach ($event->getInvitees() as $invitee) {
$invitees[$invitee->getInviteePHID()][$event_phid] = true;
}
}
// attached files
$files = array();
$file_author_phids = array();
$authors = array();
if ($file_phids) {
$files = id(new PhabricatorFileQuery())
->setViewer($this->getViewer())
->withPHIDs($file_phids)
->execute();
$files = mpull($files, null, 'getPHID');
$file_author_phids = mpull($files, 'getAuthorPHID', 'getPHID');
$authors = id(new PhabricatorHandleQuery())
->setViewer($this->getViewer())
->withPHIDs($file_author_phids)
->execute();
$authors = mpull($authors, null, 'getPHID');
}
foreach ($conpherences as $phid => $conpherence) {
$participant_phids = array_keys($conpherence->getParticipants());
$widget_data = array();
$event_phids = array();
$participant_invites = array_select_keys($invitees, $participant_phids);
foreach ($participant_invites as $invite_set) {
$event_phids += $invite_set;
}
$thread_events = array_select_keys($events, array_keys($event_phids));
$thread_events = msort($thread_events, 'getDateFrom');
$widget_data['events'] = $thread_events;
$conpherence_files = array();
$files_authors = array();
foreach ($conpherence->getFilePHIDs() as $curr_phid) {
$curr_file = idx($files, $curr_phid);
if (!$curr_file) {
// this file was deleted or user doesn't have permission to see it
// this is generally weird
continue;
}
$conpherence_files[$curr_phid] = $curr_file;
// some files don't have authors so be careful
$current_author = null;
$current_author_phid = idx($file_author_phids, $curr_phid);
if ($current_author_phid) {
$current_author = $authors[$current_author_phid];
}
$files_authors[$curr_phid] = $current_author;
}
$widget_data += array(
'files' => $conpherence_files,
'files_authors' => $files_authors,
);
$conpherence->attachWidgetData($widget_data);
}
return $this;
}
private function loadOrigPics(array $conpherences) {
return $this->loadPics(
$conpherences,

View file

@ -21,7 +21,6 @@ final class ConpherenceThread extends ConpherenceDAO
private $transactions = self::ATTACHABLE;
private $handles = self::ATTACHABLE;
private $filePHIDs = self::ATTACHABLE;
private $widgetData = self::ATTACHABLE;
private $images = self::ATTACHABLE;
public static function initializeNewRoom(PhabricatorUser $sender) {
@ -167,14 +166,6 @@ final class ConpherenceThread extends ConpherenceDAO
return $this->assertAttached($this->filePHIDs);
}
public function attachWidgetData(array $widget_data) {
$this->widgetData = $widget_data;
return $this;
}
public function getWidgetData() {
return $this->assertAttached($this->widgetData);
}
public function loadImageURI($size) {
$file = $this->getImage($size);