@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.

Include project slugs in the results of a `project.query` Conduit call.

Summary: Ref T4418. This feature will be used by D9457 to determine whether the specified slugs exist.

Test Plan:
Made a conduit call with `arc`:

```
> echo '{"slugs": ["foo"]}' | arc --conduit-uri='http://phabricator.joshuaspence.com' call-conduit project.query
Waiting for JSON parameters on stdin...
{"error":null,"errorMessage":null,"response":{"data":{"PHID-PROJ-ttomlhslujpx5sdpbu2c":{"id":"1","phid":"PHID-PROJ-ttomlhslujpx5sdpbu2c","name":"Foo","members":["PHID-USER-cb5af6p4oepy5tlgqypi"],"slugs":["foo","bar"],"dateCreated":"1402422720","dateModified":"1402422728"}},"slugMap":{"foo":"PHID-PROJ-ttomlhslujpx5sdpbu2c"},"cursor":{"limit":100,"after":null,"before":null}}}
```

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: epriestley, Korvin

Maniphest Tasks: T4418

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

+25 -2
+4
src/applications/project/conduit/ConduitAPI_project_Method.php
··· 27 27 $member_phids = $project->getMemberPHIDs(); 28 28 $member_phids = array_values($member_phids); 29 29 30 + $project_slugs = $project->getSlugs(); 31 + $project_slugs = array_values(mpull($project_slugs, 'getSlug')); 32 + 30 33 $result[$project->getPHID()] = array( 31 34 'id' => $project->getID(), 32 35 'phid' => $project->getPHID(), 33 36 'name' => $project->getName(), 34 37 'members' => $member_phids, 38 + 'slugs' => $project_slugs, 35 39 'dateCreated' => $project->getDateCreated(), 36 40 'dateModified' => $project->getDateModified(), 37 41 );
+21 -2
src/applications/project/conduit/ConduitAPI_project_query_Method.php
··· 46 46 $query = new PhabricatorProjectQuery(); 47 47 $query->setViewer($request->getUser()); 48 48 $query->needMembers(true); 49 + $query->needSlugs(true); 49 50 50 51 $ids = $request->getValue('ids'); 51 52 if ($ids) { ··· 82 83 $query->setOffset($offset); 83 84 } 84 85 85 - $results = $query->execute(); 86 - return $this->buildProjectInfoDictionaries($results); 86 + $pager = $this->newPager($request); 87 + $results = $query->executeWithCursorPager($pager); 88 + $projects = $this->buildProjectInfoDictionaries($results); 89 + 90 + // TODO: This is pretty hideous. 91 + $slug_map = array(); 92 + foreach ($slugs as $slug) { 93 + foreach ($projects as $project) { 94 + if (in_array($slug, $project['slugs'])) { 95 + $slug_map[$slug] = $project['phid']; 96 + } 97 + } 98 + } 99 + 100 + $result = array( 101 + 'data' => $projects, 102 + 'slugMap' => $slug_map, 103 + ); 104 + 105 + return $this->addPagerResults($result, $pager); 87 106 } 88 107 89 108 }