Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F100793264
ManiphestCreateMailReceiver.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Sun, Feb 2, 19:45
Size
2 KB
Mime Type
text/x-php
Expires
Tue, Feb 4, 19:45 (2 d)
Engine
blob
Format
Raw Data
Handle
24033353
Attached To
rPH Phabricator
ManiphestCreateMailReceiver.php
View Options
<?php
final
class
ManiphestCreateMailReceiver
extends
PhabricatorMailReceiver
{
public
function
isEnabled
()
{
$app_class
=
'PhabricatorApplicationManiphest'
;
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
());
}
}
Event Timeline
Log In to Comment