Page MenuHomePhabricator

Add Herald action value for content creator / author
Closed, WontfixPublic

Description

Enable Herald rules to have a value for content creator or author. This should enable rules like

If task has no projects, assign to task creator

Supporting this will be a little tricky as "content creator" is a magic variable in a UI that's currently fairly user name driven. This is likely valuable as other "magic variables" seem useful too in the long term. (@chad - any ideas here?)

This is useful for "kick back" Herald rules where the automation should kick back the content to the creator for the next step in some workflow / additional edits / changes / etc. The inspiration initially came from T5118, as a way to kick back Tasks to folks who didn't assign projects so they would a) notice and then b) add some.

Event Timeline

btrahan raised the priority of this task from to Low.
btrahan updated the task description. (Show Details)
btrahan added a project: Herald.
btrahan added subscribers: btrahan, chad.

To be clear, it's for more than just if someone filed a task without setting a project: it could be used to check the validity of various task fields like Projects or Assignee or check for a status change and kick back the task to the originator (after adding a comment as well I guess?).

If the problem to implement this is the assignee autocomplete field, would it be possible to add a new action that simply says: "Assign back to originator"?

PS: If I wanted to take a pass at this, could you tell me which PHP file implements the possible actions for Maniphest based Herald rules?

This can be built as a custom Herald action (which will eventually be documented; see T5194). Drop this in src/extensions/ and then the "Reassign to author" action should be available in "Global" Maniphest Herald rules.

<?php

class KickBackAction extends HeraldCustomAction {

  public function appliesToAdapter(HeraldAdapter $adapter) {
    return ($adapter instanceof HeraldManiphestTaskAdapter);
  }

  public function appliesToRuleType($rule_type) {
    switch ($rule_type) {
      case HeraldRuleTypeConfig::RULE_TYPE_GLOBAL:
        return true;
      case HeraldRuleTypeConfig::RULE_TYPE_PERSONAL:
      case HeraldRuleTypeConfig::RULE_TYPE_OBJECT:
      default:
        return false;
    }
  }

  public function getActionKey() {
    return "swisspol.kick";
  }

  public function getActionName() {
    return pht('Reassign to author');
  }

  public function getActionType() {
    return HeraldAdapter::VALUE_NONE;
  }

  public function applyEffect(
    HeraldAdapter $adapter,
    $object,
    HeraldEffect $effect) {

    $task = $object;

    $xactions = array();

    $xactions[] = id(new ManiphestTransaction())
      ->setTransactionType(ManiphestTransaction::TYPE_OWNER)
      ->setNewValue($original_author);

    foreach ($xactions as $xaction) {
      $adapter->queueTransaction($xaction);
    }

    return new HeraldApplyTranscript(
      $effect,
      true,
      pht('Reassigned to original author'));
  }
}

We can probably do "Task Author" / "Current Actor" eventually too, but need T4100 for the UI.

This gets a bit messy when we have something like:

  • We read a commit with Fixes T123.
  • We don't recognize the author.
  • We close T123, acting as the Diffusion application.
  • We trigger a Herald rule with this new "assign to current actor" action.

I think we have to just fail the action in this case, but it makes things a bit complicated.

I realize I'm still missing a piece: I thought you could do that in Herald but apparently not: adding a comment to a task when a rule matches. This would be needed to not just blindly re-assign the task to the author but also add some context.

the above code snippet seems not working with latest phabricator version

See T8957.

You can follow the weekly changelogs to learn about API changes:

https://secure.phabricator.com/w/changelog/2015.30/
https://secure.phabricator.com/w/changelog/2015.31/

(We don't offer support for random code I wrote in a task somewhere, so no modern version of this action is available.)

Thanks @epriestley, I'll look at that and try to modify the extension code ~

epriestley claimed this task.

This doesn't describe a use case (per Contributing Feature Requests) except by reference to requiring projects (which is covered by T6030).

If you have a use case for this, please file a new feature request according to the documentation. You may want to read T6030 and T9905 first.