4 * A message sent to an executing build target by an external system. We
5 * capture these messages and process them asynchronously to avoid race
6 * conditions where we receive a message before a build plan is ready to
9 final class HarbormasterBuildMessage
10 extends HarbormasterDAO
12 PhabricatorPolicyInterface
,
13 PhabricatorDestructibleInterface
{
15 protected $authorPHID;
16 protected $receiverPHID;
18 protected $isConsumed;
20 private $receiver = self
::ATTACHABLE
;
22 public static function initializeNewMessage(PhabricatorUser
$actor) {
23 $actor_phid = $actor->getPHID();
25 $actor_phid = id(new PhabricatorHarbormasterApplication())->getPHID();
28 return id(new HarbormasterBuildMessage())
29 ->setAuthorPHID($actor_phid)
33 protected function getConfiguration() {
35 self
::CONFIG_COLUMN_SCHEMA
=> array(
37 'isConsumed' => 'bool',
39 self
::CONFIG_KEY_SCHEMA
=> array(
40 'key_receiver' => array(
41 'columns' => array('receiverPHID'),
44 ) + parent
::getConfiguration();
47 public function getReceiver() {
48 return $this->assertAttached($this->receiver
);
51 public function attachReceiver($receiver) {
52 $this->receiver
= $receiver;
57 /* -( PhabricatorPolicyInterface )----------------------------------------- */
60 public function getCapabilities() {
62 PhabricatorPolicyCapability
::CAN_VIEW
,
66 public function getPolicy($capability) {
67 return $this->getReceiver()->getPolicy($capability);
70 public function hasAutomaticCapability($capability, PhabricatorUser
$viewer) {
71 return $this->getReceiver()->hasAutomaticCapability(
76 public function describeAutomaticCapability($capability) {
77 return pht('Build messages have the same policies as their receivers.');
81 /* -( PhabricatorDestructibleInterface )----------------------------------- */
84 public function destroyObjectPermanently(
85 PhabricatorDestructionEngine
$engine) {