Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/phabricator
Path: blob/master/src/applications/notification/client/PhabricatorNotificationClient.php
12256 views
1
<?php
2
3
final class PhabricatorNotificationClient extends Phobject {
4
5
public static function tryAnyConnection() {
6
$servers = PhabricatorNotificationServerRef::getEnabledAdminServers();
7
8
if (!$servers) {
9
return;
10
}
11
12
foreach ($servers as $server) {
13
$server->loadServerStatus();
14
return;
15
}
16
17
return;
18
}
19
20
public static function tryToPostMessage(array $data) {
21
$unique_id = Filesystem::readRandomCharacters(32);
22
$data = $data + array(
23
'uniqueID' => $unique_id,
24
);
25
26
$servers = PhabricatorNotificationServerRef::getEnabledAdminServers();
27
28
shuffle($servers);
29
30
foreach ($servers as $server) {
31
try {
32
$server->postMessage($data);
33
return;
34
} catch (Exception $ex) {
35
// Just ignore any issues here.
36
}
37
}
38
}
39
40
public static function isEnabled() {
41
return (bool)PhabricatorNotificationServerRef::getEnabledAdminServers();
42
}
43
44
}
45
46