3 final class PhabricatorMetaMTAMailProperties
4 extends PhabricatorMetaMTADAO
5 implements PhabricatorPolicyInterface
{
8 protected $mailProperties = array();
10 protected function getConfiguration() {
12 self
::CONFIG_SERIALIZATION
=> array(
13 'mailProperties' => self
::SERIALIZATION_JSON
,
15 self
::CONFIG_COLUMN_SCHEMA
=> array(),
16 self
::CONFIG_KEY_SCHEMA
=> array(
17 'key_object' => array(
18 'columns' => array('objectPHID'),
22 ) + parent
::getConfiguration();
25 public function getMailProperty($key, $default = null) {
26 return idx($this->mailProperties
, $key, $default);
29 public function setMailProperty($key, $value) {
30 $this->mailProperties
[$key] = $value;
34 public static function loadMailKey($object) {
35 // If this is an older object with an onboard "mailKey" property, just
37 // TODO: We should eventually get rid of these and get rid of this
39 if ($object->hasProperty('mailKey')) {
40 return $object->getMailKey();
43 $viewer = PhabricatorUser
::getOmnipotentUser();
44 $object_phid = $object->getPHID();
46 $properties = id(new PhabricatorMetaMTAMailPropertiesQuery())
48 ->withObjectPHIDs(array($object_phid))
51 $properties = id(new self())
52 ->setObjectPHID($object_phid);
55 $mail_key = $properties->getMailProperty('mailKey');
56 if ($mail_key !== null) {
60 $mail_key = Filesystem
::readRandomCharacters(20);
61 $properties->setMailProperty('mailKey', $mail_key);
63 $unguarded = AphrontWriteGuard
::beginScopedUnguardedWrites();
71 /* -( PhabricatorPolicyInterface )----------------------------------------- */
74 public function getCapabilities() {
76 PhabricatorPolicyCapability
::CAN_VIEW
,
80 public function getPolicy($capability) {
81 switch ($capability) {
82 case PhabricatorPolicyCapability
::CAN_VIEW
:
83 return PhabricatorPolicies
::POLICY_NOONE
;
87 public function hasAutomaticCapability($capability, PhabricatorUser
$viewer) {