Use gsid for the network name
authorMichael <heluecht@pirati.ca>
Fri, 29 Apr 2022 07:47:24 +0000 (07:47 +0000)
committerMichael <heluecht@pirati.ca>
Fri, 29 Apr 2022 07:47:24 +0000 (07:47 +0000)
database.sql
src/Content/ContactSelector.php
src/Content/Conversation.php
src/Model/Item.php
src/Object/Post.php
static/dbview.config.php

index 9952f8c3d2bbb064e186bcaef18e6dc40058b3ae..785b0f7b54ca47f89cee60d0a0a51ddd04af907c 100644 (file)
@@ -1720,6 +1720,7 @@ CREATE VIEW `post-user-view` AS SELECT
        `author`.`blocked` AS `author-blocked`,
        `author`.`hidden` AS `author-hidden`,
        `author`.`updated` AS `author-updated`,
+       `author`.`gsid` AS `author-gsid`,
        `post-user`.`owner-id` AS `owner-id`,
        `owner`.`url` AS `owner-link`,
        `owner`.`addr` AS `owner-addr`,
@@ -1887,6 +1888,7 @@ CREATE VIEW `post-thread-user-view` AS SELECT
        `author`.`blocked` AS `author-blocked`,
        `author`.`hidden` AS `author-hidden`,
        `author`.`updated` AS `author-updated`,
+       `author`.`gsid` AS `author-gsid`,
        `post-thread-user`.`owner-id` AS `owner-id`,
        `owner`.`url` AS `owner-link`,
        `owner`.`addr` AS `owner-addr`,
@@ -2040,6 +2042,7 @@ CREATE VIEW `post-view` AS SELECT
        `author`.`blocked` AS `author-blocked`,
        `author`.`hidden` AS `author-hidden`,
        `author`.`updated` AS `author-updated`,
+       `author`.`gsid` AS `author-gsid`,
        `post`.`owner-id` AS `owner-id`,
        `owner`.`url` AS `owner-link`,
        `owner`.`addr` AS `owner-addr`,
@@ -2169,6 +2172,7 @@ CREATE VIEW `post-thread-view` AS SELECT
        `author`.`blocked` AS `author-blocked`,
        `author`.`hidden` AS `author-hidden`,
        `author`.`updated` AS `author-updated`,
+       `author`.`gsid` AS `author-gsid`,
        `post-thread`.`owner-id` AS `owner-id`,
        `owner`.`url` AS `owner-link`,
        `owner`.`addr` AS `owner-addr`,
index 9035d37e73c01d3c838e35c30bbc662e1507acc0..6c7e09945f9f594ae81b0905a94dceeba7876b42 100644 (file)
@@ -184,7 +184,7 @@ class ContactSelector
         * @return string
         * @throws \Exception
         */
