Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F108609318
LegalpadReplyHandler.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
Thu, Apr 17, 15:36
Size
2 KB
Mime Type
text/x-php
Expires
Sat, Apr 19, 15:36 (1 d, 23 h)
Engine
blob
Format
Raw Data
Handle
25629436
Attached To
rPH Phabricator
LegalpadReplyHandler.php
View Options
<?php
final
class
LegalpadReplyHandler
extends
PhabricatorMailReplyHandler
{
public
function
validateMailReceiver
(
$mail_receiver
)
{
if
(!(
$mail_receiver
instanceof
LegalpadDocument
))
{
throw
new
Exception
(
'Mail receiver is not a LegalpadDocument!'
);
}
}
public
function
getPrivateReplyHandlerEmailAddress
(
PhabricatorObjectHandle
$handle
)
{
return
$this
->
getDefaultPrivateReplyHandlerEmailAddress
(
$handle
,
'L'
);
}
public
function
getPublicReplyHandlerEmailAddress
()
{
return
$this
->
getDefaultPublicReplyHandlerEmailAddress
(
'L'
);
}
protected
function
receiveEmail
(
PhabricatorMetaMTAReceivedMail
$mail
)
{
$actor
=
$this
->
getActor
();
$document
=
$this
->
getMailReceiver
();
$body_data
=
$mail
->
parseBody
();
$body
=
$body_data
[
'body'
];
$body
=
$this
->
enhanceBodyWithAttachments
(
$body
,
$mail
->
getAttachments
());
$content_source
=
PhabricatorContentSource
::
newForSource
(
PhabricatorContentSource
::
SOURCE_EMAIL
,
array
(
'id'
=>
$mail
->
getID
(),
));
$xactions
=
array
();
$command
=
$body_data
[
'command'
];
switch
(
$command
)
{
case
'unsubscribe'
:
$xaction
=
id
(
new
LegalpadTransaction
())
->
setTransactionType
(
PhabricatorTransactions
::
TYPE_SUBSCRIBERS
)
->
setNewValue
(
array
(
'-'
=>
array
(
$actor
->
getPHID
())));
$xactions
[]
=
$xaction
;
break
;
}
$xactions
[]
=
id
(
new
LegalpadTransaction
())
->
setTransactionType
(
PhabricatorTransactions
::
TYPE_COMMENT
)
->
attachComment
(
id
(
new
LegalpadTransactionComment
())
->
setDocumentID
(
$document
->
getID
())
->
setLineNumber
(
0
)
->
setLineLength
(
0
)
->
setContent
(
$body
));
$editor
=
id
(
new
LegalpadDocumentEditor
())
->
setActor
(
$actor
)
->
setContentSource
(
$content_source
)
->
setContinueOnNoEffect
(
true
)
->
setIsPreview
(
false
);
try
{
$xactions
=
$editor
->
applyTransactions
(
$document
,
$xactions
);
}
catch
(
PhabricatorApplicationTransactionNoEffectException
$ex
)
{
// just do nothing, though unclear why you're sending a blank email
return
true
;
}
$head_xaction
=
head
(
$xactions
);
return
$head_xaction
->
getID
();
}
}
Event Timeline
Log In to Comment