Path: blob/master/src/applications/metamta/query/PhabricatorMetaMTAActor.php
12256 views
<?php12final class PhabricatorMetaMTAActor extends Phobject {34const STATUS_DELIVERABLE = 'deliverable';5const STATUS_UNDELIVERABLE = 'undeliverable';67const REASON_NONE = 'none';8const REASON_UNLOADABLE = 'unloadable';9const REASON_UNMAILABLE = 'unmailable';10const REASON_NO_ADDRESS = 'noaddress';11const REASON_DISABLED = 'disabled';12const REASON_MAIL_DISABLED = 'maildisabled';13const REASON_EXTERNAL_TYPE = 'exernaltype';14const REASON_RESPONSE = 'response';15const REASON_SELF = 'self';16const REASON_MAILTAGS = 'mailtags';17const REASON_BOT = 'bot';18const REASON_FORCE = 'force';19const REASON_FORCE_HERALD = 'force-herald';20const REASON_ROUTE_AS_NOTIFICATION = 'route-as-notification';21const REASON_ROUTE_AS_MAIL = 'route-as-mail';22const REASON_UNVERIFIED = 'unverified';23const REASON_MUTED = 'muted';2425private $phid;26private $emailAddress;27private $name;28private $status = self::STATUS_DELIVERABLE;29private $reasons = array();30private $isVerified = false;3132public function setName($name) {33$this->name = $name;34return $this;35}3637public function getName() {38return $this->name;39}4041public function setEmailAddress($email_address) {42$this->emailAddress = $email_address;43return $this;44}4546public function getEmailAddress() {47return $this->emailAddress;48}4950public function setIsVerified($is_verified) {51$this->isVerified = $is_verified;52return $this;53}5455public function getIsVerified() {56return $this->isVerified;57}5859public function setPHID($phid) {60$this->phid = $phid;61return $this;62}6364public function getPHID() {65return $this->phid;66}6768public function setUndeliverable($reason) {69$this->reasons[] = $reason;70$this->status = self::STATUS_UNDELIVERABLE;71return $this;72}7374public function setDeliverable($reason) {75$this->reasons[] = $reason;76$this->status = self::STATUS_DELIVERABLE;77return $this;78}7980public function isDeliverable() {81return ($this->status === self::STATUS_DELIVERABLE);82}8384public function getDeliverabilityReasons() {85return $this->reasons;86}8788public static function isDeliveryReason($reason) {89switch ($reason) {90case self::REASON_NONE:91case self::REASON_FORCE:92case self::REASON_FORCE_HERALD:93case self::REASON_ROUTE_AS_MAIL:94return true;95default:96// All other reasons cause the message to not be delivered.97return false;98}99}100101public static function getReasonName($reason) {102$names = array(103self::REASON_NONE => pht('None'),104self::REASON_DISABLED => pht('Disabled Recipient'),105self::REASON_BOT => pht('Bot Recipient'),106self::REASON_NO_ADDRESS => pht('No Address'),107self::REASON_EXTERNAL_TYPE => pht('External Recipient'),108self::REASON_UNMAILABLE => pht('Not Mailable'),109self::REASON_RESPONSE => pht('Similar Reply'),110self::REASON_SELF => pht('Self Mail'),111self::REASON_MAIL_DISABLED => pht('Mail Disabled'),112self::REASON_MAILTAGS => pht('Mail Tags'),113self::REASON_UNLOADABLE => pht('Bad Recipient'),114self::REASON_FORCE => pht('Forced Mail'),115self::REASON_FORCE_HERALD => pht('Forced by Herald'),116self::REASON_ROUTE_AS_NOTIFICATION => pht('Route as Notification'),117self::REASON_ROUTE_AS_MAIL => pht('Route as Mail'),118self::REASON_UNVERIFIED => pht('Address Not Verified'),119self::REASON_MUTED => pht('Muted'),120);121122return idx($names, $reason, pht('Unknown ("%s")', $reason));123}124125public static function getReasonDescription($reason) {126$descriptions = array(127self::REASON_NONE => pht(128'No special rules affected this mail.'),129self::REASON_DISABLED => pht(130'This user is disabled; disabled users do not receive mail.'),131self::REASON_BOT => pht(132'This user is a bot; bot accounts do not receive mail.'),133self::REASON_NO_ADDRESS => pht(134'Unable to load an email address for this PHID.'),135self::REASON_EXTERNAL_TYPE => pht(136'Only external accounts of type "email" are deliverable; this '.137'account has a different type.'),138self::REASON_UNMAILABLE => pht(139'This PHID type does not correspond to a mailable object.'),140self::REASON_RESPONSE => pht(141'This message is a response to another email message, and this '.142'recipient received the original email message, so we are not '.143'sending them this substantially similar message (for example, '.144'the sender used "Reply All" instead of "Reply" in response to '.145'mail from this server).'),146self::REASON_SELF => pht(147'This recipient is the user whose actions caused delivery of '.148'this message, but they have set preferences so they do not '.149'receive mail about their own actions (Settings > Email '.150'Preferences > Self Actions).'),151self::REASON_MAIL_DISABLED => pht(152'This recipient has disabled all email notifications '.153'(Settings > Email Preferences > Email Notifications).'),154self::REASON_MAILTAGS => pht(155'This mail has tags which control which users receive it, and '.156'this recipient has not elected to receive mail with any of '.157'the tags on this message (Settings > Email Preferences).'),158self::REASON_UNLOADABLE => pht(159'Unable to load user record for this PHID.'),160self::REASON_FORCE => pht(161'Delivery of this mail is forced and ignores deliver preferences. '.162'Mail which uses forced delivery is usually related to account '.163'management or authentication. For example, password reset email '.164'ignores mail preferences.'),165self::REASON_FORCE_HERALD => pht(166'This recipient was added by a "Send me an Email" rule in Herald, '.167'which overrides some delivery settings.'),168self::REASON_ROUTE_AS_NOTIFICATION => pht(169'This message was downgraded to a notification by outbound mail '.170'rules in Herald.'),171self::REASON_ROUTE_AS_MAIL => pht(172'This message was upgraded to email by outbound mail rules '.173'in Herald.'),174self::REASON_UNVERIFIED => pht(175'This recipient does not have a verified primary email address.'),176self::REASON_MUTED => pht(177'This recipient has muted notifications for this object.'),178);179180return idx($descriptions, $reason, pht('Unknown Reason ("%s")', $reason));181}182183184}185186187