Select the types of activity you want to include in your feed.
@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
···11+<?php
22+33+/*
44+ * Copyright 2011 Facebook, Inc.
55+ *
66+ * Licensed under the Apache License, Version 2.0 (the "License");
77+ * you may not use this file except in compliance with the License.
88+ * You may obtain a copy of the License at
99+ *
1010+ * http://www.apache.org/licenses/LICENSE-2.0
1111+ *
1212+ * Unless required by applicable law or agreed to in writing, software
1313+ * distributed under the License is distributed on an "AS IS" BASIS,
1414+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1515+ * See the License for the specific language governing permissions and
1616+ * limitations under the License.
1717+ */
1818+1919+class ConduitAPI_differential_getalldiffs_Method extends ConduitAPIMethod {
2020+2121+ public function getMethodDescription() {
2222+ return "Load all diffs for given revisions from Differential.";
2323+ }
2424+2525+ public function defineParamTypes() {
2626+ return array(
2727+ 'revision_ids' => 'required list<int>',
2828+ );
2929+ }
3030+3131+ public function defineReturnType() {
3232+ return 'dict';
3333+ }
3434+3535+ public function defineErrorTypes() {
3636+ return array();
3737+ }
3838+3939+ protected function execute(ConduitAPIRequest $request) {
4040+ $results = array();
4141+ $revision_ids = $request->getValue('revision_ids');
4242+4343+ if (!$revision_ids) {
4444+ return $results;
4545+ }
4646+4747+ $diffs = id(new DifferentialDiff())->loadAllWhere(
4848+ 'revisionID IN (%Ld)',
4949+ $revision_ids);
5050+5151+ foreach ($diffs as $diff) {
5252+ $results[] = array(
5353+ 'revision_id' => $diff->getRevisionID(),
5454+ 'diff_id' => $diff->getID(),
5555+ );
5656+ }
5757+5858+ return $results;
5959+ }
6060+}
···11+<?php
22+33+/*
44+ * Copyright 2011 Facebook, Inc.
55+ *
66+ * Licensed under the Apache License, Version 2.0 (the "License");
77+ * you may not use this file except in compliance with the License.
88+ * You may obtain a copy of the License at
99+ *
1010+ * http://www.apache.org/licenses/LICENSE-2.0
1111+ *
1212+ * Unless required by applicable law or agreed to in writing, software
1313+ * distributed under the License is distributed on an "AS IS" BASIS,
1414+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1515+ * See the License for the specific language governing permissions and
1616+ * limitations under the License.
1717+ */
1818+1919+class ConduitAPI_differential_getrevision_Method extends ConduitAPIMethod {
2020+2121+ public function getMethodDescription() {
2222+ return "Load the content of a revision from Differential.";
2323+ }
2424+2525+ public function defineParamTypes() {
2626+ return array(
2727+ 'revision_id' => 'required id',
2828+ );
2929+ }
3030+3131+ public function defineReturnType() {
3232+ return 'nonempty dict';
3333+ }
3434+3535+ public function defineErrorTypes() {
3636+ return array(
3737+ 'ERR_BAD_REVISION' => 'No such revision exists.',
3838+ );
3939+ }
4040+4141+ protected function execute(ConduitAPIRequest $request) {
4242+ $diff = null;
4343+4444+ $revision_id = $request->getValue('revision_id');
4545+ $revision = id(new DifferentialRevision())->load($revision_id);
4646+ if (!$revision) {
4747+ throw new ConduitException('ERR_BAD_REVISION');
4848+ }
4949+5050+ $diffs = $revision->loadDiffs();
5151+5252+ $diff_dicts = array();
5353+ foreach ($diffs as $diff) {
5454+ $diff->attachChangesets($diff->loadChangesets());
5555+ // TODO: We could batch this to improve performance.
5656+ foreach ($diff->getChangesets() as $changeset) {
5757+ $changeset->attachHunks($changeset->loadHunks());
5858+ }
5959+ $diff_dicts[] =
6060+ ConduitAPI_differential_getdiff_Method::createDiffDict($diff);
6161+ }
6262+6363+ $dict = array(
6464+ 'id' => $revision->getID(),
6565+ 'phid' => $revision->getPHID(),
6666+ 'authorPHID' => $revision->getAuthorPHID(),
6767+ 'title' => $revision->getTitle(),
6868+ 'status' => $revision->getStatus(),
6969+ 'statusName' => DifferentialRevisionStatus::getNameForRevisionStatus(
7070+ $revision->getStatus()),
7171+ 'summary' => $revision->getSummary(),
7272+ 'testPlan' => $revision->getTestPlan(),
7373+ 'revertPlan' => $revision->getRevertPlan(),
7474+ 'blameRevision' => $revision->getBlameRevision(),
7575+ 'dateCommitted' => $revision->getDateCommitted(),
7676+ 'lineCount' => $revision->getLineCount(),
7777+ 'diffs' => $diff_dicts,
7878+ );
7979+8080+ return $dict;
8181+ }
8282+8383+}
···11+<?php
22+33+/*
44+ * Copyright 2011 Facebook, Inc.
55+ *
66+ * Licensed under the Apache License, Version 2.0 (the "License");
77+ * you may not use this file except in compliance with the License.
88+ * You may obtain a copy of the License at
99+ *
1010+ * http://www.apache.org/licenses/LICENSE-2.0
1111+ *
1212+ * Unless required by applicable law or agreed to in writing, software
1313+ * distributed under the License is distributed on an "AS IS" BASIS,
1414+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1515+ * See the License for the specific language governing permissions and
1616+ * limitations under the License.
1717+ */
1818+1919+class ConduitAPI_differential_getrevisionfeedback_Method
2020+ extends ConduitAPIMethod {
2121+2222+ public function getMethodDescription() {
2323+ return "Retrieve Differential Revision Feedback.";
2424+ }
2525+2626+ public function defineParamTypes() {
2727+ return array(
2828+ 'ids' => 'required list<int>',
2929+ );
3030+ }
3131+3232+ public function defineReturnType() {
3333+ return 'nonempty list<dict<string, wild>>';
3434+ }
3535+3636+ public function defineErrorTypes() {
3737+ return array(
3838+ );
3939+ }
4040+4141+ protected function execute(ConduitAPIRequest $request) {
4242+ $results = array();
4343+ $revision_ids = $request->getValue('ids');
4444+4545+ if (!$revision_ids) {
4646+ return $results;
4747+ }
4848+4949+ $comments = id(new DifferentialComment())->loadAllWhere(
5050+ 'revisionID IN (%Ld)',
5151+ $revision_ids);
5252+5353+ // Helper dictionary to keep track of where the id/action pair is
5454+ // stored in results array.
5555+ $indexes = array();
5656+ foreach ($comments as $comment) {
5757+ $action = $comment->getAction();
5858+ $revision_id = $comment->getRevisionID();
5959+6060+ if (isset($indexes[$action.$revision_id])) {
6161+ $results[$indexes[$action.$revision_id]]['count']++;
6262+ } else {
6363+ $indexes[$action.$revision_id] = count($results);
6464+ $results[] = array('id' => $revision_id,
6565+ 'action' => $action,
6666+ 'count' => 1);
6767+ }
6868+ }
6969+7070+ return $results;
7171+ }
7272+}
···11+<?php
22+33+/*
44+ * Copyright 2011 Facebook, Inc.
55+ *
66+ * Licensed under the Apache License, Version 2.0 (the "License");
77+ * you may not use this file except in compliance with the License.
88+ * You may obtain a copy of the License at
99+ *
1010+ * http://www.apache.org/licenses/LICENSE-2.0
1111+ *
1212+ * Unless required by applicable law or agreed to in writing, software
1313+ * distributed under the License is distributed on an "AS IS" BASIS,
1414+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1515+ * See the License for the specific language governing permissions and
1616+ * limitations under the License.
1717+ */
1818+1919+class ConduitAPI_path_getowners_Method extends ConduitAPIMethod {
2020+2121+ public function getMethodDescription() {
2222+ return "Find owners package given its name";
2323+ }
2424+2525+ public function defineParamTypes() {
2626+ return array(
2727+ 'repositoryCallsign' => 'required nonempty string',
2828+ 'path' => 'required nonempty string'
2929+ );
3030+ }
3131+3232+ public function defineReturnType() {
3333+ return 'array of packages containing phid, primary_owner (phid=>username),'.
3434+ 'owners(array of phid=>username)';
3535+ }
3636+3737+ public function defineErrorTypes() {
3838+ return array(
3939+ 'ERR_REP_NOT_FOUND' => 'The repository callsign is not recognized',
4040+ 'ERR_PATH_NOT_FOUND' => 'The specified path is not known to any package',
4141+ );
4242+ }
4343+4444+ protected function execute(ConduitAPIRequest $request) {
4545+4646+ $repository = id(new PhabricatorRepository())->loadOneWhere('callsign = %s',
4747+ $request->getValue('repositoryCallsign'));
4848+4949+ if (empty($repository)) {
5050+ throw new ConduitException('ERR_REP_NOT_FOUND');
5151+ }
5252+5353+ $packages = PhabricatorOwnersPackage::loadOwningPackages(
5454+ $repository, $request->getValue('path'));
5555+ if (empty($packages)) {
5656+ throw new ConduitException('ERR_PATH_NOT_FOUND');
5757+ }
5858+5959+ $owner = new PhabricatorOwnersOwner();
6060+ $user = new PhabricatorUser();
6161+ $result = array();
6262+ foreach ($packages as $package) {
6363+ $p_result = array();
6464+ $p_result['phid'] = $package->getID();
6565+ $primary_owner_phid = $package->getPrimaryOwnerPHID();
6666+ if (!empty($primary_owner_phid)) {
6767+ $p_user = $user->loadOneWhere('phid = %s',
6868+ $primary_owner_phid);
6969+ $p_result['primaryOwner'] = $p_user->getPhid();
7070+ }
7171+7272+ $p_owners = $owner->loadAllForPackages(array($package));
7373+ $p_users = $user->loadAllWhere('phid IN (%Ls)',
7474+ mpull($p_owners, 'getUserPHID'));
7575+7676+ $p_result['owners'] = array_values(mpull($p_users, 'getPhid'));
7777+7878+ $result[] = $p_result;
7979+ }
8080+8181+ return $result;
8282+ }
8383+8484+}