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

at recaptime-dev/main 126 lines 3.3 kB view raw
1<?php 2 3/** 4 * Groups a set of push logs corresponding to changes which were all pushed in 5 * the same transaction. 6 */ 7final class PhabricatorRepositoryPushEvent 8 extends PhabricatorRepositoryDAO 9 implements PhabricatorPolicyInterface { 10 11 protected $repositoryPHID; 12 protected $epoch; 13 protected $pusherPHID; 14 protected $requestIdentifier; 15 protected $remoteAddress; 16 protected $remoteProtocol; 17 protected $rejectCode; 18 protected $rejectDetails; 19 protected $writeWait; 20 protected $readWait; 21 protected $hostWait; 22 protected $hookWait; 23 24 private $repository = self::ATTACHABLE; 25 private $logs = self::ATTACHABLE; 26 27 public static function initializeNewEvent(PhabricatorUser $viewer) { 28 return id(new PhabricatorRepositoryPushEvent()) 29 ->setPusherPHID($viewer->getPHID()); 30 } 31 32 protected function getConfiguration() { 33 return array( 34 self::CONFIG_AUX_PHID => true, 35 self::CONFIG_TIMESTAMPS => false, 36 self::CONFIG_COLUMN_SCHEMA => array( 37 'requestIdentifier' => 'bytes12?', 38 'remoteAddress' => 'ipaddress?', 39 'remoteProtocol' => 'text32?', 40 'rejectCode' => 'uint32', 41 'rejectDetails' => 'text64?', 42 'writeWait' => 'uint64?', 43 'readWait' => 'uint64?', 44 'hostWait' => 'uint64?', 45 'hookWait' => 'uint64?', 46 ), 47 self::CONFIG_KEY_SCHEMA => array( 48 'key_repository' => array( 49 'columns' => array('repositoryPHID'), 50 ), 51 'key_identifier' => array( 52 'columns' => array('requestIdentifier'), 53 ), 54 'key_reject' => array( 55 'columns' => array('rejectCode', 'rejectDetails'), 56 ), 57 ), 58 ) + parent::getConfiguration(); 59 } 60 61 public function generatePHID() { 62 return PhabricatorPHID::generateNewPHID( 63 PhabricatorRepositoryPushEventPHIDType::TYPECONST); 64 } 65 66 public function attachRepository(PhabricatorRepository $repository) { 67 $this->repository = $repository; 68 return $this; 69 } 70 71 public function getRepository() { 72 return $this->assertAttached($this->repository); 73 } 74 75 public function attachLogs(array $logs) { 76 $this->logs = $logs; 77 return $this; 78 } 79 80 public function getLogs() { 81 return $this->assertAttached($this->logs); 82 } 83 84 /** 85 * @param array<PhabricatorRepositoryPushLog> $logs 86 */ 87 public function saveWithLogs(array $logs) { 88 assert_instances_of($logs, PhabricatorRepositoryPushLog::class); 89 90 $this->openTransaction(); 91 $this->save(); 92 foreach ($logs as $log) { 93 $log->setPushEventPHID($this->getPHID()); 94 $log->save(); 95 } 96 $this->saveTransaction(); 97 98 $this->attachLogs($logs); 99 100 return $this; 101 } 102 103/* -( PhabricatorPolicyInterface )----------------------------------------- */ 104 105 106 public function getCapabilities() { 107 return array( 108 PhabricatorPolicyCapability::CAN_VIEW, 109 ); 110 } 111 112 public function getPolicy($capability) { 113 return $this->getRepository()->getPolicy($capability); 114 } 115 116 public function hasAutomaticCapability($capability, PhabricatorUser $viewer) { 117 return $this->getRepository()->hasAutomaticCapability($capability, $viewer); 118 } 119 120 public function describeAutomaticCapability($capability) { 121 return pht( 122 "A repository's push events are visible to users who can see the ". 123 "repository."); 124 } 125 126}