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

Remove previous-generation Phame Conduit API methods

Summary: Ref T9897. We can now provide modern `search` and `edit` endpoints (I'll do this next).

Test Plan: Grepped for removed methods.

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T9897

Differential Revision: https://secure.phabricator.com/D14898
This commit is contained in:
epriestley 2015-12-28 03:50:22 -08:00
parent 10ed330523
commit 6cb01374a5
5 changed files with 0 additions and 289 deletions

View file

@ -3417,10 +3417,8 @@ phutil_register_library_map(array(
'PhameBlogTransaction' => 'applications/phame/storage/PhameBlogTransaction.php',
'PhameBlogTransactionQuery' => 'applications/phame/query/PhameBlogTransactionQuery.php',
'PhameBlogViewController' => 'applications/phame/controller/blog/PhameBlogViewController.php',
'PhameConduitAPIMethod' => 'applications/phame/conduit/PhameConduitAPIMethod.php',
'PhameConstants' => 'applications/phame/constants/PhameConstants.php',
'PhameController' => 'applications/phame/controller/PhameController.php',
'PhameCreatePostConduitAPIMethod' => 'applications/phame/conduit/PhameCreatePostConduitAPIMethod.php',
'PhameDAO' => 'applications/phame/storage/PhameDAO.php',
'PhameDescriptionView' => 'applications/phame/view/PhameDescriptionView.php',
'PhameDraftListView' => 'applications/phame/view/PhameDraftListView.php',
@ -3445,8 +3443,6 @@ phutil_register_library_map(array(
'PhamePostTransactionComment' => 'applications/phame/storage/PhamePostTransactionComment.php',
'PhamePostTransactionQuery' => 'applications/phame/query/PhamePostTransactionQuery.php',
'PhamePostViewController' => 'applications/phame/controller/post/PhamePostViewController.php',
'PhameQueryConduitAPIMethod' => 'applications/phame/conduit/PhameQueryConduitAPIMethod.php',
'PhameQueryPostsConduitAPIMethod' => 'applications/phame/conduit/PhameQueryPostsConduitAPIMethod.php',
'PhameSchemaSpec' => 'applications/phame/storage/PhameSchemaSpec.php',
'PhameSite' => 'applications/phame/site/PhameSite.php',
'PhluxController' => 'applications/phlux/controller/PhluxController.php',
@ -7868,10 +7864,8 @@ phutil_register_library_map(array(
'PhameBlogTransaction' => 'PhabricatorApplicationTransaction',
'PhameBlogTransactionQuery' => 'PhabricatorApplicationTransactionQuery',
'PhameBlogViewController' => 'PhameLiveController',
'PhameConduitAPIMethod' => 'ConduitAPIMethod',
'PhameConstants' => 'Phobject',
'PhameController' => 'PhabricatorController',
'PhameCreatePostConduitAPIMethod' => 'PhameConduitAPIMethod',
'PhameDAO' => 'PhabricatorLiskDAO',
'PhameDescriptionView' => 'AphrontTagView',
'PhameDraftListView' => 'AphrontTagView',
@ -7906,8 +7900,6 @@ phutil_register_library_map(array(
'PhamePostTransactionComment' => 'PhabricatorApplicationTransactionComment',
'PhamePostTransactionQuery' => 'PhabricatorApplicationTransactionQuery',
'PhamePostViewController' => 'PhameLiveController',
'PhameQueryConduitAPIMethod' => 'PhameConduitAPIMethod',
'PhameQueryPostsConduitAPIMethod' => 'PhameConduitAPIMethod',
'PhameSchemaSpec' => 'PhabricatorConfigSchemaSpec',
'PhameSite' => 'PhabricatorSite',
'PhluxController' => 'PhabricatorController',

View file

@ -1,9 +0,0 @@
<?php
abstract class PhameConduitAPIMethod extends ConduitAPIMethod {
final public function getApplication() {
return PhabricatorApplication::getByClass('PhabricatorPhameApplication');
}
}

View file

@ -1,97 +0,0 @@
<?php
final class PhameCreatePostConduitAPIMethod extends PhameConduitAPIMethod {
public function getAPIMethodName() {
return 'phame.createpost';
}
public function getMethodDescription() {
return pht('Create a phame post.');
}
public function getMethodStatus() {
return self::METHOD_STATUS_UNSTABLE;
}
protected function defineParamTypes() {
return array(
'blogPHID' => 'required phid',
'title' => 'required string',
'body' => 'required string',
'bloggerPHID' => 'optional phid',
'isDraft' => 'optional bool',
);
}
protected function defineReturnType() {
return 'list<dict>';
}
protected function defineErrorTypes() {
return array(
'ERR-INVALID-PARAMETER' =>
pht('Missing or malformed parameter.'),
'ERR-INVALID-BLOG' =>
pht('Invalid blog PHID or user can not post to blog.'),
);
}
protected function execute(ConduitAPIRequest $request) {
$user = $request->getUser();
$blog_phid = $request->getValue('blogPHID');
$title = $request->getValue('title');
$body = $request->getValue('body');
$exception_description = array();
if (!$blog_phid) {
$exception_description[] = pht('No blog phid.');
}
if (!strlen($title)) {
$exception_description[] = pht('No post title.');
}
if (!strlen($body)) {
$exception_description[] = pht('No post body.');
}
if ($exception_description) {
throw id(new ConduitException('ERR-INVALID-PARAMETER'))
->setErrorDescription(implode("\n", $exception_description));
}
$blogger_phid = $request->getValue('bloggerPHID');
if ($blogger_phid) {
$blogger = id(new PhabricatorPeopleQuery())
->setViewer($user)
->withPHIDs(array($blogger_phid))
->executeOne();
} else {
$blogger = $user;
}
$blog = id(new PhameBlogQuery())
->setViewer($blogger)
->withPHIDs(array($blog_phid))
->requireCapabilities(
array(
PhabricatorPolicyCapability::CAN_VIEW,
PhabricatorPolicyCapability::CAN_EDIT,
))
->executeOne();
if (!$blog) {
throw new ConduitException('ERR-INVALID-BLOG');
}
$post = PhamePost::initializePost($blogger, $blog);
$is_draft = $request->getValue('isDraft', false);
if (!$is_draft) {
$post->setDatePublished(time());
$post->setVisibility(PhameConstants::VISIBILITY_PUBLISHED);
}
$post->setTitle($title);
$post->setBody($body);
$post->save();
return $post->toDictionary();
}
}

View file

@ -1,78 +0,0 @@
<?php
final class PhameQueryConduitAPIMethod extends PhameConduitAPIMethod {
public function getAPIMethodName() {
return 'phame.query';
}
public function getMethodDescription() {
return pht('Query phame blogs.');
}
public function getMethodStatus() {
return self::METHOD_STATUS_UNSTABLE;
}
protected function defineParamTypes() {
return array(
'ids' => 'optional list<int>',
'phids' => 'optional list<phid>',
'after' => 'optional int',
'before' => 'optional int',
'limit' => 'optional int',
);
}
protected function defineReturnType() {
return 'list<dict>';
}
protected function execute(ConduitAPIRequest $request) {
$query = new PhameBlogQuery();
$query->setViewer($request->getUser());
$ids = $request->getValue('ids', array());
if ($ids) {
$query->withIDs($ids);
}
$phids = $request->getValue('phids', array());
if ($phids) {
$query->withPHIDs($phids);
}
$after = $request->getValue('after', null);
if ($after !== null) {
$query->setAfterID($after);
}
$before = $request->getValue('before', null);
if ($before !== null) {
$query->setBeforeID($before);
}
$limit = $request->getValue('limit', null);
if ($limit !== null) {
$query->setLimit($limit);
}
$blogs = $query->execute();
$results = array();
foreach ($blogs as $blog) {
$results[] = array(
'id' => $blog->getID(),
'phid' => $blog->getPHID(),
'name' => $blog->getName(),
'description' => $blog->getDescription(),
'domain' => $blog->getDomain(),
'creatorPHID' => $blog->getCreatorPHID(),
);
}
return $results;
}
}

View file

@ -1,97 +0,0 @@
<?php
final class PhameQueryPostsConduitAPIMethod extends PhameConduitAPIMethod {
public function getAPIMethodName() {
return 'phame.queryposts';
}
public function getMethodDescription() {
return pht('Query phame posts.');
}
public function getMethodStatus() {
return self::METHOD_STATUS_UNSTABLE;
}
protected function defineParamTypes() {
return array(
'ids' => 'optional list<int>',
'phids' => 'optional list<phid>',
'blogPHIDs' => 'optional list<phid>',
'bloggerPHIDs' => 'optional list<phid>',
'published' => 'optional bool',
'publishedAfter' => 'optional date',
'before' => 'optional int',
'after' => 'optional int',
'limit' => 'optional int',
);
}
protected function defineReturnType() {
return 'list<dict>';
}
protected function execute(ConduitAPIRequest $request) {
$query = new PhamePostQuery();
$query->setViewer($request->getUser());
$ids = $request->getValue('ids', array());
if ($ids) {
$query->withIDs($ids);
}
$phids = $request->getValue('phids', array());
if ($phids) {
$query->withPHIDs($phids);
}
$blog_phids = $request->getValue('blogPHIDs', array());
if ($blog_phids) {
$query->withBlogPHIDs($blog_phids);
}
$blogger_phids = $request->getValue('bloggerPHIDs', array());
if ($blogger_phids) {
$query->withBloggerPHIDs($blogger_phids);
}
$published = $request->getValue('published', null);
if ($published === true) {
$query->withVisibility(PhameConstants::VISIBILITY_PUBLISHED);
} else if ($published === false) {
$query->withVisibility(PhameConstants::VISIBILITY_DRAFT);
}
$published_after = $request->getValue('publishedAfter', null);
if ($published_after !== null) {
$query->withPublishedAfter($published_after);
}
$after = $request->getValue('after', null);
if ($after !== null) {
$query->setAfterID($after);
}
$before = $request->getValue('before', null);
if ($before !== null) {
$query->setBeforeID($before);
}
$limit = $request->getValue('limit', null);
if ($limit !== null) {
$query->setLimit($limit);
}
$posts = $query->execute();
$results = array();
foreach ($posts as $post) {
$results[] = $post->toDictionary();
}
return $results;
}
}