Correct Aphlict websocket URI construction after PHP8 compatibility changes
[phabricator.git] / src / applications / people / storage / PhabricatorExternalAccountIdentifier.php
blobecf766723b4c436550f36233ae671d7d80bb8c23
1 <?php
3 final class PhabricatorExternalAccountIdentifier
4 extends PhabricatorUserDAO
5 implements
6 PhabricatorPolicyInterface,
7 PhabricatorDestructibleInterface {
9 protected $externalAccountPHID;
10 protected $providerConfigPHID;
11 protected $identifierHash;
12 protected $identifierRaw;
14 public function getPHIDType() {
15 return PhabricatorPeopleExternalIdentifierPHIDType::TYPECONST;
18 protected function getConfiguration() {
19 return array(
20 self::CONFIG_AUX_PHID => true,
21 self::CONFIG_COLUMN_SCHEMA => array(
22 'identifierHash' => 'bytes12',
23 'identifierRaw' => 'text',
25 self::CONFIG_KEY_SCHEMA => array(
26 'key_identifier' => array(
27 'columns' => array('providerConfigPHID', 'identifierHash'),
28 'unique' => true,
30 'key_account' => array(
31 'columns' => array('externalAccountPHID'),
34 ) + parent::getConfiguration();
37 public function save() {
38 $identifier_raw = $this->getIdentifierRaw();
40 $identifier_hash = PhabricatorHash::digestForIndex($identifier_raw);
41 $this->setIdentifierHash($identifier_hash);
43 return parent::save();
47 /* -( PhabricatorPolicyInterface )----------------------------------------- */
49 // TODO: These permissions aren't very good. They should just be the same
50 // as the associated ExternalAccount. See T13381.
52 public function getCapabilities() {
53 return array(
54 PhabricatorPolicyCapability::CAN_VIEW,
55 PhabricatorPolicyCapability::CAN_EDIT,
59 public function getPolicy($capability) {
60 switch ($capability) {
61 case PhabricatorPolicyCapability::CAN_VIEW:
62 return PhabricatorPolicies::getMostOpenPolicy();
63 case PhabricatorPolicyCapability::CAN_EDIT:
64 return PhabricatorPolicies::POLICY_NOONE;
68 public function hasAutomaticCapability($capability, PhabricatorUser $viewer) {
69 return false;
73 /* -( PhabricatorDestructibleInterface )----------------------------------- */
76 public function destroyObjectPermanently(
77 PhabricatorDestructionEngine $engine) {
78 $this->delete();