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