Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F15417963
D8189.id18529.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
4 KB
Referenced Files
None
Subscribers
None
D8189.id18529.diff
View Options
diff --git a/resources/sql/autopatches/20140210.projcfield.4.memmig.sql b/resources/sql/autopatches/20140210.projcfield.4.memmig.sql
new file mode 100644
--- /dev/null
+++ b/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;
diff --git a/src/applications/metamta/query/PhabricatorMetaMTAMemberQuery.php b/src/applications/metamta/query/PhabricatorMetaMTAMemberQuery.php
--- a/src/applications/metamta/query/PhabricatorMetaMTAMemberQuery.php
+++ b/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;
diff --git a/src/applications/project/editor/PhabricatorProjectTransactionEditor.php b/src/applications/project/editor/PhabricatorProjectTransactionEditor.php
--- a/src/applications/project/editor/PhabricatorProjectTransactionEditor.php
+++ b/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);
diff --git a/src/applications/project/storage/PhabricatorProject.php b/src/applications/project/storage/PhabricatorProject.php
--- a/src/applications/project/storage/PhabricatorProject.php
+++ b/src/applications/project/storage/PhabricatorProject.php
@@ -171,7 +171,7 @@
}
public function shouldAllowSubscription($phid) {
- return false;
+ return $this->isUserMember($phid);
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Fri, Mar 21, 7:45 PM (3 w, 2 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7715943
Default Alt Text
D8189.id18529.diff (4 KB)
Attached To
Mode
D8189: Allow unsubscription from projects
Attached
Detach File
Event Timeline
Log In to Comment