Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F473100
ManiphestCreateMailReceiver.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
2 KB
Referenced Files
None
Subscribers
None
ManiphestCreateMailReceiver.php
View Options
<?php
final
class
ManiphestCreateMailReceiver
extends
PhabricatorMailReceiver
{
public
function
isEnabled
()
{
$app_class
=
'PhabricatorManiphestApplication'
;
return
PhabricatorApplication
::
isClassInstalled
(
$app_class
);
}
public
function
canAcceptMail
(
PhabricatorMetaMTAReceivedMail
$mail
)
{
$config_key
=
'metamta.maniphest.public-create-email'
;
$create_address
=
PhabricatorEnv
::
getEnvConfig
(
$config_key
);
foreach
(
$mail
->
getToAddresses
()
as
$to_address
)
{
if
(
$this
->
matchAddresses
(
$create_address
,
$to_address
))
{
return
true
;
}
}
return
false
;
}
public
function
loadSender
(
PhabricatorMetaMTAReceivedMail
$mail
)
{
try
{
// Try to load the sender normally.
return
parent
::
loadSender
(
$mail
);
}
catch
(
PhabricatorMetaMTAReceivedMailProcessingException
$ex
)
{
// If we failed to load the sender normally, use this special legacy
// black magic.
// TODO: Deprecate and remove this.
$default_author_key
=
'metamta.maniphest.default-public-author'
;
$default_author
=
PhabricatorEnv
::
getEnvConfig
(
$default_author_key
);
if
(!
strlen
(
$default_author
))
{
throw
$ex
;
}
$user
=
id
(
new
PhabricatorUser
())->
loadOneWhere
(
'username = %s'
,
$default_author
);
if
(
$user
)
{
return
$user
;
}
throw
new
PhabricatorMetaMTAReceivedMailProcessingException
(
MetaMTAReceivedMailStatus
::
STATUS_UNKNOWN_SENDER
,
pht
(
"Phabricator is misconfigured, the configuration key "
.
"'metamta.maniphest.default-public-author' is set to user "
.
"'%s' but that user does not exist."
,
$default_author
));
}
}
protected
function
processReceivedMail
(
PhabricatorMetaMTAReceivedMail
$mail
,
PhabricatorUser
$sender
)
{
$task
=
ManiphestTask
::
initializeNewTask
(
$sender
);
$task
->
setOriginalEmailSource
(
$mail
->
getHeader
(
'From'
));
$handler
=
PhabricatorEnv
::
newObjectFromConfig
(
'metamta.maniphest.reply-handler'
);
$handler
->
setMailReceiver
(
$task
);
$handler
->
setActor
(
$sender
);
$handler
->
setExcludeMailRecipientPHIDs
(
$mail
->
loadExcludeMailRecipientPHIDs
());
$handler
->
processEmail
(
$mail
);
$mail
->
setRelatedPHID
(
$task
->
getPHID
());
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Tue, May 6, 5:35 PM (1 d, 20 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
84822
Default Alt Text
ManiphestCreateMailReceiver.php (2 KB)
Attached To
Mode
rP Phorge
Attached
Detach File
Event Timeline
Log In to Comment