-       public static function networkToIcon($network, $profile = "")
+       public static function networkToIcon($network, $profile = "", $gsid = 0)
        {
                $nets = [
                        Protocol::DFRN      =>   'friendica',
@@ -218,7 +218,14 @@ class ContactSelector
                $network_icon = str_replace($search, $replace, $network);
 
                if ((in_array($network, Protocol::FEDERATED)) && ($profile != "")) {
-                       $gserver = self::getServerForProfile($profile);
+                       if (!empty($gsid) && !empty(self::$serverdata[$gsid])) {
+                               $gserver = self::$serverdata[$gsid];
+                       } elseif (!empty($gsid)) {
+                               $gserver = DBA::selectFirst('gserver', ['platform', 'network'], ['id' => $gsid]);
+                               self::$serverdata[$gsid] = $gserver;
+                       } else {
+                               $gserver = self::getServerForProfile($profile);
+                       }
                        if (!empty($gserver['platform'])) {
                                $network_icon = $platform_icons[strtolower($gserver['platform'])] ?? $network_icon;
                        }
index fd880a04520eac63f9ffc95a0399463fedba2446..48695b2193800b44152e705312f87eb6e0b26fdb 100644 (file)
@@ -678,8 +678,8 @@ class Conversation
                                                'created_date'         => $item['created'],
                                                'uriid'                => $item['uri-id'],
                                                'network'              => $item['network'],
-                                               'network_name'         => ContactSelector::networkToName($item['author-network'], $item['author-link'], $item['network']),
-                                               'network_icon'         => ContactSelector::networkToIcon($item['network'], $item['author-link']),
+                                               'network_name'         => ContactSelector::networkToName($item['author-network'], $item['author-link'], $item['network'], $item['author-gsid']),
+                                               'network_icon'         => ContactSelector::networkToIcon($item['network'], $item['author-link'], $item['author-gsid']),
                                                'linktitle'            => $this->l10n->t('View %s\'s profile @ %s', $profile_name, $item['author-link']),
                                                'profile_url'          => $profile_link,
                                                'item_photo_menu_html' => $this->item->photoMenu($item, $formSecurityToken),
index 3900c557c1094a82333dc240e2554e266550273a..84fa0af11b049fe55d5fc6adb8777c840b7c1b90 100644 (file)
@@ -87,7 +87,7 @@ class Item
                'wall', 'private', 'starred', 'origin', 'parent-origin', 'title', 'body', 'language',
                'content-warning', 'location', 'coord', 'app', 'rendered-hash', 'rendered-html', 'object',
                'allow_cid', 'allow_gid', 'deny_cid', 'deny_gid', 'mention', 'global',
-               'author-id', 'author-link', 'author-name', 'author-avatar', 'author-network', 'author-updated',
+               'author-id', 'author-link', 'author-name', 'author-avatar', 'author-network', 'author-updated', 'author-gsid',
                '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',
                'contact-id', 'contact-uid', 'contact-link', 'contact-name', 'contact-avatar',
index 7f5adde0ae320e5fc98e3d1fdb14a6eb63635d38..a949c24aa704ffae28e5eed4ca44ff6fdd286ffc 100644 (file)
@@ -538,8 +538,8 @@ class Post
                        'thread_level'    => $thread_level,
                        'edited'          => $edited,
                        'network'         => $item["network"],
-                       'network_name'    => ContactSelector::networkToName($item['author-network'], $item['author-link'], $item['network']),
-                       'network_icon'    => ContactSelector::networkToIcon($item['network'], $item['author-link']),
+                       'network_name'    => ContactSelector::networkToName($item['author-network'], $item['author-link'], $item['network'], $item['author-gsid']),
+                       'network_icon'    => ContactSelector::networkToIcon($item['network'], $item['author-link'], $item['author-gsid']),
                        'received'        => $item['received'],
                        'commented'       => $item['commented'],
                        'created_date'    => $item['created'],
index 3faec770f6dd6de1527ab8739943228b4e6f1525..a623e4636508c9a8f99b3973029a532001c90f2f 100644 (file)
                        "author-blocked" => ["author", "blocked"],
                        "author-hidden" => ["author", "hidden"],
                        "author-updated" => ["author", "updated"],
+                       "author-gsid" => ["author", "gsid"],
                        "owner-id" => ["post-user", "owner-id"],
                        "owner-link" => ["owner", "url"],
                        "owner-addr" => ["owner", "addr"],
                        "author-blocked" => ["author", "blocked"],
                        "author-hidden" => ["author", "hidden"],
                        "author-updated" => ["author", "updated"],
+                       "author-gsid" => ["author", "gsid"],
                        "owner-id" => ["post-thread-user", "owner-id"],
                        "owner-link" => ["owner", "url"],
                        "owner-addr" => ["owner", "addr"],
                        "author-blocked" => ["author", "blocked"],
                        "author-hidden" => ["author", "hidden"],
                        "author-updated" => ["author", "updated"],
+                       "author-gsid" => ["author", "gsid"],
                        "owner-id" => ["post", "owner-id"],
                        "owner-link" => ["owner", "url"],
                        "owner-addr" => ["owner", "addr"],
                        "author-blocked" => ["author", "blocked"],
                        "author-hidden" => ["author", "hidden"],
                        "author-updated" => ["author", "updated"],
+                       "author-gsid" => ["author", "gsid"],
                        "owner-id" => ["post-thread", "owner-id"],
                        "owner-link" => ["owner", "url"],
                        "owner-addr" => ["owner", "addr"],