Some more avatar function replacements

This commit is contained in:
Michael 2020-07-28 19:30:55 +00:00
parent 701dbdf7fc
commit 71b6226909
15 changed files with 47 additions and 63 deletions

View file

@ -40,7 +40,6 @@ use Friendica\Object\Thread;
use Friendica\Protocol\Activity;
use Friendica\Util\Crypto;
use Friendica\Util\DateTimeFormat;
use Friendica\Util\Proxy as ProxyUtils;
use Friendica\Util\Strings;
use Friendica\Util\Temporal;
use Friendica\Util\XML;
@ -593,7 +592,7 @@ function conversation(App $a, array $items, $mode, $update, $preview = false, $o
'name' => $profile_name,
'sparkle' => $sparkle,
'lock' => $lock,
'thumb' => DI::baseUrl()->remove(ProxyUtils::proxifyUrl($item['author-avatar'], false, ProxyUtils::SIZE_THUMB)),
'thumb' => DI::baseUrl()->remove($item['author-avatar']),
'title' => $title,
'body' => $body,
'tags' => $tags['tags'],
@ -613,7 +612,7 @@ function conversation(App $a, array $items, $mode, $update, $preview = false, $o
'indent' => '',
'owner_name' => $owner_name,
'owner_url' => $owner_url,
'owner_photo' => DI::baseUrl()->remove(ProxyUtils::proxifyUrl($item['owner-avatar'], false, ProxyUtils::SIZE_THUMB)),
'owner_photo' => DI::baseUrl()->remove($item['owner-avatar']),
'plink' => Item::getPlink($item),
'edpost' => false,
'isstarred' => $isstarred,

View file

@ -32,7 +32,6 @@ use Friendica\Model\Mail;
use Friendica\Model\Notify\Type;
use Friendica\Module\Security\Login;
use Friendica\Util\DateTimeFormat;
use Friendica\Util\Proxy as ProxyUtils;
use Friendica\Util\Strings;
use Friendica\Util\Temporal;
@ -393,12 +392,8 @@ function message_content(App $a)
$body_e = BBCode::convert($message['body']);
$to_name_e = $message['name'];
$contact = Contact::getByURL($message['from-url'], false, ['thumb', 'addr']);
if (isset($contact["thumb"])) {
$from_photo = $contact["thumb"];
} else {
$from_photo = $message['from-photo'];
}
$contact = Contact::getByURL($message['from-url'], false, ['thumb', 'addr', 'id', 'avatar']);
$from_photo = Contact::getThumb($contact, $message['from-photo']);
$mails[] = [
'id' => $message['id'],
@ -406,7 +401,7 @@ function message_content(App $a)
'from_url' => $from_url,
'from_addr' => $contact['addr'],
'sparkle' => $sparkle,
'from_photo' => ProxyUtils::proxifyUrl($from_photo, false, ProxyUtils::SIZE_THUMB),
'from_photo' => $from_photo,
'subject' => $subject_e,
'body' => $body_e,
'delete' => DI::l10n()->t('Delete message'),
@ -525,12 +520,8 @@ function render_messages(array $msg, $t)
$body_e = $rr['body'];
$to_name_e = $rr['name'];
$contact = Contact::getByURL($rr['url'], false, ['thumb', 'addr']);
if (isset($contact["thumb"])) {
$from_photo = $contact["thumb"];
} else {
$from_photo = (($rr['thumb']) ? $rr['thumb'] : $rr['from-photo']);
}
$contact = Contact::getByURL($rr['url'], false, ['thumb', 'addr', 'id', 'avatar']);
$from_photo = Contact::getThumb($contact, $rr['thumb'] ?: $rr['from-photo']);
$rslt .= Renderer::replaceMacros($tpl, [
'$id' => $rr['id'],
@ -538,7 +529,7 @@ function render_messages(array $msg, $t)
'$from_url' => Contact::magicLink($rr['url']),
'$from_addr' => $contact['addr'] ?? '',
'$sparkle' => ' sparkle',
'$from_photo' => ProxyUtils::proxifyUrl($from_photo, false, ProxyUtils::SIZE_THUMB),
'$from_photo' => $from_photo,
'$subject' => $rr['title'],
'$delete' => DI::l10n()->t('Delete conversation'),
'$body' => $body_e,

View file

@ -572,7 +572,7 @@ function networkThreadedView(App $a, $update, $parent)
'$title' => DI::l10n()->t('Group: %s', $group['name'])
]) . $o;
} elseif ($cid) {
$fields = ['id', 'name', 'network', 'writable', 'nurl',
$fields = ['id', 'name', 'network', 'writable', 'nurl', 'avatar',
'forum', 'prv', 'contact-type', 'addr', 'thumb', 'location'];
$condition = ["`id` = ? AND (NOT `blocked` OR `pending`)", $cid];
$contact = DBA::selectFirst('contact', $fields, $condition);

View file

@ -327,7 +327,7 @@ function ping_init(App $a)
if (DBA::isResult($notifs)) {
foreach ($notifs as $notif) {
$contact = Contact::getByURL($notif['url'], false, ['micro']);
$contact = Contact::getByURL($notif['url'], false, ['micro', 'id', 'avatar']);
$notif['photo'] = Contact::getMicro($contact, $notif['photo']);
$local_time = DateTimeFormat::local($notif['date']);

View file

@ -27,7 +27,6 @@ use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Model\Contact;
use Friendica\Model\GContact;
use Friendica\Util\Proxy as ProxyUtils;
function suggest_init(App $a)
{
@ -111,7 +110,7 @@ function suggest_content(App $a)
'itemurl' => (($contact_details['addr'] != "") ? $contact_details['addr'] : $rr['url']),
'img_hover' => $rr['url'],
'name' => $contact_details['name'],
'thumb' => ProxyUtils::proxifyUrl($contact_details['thumb'], false, ProxyUtils::SIZE_THUMB),
'thumb' => Contact::getThumb($contact_details),
'details' => $contact_details['location'],
'tags' => $contact_details['keywords'],
'about' => $contact_details['about'],

View file

@ -27,7 +27,6 @@ use Friendica\Core\Renderer;
use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Model\Contact;
use Friendica\Util\Proxy as ProxyUtils;
/**
* This class handles methods related to the forum functionality
@ -72,7 +71,7 @@ class ForumManager
$forumlist = [];
$fields = ['id', 'url', 'name', 'micro', 'thumb'];
$fields = ['id', 'url', 'name', 'micro', 'thumb', 'avatar'];
$condition = [$condition_str, Protocol::DFRN, Protocol::ACTIVITYPUB, $uid];
$contacts = DBA::select('contact', $fields, $condition, $params);
if (!$contacts) {
@ -131,7 +130,7 @@ class ForumManager
'name' => $contact['name'],
'cid' => $contact['id'],
'selected' => $selected,
'micro' => DI::baseUrl()->remove(ProxyUtils::proxifyUrl($contact['micro'], false, ProxyUtils::SIZE_MICRO)),
'micro' => DI::baseUrl()->remove(Contact::getMicro($contact)),
'id' => ++$id,
];
$entries[] = $entry;

View file

@ -30,7 +30,6 @@ use Friendica\Core\Search;
use Friendica\DI;
use Friendica\Model\Contact;
use Friendica\Util\Network;
use Friendica\Util\Proxy as ProxyUtils;
use Friendica\Util\Strings;
use Friendica\Util\XML;
use League\HTMLToMarkdown\HtmlConverter;
@ -868,7 +867,7 @@ class HTML
'$click' => $contact['click'] ?? '',
'$class' => $class,
'$url' => $url,
'$photo' => ProxyUtils::proxifyUrl($contact['thumb'], false, ProxyUtils::SIZE_THUMB),
'$photo' => Contact::getThumb($contact),
'$name' => $contact['name'],
'title' => $contact['name'] . ' [' . $contact['addr'] . ']',
'$parkle' => $sparkle,

View file

@ -34,7 +34,6 @@ use Friendica\Model\Group;
use Friendica\Model\Item;
use Friendica\Model\Profile;
use Friendica\Util\DateTimeFormat;
use Friendica\Util\Proxy as ProxyUtils;
use Friendica\Util\Strings;
use Friendica\Util\Temporal;
@ -432,10 +431,11 @@ class Widget
$entries = [];
foreach ($r as $rr) {
$contact = Contact::getByURL($rr['url']);
$entry = [
'url' => Contact::magicLink($rr['url']),
'name' => $rr['name'],
'photo' => ProxyUtils::proxifyUrl($rr['photo'], false, ProxyUtils::SIZE_THUMB),
'name' => $contact['name'] ?? $rr['name'],
'photo' => Contact::getThumb($contact, $rr['photo']),
];
$entries[] = $entry;
}

View file

@ -98,7 +98,7 @@ class ContactBlock
$contact_ids[] = $contact["id"];
}
$contacts_stmt = DBA::select('contact', ['id', 'uid', 'addr', 'url', 'name', 'thumb', 'network'], ['id' => $contact_ids]);
$contacts_stmt = DBA::select('contact', ['id', 'uid', 'addr', 'url', 'name', 'thumb', 'avatar', 'network'], ['id' => $contact_ids]);
if (DBA::isResult($contacts_stmt)) {
$contacts_title = DI::l10n()->tt('%d Contact', '%d Contacts', $total);

View file

@ -97,7 +97,7 @@ class Notification extends BaseFactory
$item['label'] = (($item['gravity'] == GRAVITY_PARENT) ? 'post' : 'comment');
$item['link'] = $this->baseUrl->get(true) . '/display/' . $item['parent-guid'];
$item['image'] = Proxy::proxifyUrl($item['author-avatar'], false, Proxy::SIZE_MICRO);
$item['image'] = $item['author-avatar'];
$item['url'] = $item['author-link'];
$item['text'] = (($item['gravity'] == GRAVITY_PARENT)
? $this->l10n->t("%s created a new post", $item['author-name'])
@ -125,7 +125,7 @@ class Notification extends BaseFactory
return new \Friendica\Object\Notification\Notification([
'label' => 'like',
'link' => $this->baseUrl->get(true) . '/display/' . $item['parent-guid'],
'image' => Proxy::proxifyUrl($item['author-avatar'], false, Proxy::SIZE_MICRO),
'image' => $item['author-avatar'],
'url' => $item['author-link'],
'text' => $this->l10n->t("%s liked %s's post", $item['author-name'], $item['parent-author-name']),
'when' => $item['when'],
@ -136,7 +136,7 @@ class Notification extends BaseFactory
return new \Friendica\Object\Notification\Notification([
'label' => 'dislike',
'link' => $this->baseUrl->get(true) . '/display/' . $item['parent-guid'],
'image' => Proxy::proxifyUrl($item['author-avatar'], false, Proxy::SIZE_MICRO),
'image' => $item['author-avatar'],
'url' => $item['author-link'],
'text' => $this->l10n->t("%s disliked %s's post", $item['author-name'], $item['parent-author-name']),
'when' => $item['when'],
@ -147,7 +147,7 @@ class Notification extends BaseFactory
return new \Friendica\Object\Notification\Notification([
'label' => 'attend',
'link' => $this->baseUrl->get(true) . '/display/' . $item['parent-guid'],
'image' => Proxy::proxifyUrl($item['author-avatar'], false, Proxy::SIZE_MICRO),
'image' => $item['author-avatar'],
'url' => $item['author-link'],
'text' => $this->l10n->t("%s is attending %s's event", $item['author-name'], $item['parent-author-name']),
'when' => $item['when'],
@ -158,7 +158,7 @@ class Notification extends BaseFactory
return new \Friendica\Object\Notification\Notification([
'label' => 'attendno',
'link' => $this->baseUrl->get(true) . '/display/' . $item['parent-guid'],
'image' => Proxy::proxifyUrl($item['author-avatar'], false, Proxy::SIZE_MICRO),
'image' => $item['author-avatar'],
'url' => $item['author-link'],
'text' => $this->l10n->t("%s is not attending %s's event", $item['author-name'], $item['parent-author-name']),
'when' => $item['when'],
@ -169,7 +169,7 @@ class Notification extends BaseFactory
return new \Friendica\Object\Notification\Notification([
'label' => 'attendmaybe',
'link' => $this->baseUrl->get(true) . '/display/' . $item['parent-guid'],
'image' => Proxy::proxifyUrl($item['author-avatar'], false, Proxy::SIZE_MICRO),
'image' => $item['author-avatar'],
'url' => $item['author-link'],
'text' => $this->l10n->t("%s may attending %s's event", $item['author-name'], $item['parent-author-name']),
'when' => $item['when'],
@ -196,7 +196,7 @@ class Notification extends BaseFactory
return new \Friendica\Object\Notification\Notification([
'label' => 'friend',
'link' => $this->baseUrl->get(true) . '/display/' . $item['parent-guid'],
'image' => Proxy::proxifyUrl($item['author-avatar'], false, Proxy::SIZE_MICRO),
'image' => $item['author-avatar'],
'url' => $item['author-link'],
'text' => $this->l10n->t("%s is now friends with %s", $item['author-name'], $item['fname']),
'when' => $item['when'],

View file

@ -31,7 +31,6 @@ use Friendica\Model;
use Friendica\Network\HTTPException;
use Friendica\Object\Search\ContactResult;
use Friendica\Object\Search\ResultList;
use Friendica\Util\Proxy as ProxyUtils;
/**
* Base class for search modules
@ -160,13 +159,14 @@ class BaseSearch extends BaseModule
}
$photo = str_replace("http:///photo/", Search::getGlobalDirectory() . "/photo/", $result->getPhoto());
$contact = Model\Contact::getByURL($result->getUrl());
$entry = [
'alt_text' => $alt_text,
'url' => Model\Contact::magicLink($result->getUrl()),
'itemurl' => $result->getItem(),
'name' => $result->getName(),
'thumb' => ProxyUtils::proxifyUrl($photo, false, ProxyUtils::SIZE_THUMB),
'name' => $contact['name'] ?? $result->getName(),
'thumb' => Model\Contact::getThumb($contact, $photo),
'img_hover' => $result->getTags(),
'conntxt' => $connTxt,
'connlnk' => $connLink,

View file

@ -40,7 +40,6 @@ use Friendica\Module\Security\Login;
use Friendica\Network\HTTPException\BadRequestException;
use Friendica\Network\HTTPException\NotFoundException;
use Friendica\Util\DateTimeFormat;
use Friendica\Util\Proxy as ProxyUtils;
use Friendica\Util\Strings;
/**
@ -1067,7 +1066,7 @@ class Contact extends BaseModule
'id' => $rr['id'],
'alt_text' => $alt_text,
'dir_icon' => $dir_icon,
'thumb' => ProxyUtils::proxifyUrl($rr['thumb'], false, ProxyUtils::SIZE_THUMB),
'thumb' => Model\Contact::getThumb($rr),
'name' => $rr['name'],
'username' => $rr['name'],
'account_type' => Model\Contact::getAccountType($rr),

View file

@ -32,7 +32,6 @@ use Friendica\DI;
use Friendica\Model\Contact;
use Friendica\Model\Item;
use Friendica\Network\HTTPException;
use Friendica\Util\Proxy as ProxyUtils;
use Friendica\Util\Strings;
/**
@ -83,14 +82,14 @@ class Acl extends BaseModule
DI::logger()->warning('Wrong result item from Search::searchGlobalContact', ['$g' => $g, '$search' => $search, '$mode' => $mode, '$page' => $page]);
continue;
}
$contact = Contact::getByURL($g['url']);
$contacts[] = [
'photo' => ProxyUtils::proxifyUrl($g['photo'], false, ProxyUtils::SIZE_MICRO),
'name' => htmlspecialchars($g['name']),
'nick' => $g['addr'] ?: $g['url'],
'network' => $g['network'],
'photo' => Contact::getMicro($contact, $g['photo']),
'name' => htmlspecialchars($contact['name'] ?? $g['name']),
'nick' => $contact['nick'] ?? ($g['addr'] ?: $g['url']),
'network' => $contact['network'] ?? $g['network'],
'link' => $g['url'],
'forum' => !empty($g['community']) ? 1 : 0,
'forum' => !empty($g['community']),
];
}
@ -231,7 +230,7 @@ class Acl extends BaseModule
$r = [];
switch ($type) {
case self::TYPE_MENTION_CONTACT_GROUP:
$r = q("SELECT `id`, `name`, `nick`, `micro`, `network`, `url`, `attag`, `addr`, `forum`, `prv`, (`prv` OR `forum`) AS `frm` FROM `contact`
$r = q("SELECT `id`, `name`, `nick`, `avatar`, `micro`, `network`, `url`, `attag`, `addr`, `forum`, `prv`, (`prv` OR `forum`) AS `frm` FROM `contact`
WHERE `uid` = %d AND NOT `self` AND NOT `deleted` AND NOT `blocked` AND NOT `pending` AND NOT `archive` AND `notify` != ''
AND NOT (`network` IN ('%s', '%s'))
$sql_extra2
@ -243,7 +242,7 @@ class Acl extends BaseModule
break;
case self::TYPE_MENTION_CONTACT:
$r = q("SELECT `id`, `name`, `nick`, `micro`, `network`, `url`, `attag`, `addr`, `forum`, `prv` FROM `contact`
$r = q("SELECT `id`, `name`, `nick`, `avatar`, `micro`, `network`, `url`, `attag`, `addr`, `forum`, `prv` FROM `contact`
WHERE `uid` = %d AND NOT `self` AND NOT `deleted` AND NOT `blocked` AND NOT `pending` AND NOT `archive` AND `notify` != ''
AND NOT (`network` IN ('%s'))
$sql_extra2
@ -254,7 +253,7 @@ class Acl extends BaseModule
break;
case self::TYPE_MENTION_FORUM:
$r = q("SELECT `id`, `name`, `nick`, `micro`, `network`, `url`, `attag`, `addr`, `forum`, `prv` FROM `contact`
$r = q("SELECT `id`, `name`, `nick`, `avatar`, `micro`, `network`, `url`, `attag`, `addr`, `forum`, `prv` FROM `contact`
WHERE `uid` = %d AND NOT `self` AND NOT `deleted` AND NOT `blocked` AND NOT `pending` AND NOT `archive` AND `notify` != ''
AND NOT (`network` IN ('%s'))
AND (`forum` OR `prv`)
@ -266,7 +265,7 @@ class Acl extends BaseModule
break;
case self::TYPE_PRIVATE_MESSAGE:
$r = q("SELECT `id`, `name`, `nick`, `micro`, `network`, `url`, `attag`, `addr` FROM `contact`
$r = q("SELECT `id`, `name`, `nick`, `avatar`, `micro`, `network`, `url`, `attag`, `addr` FROM `contact`
WHERE `uid` = %d AND NOT `self` AND NOT `deleted` AND NOT `blocked` AND NOT `pending` AND NOT `archive`
AND `network` IN ('%s', '%s', '%s')
$sql_extra2
@ -280,7 +279,7 @@ class Acl extends BaseModule
case self::TYPE_ANY_CONTACT:
default:
$r = q("SELECT `id`, `name`, `nick`, `micro`, `network`, `url`, `attag`, `addr`, `forum`, `prv` FROM `contact`
$r = q("SELECT `id`, `name`, `nick`, `avatar`, `micro`, `network`, `url`, `attag`, `addr`, `forum`, `prv`, `avatar` FROM `contact`
WHERE `uid` = %d AND NOT `deleted` AND NOT `pending` AND NOT `archive`
$sql_extra2
ORDER BY `name`",
@ -350,7 +349,7 @@ class Acl extends BaseModule
continue;
}
$contact = Contact::getByURL($author, false, ['micro', 'name', 'id', 'network', 'nick', 'addr', 'url', 'forum']);
$contact = Contact::getByURL($author, false, ['micro', 'name', 'id', 'network', 'nick', 'addr', 'url', 'forum', 'avatar']);
if (count($contact) > 0) {
$unknown_contacts[] = [

View file

@ -38,7 +38,6 @@ use Friendica\Model\User;
use Friendica\Protocol\Activity;
use Friendica\Util\Crypto;
use Friendica\Util\DateTimeFormat;
use Friendica\Util\Proxy as ProxyUtils;
use Friendica\Util\Strings;
use Friendica\Util\Temporal;
@ -447,7 +446,7 @@ class Post
'profile_url' => $profile_link,
'item_photo_menu' => item_photo_menu($item),
'name' => $name_e,
'thumb' => DI::baseUrl()->remove(ProxyUtils::proxifyUrl($item['author-avatar'], false, ProxyUtils::SIZE_THUMB)),
'thumb' => DI::baseUrl()->remove($item['author-avatar']),
'osparkle' => $osparkle,
'sparkle' => $sparkle,
'title' => $title_e,
@ -461,7 +460,7 @@ class Post
'shiny' => $shiny,
'owner_self' => $item['author-link'] == Session::get('my_url'),
'owner_url' => $this->getOwnerUrl(),
'owner_photo' => DI::baseUrl()->remove(ProxyUtils::proxifyUrl($item['owner-avatar'], false, ProxyUtils::SIZE_THUMB)),
'owner_photo' => DI::baseUrl()->remove($item['owner-avatar']),
'owner_name' => $owner_name_e,
'plink' => Item::getPlink($item),
'edpost' => $edpost,

View file

@ -18,7 +18,6 @@ use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Model\Contact;
use Friendica\Model\GContact;
use Friendica\Util\Proxy as ProxyUtils;
use Friendica\Util\Strings;
function vier_init(App $a)
@ -127,11 +126,12 @@ function vier_community_info()
$aside['$comunity_profiles_items'] = [];
foreach ($r as $rr) {
$contact = Contact::getByURL($rr['url']);
$entry = Renderer::replaceMacros($tpl, [
'$id' => $rr['id'],
'$profile_link' => 'follow/?url='.urlencode($rr['url']),
'$photo' => ProxyUtils::proxifyUrl($rr['photo'], false, ProxyUtils::SIZE_MICRO),
'$alt_text' => $rr['name'],
'$photo' => Contact::getMicro($contact, $rr['photo']),
'$alt_text' => $contact['name'] ?? $rr['name'],
]);
$aside['$comunity_profiles_items'][] = $entry;
}
@ -207,7 +207,7 @@ function vier_community_info()
'name' => $contact['name'],
'cid' => $contact['id'],
'selected' => $selected,
'micro' => DI::baseUrl()->remove(ProxyUtils::proxifyUrl($contact['micro'], false, ProxyUtils::SIZE_MICRO)),
'micro' => Contact::getMicro($contact),
'id' => ++$id,
];
$entries[] = $entry;