Skip to content

Commit a0ea40c

Browse files
committed
persist remote client document registrations
1 parent 4af346c commit a0ea40c

1 file changed

Lines changed: 8 additions & 4 deletions

File tree

lib/ClientRegistration.php

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,6 @@
55

66
class ClientRegistration {
77
public static function getRegistration($clientId) {
8-
if (preg_match("/^http(s)?:/", $clientId)) {
9-
return self::getRemoteRegistration($clientId);
10-
}
11-
128
Db::connect();
139
$query = Db::$pdo->prepare(
1410
'SELECT clientData FROM clients WHERE clientId=:clientId'
@@ -20,6 +16,14 @@ public static function getRegistration($clientId) {
2016
if (sizeof($result) === 1) {
2117
return json_decode($result[0]['clientData'], true);
2218
}
19+
if (preg_match("/^http(s)?:/", $clientId)) {
20+
$clientData = self::getRemoteRegistration($clientId);
21+
if (!isset($clientData['origin']) && isset($clientData['client_uri'])) {
22+
$clientData['origin'] = preg_replace("/\/$/", "", $clientData['client_uri']);
23+
}
24+
self::saveClientRegistration($clientData);
25+
return $clientData;
26+
}
2327
return false;
2428
}
2529

0 commit comments

Comments
 (0)