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

Don't raise the "Subscribers Won't Be Notified" draft warning if you aren't adding any non-you subscribers

Summary:
Currently, adding subscribers to a draft revision raises a warning that they won't get an email/notification.

This warning has some false positives:

  - it triggers on any subscriber change, including removing subscribers; and
  - it triggers if you're only adding yourself as a subscriber.

Narrow the scope of the warning so it is raised only if you're adding a subscriber other than yourself.

Test Plan:
  - Added a non-self subscriber, got the warning as before.
  - Added self as a subscriber, no warning (previously: warning).
  - Removed a subscriber, no warning (previously: warning).

Differential Revision: https://secure.phabricator.com/D21402
This commit is contained in:
epriestley 2020-07-09 13:30:01 -07:00
parent b21b73b8dd
commit 6e85b521fe

View file

@ -4968,8 +4968,7 @@ abstract class PhabricatorApplicationTransactionEditor
private function hasWarnings($object, $xaction) {
// TODO: For the moment, this is a very un-modular hack to support
// exactly one type of warning (mentioning users on a draft revision)
// that we want to show. See PHI433.
// a small number of warnings related to draft revisions. See PHI433.
if (!($object instanceof DifferentialRevision)) {
return false;
@ -4991,8 +4990,21 @@ abstract class PhabricatorApplicationTransactionEditor
return false;
}
// NOTE: This will currently warn even if you're only removing
// subscribers.
// We're only going to raise a warning if the transaction adds subscribers
// other than the acting user. (This implementation is clumsy because the
// code runs before a lot of normalization occurs.)
$old = $this->getTransactionOldValue($object, $xaction);
$new = $this->getPHIDTransactionNewValue($xaction, $old);
$old = array_fuse($old);
$new = array_fuse($new);
$add = array_diff_key($new, $old);
unset($add[$this->getActingAsPHID()]);
if (!$add) {
return false;
}
return true;
}