Fix FLEXIAPI-175 and FLEXISIP-231 Rewrite the Redis contacts parser to handle...

This commit is contained in:
Timothée Jaussoin 2024-05-16 13:12:30 +00:00
parent a9a7fffd9b
commit 1b5fc67985
2 changed files with 9 additions and 17 deletions

View file

@ -2,6 +2,7 @@
v1.5
----
- Fix FLEXIAPI-175 and FLEXISIP-231 Rewrite the Redis contacts parser to handle properly SIP uris (thanks @thibault.lemaire !)
- Fix FLEXIAPI-174 Check if the phone is valid before trying to recover it (deprecated endpoint)
- Fix FLEXIAPI-173 Wrong route in validateEmail (deprecated)
- Fix FLEXIAPI-171 Fix README documentation for CreateAdminAccount

View file

@ -26,25 +26,16 @@ class Device extends Model
{
public function fromRedisContact(string $contact)
{
// Ugly :'(
$result = [];
$exploded = explode(';', urldecode($contact));
preg_match("/<(.*)>;(.*)/", $contact, $matches);
foreach ($exploded as $line) {
$line = explode('=', $line);
$parsed = parse_url($matches[1]);
parse_str($parsed["query"], $query);
if (count($line) == 2) {
$result[trim($line[0])] = $line[1];
}
parse_str(str_replace(";", "&", $parsed["path"]), $sipParams);
parse_str(str_replace(";", "&", $matches[2]), $sipHeaders);
// User agent
if (count($line) == 4) {
$result['userAgent'] = substr($line[3], 0, -1);
}
}
$this->uuid = \substr($result['sip.instance'], 2, -2);
$this->update_time = Carbon::createFromTimestamp($result['updatedAt']);
$this->user_agent = $result['userAgent'];
$this->uuid = substr($sipHeaders['sip_instance'], 2, -2);
$this->update_time = Carbon::createFromTimestamp($sipParams['updatedAt']);
$this->user_agent = $query["user-agent"];
}
}