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

Use standard infrastructure for Feed in Audit

Summary: Ref T4896. Instead of using custom stuff, use standard stuff.

Test Plan: Viewed a bunch of feed stories and published some over the Asana bridge.

Reviewers: joshuaspence, btrahan

Reviewed By: btrahan

Subscribers: epriestley

Maniphest Tasks: T4896

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

+112 -62
-49
src/applications/audit/editor/PhabricatorAuditCommentEditor.php
··· 245 245 ->setExcludeMailRecipientPHIDs($this->getExcludeMailRecipientPHIDs()) 246 246 ->setDisableEmail($this->noEmail) 247 247 ->applyTransactions($commit, $xactions); 248 - 249 - $feed_dont_publish_phids = array(); 250 - foreach ($requests as $request) { 251 - $status = $request->getAuditStatus(); 252 - switch ($status) { 253 - case PhabricatorAuditStatusConstants::RESIGNED: 254 - case PhabricatorAuditStatusConstants::NONE: 255 - case PhabricatorAuditStatusConstants::AUDIT_NOT_REQUIRED: 256 - $feed_dont_publish_phids[$request->getAuditorPHID()] = 1; 257 - break; 258 - default: 259 - unset($feed_dont_publish_phids[$request->getAuditorPHID()]); 260 - break; 261 - } 262 - } 263 - $feed_dont_publish_phids = array_keys($feed_dont_publish_phids); 264 - 265 - $feed_phids = array_diff($requests_phids, $feed_dont_publish_phids); 266 - foreach ($comments as $comment) { 267 - $this->publishFeedStory($comment, $feed_phids); 268 - } 269 248 } 270 249 271 250 ··· 303 282 } 304 283 305 284 return array_keys($phids); 306 - } 307 - 308 - private function publishFeedStory( 309 - PhabricatorAuditComment $comment, 310 - array $more_phids) { 311 - 312 - $commit = $this->commit; 313 - $actor = $this->getActor(); 314 - 315 - $related_phids = array_merge( 316 - array( 317 - $actor->getPHID(), 318 - $commit->getPHID(), 319 - ), 320 - $more_phids); 321 - 322 - id(new PhabricatorFeedStoryPublisher()) 323 - ->setRelatedPHIDs($related_phids) 324 - ->setStoryAuthorPHID($actor->getPHID()) 325 - ->setStoryTime(time()) 326 - ->setStoryType(PhabricatorFeedStoryTypeConstants::STORY_AUDIT) 327 - ->setStoryData( 328 - array( 329 - 'commitPHID' => $commit->getPHID(), 330 - 'action' => $comment->getAction(), 331 - 'content' => $comment->getContent(), 332 - )) 333 - ->publish(); 334 285 } 335 286 336 287 }
+6
src/applications/audit/editor/PhabricatorAuditEditor.php
··· 234 234 return implode("\n", $block); 235 235 } 236 236 237 + protected function shouldPublishFeedStory( 238 + PhabricatorLiskDAO $object, 239 + array $xactions) { 240 + return true; 241 + } 242 + 237 243 }
+87
src/applications/audit/storage/PhabricatorAuditTransaction.php
··· 179 179 return parent::getTitle(); 180 180 } 181 181 182 + public function getTitleForFeed(PhabricatorFeedStory $story) { 183 + $old = $this->getOldValue(); 184 + $new = $this->getNewValue(); 185 + 186 + $author_handle = $this->renderHandleLink($this->getAuthorPHID()); 187 + $object_handle = $this->renderHandleLink($this->getObjectPHID()); 188 + 189 + $type = $this->getTransactionType(); 190 + 191 + switch ($type) { 192 + case PhabricatorAuditActionConstants::ADD_CCS: 193 + case PhabricatorAuditActionConstants::ADD_AUDITORS: 194 + if (!is_array($old)) { 195 + $old = array(); 196 + } 197 + if (!is_array($new)) { 198 + $new = array(); 199 + } 200 + $add = array_keys(array_diff_key($new, $old)); 201 + $rem = array_keys(array_diff_key($old, $new)); 202 + break; 203 + } 204 + 205 + switch ($type) { 206 + case PhabricatorAuditActionConstants::INLINE: 207 + return pht( 208 + '%s added inline comments to %s.', 209 + $author_handle, 210 + $object_handle); 211 + 212 + case PhabricatorAuditActionConstants::ADD_AUDITORS: 213 + if ($add && $rem) { 214 + return pht( 215 + '%s edited auditors for %s; added: %s, removed: %s.', 216 + $author_handle, 217 + $object_handle, 218 + $this->renderHandleList($add), 219 + $this->renderHandleList($rem)); 220 + } else if ($add) { 221 + return pht( 222 + '%s added auditors to %s: %s.', 223 + $author_handle, 224 + $object_handle, 225 + $this->renderHandleList($add)); 226 + } else if ($rem) { 227 + return pht( 228 + '%s removed auditors from %s: %s.', 229 + $author_handle, 230 + $object_handle, 231 + $this->renderHandleList($rem)); 232 + } else { 233 + return pht( 234 + '%s added auditors to %s...', 235 + $author_handle, 236 + $object_handle); 237 + } 238 + 239 + case PhabricatorAuditActionConstants::ACTION: 240 + switch ($new) { 241 + case PhabricatorAuditActionConstants::ACCEPT: 242 + return pht( 243 + '%s accepted %s.', 244 + $author_handle, 245 + $object_handle); 246 + case PhabricatorAuditActionConstants::CONCERN: 247 + return pht( 248 + '%s raised a concern with %s.', 249 + $author_handle, 250 + $object_handle); 251 + case PhabricatorAuditActionConstants::RESIGN: 252 + return pht( 253 + '%s resigned from auditing %s.', 254 + $author_handle, 255 + $object_handle); 256 + case PhabricatorAuditActionConstants::CLOSE: 257 + return pht( 258 + '%s closed the audit of %s.', 259 + $author_handle, 260 + $object_handle); 261 + } 262 + 263 + } 264 + 265 + return parent::getTitleForFeed($story); 266 + } 267 + 268 + 182 269 // TODO: These two mail methods can likely be abstracted by introducing a 183 270 // formal concept of "inline comment" transactions. 184 271
+1 -1
src/applications/auth/controller/PhabricatorAuthLoginController.php
··· 94 94 } else { 95 95 return $this->renderError( 96 96 pht( 97 - 'The external account ("%s") you just used to login is alerady '. 97 + 'The external account ("%s") you just used to login is already '. 98 98 'associated with another Phabricator user account. Login to the '. 99 99 'other Phabricator account and unlink the external account before '. 100 100 'linking it to a new Phabricator account.',
+17 -11
src/applications/diffusion/doorkeeper/DiffusionDoorkeeperCommitFeedStoryPublisher.php
··· 12 12 } 13 13 14 14 public function canPublishStory(PhabricatorFeedStory $story, $object) { 15 - return ($object instanceof PhabricatorRepositoryCommit); 15 + return 16 + ($story instanceof PhabricatorApplicationTransactionFeedStory) && 17 + ($object instanceof PhabricatorRepositoryCommit); 16 18 } 17 19 18 20 public function isStoryAboutObjectCreation($object) { ··· 29 31 // After ApplicationTransactions, we could annotate feed stories more 30 32 // explicitly. 31 33 32 - $story = $this->getFeedStory(); 33 - $action = $story->getStoryData()->getValue('action'); 34 - 35 - if ($action == PhabricatorAuditActionConstants::CLOSE) { 36 - return true; 37 - } 38 - 39 34 $fully_audited = PhabricatorAuditCommitStatusConstants::FULLY_AUDITED; 40 - if (($action == PhabricatorAuditActionConstants::ACCEPT) && 41 - $object->getAuditStatus() == $fully_audited) { 42 - return true; 35 + 36 + $story = $this->getFeedStory(); 37 + $xaction = $story->getPrimaryTransaction(); 38 + switch ($xaction->getTransactionType()) { 39 + case PhabricatorAuditActionConstants::ACTION: 40 + switch ($xaction->getNewValue()) { 41 + case PhabricatorAuditActionConstants::CLOSE: 42 + return true; 43 + case PhabricatorAuditActionConstants::ACCEPT: 44 + if ($object->getAuditStatus() == $fully_audited) { 45 + return true; 46 + } 47 + break; 48 + } 43 49 } 44 50 45 51 return false;
+1 -1
src/applications/transactions/feed/PhabricatorApplicationTransactionFeedStory.php
··· 30 30 return head($this->getValue('transactionPHIDs')); 31 31 } 32 32 33 - protected function getPrimaryTransaction() { 33 + public function getPrimaryTransaction() { 34 34 return $this->getObject($this->getPrimaryTransactionPHID()); 35 35 } 36 36