Using separate avatars for different peertube account types
authorMichael <heluecht@pirati.ca>
Mon, 13 Jun 2022 10:27:46 +0000 (10:27 +0000)
committerMichael <heluecht@pirati.ca>
Mon, 13 Jun 2022 10:27:46 +0000 (10:27 +0000)
images/default/peertube-account.png [new file with mode: 0644]
images/default/peertube-channel.png [new file with mode: 0644]
images/default/peertube.png [deleted file]
src/Model/Contact.php

diff --git a/images/default/peertube-account.png b/images/default/peertube-account.png
new file mode 100644 (file)
index 0000000..0bedaa0
Binary files /dev/null and b/images/default/peertube-account.png differ
diff --git a/images/default/peertube-channel.png b/images/default/peertube-channel.png
new file mode 100644 (file)
index 0000000..e247418
Binary files /dev/null and b/images/default/peertube-channel.png differ
diff --git a/images/default/peertube.png b/images/default/peertube.png
deleted file mode 100644 (file)
index e247418..0000000
Binary files a/images/default/peertube.png and /dev/null differ
index 3ebc0e6..6ee4582 100644 (file)
@@ -1818,15 +1818,18 @@ class Contact
 
                if (!DI::config()->get('system', 'remote_avatar_lookup')) {
                        $platform = '';
+                       $type     = Contact::TYPE_PERSON;
 
                        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'] ?? '';
+                               $type     = $account['contact-type'] ?? Contact::TYPE_PERSON;
                        }
        
                        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'] ?? '';
+                               $type     = $account['contact-type'] ?? Contact::TYPE_PERSON;
                        }
 
                        switch ($platform) {
@@ -1861,9 +1864,14 @@ class Contact
                                        /**
                                         * Picture credits
                                         * @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;
                        }
                        return DI::baseUrl() . $default;