1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-10 08:52:39 +01:00

Add a "Comment content" field to Herald

Summary: Ref T13583. To improve support for making it harder to improperly mix data retention policies, allow Herald to act on comment content.

Test Plan:
  - Wrote comment content Herald rules in Maniphest and Differential.
  - Submitted non-matching comments (no action) and matching comments (Herald action).
  - In Differential, triggered rules by submitting non-matching main content and a matching inline comment.

Maniphest Tasks: T13583

Differential Revision: https://secure.phabricator.com/D21479
This commit is contained in:
epriestley 2020-10-16 13:19:38 -07:00
parent 0f27cd46cc
commit 1f7c736f9a
2 changed files with 45 additions and 0 deletions

View file

@ -1557,6 +1557,7 @@ phutil_register_library_map(array(
'HeraldBuildableState' => 'applications/herald/state/HeraldBuildableState.php',
'HeraldCallWebhookAction' => 'applications/herald/action/HeraldCallWebhookAction.php',
'HeraldCommentAction' => 'applications/herald/action/HeraldCommentAction.php',
'HeraldCommentContentField' => 'applications/herald/field/HeraldCommentContentField.php',
'HeraldCommitAdapter' => 'applications/diffusion/herald/HeraldCommitAdapter.php',
'HeraldCondition' => 'applications/herald/storage/HeraldCondition.php',
'HeraldConditionTranscript' => 'applications/herald/storage/transcript/HeraldConditionTranscript.php',
@ -7770,6 +7771,7 @@ phutil_register_library_map(array(
'HeraldBuildableState' => 'HeraldState',
'HeraldCallWebhookAction' => 'HeraldAction',
'HeraldCommentAction' => 'HeraldAction',
'HeraldCommentContentField' => 'HeraldField',
'HeraldCommitAdapter' => array(
'HeraldAdapter',
'HarbormasterBuildableAdapterInterface',

View file

@ -0,0 +1,43 @@
<?php
final class HeraldCommentContentField extends HeraldField {
const FIELDCONST = 'comment.content';
public function getHeraldFieldName() {
return pht('Comment content');
}
public function getFieldGroupKey() {
return HeraldTransactionsFieldGroup::FIELDGROUPKEY;
}
public function getHeraldFieldValue($object) {
$adapter = $this->getAdapter();
$xactions = $adapter->getAppliedTransactions();
$result = array();
foreach ($xactions as $xaction) {
if (!$xaction->hasComment()) {
continue;
}
$comment = $xaction->getComment();
$content = $comment->getContent();
$result[] = $content;
}
return $result;
}
public function supportsObject($object) {
return true;
}
protected function getHeraldFieldStandardType() {
return self::STANDARD_TEXT_LIST;
}
}