Page MenuHomestyx hydra

No OneTemporary

diff --git a/src/applications/feed/conduit/ConduitAPI_feed_query_Method.php b/src/applications/feed/conduit/ConduitAPI_feed_query_Method.php
index f75d5fb33d..f9d661ee39 100644
--- a/src/applications/feed/conduit/ConduitAPI_feed_query_Method.php
+++ b/src/applications/feed/conduit/ConduitAPI_feed_query_Method.php
@@ -1,127 +1,128 @@
<?php
/**
* @group conduit
*/
final class ConduitAPI_feed_query_Method extends ConduitAPIMethod {
public function getMethodStatus() {
return self::METHOD_STATUS_UNSTABLE;
}
public function getMethodDescription() {
return "Query the feed for stories";
}
private function getDefaultLimit() {
return 100;
}
public function defineParamTypes() {
return array(
'filterPHIDs' => 'optional list <phid>',
'limit' => 'optional int (default '.$this->getDefaultLimit().')',
'after' => 'optional int',
- 'view' => 'optional string (data, html, html-summary)',
+ 'view' => 'optional string (data, html, html-summary, text)',
);
}
private function getSupportedViewTypes() {
return array(
'html' => 'Full HTML presentation of story',
'data' => 'Dictionary with various data of the story',
'html-summary' => 'Story contains only the title of the story',
+ 'text' => 'Simple one-line plain text representation of story',
);
}
public function defineErrorTypes() {
$view_types = array_keys($this->getSupportedViewTypes());
$view_types = implode(', ', $view_types);
return array(
'ERR-UNKNOWN-TYPE' =>
'Unsupported view type, possibles are: ' . $view_types
);
}
public function defineReturnType() {
return 'nonempty dict';
}
protected function execute(ConduitAPIRequest $request) {
$results = array();
$user = $request->getUser();
$view_type = $request->getValue('view');
if (!$view_type) {
$view_type = 'data';
}
$limit = $request->getValue('limit');
if (!$limit) {
$limit = $this->getDefaultLimit();
}
$filter_phids = $request->getValue('filterPHIDs');
if (!$filter_phids) {
$filter_phids = array();
}
$after = $request->getValue('after');
$query = id(new PhabricatorFeedQuery())
->setLimit($limit)
->setFilterPHIDs($filter_phids)
->setViewer($user)
->setAfterID($after);
$stories = $query->execute();
if ($stories) {
foreach ($stories as $story) {
$story_data = $story->getStoryData();
$data = null;
$view = $story->renderView();
$view->setEpoch($story->getEpoch());
$view->setUser($user);
switch ($view_type) {
case 'html':
$data = $view->render();
break;
case 'html-summary':
$view->setOneLineStory(true);
$data = $view->render();
break;
case 'data':
$data = array(
'class' => $story_data->getStoryType(),
'epoch' => $story_data->getEpoch(),
'authorPHID' => $story_data->getAuthorPHID(),
'chronologicalKey' => $story_data->getChronologicalKey(),
'data' => $story_data->getStoryData(),
);
break;
case 'text':
$data = array(
'class' => $story_data->getStoryType(),
'epoch' => $story_data->getEpoch(),
'authorPHID' => $story_data->getAuthorPHID(),
'chronologicalKey' => $story_data->getChronologicalKey(),
'text' => $story->renderText()
);
break;
default:
throw new ConduitException('ERR-UNKNOWN-TYPE');
}
$results[$story_data->getPHID()] = $data;
}
}
return $results;
}
}
diff --git a/src/applications/feed/story/PhabricatorFeedStoryPhriction.php b/src/applications/feed/story/PhabricatorFeedStoryPhriction.php
index 8efe6af6d9..9e22f7d5b2 100644
--- a/src/applications/feed/story/PhabricatorFeedStoryPhriction.php
+++ b/src/applications/feed/story/PhabricatorFeedStoryPhriction.php
@@ -1,60 +1,63 @@
<?php
final class PhabricatorFeedStoryPhriction extends PhabricatorFeedStory {
public function getPrimaryObjectPHID() {
return $this->getValue('phid');
}
public function renderView() {
$data = $this->getStoryData();
$author_phid = $data->getAuthorPHID();
$document_phid = $data->getValue('phid');
$view = new PhabricatorFeedStoryView();
$action = $data->getValue('action');
$verb = PhrictionActionConstants::getActionPastTenseVerb($action);
$view->setTitle(
$this->linkTo($author_phid).
" {$verb} the document ".
$this->linkTo($document_phid).'.');
$view->setEpoch($data->getEpoch());
$action = $data->getValue('action');
switch ($action) {
case PhrictionActionConstants::ACTION_CREATE:
$full_size = true;
break;
default:
$full_size = false;
break;
}
if ($full_size) {
$view->setImage($this->getHandle($author_phid)->getImageURI());
$content = $this->renderSummary($data->getValue('content'));
$view->appendChild($content);
} else {
$view->setOneLineStory(true);
}
return $view;
}
public function renderText() {
$author_name = $this->getHandle($this->getAuthorPHID())->getLinkName();
$document_handle = $this->getHandle($this->getPrimaryObjectPHID());
$document_title = $document_handle->getLinkName();
$document_uri = PhabricatorEnv::getURI($document_handle->getURI());
+ $action = $this->getValue('action');
+ $verb = PhrictionActionConstants::getActionPastTenseVerb($action);
+
$text = "{$author_name} {$verb} the document".
"{$document_title} {$document_uri}";
return $text;
}
}

File Metadata

Mime Type
text/x-diff
Expires
Mon, Jul 28, 8:14 PM (1 w, 3 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
187463
Default Alt Text
(5 KB)

Event Timeline