Page MenuHomePhabricator

D14853.id.diff
No OneTemporary

D14853.id.diff

diff --git a/src/applications/transactions/storage/PhabricatorApplicationTransaction.php b/src/applications/transactions/storage/PhabricatorApplicationTransaction.php
--- a/src/applications/transactions/storage/PhabricatorApplicationTransaction.php
+++ b/src/applications/transactions/storage/PhabricatorApplicationTransaction.php
@@ -565,6 +565,10 @@
}
public function shouldHideForMail(array $xactions) {
+ if ($this->isSelfSubscription()) {
+ return true;
+ }
+
switch ($this->getTransactionType()) {
case PhabricatorTransactions::TYPE_TOKEN:
return true;
@@ -614,6 +618,10 @@
}
public function shouldHideForFeed() {
+ if ($this->isSelfSubscription()) {
+ return true;
+ }
+
switch ($this->getTransactionType()) {
case PhabricatorTransactions::TYPE_TOKEN:
return true;
@@ -1103,32 +1111,11 @@
case PhabricatorTransactions::TYPE_COMMENT:
return 0.5;
case PhabricatorTransactions::TYPE_SUBSCRIBERS:
- $old = $this->getOldValue();
- $new = $this->getNewValue();
-
- $add = array_diff($old, $new);
- $rem = array_diff($new, $old);
-
- // If this action is the actor subscribing or unsubscribing themselves,
- // it is less interesting. In particular, if someone makes a comment and
- // also implicitly subscribes themselves, we should treat the
- // transaction group as "comment", not "subscribe". In this specific
- // case (one affected user, and that affected user it the actor),
- // decrease the action strength.
-
- if ((count($add) + count($rem)) != 1) {
- // Not exactly one CC change.
- break;
- }
-
- $affected_phid = head(array_merge($add, $rem));
- if ($affected_phid != $this->getAuthorPHID()) {
- // Affected user is someone else.
- break;
+ if ($this->isSelfSubscription()) {
+ // Make this weaker than TYPE_COMMENT.
+ return 0.25;
}
-
- // Make this weaker than TYPE_COMMENT.
- return 0.25;
+ break;
}
return 1.0;
@@ -1333,6 +1320,35 @@
return rtrim($text."\n\n".$body);
}
+ /**
+ * Test if this transaction is just a user subscribing or unsubscribing
+ * themselves.
+ */
+ private function isSelfSubscription() {
+ $type = $this->getTransactionType();
+ if ($type != PhabricatorTransactions::TYPE_SUBSCRIBERS) {
+ return false;
+ }
+
+ $old = $this->getOldValue();
+ $new = $this->getNewValue();
+
+ $add = array_diff($old, $new);
+ $rem = array_diff($new, $old);
+
+ if ((count($add) + count($rem)) != 1) {
+ // More than one user affected.
+ return false;
+ }
+
+ $affected_phid = head(array_merge($add, $rem));
+ if ($affected_phid != $this->getAuthorPHID()) {
+ // Affected user is someone else.
+ return false;
+ }
+
+ return true;
+ }
/* -( PhabricatorPolicyInterface Implementation )-------------------------- */

File Metadata

Mime Type
text/plain
Expires
Tue, May 14, 4:26 AM (3 w, 2 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6290900
Default Alt Text
D14853.id.diff (2 KB)

Event Timeline