From fe137a92ef20109708e7af1359b694c8d76576f6 Mon Sep 17 00:00:00 2001 From: Michael Vogel Date: Sat, 11 Jul 2015 14:36:04 +0200 Subject: [PATCH 1/7] Automatically update contact data. --- include/follow.php | 32 +++++++++++++++++++++++++++++--- include/items.php | 8 ++++---- include/onepoll.php | 21 ++++++++++++++------- mod/receive.php | 2 +- 4 files changed, 48 insertions(+), 15 deletions(-) diff --git a/include/follow.php b/include/follow.php index 287a38b6bf..b2b6c75027 100644 --- a/include/follow.php +++ b/include/follow.php @@ -1,5 +1,30 @@ Date: Sun, 12 Jul 2015 11:19:40 +0200 Subject: [PATCH 2/7] Some precaution to avoid overwriting of existing data with blanks --- include/follow.php | 12 +++++++++++- include/items.php | 2 +- object/Item.php | 3 +++ 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/include/follow.php b/include/follow.php index b2b6c75027..62180e4c61 100644 --- a/include/follow.php +++ b/include/follow.php @@ -1,7 +1,12 @@ $val) + if (isset($r[0][$key]) AND ($r[0][$key] != "") AND ($val == "")) + $ret[$key] = $r[0][$key]; + q("UPDATE `contact` SET `url` = '%s', `nurl` = '%s', `addr` = '%s', `alias` = '%s', `batch` = '%s', `notify` = '%s', `poll` = '%s', `poco` = '%s', `name` = '%s', `nick` = '%s' WHERE `id` = %d", dbesc($ret['url']), dbesc(normalise_link($ret['url'])), diff --git a/include/items.php b/include/items.php index c61ad1b1e2..8fd1cbcb48 100644 --- a/include/items.php +++ b/include/items.php @@ -2076,7 +2076,7 @@ function dfrn_deliver($owner,$contact,$atom, $dissolve = false) { $final_dfrn_id = substr($final_dfrn_id,2); if($final_dfrn_id != $orig_id) { - logger('dfrn_deliver: wrong dfrn_id. Original: '.$orig_id.' Target: '.$final_dfrn_id.' Test: '.$test); + logger('dfrn_deliver: wrong dfrn_id.'); // did not decode properly - cannot trust this site return 3; } diff --git a/object/Item.php b/object/Item.php index 3211048cef..fcc5ea3dca 100644 --- a/object/Item.php +++ b/object/Item.php @@ -308,6 +308,9 @@ class Item extends BaseObject { if (($item["item_network"] == NETWORK_FACEBOOK) AND ($indent == 'comment') AND isset($buttons["like"])) unset($buttons["like"]); + // Likes don't federate at OStatus + if (($item["item_network"] == NETWORK_OSTATUS) AND isset($buttons["like"])) + unset($buttons["like"]); $tmp_item = array( 'template' => $this->get_template(), From cf663df69f7f266ebc58e500ec7c663400c8b716 Mon Sep 17 00:00:00 2001 From: Michael Vogel Date: Sun, 12 Jul 2015 11:22:36 +0200 Subject: [PATCH 3/7] Testing code removed --- include/items.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/include/items.php b/include/items.php index 8fd1cbcb48..45d25e379f 100644 --- a/include/items.php +++ b/include/items.php @@ -2064,11 +2064,11 @@ function dfrn_deliver($owner,$contact,$atom, $dissolve = false) { || ($contact['rel'] == CONTACT_IS_SHARING && strlen($contact['pubkey']))) { openssl_public_decrypt($sent_dfrn_id,$final_dfrn_id,$contact['pubkey']); openssl_public_decrypt($challenge,$postvars['challenge'],$contact['pubkey']); - } elseif($contact['prvkey']) { + } + else { openssl_private_decrypt($sent_dfrn_id,$final_dfrn_id,$contact['prvkey']); openssl_private_decrypt($challenge,$postvars['challenge'],$contact['prvkey']); - } else - logger("No private or public key for contact ".$contact['id']." ".$contact['url']); + } $final_dfrn_id = substr($final_dfrn_id, 0, strpos($final_dfrn_id, '.')); From 9106baf10f5d261b866028826c427636302c0e37 Mon Sep 17 00:00:00 2001 From: Michael Vogel Date: Sun, 12 Jul 2015 11:24:01 +0200 Subject: [PATCH 4/7] Some more test code removed --- include/onepoll.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/include/onepoll.php b/include/onepoll.php index 57b3521d53..eb52a97ead 100644 --- a/include/onepoll.php +++ b/include/onepoll.php @@ -237,11 +237,11 @@ function onepoll_run(&$argv, &$argc){ if(($contact['duplex']) && strlen($contact['prvkey'])) { openssl_private_decrypt($sent_dfrn_id,$final_dfrn_id,$contact['prvkey']); openssl_private_decrypt($challenge,$postvars['challenge'],$contact['prvkey']); - } elseif($contact['pubkey']) { + } + else { openssl_public_decrypt($sent_dfrn_id,$final_dfrn_id,$contact['pubkey']); openssl_public_decrypt($challenge,$postvars['challenge'],$contact['pubkey']); - } else - logger("No private or public key for contact ".$contact['id']." ".$contact['url']); + } $final_dfrn_id = substr($final_dfrn_id, 0, strpos($final_dfrn_id, '.')); From f48f7394e9a56f2f54159d4269c9c1b4bffa06c9 Mon Sep 17 00:00:00 2001 From: Michael Vogel Date: Sun, 12 Jul 2015 11:46:08 +0200 Subject: [PATCH 5/7] Only update communication relevant data. And only update if needed. --- include/follow.php | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/include/follow.php b/include/follow.php index 62180e4c61..79666f30dc 100644 --- a/include/follow.php +++ b/include/follow.php @@ -6,7 +6,7 @@ function update_contact($id) { This will reliably kill your communication with Friendica contacts. */ - $r = q("SELECT `url`, `nurl`, `addr`, `alias`, `batch`, `notify`, `poll`, `poco`, `name`, `nick`, `network` FROM `contact` WHERE `id` = %d", intval($id)); + $r = q("SELECT `url`, `nurl`, `addr`, `alias`, `batch`, `notify`, `poll`, `poco`, `network` FROM `contact` WHERE `id` = %d", intval($id)); if (!$r) return; @@ -16,12 +16,21 @@ function update_contact($id) { if ($ret["network"] != $r[0]["network"]) return; + $update = false; + // make sure to not overwrite existing values with blank entries - foreach ($ret AS $key => $val) + foreach ($ret AS $key => $val) { if (isset($r[0][$key]) AND ($r[0][$key] != "") AND ($val == "")) $ret[$key] = $r[0][$key]; - q("UPDATE `contact` SET `url` = '%s', `nurl` = '%s', `addr` = '%s', `alias` = '%s', `batch` = '%s', `notify` = '%s', `poll` = '%s', `poco` = '%s', `name` = '%s', `nick` = '%s' WHERE `id` = %d", + if (isset($r[0][$key]) AND ($ret[$key] != $r[0][$key])) + $update = true; + } + + if (!$update) + return; + + q("UPDATE `contact` SET `url` = '%s', `nurl` = '%s', `addr` = '%s', `alias` = '%s', `batch` = '%s', `notify` = '%s', `poll` = '%s', `poco` = '%s' WHERE `id` = %d", dbesc($ret['url']), dbesc(normalise_link($ret['url'])), dbesc($ret['addr']), @@ -30,8 +39,6 @@ function update_contact($id) { dbesc($ret['notify']), dbesc($ret['poll']), dbesc($ret['poco']), - dbesc($ret['name']), - dbesc($ret['nick']), intval($id) ); } From 65468bf202ef3188a86fb18cd4ec1d553f78b16d Mon Sep 17 00:00:00 2001 From: Michael Vogel Date: Sun, 12 Jul 2015 12:03:39 +0200 Subject: [PATCH 6/7] Moved the needed include to a better place. --- include/follow.php | 1 + include/onepoll.php | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/include/follow.php b/include/follow.php index 79666f30dc..6c998e1781 100644 --- a/include/follow.php +++ b/include/follow.php @@ -1,4 +1,5 @@ Date: Sun, 12 Jul 2015 14:57:09 +0200 Subject: [PATCH 7/7] Likes do federate ... --- object/Item.php | 4 ---- 1 file changed, 4 deletions(-) diff --git a/object/Item.php b/object/Item.php index fcc5ea3dca..8e38080e43 100644 --- a/object/Item.php +++ b/object/Item.php @@ -308,10 +308,6 @@ class Item extends BaseObject { if (($item["item_network"] == NETWORK_FACEBOOK) AND ($indent == 'comment') AND isset($buttons["like"])) unset($buttons["like"]); - // Likes don't federate at OStatus - if (($item["item_network"] == NETWORK_OSTATUS) AND isset($buttons["like"])) - unset($buttons["like"]); - $tmp_item = array( 'template' => $this->get_template(),