Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F110621121
PonderQuestionCreateMailReceiver.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, Apr 27, 05:01
Size
1 KB
Mime Type
text/x-php
Expires
Tue, Apr 29, 05:01 (2 d)
Engine
blob
Format
Raw Data
Handle
25834527
Attached To
rPH Phabricator
PonderQuestionCreateMailReceiver.php
View Options
<?php
final
class
PonderQuestionCreateMailReceiver
extends
PhabricatorMailReceiver
{
public
function
isEnabled
()
{
$app_class
=
'PhabricatorPonderApplication'
;
return
PhabricatorApplication
::
isClassInstalled
(
$app_class
);
}
public
function
canAcceptMail
(
PhabricatorMetaMTAReceivedMail
$mail
)
{
$ponder_app
=
new
PhabricatorPonderApplication
();
return
$this
->
canAcceptApplicationMail
(
$ponder_app
,
$mail
);
}
protected
function
processReceivedMail
(
PhabricatorMetaMTAReceivedMail
$mail
,
PhabricatorUser
$sender
)
{
$title
=
$mail
->
getSubject
();
if
(!
strlen
(
$title
))
{
$title
=
pht
(
'New Question'
);
}
$xactions
=
array
();
$xactions
[]
=
id
(
new
PonderQuestionTransaction
())
->
setTransactionType
(
PonderQuestionTransaction
::
TYPE_TITLE
)
->
setNewValue
(
$title
);
$xactions
[]
=
id
(
new
PonderQuestionTransaction
())
->
setTransactionType
(
PonderQuestionTransaction
::
TYPE_CONTENT
)
->
setNewValue
(
$mail
->
getCleanTextBody
());
$question
=
PonderQuestion
::
initializeNewQuestion
(
$sender
);
$content_source
=
$mail
->
newContentSource
();
$editor
=
id
(
new
PonderQuestionEditor
())
->
setActor
(
$sender
)
->
setContentSource
(
$content_source
)
->
setContinueOnNoEffect
(
true
);
$xactions
=
$editor
->
applyTransactions
(
$question
,
$xactions
);
$mail
->
setRelatedPHID
(
$question
->
getPHID
());
}
}
Event Timeline
Log In to Comment