1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2025-01-07 13:21:02 +01:00
phorge-phorge/src/applications/conpherence/conduit/ConpherenceQueryTransactionConduitAPIMethod.php
Bob Trahan 541e3d9e1c Conpherence - remove room vs message distinction as far as users are concerned
Summary:
Ref T8488, T8469, T8485.

This is done in regards to T8488 as far as users are concerned. There's still some classes, and etc. that should be re-named probably. T8469 and T8485 are basically moot now though.

Rather than having "Send Message" exposed, just expose "Create Room". Users get the full form. One change is "title" is now required.

This diff removes the concept of "isRoom" entirely.

Test Plan: Verifed a user with no conpherences had sensible data in both column view and full conpherence view. Created rooms with various policies and things worked well.

Reviewers: epriestley

Reviewed By: epriestley

Subscribers: chad, epriestley, Korvin

Maniphest Tasks: T8469, T8485, T8488

Differential Revision: https://secure.phabricator.com/D13351
2015-06-25 13:14:20 -07:00

97 lines
2.8 KiB
PHP

<?php
final class ConpherenceQueryTransactionConduitAPIMethod
extends ConpherenceConduitAPIMethod {
public function getAPIMethodName() {
return 'conpherence.querytransaction';
}
public function getMethodDescription() {
return pht(
'Query for transactions for the logged in user within a specific '.
'Conpherence room. You can specify the room by ID or PHID. '.
'Otherwise, specify limit and offset to query the most recent '.
'transactions within the Conpherence room for the logged in user.');
}
protected function defineParamTypes() {
return array(
'roomID' => 'optional int',
'roomPHID' => 'optional phid',
'limit' => 'optional int',
'offset' => 'optional int',
);
}
protected function defineReturnType() {
return 'nonempty dict';
}
protected function defineErrorTypes() {
return array(
'ERR_USAGE_NO_ROOM_ID' => pht(
'You must specify a room id or room PHID to query transactions '.
'from.'),
);
}
protected function execute(ConduitAPIRequest $request) {
$user = $request->getUser();
$room_id = $request->getValue('roomID');
$room_phid = $request->getValue('roomPHID');
$limit = $request->getValue('limit');
$offset = $request->getValue('offset');
$query = id(new ConpherenceThreadQuery())
->setViewer($user);
if ($room_id) {
$query->withIDs(array($room_id));
} else if ($room_phid) {
$query->withPHIDs(array($room_phid));
} else {
throw new ConduitException('ERR_USAGE_NO_ROOM_ID');
}
$conpherence = $query->executeOne();
$query = id(new ConpherenceTransactionQuery())
->setViewer($user)
->withObjectPHIDs(array($conpherence->getPHID()))
->setLimit($limit)
->setOffset($offset);
$transactions = $query->execute();
$data = array();
foreach ($transactions as $transaction) {
$comment = null;
$comment_obj = $transaction->getComment();
if ($comment_obj) {
$comment = $comment_obj->getContent();
}
$title = null;
$title_obj = $transaction->getTitle();
if ($title_obj) {
$title = $title_obj->getHTMLContent();
}
$id = $transaction->getID();
$data[$id] = array(
'transactionID' => $id,
'transactionType' => $transaction->getTransactionType(),
'transactionTitle' => $title,
'transactionComment' => $comment,
'transactionOldValue' => $transaction->getOldValue(),
'transactionNewValue' => $transaction->getNewValue(),
'transactionMetadata' => $transaction->getMetadata(),
'authorPHID' => $transaction->getAuthorPHID(),
'dateCreated' => $transaction->getDateCreated(),
'roomID' => $conpherence->getID(),
'roomPHID' => $conpherence->getPHID(),
);
}
return $data;
}
}