diff --git a/src/applications/feed/worker/FeedPublisherHTTPWorker.php b/src/applications/feed/worker/FeedPublisherHTTPWorker.php index 1d14a6d9ea..e949359f18 100644 --- a/src/applications/feed/worker/FeedPublisherHTTPWorker.php +++ b/src/applications/feed/worker/FeedPublisherHTTPWorker.php @@ -1,29 +1,30 @@ loadFeedStory(); $data = $story->getStoryData(); $uri = idx($this->getTaskData(), 'uri'); $post_data = array( 'storyID' => $data->getID(), 'storyType' => $data->getStoryType(), 'storyData' => $data->getStoryData(), 'storyAuthorPHID' => $data->getAuthorPHID(), + 'storyText' => $story->renderText(), 'epoch' => $data->getEpoch(), ); id(new HTTPSFuture($uri, $post_data)) ->setMethod('POST') ->setTimeout(30) ->resolvex(); } public function getWaitBeforeRetry(PhabricatorWorkerTask $task) { return max($task->getFailureCount(), 1) * 60; } } diff --git a/src/applications/tokens/feed/PhabricatorTokenGivenFeedStory.php b/src/applications/tokens/feed/PhabricatorTokenGivenFeedStory.php index 370a54c55d..f8a89d968b 100644 --- a/src/applications/tokens/feed/PhabricatorTokenGivenFeedStory.php +++ b/src/applications/tokens/feed/PhabricatorTokenGivenFeedStory.php @@ -1,54 +1,54 @@ getValue('objectPHID'); } public function getRequiredHandlePHIDs() { $phids = array(); $phids[] = $this->getValue('objectPHID'); $phids[] = $this->getValue('authorPHID'); return $phids; } public function getRequiredObjectPHIDs() { $phids = array(); $phids[] = $this->getValue('tokenPHID'); return $phids; } public function renderView() { $view = $this->newStoryView(); $view->setAppIcon('token-dark'); $author_phid = $this->getValue('authorPHID'); $href = $this->getHandle($this->getPrimaryObjectPHID())->getURI(); $view->setHref($href); $token = $this->getObject($this->getValue('tokenPHID')); $title = pht( '%s awarded %s a %s token.', $this->linkTo($this->getValue('authorPHID')), $this->linkTo($this->getValue('objectPHID')), $token->getName()); $view->setTitle($title); $view->setImage($this->getHandle($author_phid)->getImageURI()); return $view; } public function renderText() { // TODO: This is grotesque; the feed notification handler relies on it. return htmlspecialchars_decode( strip_tags( hsprintf( '%s', - $this->renderView()->render()))); + $this->renderView()->getTitle()))); } } diff --git a/src/applications/transactions/feed/PhabricatorApplicationTransactionFeedStory.php b/src/applications/transactions/feed/PhabricatorApplicationTransactionFeedStory.php index a5af332ff3..c6916ce38b 100644 --- a/src/applications/transactions/feed/PhabricatorApplicationTransactionFeedStory.php +++ b/src/applications/transactions/feed/PhabricatorApplicationTransactionFeedStory.php @@ -1,76 +1,76 @@ getValue('objectPHID'); } public function getRequiredObjectPHIDs() { return $this->getValue('transactionPHIDs'); } public function getRequiredHandlePHIDs() { $phids = array(); $phids[] = $this->getValue('objectPHID'); foreach ($this->getValue('transactionPHIDs') as $xaction_phid) { $xaction = $this->getObject($xaction_phid); foreach ($xaction->getRequiredHandlePHIDs() as $handle_phid) { $phids[] = $handle_phid; } } return $phids; } protected function getPrimaryTransactionPHID() { return head($this->getValue('transactionPHIDs')); } protected function getPrimaryTransaction() { return $this->getObject($this->getPrimaryTransactionPHID()); } public function renderView() { $view = $this->newStoryView(); $handle = $this->getHandle($this->getPrimaryObjectPHID()); $view->setHref($handle->getURI()); $view->setAppIconFromPHID($handle->getPHID()); $xaction_phids = $this->getValue('transactionPHIDs'); $xaction = $this->getPrimaryTransaction(); $xaction->setHandles($this->getHandles()); $view->setTitle($xaction->getTitleForFeed($this)); foreach ($xaction_phids as $xaction_phid) { $secondary_xaction = $this->getObject($xaction_phid); $secondary_xaction->setHandles($this->getHandles()); $body = $secondary_xaction->getBodyForFeed($this); if (nonempty($body)) { $view->appendChild($body); } } $view->setImage( $this->getHandle($xaction->getAuthorPHID())->getImageURI()); return $view; } public function renderText() { // TODO: This is grotesque; the feed notification handler relies on it. return htmlspecialchars_decode( strip_tags( hsprintf( '%s', - $this->renderView()->render()))); + $this->renderView()->getTitle()))); } } diff --git a/src/view/phui/PHUIFeedStoryView.php b/src/view/phui/PHUIFeedStoryView.php index edf26ba7d6..c1b4df9cb2 100644 --- a/src/view/phui/PHUIFeedStoryView.php +++ b/src/view/phui/PHUIFeedStoryView.php @@ -1,283 +1,287 @@ chronologicalKey = $chronological_key; return $this; } public function getChronologicalKey() { return $this->chronologicalKey; } public function setTitle($title) { $this->title = $title; return $this; } + public function getTitle() { + return $this->title; + } + public function setEpoch($epoch) { $this->epoch = $epoch; return $this; } public function setImage($image) { $this->image = $image; return $this; } public function setImageHref($image_href) { $this->imageHref = $image_href; return $this; } public function setAppIcon($icon) { $this->appIcon = $icon; return $this; } public function setViewed($viewed) { $this->viewed = $viewed; return $this; } public function getViewed() { return $this->viewed; } public function setHref($href) { $this->href = $href; return $this; } public function setTokenBar(array $tokens) { $this->tokenBar = $tokens; return $this; } public function addProject($project) { $this->projects[] = $project; return $this; } public function addAction(PHUIIconView $action) { $this->actions[] = $action; return $this; } public function setPontification($text, $title = null) { if ($title) { $title = phutil_tag('h3', array(), $title); } $copy = phutil_tag( 'div', array( 'class' => 'phui-feed-story-bigtext-post', ), array( $title, $text)); $this->appendChild($copy); return $this; } public function getHref() { return $this->href; } public function renderNotification($user) { $classes = array( 'phabricator-notification', ); if (!$this->viewed) { $classes[] = 'phabricator-notification-unread'; } if ($this->epoch) { if ($user) { $foot = phabricator_datetime($this->epoch, $user); $foot = phutil_tag( 'span', array( 'class' => 'phabricator-notification-date'), $foot); } else { $foot = null; } } else { $foot = pht('No time specified.'); } return javelin_tag( 'div', array( 'class' => implode(' ', $classes), 'sigil' => 'notification', 'meta' => array( 'href' => $this->getHref(), ), ), array($this->title, $foot)); } public function render() { require_celerity_resource('phui-feed-story-css'); Javelin::initBehavior('phabricator-hovercards'); $oneline = !$this->hasChildren(); $body = null; $foot = null; $image_style = null; $actor = ''; if ($this->image) { $actor = new PHUIIconView(); $actor->setImage($this->image); $actor->addClass('phui-feed-story-actor-image'); if ($this->imageHref) { $actor->setHref($this->imageHref); } } if ($this->epoch) { // TODO: This is really bad; when rendering through Conduit and via // renderText() we don't have a user. if ($this->user) { $foot = phabricator_datetime($this->epoch, $this->user); } else { $foot = null; } } else { $foot = pht('No time specified.'); } if ($this->chronologicalKey) { $foot = phutil_tag( 'a', array( 'href' => '/feed/'.$this->chronologicalKey.'/', ), $foot); } $icon = null; if ($this->appIcon) { $icon = new PHUIIconView(); $icon->setSpriteIcon($this->appIcon); $icon->setSpriteSheet(PHUIIconView::SPRITE_APPS); } $ol_foot = null; if ($oneline) { $ol_foot = phutil_tag( 'div', array( 'class' => 'phui-feed-story-oneline-foot' ), array( $icon, $foot)); } $action_list = array(); $icons = null; foreach ($this->actions as $action) { $action_list[] = phutil_tag( 'li', array( 'class' => 'phui-feed-story-action-item' ), $action); } if (!empty($action_list)) { $icons = phutil_tag( 'ul', array( 'class' => 'phui-feed-story-action-list' ), $action_list); } $head = phutil_tag( 'div', array( 'class' => 'phui-feed-story-head', ), array( (!$oneline ? $actor : null), nonempty($this->title, pht('Untitled Story')), $icons, $ol_foot )); if (!empty($this->tokenBar)) { $tokenview = phutil_tag( 'div', array( 'class' => 'phui-feed-token-bar' ), $this->tokenBar); $this->appendChild($tokenview); } $body_content = $this->renderChildren(); if ($body_content) { $body = phutil_tag( 'div', array( 'class' => 'phui-feed-story-body', ), $body_content); } if ($oneline) { $foot = null; } else { $foot = phutil_tag( 'div', array( 'class' => 'phui-feed-story-foot', ), array( $icon, $foot)); } $classes = array('phui-feed-story'); if ($oneline) { $classes[] = 'phui-feed-story-oneline'; } return id(new PHUIBoxView()) ->addClass(implode(' ', $classes)) ->setBorder(true) ->addMargin(PHUI::MARGIN_MEDIUM_BOTTOM) ->appendChild(array($head, $body, $foot)); } public function setAppIconFromPHID($phid) { switch (phid_get_type($phid)) { case PholioPHIDTypeMock::TYPECONST: $this->setAppIcon("pholio-dark"); break; case PhabricatorMacroPHIDTypeMacro::TYPECONST: $this->setAppIcon("macro-dark"); break; } } }