1
0
Fork 0

Bugfix: Revive dead contacts

This commit is contained in:
Michael 2017-10-15 19:34:15 +00:00
parent 1441abd15a
commit 08f461f70c
5 changed files with 17 additions and 14 deletions

View file

@ -155,7 +155,7 @@ function mark_for_death($contact) {
function unmark_for_death($contact) { function unmark_for_death($contact) {
$r = q("SELECT `term-date` FROM `contact` WHERE `id` = %d AND `term-date` > '%s'", $r = q("SELECT `term-date` FROM `contact` WHERE `id` = %d AND (`term-date` > '%s' OR `archive`)",
intval($contact['id']), intval($contact['id']),
dbesc('1000-00-00 00:00:00') dbesc('1000-00-00 00:00:00')
); );
@ -166,16 +166,11 @@ function unmark_for_death($contact) {
} }
// It's a miracle. Our dead contact has inexplicably come back to life. // It's a miracle. Our dead contact has inexplicably come back to life.
q("UPDATE `contact` SET `term-date` = '%s' WHERE `id` = %d", $fields = array('term-date' => NULL_DATE, 'archive' => false);
dbesc(NULL_DATE), dba::update('contact', $fields, array('id' => $contact['id']));
intval($contact['id'])
);
if ($contact['url'] != '') { if ($contact['url'] != '') {
q("UPDATE `contact` SET `term-date` = '%s' WHERE `nurl` = '%s'", dba::update('contact', $fields, array('nurl' => normalise_link($contact['url'])));
dbesc(NULL_DATE),
dbesc(normalise_link($contact['url']))
);
} }
} }

View file

@ -2,6 +2,7 @@
use Friendica\App; use Friendica\App;
use Friendica\Core\System; use Friendica\Core\System;
use Friendica\Network\Probe;
require_once 'include/probe.php'; require_once 'include/probe.php';
require_once 'include/socgraph.php'; require_once 'include/socgraph.php';
@ -71,7 +72,7 @@ function update_contact($id) {
function new_contact($uid,$url,$interactive = false) { function new_contact($uid, $url, $interactive = false, $network = '') {
$result = array('cid' => -1, 'success' => false,'message' => ''); $result = array('cid' => -1, 'success' => false,'message' => '');
@ -102,9 +103,13 @@ function new_contact($uid,$url,$interactive = false) {
if (x($arr['contact'],'name')) { if (x($arr['contact'],'name')) {
$ret = $arr['contact']; $ret = $arr['contact'];
} else {
$ret = Probe::uri($url, $network, $uid, false);
} }
else {
$ret = probe_url($url); if (($network != '') && ($ret['network'] != $network)) {
logger('Expected network '.$network.' does not match actual network '.$ret['network']);
return result;
} }
if ($ret['network'] === NETWORK_DFRN) { if ($ret['network'] === NETWORK_DFRN) {

View file

@ -149,6 +149,9 @@ class ostatus {
// Only update the contacts if it is an OStatus contact // Only update the contacts if it is an OStatus contact
if ($r && ($r['id'] > 0) && !$onlyfetch && ($contact["network"] == NETWORK_OSTATUS)) { if ($r && ($r['id'] > 0) && !$onlyfetch && ($contact["network"] == NETWORK_OSTATUS)) {
// This contact is vital, so we awake it from the dead
unmark_for_death($contact);
// Update contact data // Update contact data
$current = $contact; $current = $contact;

View file

@ -244,7 +244,7 @@ function _contact_update($contact_id) {
return; return;
if ($r[0]["network"] == NETWORK_OSTATUS) { if ($r[0]["network"] == NETWORK_OSTATUS) {
$result = new_contact($uid, $r[0]["url"], false); $result = new_contact($uid, $r[0]["url"], false, $r[0]["network"]);
if ($result['success']) if ($result['success'])
$r = q("UPDATE `contact` SET `subhub` = 1 WHERE `id` = %d", $r = q("UPDATE `contact` SET `subhub` = 1 WHERE `id` = %d",

View file

@ -66,7 +66,7 @@ function ostatus_subscribe_content(App $a) {
$data = probe_url($url); $data = probe_url($url);
if ($data["network"] == NETWORK_OSTATUS) { if ($data["network"] == NETWORK_OSTATUS) {
$result = new_contact($uid,$url,true); $result = new_contact($uid, $url, true, NETWORK_OSTATUS);
if ($result["success"]) { if ($result["success"]) {
$o .= " - ".t("success"); $o .= " - ".t("success");
} else { } else {