Using separate avatars for different peertube account types

This commit is contained in:
Michael 2022-06-13 10:27:46 +00:00
parent a47f1efec3
commit d9fb081db9
3 changed files with 12 additions and 4 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.8 KiB

View File

Before

Width:  |  Height:  |  Size: 3.9 KiB

After

Width:  |  Height:  |  Size: 3.9 KiB

View File

@ -1818,15 +1818,18 @@ class Contact
if (!DI::config()->get('system', 'remote_avatar_lookup')) { if (!DI::config()->get('system', 'remote_avatar_lookup')) {
$platform = ''; $platform = '';
$type = Contact::TYPE_PERSON;
if (!empty($contact['id'])) { if (!empty($contact['id'])) {
$account = DBA::selectFirst('account-user-view', ['platform'], ['id' => $contact['id']]); $account = DBA::selectFirst('account-user-view', ['platform', 'contact-type'], ['id' => $contact['id']]);
$platform = $account['platform'] ?? ''; $platform = $account['platform'] ?? '';
$type = $account['contact-type'] ?? Contact::TYPE_PERSON;
} }
if (empty($platform) && !empty($contact['uri-id'])) { if (empty($platform) && !empty($contact['uri-id'])) {
$account = DBA::selectFirst('account-user-view', ['platform'], ['uri-id' => $contact['uri-id']]); $account = DBA::selectFirst('account-user-view', ['platform', 'contact-type'], ['uri-id' => $contact['uri-id']]);
$platform = $account['platform'] ?? ''; $platform = $account['platform'] ?? '';
$type = $account['contact-type'] ?? Contact::TYPE_PERSON;
} }
switch ($platform) { switch ($platform) {
@ -1861,9 +1864,14 @@ class Contact
/** /**
* Picture credits * Picture credits
* @license GNU Affero General Public License v3.0 * @license GNU Affero General Public License v3.0
* @link https://github.com/Chocobozzz/PeerTube/blob/develop/client/src/assets/images/default-avatar-video-channel.png
*/ */
$default = '/images/default/peertube.png'; if ($type == Contact::TYPE_COMMUNITY) {
// @link https://github.com/Chocobozzz/PeerTube/blob/develop/client/src/assets/images/default-avatar-video-channel.png
$default = '/images/default/peertube-channel.png';
} else {
// @link https://github.com/Chocobozzz/PeerTube/blob/develop/client/src/assets/images/default-avatar-account.png
$default = '/images/default/peertube-account.png';
}
break; break;
} }
return DI::baseUrl() . $default; return DI::baseUrl() . $default;