Page MenuHomePhabricator

Allow admins to rename personal Herald rules
Closed, ResolvedPublicFeature

Description

Herald rules are expensive per T108586. We have way more than 100 active Herald rules in our installation.

It's currently hard to recognize patterns in Herald as folks create Herald rules with rather ambiguous/vague names (like "Notify me" or "My Herald Rule").

Being able to recognize common patterns helps to identify potential feature functionality to introduce outside of Herald with a more performant architecture.

Some random common personal rule condition examples include "Notify me via email only for newly created tasks in project X as I otherwise rely on web notifications", or "Subscribe me when the task title or description include a regex related to a certain language (stuff like enwiki)", for example.

Details

Related Changes in GitLab:
TitleReferenceAuthorSource BranchDest Branch
Allow admins to rename / edit personal Herald rulesrepos/phabricator/phabricator!94aklapperaklapper-wmf/T386703-adminsEditHeraldRuleswmf/stable
Customize query in GitLab

Event Timeline

After a quick look at the design decisions in the Phorge code I'll decline this:

As there is no per-rule "Edit Policy" concept, HeraldRule::getPolicy($capability) accepts a string parameter like view or edit and it returns a string, for example admin as the result of $herald->getPolicy($global) per the current Herald Application settings at /applications/view/PhabricatorHeraldApplication/, or in case of personal rules always return $this->getAuthorPHID() as the rule policy.
So there is no way to set some custom "allow both admins and rule author to edit a personal rule" permissions currently. Only the default hardcoded policies are available.

Which also explains why we the only way to edit some objects is by changing the edit policy to your own user account: https://wikitech.wikimedia.org/wiki/Phabricator#Unlocking_edit_permissions_on_random_objects :)

Aklapper claimed this task.
Aklapper triaged this task as Low priority.

I'm going to reopen because once again came back to this thought today as it is getting harder to find existing Herald rules to potentially amend.
Or rules that duplicate functionality.
Because of random naming and because we have so many rules.

So, unrelated, I changed the default query on https://phabricator.wikimedia.org/herald/ to be "Active" instead of "Authored".
Because that's what I usually want to see first, always.

Playing locally with a "Personal Rule" created by a non-admin account,

diff --git a/src/applications/herald/storage/HeraldRule.php b/src/applications/herald/storage/HeraldRule.php
index c489ee61f8..a8ab3f8a58 100644
--- a/src/applications/herald/storage/HeraldRule.php
+++ b/src/applications/herald/storage/HeraldRule.php
@@ -371,6 +371,9 @@ final class HeraldRule extends HeraldDAO
   }
 
   public function hasAutomaticCapability($capability, PhabricatorUser $viewer) {
+    if ($viewer->getIsAdmin()) {
+      return true;
+    }
     return false;
   }

seems to do the job: I can edit a Personal Rule created by an average user as an admin but cannot edited a Personal Rule created by an admin as an average user?

This seems to work - at least the "Edit Rule" button is now available to Phab admins on Herald Rules, before it wasn't.

NOTE: As Personal Rules are personal, the UI shows "Send an email to rule author" as action. In "Edit Rule" mode that action says "Send me an email". Same applies for "Assign task to me" or "Send me an email". This is only the UI being misleading due to our local hack. The rules still work as expected, these "me" actions apply to the actual rule author and not to the admin.