Fix the key fields in the self contacts

2022.09-rc
Michael 2020-09-26 20:59:28 +00:00
rodzic f1830b84cd
commit 9c675c3f01
2 zmienionych plików z 8 dodań i 6 usunięć

Wyświetl plik

@ -554,7 +554,7 @@ class Contact
return true; return true;
} }
$user = DBA::selectFirst('user', ['uid', 'username', 'nickname'], ['uid' => $uid]); $user = DBA::selectFirst('user', ['uid', 'username', 'nickname', 'pubkey', 'prvkey'], ['uid' => $uid]);
if (!DBA::isResult($user)) { if (!DBA::isResult($user)) {
return false; return false;
} }
@ -565,6 +565,8 @@ class Contact
'self' => 1, 'self' => 1,
'name' => $user['username'], 'name' => $user['username'],
'nick' => $user['nickname'], 'nick' => $user['nickname'],
'pubkey' => $user['pubkey'],
'prvkey' => $user['prvkey'],
'photo' => DI::baseUrl() . '/photo/profile/' . $user['uid'] . '.jpg', 'photo' => DI::baseUrl() . '/photo/profile/' . $user['uid'] . '.jpg',
'thumb' => DI::baseUrl() . '/photo/avatar/' . $user['uid'] . '.jpg', 'thumb' => DI::baseUrl() . '/photo/avatar/' . $user['uid'] . '.jpg',
'micro' => DI::baseUrl() . '/photo/micro/' . $user['uid'] . '.jpg', 'micro' => DI::baseUrl() . '/photo/micro/' . $user['uid'] . '.jpg',
@ -596,7 +598,7 @@ class Contact
*/ */
public static function updateSelfFromUserID($uid, $update_avatar = false) public static function updateSelfFromUserID($uid, $update_avatar = false)
{ {
$fields = ['id', 'name', 'nick', 'location', 'about', 'keywords', 'avatar', $fields = ['id', 'name', 'nick', 'location', 'about', 'keywords', 'avatar', 'prvkey', 'pubkey',
'xmpp', 'contact-type', 'forum', 'prv', 'avatar-date', 'url', 'nurl', 'unsearchable', 'xmpp', 'contact-type', 'forum', 'prv', 'avatar-date', 'url', 'nurl', 'unsearchable',
'photo', 'thumb', 'micro', 'addr', 'request', 'notify', 'poll', 'confirm', 'poco']; 'photo', 'thumb', 'micro', 'addr', 'request', 'notify', 'poll', 'confirm', 'poco'];
$self = DBA::selectFirst('contact', $fields, ['uid' => $uid, 'self' => true]); $self = DBA::selectFirst('contact', $fields, ['uid' => $uid, 'self' => true]);
@ -604,7 +606,7 @@ class Contact
return; return;
} }
$fields = ['nickname', 'page-flags', 'account-type']; $fields = ['nickname', 'page-flags', 'account-type', 'prvkey', 'pubkey'];
$user = DBA::selectFirst('user', $fields, ['uid' => $uid]); $user = DBA::selectFirst('user', $fields, ['uid' => $uid]);
if (!DBA::isResult($user)) { if (!DBA::isResult($user)) {
return; return;
@ -622,8 +624,8 @@ class Contact
$fields = ['name' => $profile['name'], 'nick' => $user['nickname'], $fields = ['name' => $profile['name'], 'nick' => $user['nickname'],
'avatar-date' => $self['avatar-date'], 'location' => Profile::formatLocation($profile), 'avatar-date' => $self['avatar-date'], 'location' => Profile::formatLocation($profile),
'about' => $profile['about'], 'keywords' => $profile['pub_keywords'], 'about' => $profile['about'], 'keywords' => $profile['pub_keywords'],
'contact-type' => $user['account-type'], 'contact-type' => $user['account-type'], 'prvkey' => $user['prvkey'],
'xmpp' => $profile['xmpp']]; 'pubkey' => $user['pubkey'], 'xmpp' => $profile['xmpp']];
$avatar = Photo::selectFirst(['resource-id', 'type'], ['uid' => $uid, 'profile' => true]); $avatar = Photo::selectFirst(['resource-id', 'type'], ['uid' => $uid, 'profile' => true]);
if (DBA::isResult($avatar)) { if (DBA::isResult($avatar)) {

Wyświetl plik

@ -366,7 +366,7 @@ class User
if (!$repair) { if (!$repair) {
// Check if "addr" is present and correct // Check if "addr" is present and correct
$addr = $owner['nickname'] . '@' . substr(DI::baseUrl(), strpos(DI::baseUrl(), '://') + 3); $addr = $owner['nickname'] . '@' . substr(DI::baseUrl(), strpos(DI::baseUrl(), '://') + 3);
$repair = ($addr != $owner['addr']); $repair = ($addr != $owner['addr']) || empty($owner['prvkey']) || empty($owner['pubkey']);
} }
if (!$repair) { if (!$repair) {