1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-27 09:12:41 +01:00

Add basic feed stories for Conpherence

Summary: [Draft] Posting this up because feed is pulling `getTitle` and not `getTitleForFeed` and I'm super confused. Restarted phd and apache.

Test Plan: Create a new room, see link in feed. Change topic, see story, add people, don't see story.

Reviewers: epriestley

Reviewed By: epriestley

Subscribers: Korvin

Maniphest Tasks: T11645

Differential Revision: https://secure.phabricator.com/D16561
This commit is contained in:
Chad Little 2016-09-16 14:24:39 -07:00
parent 7f6fa28363
commit 1ea6fe9387
3 changed files with 64 additions and 4 deletions

View file

@ -16,16 +16,16 @@ final class ConpherenceNewRoomController extends ConpherenceController {
$editor = new ConpherenceEditor(); $editor = new ConpherenceEditor();
$xactions = array(); $xactions = array();
$xactions[] = id(new ConpherenceTransaction())
->setTransactionType(ConpherenceTransaction::TYPE_TITLE)
->setNewValue($request->getStr('title'));
$participants = $request->getArr('participants'); $participants = $request->getArr('participants');
$participants[] = $user->getPHID(); $participants[] = $user->getPHID();
$participants = array_unique($participants); $participants = array_unique($participants);
$xactions[] = id(new ConpherenceTransaction()) $xactions[] = id(new ConpherenceTransaction())
->setTransactionType(ConpherenceTransaction::TYPE_PARTICIPANTS) ->setTransactionType(ConpherenceTransaction::TYPE_PARTICIPANTS)
->setNewValue(array('+' => $participants)); ->setNewValue(array('+' => $participants));
$xactions[] = id(new ConpherenceTransaction())
->setTransactionType(ConpherenceTransaction::TYPE_TITLE)
->setNewValue($request->getStr('title'));
$xactions[] = id(new ConpherenceTransaction()) $xactions[] = id(new ConpherenceTransaction())
->setTransactionType(ConpherenceTransaction::TYPE_TOPIC) ->setTransactionType(ConpherenceTransaction::TYPE_TOPIC)
->setNewValue($request->getStr('topic')); ->setNewValue($request->getStr('topic'));

View file

@ -623,6 +623,17 @@ final class ConpherenceEditor extends PhabricatorApplicationTransactionEditor {
protected function shouldPublishFeedStory( protected function shouldPublishFeedStory(
PhabricatorLiskDAO $object, PhabricatorLiskDAO $object,
array $xactions) { array $xactions) {
foreach ($xactions as $xaction) {
switch ($xaction->getTransactionType()) {
case ConpherenceTransaction::TYPE_TITLE:
case ConpherenceTransaction::TYPE_TOPIC:
case ConpherenceTransaction::TYPE_PICTURE:
return true;
default:
return false;
}
}
return false; return false;
} }

View file

@ -123,6 +123,55 @@ final class ConpherenceTransaction extends PhabricatorApplicationTransaction {
return parent::getTitle(); return parent::getTitle();
} }
public function getTitleForFeed() {
$author_phid = $this->getAuthorPHID();
$object_phid = $this->getObjectPHID();
$old = $this->getOldValue();
$new = $this->getNewValue();
$type = $this->getTransactionType();
switch ($type) {
case self::TYPE_TITLE:
if (strlen($old) && strlen($new)) {
return pht(
'%s renamed %s from "%s" to "%s".',
$this->renderHandleLink($author_phid),
$this->renderHandleLink($object_phid),
$old,
$new);
} else {
return pht(
'%s created the room %s.',
$this->renderHandleLink($author_phid),
$this->renderHandleLink($object_phid));
}
break;
break;
case self::TYPE_TOPIC:
if (strlen($new)) {
return pht(
'%s set the topic of %s to "%s".',
$this->renderHandleLink($author_phid),
$this->renderHandleLink($object_phid),
$new);
} else if (strlen($old)) {
return pht(
'%s deleted the topic in %s',
$this->renderHandleLink($author_phid),
$this->renderHandleLink($object_phid));
}
break;
case self::TYPE_PICTURE:
return pht(
'%s updated the room image for %s.',
$this->renderHandleLink($author_phid),
$this->renderHandleLink($object_phid));
break;
}
return parent::getTitleForFeed();
}
private function getRoomTitle() { private function getRoomTitle() {
$author_phid = $this->getAuthorPHID(); $author_phid = $this->getAuthorPHID();