1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2025-01-03 03:11:01 +01:00

Deduplicate application-level notifications from Aphlict

Summary:
Fixes T12564. We already had some code which seems to deal with this properly, it just wasn't getting used.

Assign each application-level notification a unique ID, then ignore messages with duplicate IDs.

Test Plan:
  - In browser A, loaded `/T123`.
  - In browser B, loaded `/T123`.
  - Made a comment as B.
  - Saw notification as A.
  - Mashed "Replay" a bunch.
  - Before patch: piles of duplicate notifications.
  - After patch: no duplicates.

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T12564

Differential Revision: https://secure.phabricator.com/D17710
This commit is contained in:
epriestley 2017-04-17 14:42:54 -07:00
parent 953ab039ac
commit eaecf35324
3 changed files with 18 additions and 11 deletions

View file

@ -10,7 +10,7 @@ return array(
'conpherence.pkg.css' => 'a34d59bd',
'conpherence.pkg.js' => '5f86c17d',
'core.pkg.css' => '959330a2',
'core.pkg.js' => '1cedf416',
'core.pkg.js' => '2e969052',
'darkconsole.pkg.js' => '31272f61',
'differential.pkg.css' => '90b30783',
'differential.pkg.js' => 'ddfeb49b',
@ -361,7 +361,7 @@ return array(
'rsrc/image/texture/table_header.png' => '5c433037',
'rsrc/image/texture/table_header_hover.png' => '038ec3b9',
'rsrc/image/texture/table_header_tall.png' => 'd56b434f',
'rsrc/js/application/aphlict/Aphlict.js' => '7cacce98',
'rsrc/js/application/aphlict/Aphlict.js' => '9b5dda26',
'rsrc/js/application/aphlict/behavior-aphlict-dropdown.js' => 'caade6f2',
'rsrc/js/application/aphlict/behavior-aphlict-listen.js' => 'd82b1ff9',
'rsrc/js/application/aphlict/behavior-aphlict-status.js' => '5e2634b9',
@ -583,7 +583,7 @@ return array(
'herald-rule-editor' => 'd6a7e717',
'herald-test-css' => 'a52e323e',
'inline-comment-summary-css' => '51efda3a',
'javelin-aphlict' => '7cacce98',
'javelin-aphlict' => '9b5dda26',
'javelin-behavior' => '61cbc29a',
'javelin-behavior-aphlict-dropdown' => 'caade6f2',
'javelin-behavior-aphlict-listen' => 'd82b1ff9',
@ -1468,13 +1468,6 @@ return array(
'owners-path-editor',
'javelin-behavior',
),
'7cacce98' => array(
'javelin-install',
'javelin-util',
'javelin-websocket',
'javelin-leader',
'javelin-json',
),
'7cbe244b' => array(
'javelin-install',
'javelin-util',
@ -1686,6 +1679,13 @@ return array(
'aphront-typeahead-control-css',
'phui-tag-view-css',
),
'9b5dda26' => array(
'javelin-install',
'javelin-util',
'javelin-websocket',
'javelin-leader',
'javelin-json',
),
'9bbf3762' => array(
'javelin-behavior',
'javelin-dom',

View file

@ -18,6 +18,11 @@ final class PhabricatorNotificationClient extends Phobject {
}
public static function tryToPostMessage(array $data) {
$unique_id = Filesystem::readRandomCharacters(32);
$data = $data + array(
'uniqueID' => $unique_id,
);
$servers = PhabricatorNotificationServerRef::getEnabledAdminServers();
shuffle($servers);

View file

@ -130,7 +130,9 @@ JX.install('Aphlict', {
_message: function(raw) {
var message = JX.JSON.parse(raw);
JX.Leader.broadcast(null, {type: 'aphlict.server', data: message});
var id = message.uniqueID || null;
JX.Leader.broadcast(id, {type: 'aphlict.server', data: message});
},
_receive: function(message, is_leader) {