diff --git a/src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php b/src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php --- a/src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php +++ b/src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php @@ -1516,6 +1516,37 @@ $new_texts); $phids = array_diff($new_phids, $old_phids); + + // Count any users who were explicitly added as subscribers (other than + // the actor) as "mentioned". If someone: just adds another user as a + // subscriber; or adds them as a subscriber explicitly, then writes a + // comment without actually "@mentioning" them, we still want it to + // behave like a mention for the purposes of mail stamps. + + $subscriber_type = PhabricatorTransactions::TYPE_SUBSCRIBERS; + $old_state = array_values($this->subscribers); + $old_state = array_fuse($old_state); + foreach ($xactions as $xaction) { + if ($xaction->getTransactionType() != $subscriber_type) { + continue; + } + + $new_value = $xaction->getNewValue(); + + $new_phids = array_merge( + idx($new_value, '=', array()), + idx($new_value, '+', array())); + + foreach ($new_phids as $phid) { + if ($phid === $this->getActingAsPHID()) { + continue; + } + + if (!isset($old_state[$phid])) { + $phids[] = $phid; + } + } + } } else { $phids = array(); }