@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Add phame.queryblog and phame.querypost Conduit calls.

Summary: This implements Conduit calls for querying Phame blogs and Phame posts.

Test Plan: Made some calls and they seem to generally work.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley

CC: Korvin, epriestley, aran

Maniphest Tasks: T3695

Differential Revision: https://secure.phabricator.com/D7478

authored by

James Rhodes and committed by
epriestley
24579e29 10a9f650

+223
+6
src/__phutil_library_map__.php
··· 195 195 'ConduitAPI_paste_create_Method' => 'applications/paste/conduit/ConduitAPI_paste_create_Method.php', 196 196 'ConduitAPI_paste_info_Method' => 'applications/paste/conduit/ConduitAPI_paste_info_Method.php', 197 197 'ConduitAPI_paste_query_Method' => 'applications/paste/conduit/ConduitAPI_paste_query_Method.php', 198 + 'ConduitAPI_phame_Method' => 'applications/phame/conduit/ConduitAPI_phame_Method.php', 199 + 'ConduitAPI_phame_query_Method' => 'applications/phame/conduit/ConduitAPI_phame_query_Method.php', 200 + 'ConduitAPI_phame_queryposts_Method' => 'applications/phame/conduit/ConduitAPI_phame_queryposts_Method.php', 198 201 'ConduitAPI_phid_Method' => 'applications/phid/conduit/ConduitAPI_phid_Method.php', 199 202 'ConduitAPI_phid_info_Method' => 'applications/phid/conduit/ConduitAPI_phid_info_Method.php', 200 203 'ConduitAPI_phid_lookup_Method' => 'applications/phid/conduit/ConduitAPI_phid_lookup_Method.php', ··· 2406 2409 'ConduitAPI_paste_create_Method' => 'ConduitAPI_paste_Method', 2407 2410 'ConduitAPI_paste_info_Method' => 'ConduitAPI_paste_Method', 2408 2411 'ConduitAPI_paste_query_Method' => 'ConduitAPI_paste_Method', 2412 + 'ConduitAPI_phame_Method' => 'ConduitAPIMethod', 2413 + 'ConduitAPI_phame_query_Method' => 'ConduitAPI_phame_Method', 2414 + 'ConduitAPI_phame_queryposts_Method' => 'ConduitAPI_phame_Method', 2409 2415 'ConduitAPI_phid_Method' => 'ConduitAPIMethod', 2410 2416 'ConduitAPI_phid_info_Method' => 'ConduitAPI_phid_Method', 2411 2417 'ConduitAPI_phid_lookup_Method' => 'ConduitAPI_phid_Method',
+12
src/applications/phame/conduit/ConduitAPI_phame_Method.php
··· 1 + <?php 2 + 3 + /** 4 + * @group conduit 5 + */ 6 + abstract class ConduitAPI_phame_Method extends ConduitAPIMethod { 7 + 8 + public function getApplication() { 9 + return PhabricatorApplication::getByClass('PhabricatorApplicationPhame'); 10 + } 11 + 12 + }
+84
src/applications/phame/conduit/ConduitAPI_phame_query_Method.php
··· 1 + <?php 2 + 3 + /** 4 + * @group conduit 5 + */ 6 + final class ConduitAPI_phame_query_Method extends ConduitAPI_phame_Method { 7 + 8 + public function getMethodDescription() { 9 + return "Query phame blogs."; 10 + } 11 + 12 + public function getMethodStatus() { 13 + return self::METHOD_STATUS_UNSTABLE; 14 + } 15 + 16 + public function defineParamTypes() { 17 + return array( 18 + 'ids' => 'optional list<int>', 19 + 'phids' => 'optional list<phid>', 20 + 'after' => 'optional int', 21 + 'before' => 'optional int', 22 + 'limit' => 'optional int', 23 + ); 24 + } 25 + 26 + public function defineReturnType() { 27 + return 'list<dict>'; 28 + } 29 + 30 + public function defineErrorTypes() { 31 + return array( 32 + ); 33 + } 34 + 35 + protected function execute(ConduitAPIRequest $request) { 36 + 37 + $query = new PhameBlogQuery(); 38 + 39 + $query->setViewer($request->getUser()); 40 + 41 + $ids = $request->getValue('ids', array()); 42 + if ($ids) { 43 + $query->withIDs($ids); 44 + } 45 + 46 + $phids = $request->getValue('phids', array()); 47 + if ($phids) { 48 + $query->withPHIDs($phids); 49 + } 50 + 51 + $after = $request->getValue('after', null); 52 + if ($after !== null) { 53 + $query->setAfterID($after); 54 + } 55 + 56 + $before = $request->getValue('before', null); 57 + if ($before !== null) { 58 + $query->setBeforeID($before); 59 + } 60 + 61 + $limit = $request->getValue('limit', null); 62 + if ($limit !== null) { 63 + $query->setLimit($limit); 64 + } 65 + 66 + $blogs = $query->execute(); 67 + 68 + $results = array(); 69 + foreach ($blogs as $blog) { 70 + $results[] = array( 71 + 'id' => $blog->getID(), 72 + 'phid' => $blog->getPHID(), 73 + 'name' => $blog->getName(), 74 + 'description' => $blog->getDescription(), 75 + 'domain' => $blog->getDomain(), 76 + 'creatorPHID' => $blog->getCreatorPHID(), 77 + ); 78 + } 79 + 80 + return $results; 81 + } 82 + 83 + 84 + }
+121
src/applications/phame/conduit/ConduitAPI_phame_queryposts_Method.php
··· 1 + <?php 2 + 3 + /** 4 + * @group conduit 5 + */ 6 + final class ConduitAPI_phame_queryposts_Method extends ConduitAPI_phame_Method { 7 + 8 + public function getMethodDescription() { 9 + return "Query phame posts."; 10 + } 11 + 12 + public function getMethodStatus() { 13 + return self::METHOD_STATUS_UNSTABLE; 14 + } 15 + 16 + public function defineParamTypes() { 17 + return array( 18 + 'ids' => 'optional list<int>', 19 + 'phids' => 'optional list<phid>', 20 + 'blogPHIDs' => 'optional list<phid>', 21 + 'bloggerPHIDs' => 'optional list<phid>', 22 + 'phameTitles' => 'optional list<string>', 23 + 'published' => 'optional bool', 24 + 'publishedAfter' => 'optional date', 25 + 'before' => 'optional int', 26 + 'after' => 'optional int', 27 + 'limit' => 'optional int', 28 + ); 29 + } 30 + 31 + public function defineReturnType() { 32 + return 'list<dict>'; 33 + } 34 + 35 + public function defineErrorTypes() { 36 + return array( 37 + ); 38 + } 39 + 40 + protected function execute(ConduitAPIRequest $request) { 41 + 42 + $query = new PhamePostQuery(); 43 + 44 + $query->setViewer($request->getUser()); 45 + 46 + $ids = $request->getValue('ids', array()); 47 + if ($ids) { 48 + $query->withIDs($ids); 49 + } 50 + 51 + $phids = $request->getValue('phids', array()); 52 + if ($phids) { 53 + $query->withPHIDs($phids); 54 + } 55 + 56 + $blog_phids = $request->getValue('blogPHIDs', array()); 57 + if ($blog_phids) { 58 + $query->withBlogPHIDs($blog_phids); 59 + } 60 + 61 + $blogger_phids = $request->getValue('bloggerPHIDs', array()); 62 + if ($blogger_phids) { 63 + $query->withBloggerPHIDs($blogger_phids); 64 + } 65 + 66 + $phame_titles = $request->getValue('phameTitles', array()); 67 + if ($phame_titles) { 68 + $query->withPhameTitles($phame_titles); 69 + } 70 + 71 + $published = $request->getValue('published', null); 72 + if ($published === true) { 73 + $query->withVisibility(PhamePost::VISIBILITY_PUBLISHED); 74 + } else if ($published === false) { 75 + $query->withVisibility(PhamePost::VISIBILITY_DRAFT); 76 + } 77 + 78 + $published_after = $request->getValue('publishedAfter', null); 79 + if ($published_after !== null) { 80 + $query->withPublishedAfter($published_after); 81 + } 82 + 83 + $after = $request->getValue('after', null); 84 + if ($after !== null) { 85 + $query->setAfterID($after); 86 + } 87 + 88 + $before = $request->getValue('before', null); 89 + if ($before !== null) { 90 + $query->setBeforeID($before); 91 + } 92 + 93 + $limit = $request->getValue('limit', null); 94 + if ($limit !== null) { 95 + $query->setLimit($limit); 96 + } 97 + 98 + $blogs = $query->execute(); 99 + 100 + $results = array(); 101 + foreach ($blogs as $blog) { 102 + $results[] = array( 103 + 'id' => $blog->getID(), 104 + 'phid' => $blog->getPHID(), 105 + 'blogPHID' => $blog->getBlogPHID(), 106 + 'bloggerPHID' => $blog->getBloggerPHID(), 107 + 'viewURI' => $blog->getViewURI(), 108 + 'title' => $blog->getTitle(), 109 + 'phameTitle' => $blog->getPhameTitle(), 110 + 'body' => $blog->getBody(), 111 + 'summary' => PhabricatorMarkupEngine::summarize($blog->getBody()), 112 + 'datePublished' => $blog->getDatePublished(), 113 + 'published' => !$blog->isDraft(), 114 + ); 115 + } 116 + 117 + return $results; 118 + } 119 + 120 + 121 + }