mirror of
https://github.com/friendica/friendica
synced 2024-12-23 11:20:15 +00:00
Merge pull request #2452 from annando/1604-clean-contact-url
Clean gcontact url before saving in gcontact table
This commit is contained in:
commit
e44bec3c37
1 changed files with 26 additions and 0 deletions
|
@ -1354,6 +1354,29 @@ function poco_discover_server($data, $default_generation = 0) {
|
||||||
return $success;
|
return $success;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Removes unwanted parts from a contact url
|
||||||
|
*
|
||||||
|
* @param string $url Contact url
|
||||||
|
* @return string Contact url with the wanted parts
|
||||||
|
*/
|
||||||
|
function clean_contact_url($url) {
|
||||||
|
$parts = parse_url($url);
|
||||||
|
|
||||||
|
if (!isset($parts["scheme"]) OR !isset($parts["host"]))
|
||||||
|
return $url;
|
||||||
|
|
||||||
|
$new_url = $parts["scheme"]."://".$parts["host"];
|
||||||
|
|
||||||
|
if (isset($parts["port"]))
|
||||||
|
$new_url .= ":".$parts["port"];
|
||||||
|
|
||||||
|
if (isset($parts["path"]))
|
||||||
|
$new_url .= $parts["path"];
|
||||||
|
|
||||||
|
return $new_url;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Fetch the gcontact id, add an entry if not existed
|
* @brief Fetch the gcontact id, add an entry if not existed
|
||||||
*
|
*
|
||||||
|
@ -1367,6 +1390,9 @@ function get_gcontact_id($contact) {
|
||||||
if ($contact["network"] == NETWORK_STATUSNET)
|
if ($contact["network"] == NETWORK_STATUSNET)
|
||||||
$contact["network"] = NETWORK_OSTATUS;
|
$contact["network"] = NETWORK_OSTATUS;
|
||||||
|
|
||||||
|
// Remove unwanted parts from the contact url (e.g. "?zrl=...")
|
||||||
|
$contact["url"] = clean_contact_url($contact["url"]);
|
||||||
|
|
||||||
$r = q("SELECT `id` FROM `gcontact` WHERE `nurl` = '%s' ORDER BY `id` LIMIT 2",
|
$r = q("SELECT `id` FROM `gcontact` WHERE `nurl` = '%s' ORDER BY `id` LIMIT 2",
|
||||||
dbesc(normalise_link($contact["url"])));
|
dbesc(normalise_link($contact["url"])));
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue