]> git.mxchange.org Git - friendica.git/commitdiff
Prticipation is now a view as well
authorMichael <heluecht@pirati.ca>
Fri, 24 Apr 2020 17:55:49 +0000 (17:55 +0000)
committerMichael <heluecht@pirati.ca>
Fri, 24 Apr 2020 17:55:49 +0000 (17:55 +0000)
src/Protocol/Diaspora.php
static/dbview.config.php

index 19ef391a0a01c800342e70b890f3fc346a8181fa..fe6c328d9f6da63f76ea147606cced05f4c48ae1 100644 (file)
@@ -259,27 +259,13 @@ class Diaspora
         */
        public static function participantsForThread($thread, array $contacts)
        {
-               $r = DBA::p("SELECT `contact`.`batch`, `contact`.`id`, `contact`.`url`, `contact`.`name`, `contact`.`network`, `contact`.`protocol`,
-                               `fcontact`.`batch` AS `fbatch`, `fcontact`.`network` AS `fnetwork` FROM `participation`
-                               INNER JOIN `contact` ON `contact`.`id` = `participation`.`cid`
-                               INNER JOIN `fcontact` ON `fcontact`.`id` = `participation`.`fid`
-                               WHERE `participation`.`iid` = ? AND NOT `contact`.`archive`", $thread);
-
-               while ($contact = DBA::fetch($r)) {
-                       if (!empty($contact['fnetwork'])) {
-                               $contact['network'] = $contact['fnetwork'];
-                       }
-                       unset($contact['fnetwork']);
+               $participation = DBA::select('participation-view', [], ['iid' => $thread]);
 
+               while ($contact = DBA::fetch($participation)) { 
                        if (empty($contact['protocol'])) {
                                $contact['protocol'] = $contact['network'];
                        }
 
-                       if (empty($contact['batch']) && !empty($contact['fbatch'])) {
-                               $contact['batch'] = $contact['fbatch'];
-                       }
-                       unset($contact['fbatch']);
-
                        $exists = false;
                        foreach ($contacts as $entry) {
                                if ($entry['batch'] == $contact['batch']) {
@@ -291,7 +277,8 @@ class Diaspora
                                $contacts[] = $contact;
                        }
                }
-               DBA::close($r);
+
+               DBA::close($participation);
 
                return $contacts;
        }
index 9722ca3819a62bc47351f0e7a826550b5ef8a252..7e0ce0a0f6b8fdde39ab4705f0a9a29a4aa57192 100755 (executable)
@@ -175,6 +175,20 @@ return [
                        INNER JOIN `contact` ON `contact`.`uid` = `user`.`uid` AND `contact`.`self`
                        INNER JOIN `profile` ON `profile`.`uid` = `user`.`uid`"
        ],
+       "participation-view" => [
+               "fields" => [
+                       "iid" => ["participation", "iid"],
+                       "id" => ["contact", "id"],
+                       "url" => ["contact", "url"],
+                       "name" => ["contact", "name"],
+                       "protocol" => ["contact", "protocol"],
+                       "batch" => "CASE `contact`.`batch` WHEN '' THEN `fcontact`.`batch` ELSE `contact`.`batch` END",
+                       "network" => "CASE `fcontact`.`network` WHEN '' THEN `contact`.`network` ELSE `fcontact`.`network` END",
+               ],
+               "query" => "FROM `participation`
+                       INNER JOIN `contact` ON `contact`.`id` = `participation`.`cid` AND NOT `contact`.`archive`
+                       INNER JOIN `fcontact` ON `fcontact`.`id` = `participation`.`fid`"
+       ],
        "pending-view" => [
                "fields" => [
                        "id" => ["register", "id"],