From fe52719d374fc0dc7155835c930de338095b258e Mon Sep 17 00:00:00 2001 From: very-ape Date: Thu, 20 May 2021 13:47:12 -0700 Subject: [PATCH 1/3] Fix Message button. --- src/Model/Profile.php | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/Model/Profile.php b/src/Model/Profile.php index 3e35d60c29..ff08977498 100644 --- a/src/Model/Profile.php +++ b/src/Model/Profile.php @@ -145,7 +145,7 @@ class Profile */ public static function load(App $a, $nickname, array $profiledata = [], $show_connect = true) { - $user = DBA::selectFirst('user', ['uid'], ['nickname' => $nickname, 'account_removed' => false]); + $user = DBA::selectFirst('user', [], ['nickname' => $nickname, 'account_removed' => false]); if (!DBA::isResult($user) && empty($profiledata)) { Logger::log('profile error: ' . DI::args()->getQueryString(), Logger::DEBUG); @@ -166,7 +166,16 @@ class Profile } } - $profile = !empty($user['uid']) ? User::getOwnerDataById($user['uid'], false) : []; + if (empty($user['uid'])) { + $profile = []; + } else { + $profile = array_merge( + $user, + Profile::getByUID($user['uid']), + Contact::getById(Contact::getIdForURL(Strings::normaliseLink(DI::baseurl() . '/profile/' . $nickname), local_user())) + ); + $profile['cid'] = $profile['id']; + } if (empty($profile) && empty($profiledata)) { Logger::log('profile error: ' . DI::args()->getQueryString(), Logger::DEBUG); @@ -334,7 +343,7 @@ class Profile if (Contact::canReceivePrivateMessages($profile)) { if ($visitor_is_followed || $visitor_is_following) { - $wallmessage_link = $visitor_base_path . '/message/new/' . base64_encode($profile['addr'] ?? ''); + $wallmessage_link = $visitor_base_path . '/message/new/' . $profile['cid']; } elseif ($visitor_is_authenticated && !empty($profile['unkmail'])) { $wallmessage_link = 'wallmessage/' . $profile['nickname']; } From 93926e99b89524a9f4ce7e52a7a583960e178505 Mon Sep 17 00:00:00 2001 From: very-ape Date: Fri, 21 May 2021 10:15:32 -0700 Subject: [PATCH 2/3] Use getByNickname as suggested in code review. --- src/Model/Profile.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Model/Profile.php b/src/Model/Profile.php index ff08977498..7454929943 100644 --- a/src/Model/Profile.php +++ b/src/Model/Profile.php @@ -145,7 +145,7 @@ class Profile */ public static function load(App $a, $nickname, array $profiledata = [], $show_connect = true) { - $user = DBA::selectFirst('user', [], ['nickname' => $nickname, 'account_removed' => false]); + $user = User::getByNickname($nickname); if (!DBA::isResult($user) && empty($profiledata)) { Logger::log('profile error: ' . DI::args()->getQueryString(), Logger::DEBUG); From 97a9ec4e401155f0041326bd471566e4fe12e5fb Mon Sep 17 00:00:00 2001 From: very-ape Date: Fri, 21 May 2021 11:38:50 -0700 Subject: [PATCH 3/3] Bug fix: last commit results in logged-in user's contacts being displayed on contact profile sidebar. --- src/Model/Profile.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Model/Profile.php b/src/Model/Profile.php index 7454929943..1476d67a51 100644 --- a/src/Model/Profile.php +++ b/src/Model/Profile.php @@ -169,12 +169,13 @@ class Profile if (empty($user['uid'])) { $profile = []; } else { + $contact_id = Contact::getIdForURL(Strings::normaliseLink(DI::baseurl() . '/profile/' . $nickname), local_user()); $profile = array_merge( $user, + Contact::getById($contact_id), Profile::getByUID($user['uid']), - Contact::getById(Contact::getIdForURL(Strings::normaliseLink(DI::baseurl() . '/profile/' . $nickname), local_user())) ); - $profile['cid'] = $profile['id']; + $profile['cid'] = $contact_id; } if (empty($profile) && empty($profiledata)) {