Page MenuHomePhabricator

D8189.id.diff
No OneTemporary

D8189.id.diff

Index: resources/sql/autopatches/20140210.projcfield.4.memmig.sql
===================================================================
--- /dev/null
+++ resources/sql/autopatches/20140210.projcfield.4.memmig.sql
@@ -0,0 +1,8 @@
+/* These are here so `grep` will find them if we ever change things: */
+
+/* PhabricatorEdgeConfig::TYPE_PROJ_MEMBER = 13 */
+/* PhabricatorEdgeConfig::TYPE_OBJECT_HAS_SUBSCRIBER = 21 */
+
+INSERT IGNORE INTO {$NAMESPACE}_project.edge (src, type, dst, dateCreated)
+ SELECT src, 21, dst, dateCreated FROM {$NAMESPACE}_project.edge
+ WHERE type = 13;
Index: src/applications/metamta/query/PhabricatorMetaMTAMemberQuery.php
===================================================================
--- src/applications/metamta/query/PhabricatorMetaMTAMemberQuery.php
+++ src/applications/metamta/query/PhabricatorMetaMTAMemberQuery.php
@@ -37,24 +37,24 @@
foreach ($type_map as $type => $phids) {
switch ($type) {
case PhabricatorProjectPHIDTypeProject::TYPECONST:
- // TODO: For now, project members are always on the "mailing list"
- // implied by the project, but we should differentiate members and
- // subscribers (i.e., allow you to unsubscribe from mail about
- // a project).
+ // NOTE: We're loading the projects here in order to respect policies.
$projects = id(new PhabricatorProjectQuery())
->setViewer($this->getViewer())
- ->needMembers(true)
->withPHIDs($phids)
->execute();
+ $subscribers = id(new PhabricatorSubscribersQuery())
+ ->withObjectPHIDs($phids)
+ ->execute();
+
$projects = mpull($projects, null, 'getPHID');
foreach ($phids as $phid) {
$project = idx($projects, $phid);
if (!$project) {
$results[$phid] = array();
} else {
- $results[$phid] = $project->getMemberPHIDs();
+ $results[$phid] = idx($subscribers, $phid, array());
}
}
break;
Index: src/applications/project/editor/PhabricatorProjectTransactionEditor.php
===================================================================
--- src/applications/project/editor/PhabricatorProjectTransactionEditor.php
+++ src/applications/project/editor/PhabricatorProjectTransactionEditor.php
@@ -118,10 +118,36 @@
case PhabricatorTransactions::TYPE_VIEW_POLICY:
case PhabricatorTransactions::TYPE_EDIT_POLICY:
case PhabricatorTransactions::TYPE_JOIN_POLICY:
- case PhabricatorTransactions::TYPE_EDGE:
case PhabricatorProjectTransaction::TYPE_STATUS:
case PhabricatorProjectTransaction::TYPE_IMAGE:
return;
+ case PhabricatorTransactions::TYPE_EDGE:
+ switch ($xaction->getMetadataValue('edge:type')) {
+ case PhabricatorEdgeConfig::TYPE_PROJ_MEMBER:
+ // When project members are added or removed, add or remove their
+ // subscriptions.
+ $old = $xaction->getOldValue();
+ $new = $xaction->getNewValue();
+ $add = array_keys(array_diff_key($new, $old));
+ $rem = array_keys(array_diff_key($old, $new));
+
+ // NOTE: The subscribe is "explicit" because there's no implicit
+ // unsubscribe, so Join -> Leave -> Join doesn't resubscribe you
+ // if we use an implicit subscribe, even though you never willfully
+ // unsubscribed. Not sure if adding implicit unsubscribe (which
+ // would not write the unsubscribe row) is justified to deal with
+ // this, which is a fairly weird edge case and pretty arguable both
+ // ways.
+
+ id(new PhabricatorSubscriptionsEditor())
+ ->setActor($this->requireActor())
+ ->setObject($object)
+ ->subscribeExplicit($add)
+ ->unsubscribe($rem)
+ ->save();
+ break;
+ }
+ return;
}
return parent::applyCustomExternalTransaction($object, $xaction);
Index: src/applications/project/storage/PhabricatorProject.php
===================================================================
--- src/applications/project/storage/PhabricatorProject.php
+++ src/applications/project/storage/PhabricatorProject.php
@@ -171,7 +171,7 @@
}
public function shouldAllowSubscription($phid) {
- return false;
+ return $this->isUserMember($phid);
}

File Metadata

Mime Type
text/plain
Expires
Mon, Mar 17, 11:31 PM (3 w, 6 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7605487
Default Alt Text
D8189.id.diff (4 KB)

Event Timeline