Delete the old OStatus entries
This commit is contained in:
parent
2d589a7d0c
commit
98cd37438f
|
@ -171,6 +171,8 @@ function poco_check($profile_url, $name, $network, $profile_photo, $about, $loca
|
||||||
|
|
||||||
$gcid = "";
|
$gcid = "";
|
||||||
|
|
||||||
|
$alternate = poco_alternate_ostatus_url($profile_url);
|
||||||
|
|
||||||
if ($profile_url == "")
|
if ($profile_url == "")
|
||||||
return $gcid;
|
return $gcid;
|
||||||
|
|
||||||
|
@ -231,7 +233,7 @@ function poco_check($profile_url, $name, $network, $profile_photo, $about, $loca
|
||||||
$nick = end(explode("/", $urlparts["path"]));
|
$nick = end(explode("/", $urlparts["path"]));
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((($network == "") OR ($name == "") OR ($profile_photo == "") OR ($server_url == ""))
|
if ((($network == "") OR ($name == "") OR ($profile_photo == "") OR ($server_url == "") OR $alternate)
|
||||||
AND poco_reachable($profile_url, $server_url, $network, true)) {
|
AND poco_reachable($profile_url, $server_url, $network, true)) {
|
||||||
$data = probe_url($profile_url);
|
$data = probe_url($profile_url);
|
||||||
|
|
||||||
|
@ -241,8 +243,14 @@ function poco_check($profile_url, $name, $network, $profile_photo, $about, $loca
|
||||||
$profile_url = $data["url"];
|
$profile_url = $data["url"];
|
||||||
$profile_photo = $data["photo"];
|
$profile_photo = $data["photo"];
|
||||||
$server_url = $data["baseurl"];
|
$server_url = $data["baseurl"];
|
||||||
|
|
||||||
|
if ($alternate AND ($network == NETWORK_OSTATUS))
|
||||||
|
poco_check($profile_url, $name, $network, $profile_photo, $about, $location, $gender, $keywords, $connect_url, $updated, $generation, $cid, $uid, $zcid);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($alternate AND ($network == NETWORK_OSTATUS))
|
||||||
|
return $gcid;
|
||||||
|
|
||||||
if (count($x) AND ($x[0]["network"] == "") AND ($network != "")) {
|
if (count($x) AND ($x[0]["network"] == "") AND ($network != "")) {
|
||||||
q("UPDATE `gcontact` SET `network` = '%s' WHERE `nurl` = '%s'",
|
q("UPDATE `gcontact` SET `network` = '%s' WHERE `nurl` = '%s'",
|
||||||
dbesc($network),
|
dbesc($network),
|
||||||
|
@ -404,6 +412,10 @@ function poco_detect_server($profile) {
|
||||||
return $server_url;
|
return $server_url;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function poco_alternate_ostatus_url($url) {
|
||||||
|
return(preg_match("=https?://.+/user/\d+=ism", $url, $matches));
|
||||||
|
}
|
||||||
|
|
||||||
function poco_last_updated($profile, $force = false) {
|
function poco_last_updated($profile, $force = false) {
|
||||||
|
|
||||||
$gcontacts = q("SELECT * FROM `gcontact` WHERE `nurl` = '%s'",
|
$gcontacts = q("SELECT * FROM `gcontact` WHERE `nurl` = '%s'",
|
||||||
|
@ -530,17 +542,19 @@ function poco_last_updated($profile, $force = false) {
|
||||||
$data = probe_url($profile);
|
$data = probe_url($profile);
|
||||||
|
|
||||||
// Is the profile link the alternate OStatus link notation? (http://domain.tld/user/4711)
|
// Is the profile link the alternate OStatus link notation? (http://domain.tld/user/4711)
|
||||||
// Then check the other link and mark this one as a failure
|
// Then check the other link and delete this one
|
||||||
if (($data["network"] == NETWORK_OSTATUS) AND
|
if (($data["network"] == NETWORK_OSTATUS) AND poco_alternate_ostatus_url($profile) AND
|
||||||
(normalise_link($profile) == normalise_link($data["alias"])) AND
|
(normalise_link($profile) == normalise_link($data["alias"])) AND
|
||||||
(normalise_link($profile) != normalise_link($data["url"]))) {
|
(normalise_link($profile) != normalise_link($data["url"]))) {
|
||||||
|
|
||||||
|
// Delete the old entry
|
||||||
|
q("DELETE FROM `gcontact` WHERE `nurl` = '%s'", dbesc(normalise_link($profile)));
|
||||||
|
q("DELETE FROM `glink` WHERE `gcid` = %d", intval($gcontacts[0]["id"]));
|
||||||
|
|
||||||
poco_check($data["url"], $data["name"], $data["network"], $data["photo"], $gcontacts[0]["about"], $gcontacts[0]["location"],
|
poco_check($data["url"], $data["name"], $data["network"], $data["photo"], $gcontacts[0]["about"], $gcontacts[0]["location"],
|
||||||
$gcontacts[0]["gender"], $gcontacts[0]["keywords"], $data["addr"], $gcontacts[0]["updated"], $gcontacts[0]["generation"]);
|
$gcontacts[0]["gender"], $gcontacts[0]["keywords"], $data["addr"], $gcontacts[0]["updated"], $gcontacts[0]["generation"]);
|
||||||
|
|
||||||
q("UPDATE `gcontact` SET `last_failure` = '%s' WHERE `nurl` = '%s'",
|
poco_last_updated($data["url"], $force);
|
||||||
dbesc(datetime_convert()), dbesc(normalise_link($profile)));
|
|
||||||
|
|
||||||
poco_last_updated($data["url"], $force);
|
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user