Fetch avatar by id

This commit is contained in:
Michael 2022-04-29 07:30:13 +00:00
parent 1326239576
commit d44641e58c
7 changed files with 45 additions and 9 deletions

View file

@ -1,6 +1,6 @@
-- ------------------------------------------ -- ------------------------------------------
-- Friendica 2022.05-dev (Siberian Iris) -- Friendica 2022.05-dev (Siberian Iris)
-- DB_UPDATE_VERSION 1460 -- DB_UPDATE_VERSION 1461
-- ------------------------------------------ -- ------------------------------------------
@ -1719,6 +1719,7 @@ CREATE VIEW `post-user-view` AS SELECT
`author`.`network` AS `author-network`, `author`.`network` AS `author-network`,
`author`.`blocked` AS `author-blocked`, `author`.`blocked` AS `author-blocked`,
`author`.`hidden` AS `author-hidden`, `author`.`hidden` AS `author-hidden`,
`author`.`updated` AS `author-updated`,
`post-user`.`owner-id` AS `owner-id`, `post-user`.`owner-id` AS `owner-id`,
`owner`.`url` AS `owner-link`, `owner`.`url` AS `owner-link`,
`owner`.`addr` AS `owner-addr`, `owner`.`addr` AS `owner-addr`,
@ -1728,6 +1729,7 @@ CREATE VIEW `post-user-view` AS SELECT
`owner`.`network` AS `owner-network`, `owner`.`network` AS `owner-network`,
`owner`.`blocked` AS `owner-blocked`, `owner`.`blocked` AS `owner-blocked`,
`owner`.`hidden` AS `owner-hidden`, `owner`.`hidden` AS `owner-hidden`,
`owner`.`updated` AS `owner-updated`,
`owner`.`contact-type` AS `owner-contact-type`, `owner`.`contact-type` AS `owner-contact-type`,
`post-user`.`causer-id` AS `causer-id`, `post-user`.`causer-id` AS `causer-id`,
`causer`.`url` AS `causer-link`, `causer`.`url` AS `causer-link`,
@ -1884,6 +1886,7 @@ CREATE VIEW `post-thread-user-view` AS SELECT
`author`.`network` AS `author-network`, `author`.`network` AS `author-network`,
`author`.`blocked` AS `author-blocked`, `author`.`blocked` AS `author-blocked`,
`author`.`hidden` AS `author-hidden`, `author`.`hidden` AS `author-hidden`,
`author`.`updated` AS `author-updated`,
`post-thread-user`.`owner-id` AS `owner-id`, `post-thread-user`.`owner-id` AS `owner-id`,
`owner`.`url` AS `owner-link`, `owner`.`url` AS `owner-link`,
`owner`.`addr` AS `owner-addr`, `owner`.`addr` AS `owner-addr`,
@ -1893,6 +1896,7 @@ CREATE VIEW `post-thread-user-view` AS SELECT
`owner`.`network` AS `owner-network`, `owner`.`network` AS `owner-network`,
`owner`.`blocked` AS `owner-blocked`, `owner`.`blocked` AS `owner-blocked`,
`owner`.`hidden` AS `owner-hidden`, `owner`.`hidden` AS `owner-hidden`,
`owner`.`updated` AS `owner-updated`,
`owner`.`contact-type` AS `owner-contact-type`, `owner`.`contact-type` AS `owner-contact-type`,
`post-thread-user`.`causer-id` AS `causer-id`, `post-thread-user`.`causer-id` AS `causer-id`,
`causer`.`url` AS `causer-link`, `causer`.`url` AS `causer-link`,
@ -2035,6 +2039,7 @@ CREATE VIEW `post-view` AS SELECT
`author`.`network` AS `author-network`, `author`.`network` AS `author-network`,
`author`.`blocked` AS `author-blocked`, `author`.`blocked` AS `author-blocked`,
`author`.`hidden` AS `author-hidden`, `author`.`hidden` AS `author-hidden`,
`author`.`updated` AS `author-updated`,
`post`.`owner-id` AS `owner-id`, `post`.`owner-id` AS `owner-id`,
`owner`.`url` AS `owner-link`, `owner`.`url` AS `owner-link`,
`owner`.`addr` AS `owner-addr`, `owner`.`addr` AS `owner-addr`,
@ -2044,6 +2049,7 @@ CREATE VIEW `post-view` AS SELECT
`owner`.`network` AS `owner-network`, `owner`.`network` AS `owner-network`,
`owner`.`blocked` AS `owner-blocked`, `owner`.`blocked` AS `owner-blocked`,
`owner`.`hidden` AS `owner-hidden`, `owner`.`hidden` AS `owner-hidden`,
`owner`.`updated` AS `owner-updated`,
`owner`.`contact-type` AS `owner-contact-type`, `owner`.`contact-type` AS `owner-contact-type`,
`post`.`causer-id` AS `causer-id`, `post`.`causer-id` AS `causer-id`,
`causer`.`url` AS `causer-link`, `causer`.`url` AS `causer-link`,
@ -2162,6 +2168,7 @@ CREATE VIEW `post-thread-view` AS SELECT
`author`.`network` AS `author-network`, `author`.`network` AS `author-network`,
`author`.`blocked` AS `author-blocked`, `author`.`blocked` AS `author-blocked`,
`author`.`hidden` AS `author-hidden`, `author`.`hidden` AS `author-hidden`,
`author`.`updated` AS `author-updated`,
`post-thread`.`owner-id` AS `owner-id`, `post-thread`.`owner-id` AS `owner-id`,
`owner`.`url` AS `owner-link`, `owner`.`url` AS `owner-link`,
`owner`.`addr` AS `owner-addr`, `owner`.`addr` AS `owner-addr`,
@ -2171,6 +2178,7 @@ CREATE VIEW `post-thread-view` AS SELECT
`owner`.`network` AS `owner-network`, `owner`.`network` AS `owner-network`,
`owner`.`blocked` AS `owner-blocked`, `owner`.`blocked` AS `owner-blocked`,
`owner`.`hidden` AS `owner-hidden`, `owner`.`hidden` AS `owner-hidden`,
`owner`.`updated` AS `owner-updated`,
`owner`.`contact-type` AS `owner-contact-type`, `owner`.`contact-type` AS `owner-contact-type`,
`post-thread`.`causer-id` AS `causer-id`, `post-thread`.`causer-id` AS `causer-id`,
`causer`.`url` AS `causer-link`, `causer`.`url` AS `causer-link`,

