mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-12 08:36:13 +01:00
eaecf35324
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
40 lines
815 B
PHP
40 lines
815 B
PHP
<?php
|
|
|
|
final class PhabricatorNotificationClient extends Phobject {
|
|
|
|
public static function tryAnyConnection() {
|
|
$servers = PhabricatorNotificationServerRef::getEnabledAdminServers();
|
|
|
|
if (!$servers) {
|
|
return;
|
|
}
|
|
|
|
foreach ($servers as $server) {
|
|
$server->loadServerStatus();
|
|
return;
|
|
}
|
|
|
|
return;
|
|
}
|
|
|
|
public static function tryToPostMessage(array $data) {
|
|
$unique_id = Filesystem::readRandomCharacters(32);
|
|
$data = $data + array(
|
|
'uniqueID' => $unique_id,
|
|
);
|
|
|
|
$servers = PhabricatorNotificationServerRef::getEnabledAdminServers();
|
|
|
|
shuffle($servers);
|
|
|
|
foreach ($servers as $server) {
|
|
try {
|
|
$server->postMessage($data);
|
|
return;
|
|
} catch (Exception $ex) {
|
|
// Just ignore any issues here.
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|