Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F92693574
ConpherenceCreateThreadMailReceiver.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
Fri, Nov 22, 20:26
Size
1 KB
Mime Type
text/x-php
Expires
Sun, Nov 24, 20:26 (2 d)
Engine
blob
Format
Raw Data
Handle
22488845
Attached To
rPH Phabricator
ConpherenceCreateThreadMailReceiver.php
View Options
<?php
final
class
ConpherenceCreateThreadMailReceiver
extends
PhabricatorMailReceiver
{
public
function
isEnabled
()
{
$app_class
=
'PhabricatorConpherenceApplication'
;
return
PhabricatorApplication
::
isClassInstalled
(
$app_class
);
}
public
function
canAcceptMail
(
PhabricatorMetaMTAReceivedMail
$mail
)
{
$usernames
=
$this
->
getMailUsernames
(
$mail
);
if
(!
$usernames
)
{
return
false
;
}
$users
=
$this
->
loadMailUsers
(
$mail
);
if
(
count
(
$users
)
!=
count
(
$usernames
))
{
// At least some of the addresses are not users, so don't accept this as
// a new Conpherence thread.
return
false
;
}
return
true
;
}
private
function
getMailUsernames
(
PhabricatorMetaMTAReceivedMail
$mail
)
{
$usernames
=
array
();
foreach
(
$mail
->
getToAddresses
()
as
$to_address
)
{
$address
=
self
::
stripMailboxPrefix
(
$to_address
);
$usernames
[]
=
id
(
new
PhutilEmailAddress
(
$address
))->
getLocalPart
();
}
return
array_unique
(
$usernames
);
}
private
function
loadMailUsers
(
PhabricatorMetaMTAReceivedMail
$mail
)
{
$usernames
=
$this
->
getMailUsernames
(
$mail
);
if
(!
$usernames
)
{
return
array
();
}
return
id
(
new
PhabricatorUser
())->
loadAllWhere
(
'username in (%Ls)'
,
$usernames
);
}
protected
function
processReceivedMail
(
PhabricatorMetaMTAReceivedMail
$mail
,
PhabricatorUser
$sender
)
{
$users
=
$this
->
loadMailUsers
(
$mail
);
$phids
=
mpull
(
$users
,
'getPHID'
);
$conpherence
=
id
(
new
ConpherenceReplyHandler
())
->
setMailReceiver
(
ConpherenceThread
::
initializeNewRoom
(
$sender
))
->
setMailAddedParticipantPHIDs
(
$phids
)
->
setActor
(
$sender
)
->
setExcludeMailRecipientPHIDs
(
$mail
->
loadExcludeMailRecipientPHIDs
())
->
processEmail
(
$mail
);
if
(
$conpherence
)
{
$mail
->
setRelatedPHID
(
$conpherence
->
getPHID
());
}
}
}
Event Timeline
Log In to Comment