mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-03 04:02:43 +01:00
2c03cd931b
Summary: Supports !unsubscribe and commenting on replies. Subscribers get mailed something reasonable. Fixes T3480. Sneaks in /LX/ support. In the near future I want to have that /LX/ be a clean "signature" page sans all the edit actions and other fluff... Will resolve this as part of T3481. Test Plan: used the metamta console to add comments and unsubscribe. added a phlog() inside mail code to verify mail bodies looked okay. Reviewers: epriestley Reviewed By: epriestley CC: aran, Korvin Maniphest Tasks: T3480 Differential Revision: https://secure.phabricator.com/D6369
82 lines
2.1 KiB
PHP
82 lines
2.1 KiB
PHP
<?php
|
|
|
|
/**
|
|
* @group legalpad
|
|
*/
|
|
final class LegalpadDocumentCommentController extends LegalpadController {
|
|
|
|
private $id;
|
|
|
|
public function willProcessRequest(array $data) {
|
|
$this->id = $data['id'];
|
|
}
|
|
|
|
public function processRequest() {
|
|
$request = $this->getRequest();
|
|
$user = $request->getUser();
|
|
|
|
if (!$request->isFormPost()) {
|
|
return new Aphront400Response();
|
|
}
|
|
|
|
$document = id(new LegalpadDocumentQuery())
|
|
->setViewer($user)
|
|
->withIDs(array($this->id))
|
|
->needDocumentBodies(true)
|
|
->executeOne();
|
|
|
|
if (!$document) {
|
|
return new Aphront404Response();
|
|
}
|
|
|
|
$is_preview = $request->isPreviewRequest();
|
|
|
|
$draft = PhabricatorDraft::buildFromRequest($request);
|
|
|
|
$document_uri = $this->getApplicationURI('view/'.$document->getID());
|
|
|
|
$comment = $request->getStr('comment');
|
|
|
|
$xactions = array();
|
|
|
|
if (strlen($comment)) {
|
|
$xactions[] = id(new LegalpadTransaction())
|
|
->setTransactionType(PhabricatorTransactions::TYPE_COMMENT)
|
|
->attachComment(
|
|
id(new LegalpadTransactionComment())
|
|
->setDocumentID($document->getID())
|
|
->setLineNumber(0)
|
|
->setLineLength(0)
|
|
->setContent($comment));
|
|
}
|
|
|
|
$editor = id(new LegalpadDocumentEditor())
|
|
->setActor($user)
|
|
->setContentSourceFromRequest($request)
|
|
->setContinueOnNoEffect($request->isContinueRequest())
|
|
->setIsPreview($is_preview);
|
|
|
|
try {
|
|
$xactions = $editor->applyTransactions($document, $xactions);
|
|
} catch (PhabricatorApplicationTransactionNoEffectException $ex) {
|
|
return id(new PhabricatorApplicationTransactionNoEffectResponse())
|
|
->setCancelURI($document_uri)
|
|
->setException($ex);
|
|
}
|
|
|
|
if ($draft) {
|
|
$draft->replaceOrDelete();
|
|
}
|
|
|
|
if ($request->isAjax()) {
|
|
return id(new PhabricatorApplicationTransactionResponse())
|
|
->setViewer($user)
|
|
->setTransactions($xactions)
|
|
->setIsPreview($is_preview)
|
|
->setAnchorOffset($request->getStr('anchor'));
|
|
} else {
|
|
return id(new AphrontRedirectResponse())->setURI($document_uri);
|
|
}
|
|
}
|
|
|
|
}
|