1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-23 05:50:55 +01:00

ApplicationTransactions - reload subscribers if there's a transaction that changes them

Summary: in applyExternalEffects, for subscriber transactions, we now re-load subscribers. also fixes a bug where a user can get emailed 2x when they take an action on a mock they created.

Test Plan: made some mocks. verified one copy sent to creator and one to each subscriber. (note having problems with email so I verified the phids mail was supposed to be sent to and did not get the actual email delivered)

Reviewers: epriestley, chad

Reviewed By: epriestley

CC: aran, Korvin

Maniphest Tasks: T3315

Differential Revision: https://secure.phabricator.com/D6206
This commit is contained in:
Bob Trahan 2013-06-20 16:40:56 -07:00
parent 46a7c61c80
commit a5ca96a590

View file

@ -217,6 +217,15 @@ abstract class PhabricatorApplicationTransactionEditor
array_diff_key($new_map, $old_map))); array_diff_key($new_map, $old_map)));
$subeditor->save(); $subeditor->save();
// for the rest of these edits, subscribers should include those just
// added as well as those just removed.
$subscribers = array_unique(array_merge(
$this->subscribers,
$xaction->getOldValue(),
$xaction->getNewValue()));
$this->subscribers = $subscribers;
break; break;
case PhabricatorTransactions::TYPE_EDGE: case PhabricatorTransactions::TYPE_EDGE:
$old = $xaction->getOldValue(); $old = $xaction->getOldValue();
@ -307,14 +316,7 @@ abstract class PhabricatorApplicationTransactionEditor
$actor = $this->requireActor(); $actor = $this->requireActor();
if ($object->getPHID() && $this->loadSubscribers($object);
($object instanceof PhabricatorSubscribableInterface)) {
$subs = PhabricatorSubscribersQuery::loadSubscribersForPHID(
$object->getPHID());
$this->subscribers = array_fuse($subs);
} else {
$this->subscribers = array();
}
$xactions = $this->applyImplicitCC($object, $xactions); $xactions = $this->applyImplicitCC($object, $xactions);
@ -505,6 +507,17 @@ abstract class PhabricatorApplicationTransactionEditor
} }
} }
private function loadSubscribers(PhabricatorLiskDAO $object) {
if ($object->getPHID() &&
($object instanceof PhabricatorSubscribableInterface)) {
$subs = PhabricatorSubscribersQuery::loadSubscribersForPHID(
$object->getPHID());
$this->subscribers = array_fuse($subs);
} else {
$this->subscribers = array();
}
}
private function validateEditParameters( private function validateEditParameters(
PhabricatorLiskDAO $object, PhabricatorLiskDAO $object,
array $xactions) { array $xactions) {
@ -1017,8 +1030,8 @@ abstract class PhabricatorApplicationTransactionEditor
PhabricatorLiskDAO $object, PhabricatorLiskDAO $object,
array $xactions) { array $xactions) {
$email_to = $this->getMailTo($object); $email_to = array_unique($this->getMailTo($object));
$email_cc = $this->getMailCC($object); $email_cc = array_unique($this->getMailCC($object));
$phids = array_merge($email_to, $email_cc); $phids = array_merge($email_to, $email_cc);
$handles = id(new PhabricatorObjectHandleData($phids)) $handles = id(new PhabricatorObjectHandleData($phids))
@ -1203,9 +1216,9 @@ abstract class PhabricatorApplicationTransactionEditor
PhabricatorLiskDAO $object, PhabricatorLiskDAO $object,
array $xactions) { array $xactions) {
return array_merge( return array_unique(array_merge(
$this->getMailTo($object), $this->getMailTo($object),
$this->getMailCC($object)); $this->getMailCC($object)));
} }