Fix avatar for messages and feeds
authorMichael <heluecht@pirati.ca>
Sat, 4 Jun 2022 07:57:11 +0000 (07:57 +0000)
committerMichael <heluecht@pirati.ca>
Sat, 4 Jun 2022 07:57:11 +0000 (07:57 +0000)
mod/message.php
src/Content/Widget/VCard.php

index a007de8d84f5037201b9a8a4bc1b6eb0948d2dbc..a07c8b44931284ca72757ebef8df8e0ccc2b3a70 100644 (file)
@@ -308,7 +308,7 @@ function message_content(App $a)
                        $body_e = BBCode::convertForUriId($message['uri-id'], $message['body']);
                        $to_name_e = $message['name'];
 
-                       $contact = Contact::getByURL($message['from-url'], false, ['thumb', 'addr', 'id', 'avatar']);
+                       $contact = Contact::getByURL($message['from-url'], false, ['thumb', 'addr', 'id', 'avatar', 'url']);
                        $from_photo = Contact::getThumb($contact);
 
                        $mails[] = [
@@ -440,7 +440,7 @@ function render_messages(array $msg, $t)
                        continue;
                }
 
-               $contact = Contact::getByURL($rr['url'], false, ['thumb', 'addr', 'id', 'avatar']);
+               $contact = Contact::getByURL($rr['url'], false, ['thumb', 'addr', 'id', 'avatar', 'url']);
                $from_photo = Contact::getThumb($contact);
 
                $rslt .= Renderer::replaceMacros($tpl, [
index 7f75c6c9c0e588a9c567d30cdc1a0530007a8c8a..96f35e6584503f2aec7cd7a2fe9dbba6ab0ce03a 100644 (file)
@@ -62,17 +62,23 @@ class VCard
                $unfollow_link    = '';
                $wallmessage_link = '';
 
+               $photo   = Contact::getPhoto($contact);
+
                if (local_user()) {
                        if ($contact['uid']) {
                                $id      = $contact['id'];
                                $rel     = $contact['rel'];
                                $pending = $contact['pending'];
                        } else {
-                               $pcontact = Contact::selectFirst(['id', 'rel', 'pending'], ['uid' => local_user(), 'uri-id' => $contact['uri-id']]);
+                               $pcontact = Contact::selectFirst([], ['uid' => local_user(), 'uri-id' => $contact['uri-id']]);
 
                                $id      = $pcontact['id'] ?? 0;
                                $rel     = $pcontact['rel'] ?? Contact::NOTHING;
                                $pending = $pcontact['pending'] ?? false;
+
+                               if (!empty($pcontact) && in_array($pcontact['network'], [Protocol::MAIL, Protocol::FEED])) {
+                                       $photo = Contact::getPhoto($pcontact);
+                               }
                        }
 
                        if (empty($contact['self']) && Protocol::supportsFollow($contact['network'])) {
@@ -90,7 +96,7 @@ class VCard
 
                return Renderer::replaceMacros(Renderer::getMarkupTemplate('widget/vcard.tpl'), [
                        '$contact'          => $contact,
-                       '$photo'            => Contact::getPhoto($contact),
+                       '$photo'            => $photo,
                        '$url'              => Contact::magicLinkByContact($contact, $contact['url']),
                        '$about'            => BBCode::convertForUriId($contact['uri-id'] ?? 0, $contact['about'] ?? ''),
                        '$xmpp'             => DI::l10n()->t('XMPP:'),