From 6510df4b518d7ac891a15fd1a26edb65209a05e1 Mon Sep 17 00:00:00 2001 From: Michael Date: Thu, 7 Dec 2017 06:51:38 +0000 Subject: [PATCH] Update the public key for public contacts if the key was empty before --- src/Object/Contact.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/Object/Contact.php b/src/Object/Contact.php index 64e61b9ce2..f72ec025a4 100644 --- a/src/Object/Contact.php +++ b/src/Object/Contact.php @@ -694,7 +694,8 @@ class Contact extends BaseObject self::updateAvatar($data["photo"], $uid, $contact_id); - $contact = dba::select('contact', array('url', 'nurl', 'addr', 'alias', 'name', 'nick', 'keywords', 'location', 'about', 'avatar-date'), array('id' => $contact_id), array('limit' => 1)); + $fields = array('url', 'nurl', 'addr', 'alias', 'name', 'nick', 'keywords', 'location', 'about', 'avatar-date', 'pubkey'); + $contact = dba::select('contact', $fields, array('id' => $contact_id), array('limit' => 1)); // This condition should always be true if (!DBM::is_result($contact)) { @@ -708,6 +709,13 @@ class Contact extends BaseObject 'name' => $data['name'], 'nick' => $data['nick']); + // Only fill the pubkey if it was empty before. We have to prevent identity theft. + if (!empty($contact['pubkey'])) { + unset($contact['pubkey']); + } else { + $updated['pubkey'] = $data['pubkey']; + } + if ($data['keywords'] != '') { $updated['keywords'] = $data['keywords']; } -- 2.39.5