View file

@ -659,6 +659,16 @@ class Conversation
$pinned = ''; $pinned = '';
} }
if (in_array($item['network'], [Protocol::FEED, Protocol::MAIL])) {
$owner_avatar = $author_avatar = $item['contact-id'];
$owner_updated = $author_updated = '';
} else {
$owner_avatar = $item['owner-id'];
$owner_updated = $item['owner-updated'];
$author_avatar = $item['author-id'];
$author_updated = $item['author-updated'];
}
$tmp_item = [ $tmp_item = [
'template' => $tpl, 'template' => $tpl,
'id' => ($preview ? 'P0' : $item['id']), 'id' => ($preview ? 'P0' : $item['id']),
@ -676,7 +686,7 @@ class Conversation
'name' => $profile_name, 'name' => $profile_name,
'sparkle' => $sparkle, 'sparkle' => $sparkle,
'lock' => false, 'lock' => false,
'thumb' => $this->baseURL->remove(Contact::getAvatarUrlForUrl($item['author-link'], $item['uid'], Proxy::SIZE_THUMB)), 'thumb' => $this->baseURL->remove(Contact::getAvatarUrlForId($author_avatar, Proxy::SIZE_THUMB, $author_updated)),
'title' => $title, 'title' => $title,
'body_html' => $body_html, 'body_html' => $body_html,
'tags' => $tags['tags'], 'tags' => $tags['tags'],
@ -697,7 +707,7 @@ class Conversation
'indent' => '', 'indent' => '',
'owner_name' => '', 'owner_name' => '',
'owner_url' => '', 'owner_url' => '',
'owner_photo' => $this->baseURL->remove(Contact::getAvatarUrlForUrl($item['owner-link'], $item['uid'], Proxy::SIZE_THUMB)), 'owner_photo' => $this->baseURL->remove(Contact::getAvatarUrlForId($owner_avatar, Proxy::SIZE_THUMB, $owner_updated)),
'plink' => ItemModel::getPlink($item), 'plink' => ItemModel::getPlink($item),
'edpost' => false, 'edpost' => false,
'pinned' => $pinned, 'pinned' => $pinned,

View file

@ -1799,7 +1799,7 @@ class Contact
{ {
// We have to fetch the "updated" variable when it wasn't provided // We have to fetch the "updated" variable when it wasn't provided
// The parameter can be provided to improve performance // The parameter can be provided to improve performance
if (empty($updated) || empty($guid)) { if (empty($updated)) {
$account = DBA::selectFirst('account-user-view', ['updated', 'guid'], ['id' => $cid]); $account = DBA::selectFirst('account-user-view', ['updated', 'guid'], ['id' => $cid]);
$updated = $account['updated'] ?? ''; $updated = $account['updated'] ?? '';
$guid = $account['guid'] ?? ''; $guid = $account['guid'] ?? '';

View file

@ -87,8 +87,8 @@ class Item
'wall', 'private', 'starred', 'origin', 'parent-origin', 'title', 'body', 'language', 'wall', 'private', 'starred', 'origin', 'parent-origin', 'title', 'body', 'language',
'content-warning', 'location', 'coord', 'app', 'rendered-hash', 'rendered-html', 'object', 'content-warning', 'location', 'coord', 'app', 'rendered-hash', 'rendered-html', 'object',
'allow_cid', 'allow_gid', 'deny_cid', 'deny_gid', 'mention', 'global', 'allow_cid', 'allow_gid', 'deny_cid', 'deny_gid', 'mention', 'global',
'author-id', 'author-link', 'author-name', 'author-avatar', 'author-network', 'author-id', 'author-link', 'author-name', 'author-avatar', 'author-network', 'author-updated',
'owner-id', 'owner-link', 'owner-name', 'owner-avatar', 'owner-network', 'owner-contact-type', 'owner-id', 'owner-link', 'owner-name', 'owner-avatar', 'owner-network', 'owner-contact-type', 'owner-updated',
'causer-id', 'causer-link', 'causer-name', 'causer-avatar', 'causer-contact-type', 'causer-network', 'causer-id', 'causer-link', 'causer-name', 'causer-avatar', 'causer-contact-type', 'causer-network',
'contact-id', 'contact-uid', 'contact-link', 'contact-name', 'contact-avatar', 'contact-id', 'contact-uid', 'contact-link', 'contact-name', 'contact-avatar',
'writable', 'self', 'cid', 'alias', 'writable', 'self', 'cid', 'alias',

View file

@ -450,6 +450,16 @@ class Post
$browsershare = null; $browsershare = null;
} }
if (in_array($item['network'], [Protocol::FEED, Protocol::MAIL])) {
$owner_avatar = $author_avatar = $item['contact-id'];
$owner_updated = $author_updated = '';
} else {
$owner_avatar = $item['owner-id'];
$owner_updated = $item['owner-updated'];
$author_avatar = $item['author-id'];
$author_updated = $item['author-updated'];
}
$tmp_item = [ $tmp_item = [
'template' => $this->getTemplate(), 'template' => $this->getTemplate(),
'type' => implode("", array_slice(explode("/", $item['verb']), -1)), 'type' => implode("", array_slice(explode("/", $item['verb']), -1)),
@ -481,7 +491,7 @@ class Post
'profile_url' => $profile_link, 'profile_url' => $profile_link,
'name' => $profile_name, 'name' => $profile_name,
'item_photo_menu_html' => DI::contentItem()->photoMenu($item, $formSecurityToken), 'item_photo_menu_html' => DI::contentItem()->photoMenu($item, $formSecurityToken),
'thumb' => DI::baseUrl()->remove(Contact::getAvatarUrlForUrl($item['author-link'], $item['uid'], Proxy::SIZE_THUMB)), 'thumb' => DI::baseUrl()->remove(Contact::getAvatarUrlForId($author_avatar, Proxy::SIZE_THUMB, $author_updated)),
'osparkle' => $osparkle, 'osparkle' => $osparkle,
'sparkle' => $sparkle, 'sparkle' => $sparkle,
'title' => $title, 'title' => $title,
@ -498,7 +508,7 @@ class Post
'shiny' => $shiny, 'shiny' => $shiny,
'owner_self' => $item['author-link'] == Session::get('my_url'), 'owner_self' => $item['author-link'] == Session::get('my_url'),
'owner_url' => $this->getOwnerUrl(), 'owner_url' => $this->getOwnerUrl(),
'owner_photo' => DI::baseUrl()->remove(Contact::getAvatarUrlForUrl($item['owner-link'], $item['uid'], Proxy::SIZE_THUMB)), 'owner_photo' => DI::baseUrl()->remove(Contact::getAvatarUrlForId($owner_avatar, Proxy::SIZE_THUMB, $owner_updated)),
'owner_name' => $this->getOwnerName(), 'owner_name' => $this->getOwnerName(),
'plink' => Item::getPlink($item), 'plink' => Item::getPlink($item),
'browsershare' => $browsershare, 'browsershare' => $browsershare,

View file

@ -55,7 +55,7 @@
use Friendica\Database\DBA; use Friendica\Database\DBA;
if (!defined('DB_UPDATE_VERSION')) { if (!defined('DB_UPDATE_VERSION')) {
define('DB_UPDATE_VERSION', 1460); define('DB_UPDATE_VERSION', 1461);
} }
return [ return [

View file

@ -146,6 +146,7 @@
"author-network" => ["author", "network"], "author-network" => ["author", "network"],
"author-blocked" => ["author", "blocked"], "author-blocked" => ["author", "blocked"],
"author-hidden" => ["author", "hidden"], "author-hidden" => ["author", "hidden"],
"author-updated" => ["author", "updated"],
"owner-id" => ["post-user", "owner-id"], "owner-id" => ["post-user", "owner-id"],
"owner-link" => ["owner", "url"], "owner-link" => ["owner", "url"],
"owner-addr" => ["owner", "addr"], "owner-addr" => ["owner", "addr"],
@ -155,6 +156,7 @@
"owner-network" => ["owner", "network"], "owner-network" => ["owner", "network"],
"owner-blocked" => ["owner", "blocked"], "owner-blocked" => ["owner", "blocked"],
"owner-hidden" => ["owner", "hidden"], "owner-hidden" => ["owner", "hidden"],
"owner-updated" => ["owner", "updated"],
"owner-contact-type" => ["owner", "contact-type"], "owner-contact-type" => ["owner", "contact-type"],
"causer-id" => ["post-user", "causer-id"], "causer-id" => ["post-user", "causer-id"],
"causer-link" => ["causer", "url"], "causer-link" => ["causer", "url"],
@ -309,6 +311,7 @@
"author-network" => ["author", "network"], "author-network" => ["author", "network"],
"author-blocked" => ["author", "blocked"], "author-blocked" => ["author", "blocked"],
"author-hidden" => ["author", "hidden"], "author-hidden" => ["author", "hidden"],
"author-updated" => ["author", "updated"],
"owner-id" => ["post-thread-user", "owner-id"], "owner-id" => ["post-thread-user", "owner-id"],
"owner-link" => ["owner", "url"], "owner-link" => ["owner", "url"],
"owner-addr" => ["owner", "addr"], "owner-addr" => ["owner", "addr"],
@ -318,6 +321,7 @@
"owner-network" => ["owner", "network"], "owner-network" => ["owner", "network"],
"owner-blocked" => ["owner", "blocked"], "owner-blocked" => ["owner", "blocked"],
"owner-hidden" => ["owner", "hidden"], "owner-hidden" => ["owner", "hidden"],
"owner-updated" => ["owner", "updated"],
"owner-contact-type" => ["owner", "contact-type"], "owner-contact-type" => ["owner", "contact-type"],
"causer-id" => ["post-thread-user", "causer-id"], "causer-id" => ["post-thread-user", "causer-id"],
"causer-link" => ["causer", "url"], "causer-link" => ["causer", "url"],
@ -458,6 +462,7 @@
"author-network" => ["author", "network"], "author-network" => ["author", "network"],
"author-blocked" => ["author", "blocked"], "author-blocked" => ["author", "blocked"],
"author-hidden" => ["author", "hidden"], "author-hidden" => ["author", "hidden"],
"author-updated" => ["author", "updated"],
"owner-id" => ["post", "owner-id"], "owner-id" => ["post", "owner-id"],
"owner-link" => ["owner", "url"], "owner-link" => ["owner", "url"],
"owner-addr" => ["owner", "addr"], "owner-addr" => ["owner", "addr"],
@ -467,6 +472,7 @@
"owner-network" => ["owner", "network"], "owner-network" => ["owner", "network"],
"owner-blocked" => ["owner", "blocked"], "owner-blocked" => ["owner", "blocked"],
"owner-hidden" => ["owner", "hidden"], "owner-hidden" => ["owner", "hidden"],
"owner-updated" => ["owner", "updated"],
"owner-contact-type" => ["owner", "contact-type"], "owner-contact-type" => ["owner", "contact-type"],
"causer-id" => ["post", "causer-id"], "causer-id" => ["post", "causer-id"],
"causer-link" => ["causer", "url"], "causer-link" => ["causer", "url"],
@ -583,6 +589,7 @@
"author-network" => ["author", "network"], "author-network" => ["author", "network"],
"author-blocked" => ["author", "blocked"], "author-blocked" => ["author", "blocked"],
"author-hidden" => ["author", "hidden"], "author-hidden" => ["author", "hidden"],
"author-updated" => ["author", "updated"],
"owner-id" => ["post-thread", "owner-id"], "owner-id" => ["post-thread", "owner-id"],
"owner-link" => ["owner", "url"], "owner-link" => ["owner", "url"],
"owner-addr" => ["owner", "addr"], "owner-addr" => ["owner", "addr"],
@ -592,6 +599,7 @@
"owner-network" => ["owner", "network"], "owner-network" => ["owner", "network"],
"owner-blocked" => ["owner", "blocked"], "owner-blocked" => ["owner", "blocked"],
"owner-hidden" => ["owner", "hidden"], "owner-hidden" => ["owner", "hidden"],
"owner-updated" => ["owner", "updated"],
"owner-contact-type" => ["owner", "contact-type"], "owner-contact-type" => ["owner", "contact-type"],
"causer-id" => ["post-thread", "causer-id"], "causer-id" => ["post-thread", "causer-id"],
"causer-link" => ["causer", "url"], "causer-link" => ["causer", "url"],