Some refinement to the contact update

This commit is contained in:
Michael Vogel 2015-04-12 10:32:02 +02:00
parent 1058d055d1
commit 64e343ed4b
2 changed files with 9 additions and 3 deletions

View file

@ -211,12 +211,16 @@ function _contact_update($contact_id) {
} }
function _contact_update_profile($contact_id) { function _contact_update_profile($contact_id) {
$r = q("SELECT `url` FROM `contact` WHERE `id` = %d", intval($contact_id)); $r = q("SELECT `url`, `network` FROM `contact` WHERE `id` = %d", intval($contact_id));
if (!$r) if (!$r)
return; return;
$data = probe_url($r[0]["url"]); $data = probe_url($r[0]["url"]);
// "Feed" is mostly a sign of communication problems
if (($data["network"] == NETWORK_FEED) AND ($data["network"] != $r[0]["network"]))
return;
$updatefields = array("name", "nick", "url", "addr", "batch", "notify", "poll", "request", "confirm", $updatefields = array("name", "nick", "url", "addr", "batch", "notify", "poll", "request", "confirm",
"poco", "network", "alias", "pubkey"); "poco", "network", "alias", "pubkey");
$update = array(); $update = array();
@ -225,6 +229,8 @@ function _contact_update_profile($contact_id) {
if (isset($data[$field]) AND ($data[$field] != "")) if (isset($data[$field]) AND ($data[$field] != ""))
$update[$field] = $data[$field]; $update[$field] = $data[$field];
$update["nurl"] = normalise_link($data["url"]);
$query = ""; $query = "";
if (isset($data["priority"]) AND ($data["priority"] != 0)) if (isset($data["priority"]) AND ($data["priority"] != 0))
@ -344,7 +350,7 @@ function contacts_content(&$a) {
if($cmd === 'updateprofile') { if($cmd === 'updateprofile') {
_contact_update_profile($contact_id); _contact_update_profile($contact_id);
goaway($a->get_baseurl(true) . '/contacts/' . $contact_id); goaway($a->get_baseurl(true) . '/crepair/' . $contact_id);
// NOTREACHED // NOTREACHED
} }

View file

@ -165,7 +165,7 @@ function crepair_content(&$a) {
$tpl = get_markup_template('crepair.tpl'); $tpl = get_markup_template('crepair.tpl');
$o .= replace_macros($tpl, array( $o .= replace_macros($tpl, array(
'$update_profile' => update_profile, '$update_profile' => update_profile,
'$udprofilenow' => t('Update profile now'), '$udprofilenow' => t('Refetch contact data'),
'$label_name' => t('Name'), '$label_name' => t('Name'),
'$label_nick' => t('Account Nickname'), '$label_nick' => t('Account Nickname'),
'$label_attag' => t('@Tagname - overrides Name/Nickname'), '$label_attag' => t('@Tagname - overrides Name/Nickname'),